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 */
13 #define SAVE_REGS_STRING \
14 /* Skip cs, ip, orig_ax. */ \
33 #define RESTORE_REGS_STRING \
49 /* Skip orig_ax, ip, cs */ \
53 #define SAVE_REGS_STRING \
54 /* Skip cs, ip, orig_ax and gs. */ \
55 " subl $4*4, %esp\n" \
68 #define RESTORE_REGS_STRING \
76 /* Skip ds, es, fs, gs, orig_ax, ip, and cs. */\
80 /* Ensure if the instruction can be boostable */
81 extern int can_boost(struct insn *insn, void *orig_addr);
82 /* Recover instruction if given address is probed */
83 extern unsigned long recover_probed_instruction(kprobe_opcode_t *buf,
86 * Copy an instruction and adjust the displacement if the instruction
87 * uses the %rip-relative addressing mode.
89 extern int __copy_instruction(u8 *dest, u8 *src, u8 *real, struct insn *insn);
91 /* Generate a relative-jump/call instruction */
92 extern void synthesize_reljump(void *dest, void *from, void *to);
93 extern void synthesize_relcall(void *dest, void *from, void *to);
95 #ifdef CONFIG_OPTPROBES
96 extern int setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter);
97 extern unsigned long __recover_optprobed_insn(kprobe_opcode_t *buf, unsigned long addr);
98 #else /* !CONFIG_OPTPROBES */
99 static inline int setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
103 static inline unsigned long __recover_optprobed_insn(kprobe_opcode_t *buf, unsigned long addr)