2 * Code to prepare detour buffer for optprobes in Kernel.
4 * Copyright 2017, Anju T, IBM Corp.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <asm/ppc_asm.h>
13 #include <asm/ptrace.h>
14 #include <asm/asm-offsets.h>
16 #define OPT_SLOT_SIZE 65536
21 * Reserve an area to allocate slots for detour buffer.
22 * This is part of .text section (rather than vmalloc area)
23 * as this needs to be within 32MB of the probed address.
31 * This template gets copied into one of the slots in optinsn_slot
32 * and gets fixed up with real optprobe structures et al.
34 .global optprobe_template_entry
35 optprobe_template_entry:
36 /* Create an in-memory pt_regs */
37 stdu r1,-INT_FRAME_SIZE(r1)
39 /* Save the previous SP into stack */
40 addi r0,r1,INT_FRAME_SIZE
61 lbz r5,PACASOFTIRQEN(r13)
65 * We may get here from a module, so load the kernel TOC in r2.
66 * The original TOC gets restored when pt_regs is restored
71 .global optprobe_template_op_address
72 optprobe_template_op_address:
74 * Parameters to optimized_callback():
75 * 1. optimized_kprobe structure in r3
82 /* 2. pt_regs pointer in r4 */
83 addi r4,r1,STACK_FRAME_OVERHEAD
85 .global optprobe_template_call_handler
86 optprobe_template_call_handler:
87 /* Branch to optimized_callback() */
91 * Parameters for instruction emulation:
92 * 1. Pass SP in register r3.
94 addi r3,r1,STACK_FRAME_OVERHEAD
96 .global optprobe_template_insn
97 optprobe_template_insn:
98 /* 2, Pass instruction to be emulated in r4 */
102 .global optprobe_template_call_emulate
103 optprobe_template_call_emulate:
104 /* Branch to emulate_step() */
109 * Now, restore the registers...
125 /* Restore the previous SP */
126 addi r1,r1,INT_FRAME_SIZE
128 .global optprobe_template_ret
129 optprobe_template_ret:
130 /* ... and jump back from trampoline */
133 .global optprobe_template_end
134 optprobe_template_end: