···11+#ifndef _ASM_X86_PTRACE_H22+#define _ASM_X86_PTRACE_H33+44+#include <linux/compiler.h> /* For __user */55+#include <asm/ptrace-abi.h>66+77+#ifndef __ASSEMBLY__88+99+#ifdef __i386__1010+/* this struct defines the way the registers are stored on the1111+ stack during a system call. */1212+1313+struct pt_regs {1414+ long ebx;1515+ long ecx;1616+ long edx;1717+ long esi;1818+ long edi;1919+ long ebp;2020+ long eax;2121+ int xds;2222+ int xes;2323+ int xfs;2424+ /* int xgs; */2525+ long orig_eax;2626+ long eip;2727+ int xcs;2828+ long eflags;2929+ long esp;3030+ int xss;3131+};3232+133#ifdef __KERNEL__22-# ifdef CONFIG_X86_3233-# include "ptrace_32.h"44-# else55-# include "ptrace_64.h"66-# endif77-#else88-# ifdef __i386__99-# include "ptrace_32.h"1010-# else1111-# include "ptrace_64.h"1212-# endif3434+3535+#include <asm/vm86.h>3636+#include <asm/segment.h>3737+3838+struct task_struct;3939+extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code);4040+4141+/*4242+ * user_mode_vm(regs) determines whether a register set came from user mode.4343+ * This is true if V8086 mode was enabled OR if the register set was from4444+ * protected mode with RPL-3 CS value. This tricky test checks that with4545+ * one comparison. Many places in the kernel can bypass this full check4646+ * if they have already ruled out V8086 mode, so user_mode(regs) can be used.4747+ */4848+static inline int user_mode(struct pt_regs *regs)4949+{5050+ return (regs->xcs & SEGMENT_RPL_MASK) == USER_RPL;5151+}5252+static inline int user_mode_vm(struct pt_regs *regs)5353+{5454+ return ((regs->xcs & SEGMENT_RPL_MASK) | (regs->eflags & VM_MASK)) >= USER_RPL;5555+}5656+static inline int v8086_mode(struct pt_regs *regs)5757+{5858+ return (regs->eflags & VM_MASK);5959+}6060+6161+#define instruction_pointer(regs) ((regs)->eip)6262+#define frame_pointer(regs) ((regs)->ebp)6363+#define stack_pointer(regs) ((regs)->esp)6464+#define regs_return_value(regs) ((regs)->eax)6565+6666+extern unsigned long profile_pc(struct pt_regs *regs);6767+#endif /* __KERNEL__ */6868+6969+#else /* __i386__ */7070+7171+struct pt_regs {7272+ unsigned long r15;7373+ unsigned long r14;7474+ unsigned long r13;7575+ unsigned long r12;7676+ unsigned long rbp;7777+ unsigned long rbx;7878+/* arguments: non interrupts/non tracing syscalls only save upto here*/7979+ unsigned long r11;8080+ unsigned long r10;8181+ unsigned long r9;8282+ unsigned long r8;8383+ unsigned long rax;8484+ unsigned long rcx;8585+ unsigned long rdx;8686+ unsigned long rsi;8787+ unsigned long rdi;8888+ unsigned long orig_rax;8989+/* end of arguments */9090+/* cpu exception frame or undefined */9191+ unsigned long rip;9292+ unsigned long cs;9393+ unsigned long eflags;9494+ unsigned long rsp;9595+ unsigned long ss;9696+/* top of stack page */9797+};9898+9999+#ifdef __KERNEL__100100+101101+#define user_mode(regs) (!!((regs)->cs & 3))102102+#define user_mode_vm(regs) user_mode(regs)103103+#define instruction_pointer(regs) ((regs)->rip)104104+#define frame_pointer(regs) ((regs)->rbp)105105+#define stack_pointer(regs) ((regs)->rsp)106106+#define regs_return_value(regs) ((regs)->rax)107107+108108+extern unsigned long profile_pc(struct pt_regs *regs);109109+void signal_fault(struct pt_regs *regs, void __user *frame, char *where);110110+111111+struct task_struct;112112+113113+extern unsigned long114114+convert_rip_to_linear(struct task_struct *child, struct pt_regs *regs);115115+116116+enum {117117+ EF_CF = 0x00000001,118118+ EF_PF = 0x00000004,119119+ EF_AF = 0x00000010,120120+ EF_ZF = 0x00000040,121121+ EF_SF = 0x00000080,122122+ EF_TF = 0x00000100,123123+ EF_IE = 0x00000200,124124+ EF_DF = 0x00000400,125125+ EF_OF = 0x00000800,126126+ EF_IOPL = 0x00003000,127127+ EF_IOPL_RING0 = 0x00000000,128128+ EF_IOPL_RING1 = 0x00001000,129129+ EF_IOPL_RING2 = 0x00002000,130130+ EF_NT = 0x00004000, /* nested task */131131+ EF_RF = 0x00010000, /* resume */132132+ EF_VM = 0x00020000, /* virtual mode */133133+ EF_AC = 0x00040000, /* alignment */134134+ EF_VIF = 0x00080000, /* virtual interrupt */135135+ EF_VIP = 0x00100000, /* virtual interrupt pending */136136+ EF_ID = 0x00200000, /* id */137137+};138138+#endif /* __KERNEL__ */139139+#endif /* !__i386__ */140140+#endif /* !__ASSEMBLY__ */141141+13142#endif
-65
include/asm-x86/ptrace_32.h
···11-#ifndef _I386_PTRACE_H22-#define _I386_PTRACE_H33-44-#include <asm/ptrace-abi.h>55-66-/* this struct defines the way the registers are stored on the 77- stack during a system call. */88-99-struct pt_regs {1010- long ebx;1111- long ecx;1212- long edx;1313- long esi;1414- long edi;1515- long ebp;1616- long eax;1717- int xds;1818- int xes;1919- int xfs;2020- /* int xgs; */2121- long orig_eax;2222- long eip;2323- int xcs;2424- long eflags;2525- long esp;2626- int xss;2727-};2828-2929-#ifdef __KERNEL__3030-3131-#include <asm/vm86.h>3232-#include <asm/segment.h>3333-3434-struct task_struct;3535-extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code);3636-3737-/*3838- * user_mode_vm(regs) determines whether a register set came from user mode.3939- * This is true if V8086 mode was enabled OR if the register set was from4040- * protected mode with RPL-3 CS value. This tricky test checks that with4141- * one comparison. Many places in the kernel can bypass this full check4242- * if they have already ruled out V8086 mode, so user_mode(regs) can be used.4343- */4444-static inline int user_mode(struct pt_regs *regs)4545-{4646- return (regs->xcs & SEGMENT_RPL_MASK) == USER_RPL;4747-}4848-static inline int user_mode_vm(struct pt_regs *regs)4949-{5050- return ((regs->xcs & SEGMENT_RPL_MASK) | (regs->eflags & VM_MASK)) >= USER_RPL;5151-}5252-static inline int v8086_mode(struct pt_regs *regs)5353-{5454- return (regs->eflags & VM_MASK);5555-}5656-5757-#define instruction_pointer(regs) ((regs)->eip)5858-#define frame_pointer(regs) ((regs)->ebp)5959-#define stack_pointer(regs) ((regs)->esp)6060-#define regs_return_value(regs) ((regs)->eax)6161-6262-extern unsigned long profile_pc(struct pt_regs *regs);6363-#endif /* __KERNEL__ */6464-6565-#endif
-80
include/asm-x86/ptrace_64.h
···11-#ifndef _X86_64_PTRACE_H22-#define _X86_64_PTRACE_H33-44-#include <linux/compiler.h> /* For __user */55-#include <asm/ptrace-abi.h>66-77-#ifndef __ASSEMBLY__88-99-struct pt_regs {1010- unsigned long r15;1111- unsigned long r14;1212- unsigned long r13;1313- unsigned long r12;1414- unsigned long rbp;1515- unsigned long rbx;1616-/* arguments: non interrupts/non tracing syscalls only save upto here*/1717- unsigned long r11;1818- unsigned long r10;1919- unsigned long r9;2020- unsigned long r8;2121- unsigned long rax;2222- unsigned long rcx;2323- unsigned long rdx;2424- unsigned long rsi;2525- unsigned long rdi;2626- unsigned long orig_rax;2727-/* end of arguments */2828-/* cpu exception frame or undefined */2929- unsigned long rip;3030- unsigned long cs;3131- unsigned long eflags;3232- unsigned long rsp;3333- unsigned long ss;3434-/* top of stack page */3535-};3636-3737-#endif3838-3939-#if defined(__KERNEL__) && !defined(__ASSEMBLY__) 4040-#define user_mode(regs) (!!((regs)->cs & 3))4141-#define user_mode_vm(regs) user_mode(regs)4242-#define instruction_pointer(regs) ((regs)->rip)4343-#define frame_pointer(regs) ((regs)->rbp)4444-#define stack_pointer(regs) ((regs)->rsp)4545-#define regs_return_value(regs) ((regs)->rax)4646-4747-extern unsigned long profile_pc(struct pt_regs *regs);4848-void signal_fault(struct pt_regs *regs, void __user *frame, char *where);4949-5050-struct task_struct;5151-5252-extern unsigned long5353-convert_rip_to_linear(struct task_struct *child, struct pt_regs *regs);5454-5555-enum {5656- EF_CF = 0x00000001,5757- EF_PF = 0x00000004,5858- EF_AF = 0x00000010,5959- EF_ZF = 0x00000040,6060- EF_SF = 0x00000080,6161- EF_TF = 0x00000100,6262- EF_IE = 0x00000200,6363- EF_DF = 0x00000400,6464- EF_OF = 0x00000800,6565- EF_IOPL = 0x00003000,6666- EF_IOPL_RING0 = 0x00000000,6767- EF_IOPL_RING1 = 0x00001000,6868- EF_IOPL_RING2 = 0x00002000,6969- EF_NT = 0x00004000, /* nested task */7070- EF_RF = 0x00010000, /* resume */7171- EF_VM = 0x00020000, /* virtual mode */7272- EF_AC = 0x00040000, /* alignment */7373- EF_VIF = 0x00080000, /* virtual interrupt */7474- EF_VIP = 0x00100000, /* virtual interrupt pending */7575- EF_ID = 0x00200000, /* id */7676-};7777-7878-#endif7979-8080-#endif