~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/x86/kernel/kprobes/common.h

Version: ~ [ linux-5.4-rc3 ] ~ [ linux-5.3.6 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.79 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.149 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.196 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.196 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.75 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef __X86_KERNEL_KPROBES_COMMON_H
  3 #define __X86_KERNEL_KPROBES_COMMON_H
  4 
  5 /* Kprobes and Optprobes common header */
  6 
  7 #include <asm/asm.h>
  8 
  9 #ifdef CONFIG_FRAME_POINTER
 10 # define SAVE_RBP_STRING "      push %" _ASM_BP "\n" \
 11                          "      mov  %" _ASM_SP ", %" _ASM_BP "\n"
 12 #else
 13 # define SAVE_RBP_STRING "      push %" _ASM_BP "\n"
 14 #endif
 15 
 16 #ifdef CONFIG_X86_64
 17 #define SAVE_REGS_STRING                        \
 18         /* Skip cs, ip, orig_ax. */             \
 19         "       subq $24, %rsp\n"               \
 20         "       pushq %rdi\n"                   \
 21         "       pushq %rsi\n"                   \
 22         "       pushq %rdx\n"                   \
 23         "       pushq %rcx\n"                   \
 24         "       pushq %rax\n"                   \
 25         "       pushq %r8\n"                    \
 26         "       pushq %r9\n"                    \
 27         "       pushq %r10\n"                   \
 28         "       pushq %r11\n"                   \
 29         "       pushq %rbx\n"                   \
 30         SAVE_RBP_STRING                         \
 31         "       pushq %r12\n"                   \
 32         "       pushq %r13\n"                   \
 33         "       pushq %r14\n"                   \
 34         "       pushq %r15\n"
 35 #define RESTORE_REGS_STRING                     \
 36         "       popq %r15\n"                    \
 37         "       popq %r14\n"                    \
 38         "       popq %r13\n"                    \
 39         "       popq %r12\n"                    \
 40         "       popq %rbp\n"                    \
 41         "       popq %rbx\n"                    \
 42         "       popq %r11\n"                    \
 43         "       popq %r10\n"                    \
 44         "       popq %r9\n"                     \
 45         "       popq %r8\n"                     \
 46         "       popq %rax\n"                    \
 47         "       popq %rcx\n"                    \
 48         "       popq %rdx\n"                    \
 49         "       popq %rsi\n"                    \
 50         "       popq %rdi\n"                    \
 51         /* Skip orig_ax, ip, cs */              \
 52         "       addq $24, %rsp\n"
 53 #else
 54 #define SAVE_REGS_STRING                        \
 55         /* Skip cs, ip, orig_ax and gs. */      \
 56         "       subl $16, %esp\n"               \
 57         "       pushl %fs\n"                    \
 58         "       pushl %es\n"                    \
 59         "       pushl %ds\n"                    \
 60         "       pushl %eax\n"                   \
 61         SAVE_RBP_STRING                         \
 62         "       pushl %edi\n"                   \
 63         "       pushl %esi\n"                   \
 64         "       pushl %edx\n"                   \
 65         "       pushl %ecx\n"                   \
 66         "       pushl %ebx\n"
 67 #define RESTORE_REGS_STRING                     \
 68         "       popl %ebx\n"                    \
 69         "       popl %ecx\n"                    \
 70         "       popl %edx\n"                    \
 71         "       popl %esi\n"                    \
 72         "       popl %edi\n"                    \
 73         "       popl %ebp\n"                    \
 74         "       popl %eax\n"                    \
 75         /* Skip ds, es, fs, gs, orig_ax, and ip. Note: don't pop cs here*/\
 76         "       addl $24, %esp\n"
 77 #endif
 78 
 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,
 83                                          unsigned long addr);
 84 /*
 85  * Copy an instruction and adjust the displacement if the instruction
 86  * uses the %rip-relative addressing mode.
 87  */
 88 extern int __copy_instruction(u8 *dest, u8 *src, u8 *real, struct insn *insn);
 89 
 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);
 93 
 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)
 99 {
100         return 0;
101 }
102 static inline unsigned long __recover_optprobed_insn(kprobe_opcode_t *buf, unsigned long addr)
103 {
104         return addr;
105 }
106 #endif
107 
108 #ifdef CONFIG_KPROBES_ON_FTRACE
109 extern int skip_singlestep(struct kprobe *p, struct pt_regs *regs,
110                            struct kprobe_ctlblk *kcb);
111 #else
112 static inline int skip_singlestep(struct kprobe *p, struct pt_regs *regs,
113                                   struct kprobe_ctlblk *kcb)
114 {
115         return 0;
116 }
117 #endif
118 #endif
119 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp