powerpc/kprobes: Implement Optprobes
Current infrastructure of kprobe uses the unconditional trap instruction to probe a running kernel. Optprobe allows kprobe to replace the trap with a branch instruction to a detour buffer. Detour buffer contains instructions to create an in memory pt_regs. Detour buffer also has a call to optimized_callback() which in turn call the pre_handler(). After the execution of the pre-handler, a call is made for instruction emulation. The NIP is determined in advanced through dummy instruction emulation and a branch instruction is created to the NIP at the end of the trampoline. To address the limitation of branch instruction in POWER architecture, detour buffer slot is allocated from a reserved area. For the time being, 64KB is reserved in memory for this purpose. Instructions which can be emulated using analyse_instr() are the candidates for optimization. Before optimization ensure that the address range between the detour buffer allocated and the instruction being probed is within +/- 32MB. Signed-off-by:Anju T Sudhakar <anju@linux.vnet.ibm.com> Signed-off-by:
Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> Acked-by:
Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by:
Michael Ellerman <mpe@ellerman.id.au>
Showing
- arch/powerpc/Kconfig 1 addition, 0 deletionsarch/powerpc/Kconfig
- arch/powerpc/include/asm/code-patching.h 1 addition, 0 deletionsarch/powerpc/include/asm/code-patching.h
- arch/powerpc/include/asm/kprobes.h 23 additions, 1 deletionarch/powerpc/include/asm/kprobes.h
- arch/powerpc/kernel/Makefile 1 addition, 0 deletionsarch/powerpc/kernel/Makefile
- arch/powerpc/kernel/optprobes.c 348 additions, 0 deletionsarch/powerpc/kernel/optprobes.c
- arch/powerpc/kernel/optprobes_head.S 135 additions, 0 deletionsarch/powerpc/kernel/optprobes_head.S
- arch/powerpc/lib/code-patching.c 21 additions, 0 deletionsarch/powerpc/lib/code-patching.c
Loading
Please register or sign in to comment