1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __X86_KERNEL_KPROBES_COMMON_H
3 #define __X86_KERNEL_KPROBES_COMMON_H
5 /* Kprobes and Optprobes common header */
9 #ifdef CONFIG_FRAME_POINTER
10 # define SAVE_RBP_STRING " push %" _ASM_BP "\n" \
11 " mov %" _ASM_SP ", %" _ASM_BP "\n"
13 # define SAVE_RBP_STRING " push %" _ASM_BP "\n"
17 #define SAVE_REGS_STRING \
18 /* Skip cs, ip, orig_ax. */ \
35 #define RESTORE_REGS_STRING \
51 /* Skip orig_ax, ip, cs */ \
54 #define SAVE_REGS_STRING \
55 /* Skip cs, ip, orig_ax and gs. */ \
67 #define RESTORE_REGS_STRING \
75 /* Skip ds, es, fs, gs, orig_ax, and ip. Note: don't pop cs here*/\
79 /* Ensure if the instruction can be boostable */
80 extern int can_boost(struct insn
*insn
, void *orig_addr
);
81 /* Recover instruction if given address is probed */
82 extern unsigned long recover_probed_instruction(kprobe_opcode_t
*buf
,
85 * Copy an instruction and adjust the displacement if the instruction
86 * uses the %rip-relative addressing mode.
88 extern int __copy_instruction(u8
*dest
, u8
*src
, u8
*real
, struct insn
*insn
);
90 /* Generate a relative-jump/call instruction */
91 extern void synthesize_reljump(void *dest
, void *from
, void *to
);
92 extern void synthesize_relcall(void *dest
, void *from
, void *to
);
94 #ifdef CONFIG_OPTPROBES
95 extern int setup_detour_execution(struct kprobe
*p
, struct pt_regs
*regs
, int reenter
);
96 extern unsigned long __recover_optprobed_insn(kprobe_opcode_t
*buf
, unsigned long addr
);
97 #else /* !CONFIG_OPTPROBES */
98 static inline int setup_detour_execution(struct kprobe
*p
, struct pt_regs
*regs
, int reenter
)
102 static inline unsigned long __recover_optprobed_insn(kprobe_opcode_t
*buf
, unsigned long addr
)
108 #ifdef CONFIG_KPROBES_ON_FTRACE
109 extern int skip_singlestep(struct kprobe
*p
, struct pt_regs
*regs
,
110 struct kprobe_ctlblk
*kcb
);
112 static inline int skip_singlestep(struct kprobe
*p
, struct pt_regs
*regs
,
113 struct kprobe_ctlblk
*kcb
)