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 */
12 #define SAVE_REGS_STRING \
13 /* Skip cs, ip, orig_ax. */ \
32 #define RESTORE_REGS_STRING \
48 /* Skip orig_ax, ip, cs */ \
52 #define SAVE_REGS_STRING \
53 /* Skip cs, ip, orig_ax and gs. */ \
54 " subl $4*4, %esp\n" \
67 #define RESTORE_REGS_STRING \
75 /* Skip ds, es, fs, gs, orig_ax, ip, and cs. */\
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)