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

TOMOYO Linux Cross Reference
Linux/arch/x86/include/asm/kprobes.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0-or-later */
  2 #ifndef _ASM_X86_KPROBES_H
  3 #define _ASM_X86_KPROBES_H
  4 /*
  5  *  Kernel Probes (KProbes)
  6  *
  7  * Copyright (C) IBM Corporation, 2002, 2004
  8  *
  9  * See arch/x86/kernel/kprobes.c for x86 kprobes history.
 10  */
 11 
 12 #include <asm-generic/kprobes.h>
 13 
 14 #ifdef CONFIG_KPROBES
 15 #include <linux/types.h>
 16 #include <linux/ptrace.h>
 17 #include <linux/percpu.h>
 18 #include <asm/text-patching.h>
 19 #include <asm/insn.h>
 20 
 21 #define  __ARCH_WANT_KPROBES_INSN_SLOT
 22 
 23 struct pt_regs;
 24 struct kprobe;
 25 
 26 typedef u8 kprobe_opcode_t;
 27 
 28 #define MAX_STACK_SIZE 64
 29 #define CUR_STACK_SIZE(ADDR) \
 30         (current_top_of_stack() - (unsigned long)(ADDR))
 31 #define MIN_STACK_SIZE(ADDR)                            \
 32         (MAX_STACK_SIZE < CUR_STACK_SIZE(ADDR) ?        \
 33          MAX_STACK_SIZE : CUR_STACK_SIZE(ADDR))
 34 
 35 #define flush_insn_slot(p)      do { } while (0)
 36 
 37 /* optinsn template addresses */
 38 extern __visible kprobe_opcode_t optprobe_template_entry[];
 39 extern __visible kprobe_opcode_t optprobe_template_clac[];
 40 extern __visible kprobe_opcode_t optprobe_template_val[];
 41 extern __visible kprobe_opcode_t optprobe_template_call[];
 42 extern __visible kprobe_opcode_t optprobe_template_end[];
 43 #define MAX_OPTIMIZED_LENGTH (MAX_INSN_SIZE + DISP32_SIZE)
 44 #define MAX_OPTINSN_SIZE                                \
 45         (((unsigned long)optprobe_template_end -        \
 46           (unsigned long)optprobe_template_entry) +     \
 47          MAX_OPTIMIZED_LENGTH + JMP32_INSN_SIZE)
 48 
 49 extern const int kretprobe_blacklist_size;
 50 
 51 void arch_remove_kprobe(struct kprobe *p);
 52 
 53 /* Architecture specific copy of original instruction*/
 54 struct arch_specific_insn {
 55         /* copy of the original instruction */
 56         kprobe_opcode_t *insn;
 57         /*
 58          * boostable = 0: This instruction type is not boostable.
 59          * boostable = 1: This instruction has been boosted: we have
 60          * added a relative jump after the instruction copy in insn,
 61          * so no single-step and fixup are needed (unless there's
 62          * a post_handler).
 63          */
 64         unsigned boostable:1;
 65         unsigned char size;     /* The size of insn */
 66         union {
 67                 unsigned char opcode;
 68                 struct {
 69                         unsigned char type;
 70                 } jcc;
 71                 struct {
 72                         unsigned char type;
 73                         unsigned char asize;
 74                 } loop;
 75                 struct {
 76                         unsigned char reg;
 77                 } indirect;
 78         };
 79         s32 rel32;      /* relative offset must be s32, s16, or s8 */
 80         void (*emulate_op)(struct kprobe *p, struct pt_regs *regs);
 81         /* Number of bytes of text poked */
 82         int tp_len;
 83 };
 84 
 85 struct arch_optimized_insn {
 86         /* copy of the original instructions */
 87         kprobe_opcode_t copied_insn[DISP32_SIZE];
 88         /* detour code buffer */
 89         kprobe_opcode_t *insn;
 90         /* the size of instructions copied to detour code buffer */
 91         size_t size;
 92 };
 93 
 94 /* Return true (!0) if optinsn is prepared for optimization. */
 95 static inline int arch_prepared_optinsn(struct arch_optimized_insn *optinsn)
 96 {
 97         return optinsn->size;
 98 }
 99 
100 struct prev_kprobe {
101         struct kprobe *kp;
102         unsigned long status;
103         unsigned long old_flags;
104         unsigned long saved_flags;
105 };
106 
107 /* per-cpu kprobe control block */
108 struct kprobe_ctlblk {
109         unsigned long kprobe_status;
110         unsigned long kprobe_old_flags;
111         unsigned long kprobe_saved_flags;
112         struct prev_kprobe prev_kprobe;
113 };
114 
115 extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
116 extern int kprobe_int3_handler(struct pt_regs *regs);
117 
118 #else
119 
120 static inline int kprobe_debug_handler(struct pt_regs *regs) { return 0; }
121 
122 #endif /* CONFIG_KPROBES */
123 #endif /* _ASM_X86_KPROBES_H */
124 

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

kernel.org | git.kernel.org | LWN.net | Project Home | 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.

sflogo.php