X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=include%2Fasm-x86%2Fptrace.h;h=9f922b0b95d6d3961275c9cac804acf22cbb8ef6;hb=13a6ddb08e58a1bd344da7898c4e2f13bdf18c2f;hp=a9a1bab1451ac670720125c5d0b23bb34cc519c1;hpb=eee3af4a2c83a97fff107ddc445d9df6fded9ce4;p=linux-2.6 diff --git a/include/asm-x86/ptrace.h b/include/asm-x86/ptrace.h index a9a1bab145..9f922b0b95 100644 --- a/include/asm-x86/ptrace.h +++ b/include/asm-x86/ptrace.h @@ -7,16 +7,6 @@ #ifndef __ASSEMBLY__ -#ifdef __KERNEL__ - -#include - -struct task_struct; -extern void ptrace_bts_take_timestamp(struct task_struct *, enum bts_qualifier); - -#endif /* __KERNEL__ */ - - #ifdef __i386__ /* this struct defines the way the registers are stored on the stack during a system call. */ @@ -46,58 +36,28 @@ struct pt_regs { #else /* __KERNEL__ */ struct pt_regs { - long bx; - long cx; - long dx; - long si; - long di; - long bp; - long ax; - int ds; - int es; - int fs; + unsigned long bx; + unsigned long cx; + unsigned long dx; + unsigned long si; + unsigned long di; + unsigned long bp; + unsigned long ax; + unsigned long ds; + unsigned long es; + unsigned long fs; /* int gs; */ - long orig_ax; - long ip; - int cs; - long flags; - long sp; - int ss; + unsigned long orig_ax; + unsigned long ip; + unsigned long cs; + unsigned long flags; + unsigned long sp; + unsigned long ss; }; #include #include -struct task_struct; -extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code); - -/* - * user_mode_vm(regs) determines whether a register set came from user mode. - * This is true if V8086 mode was enabled OR if the register set was from - * protected mode with RPL-3 CS value. This tricky test checks that with - * one comparison. Many places in the kernel can bypass this full check - * if they have already ruled out V8086 mode, so user_mode(regs) can be used. - */ -static inline int user_mode(struct pt_regs *regs) -{ - return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL; -} -static inline int user_mode_vm(struct pt_regs *regs) -{ - return ((regs->cs & SEGMENT_RPL_MASK) | - (regs->flags & VM_MASK)) >= USER_RPL; -} -static inline int v8086_mode(struct pt_regs *regs) -{ - return (regs->flags & VM_MASK); -} - -#define instruction_pointer(regs) ((regs)->ip) -#define frame_pointer(regs) ((regs)->bp) -#define stack_pointer(regs) ((unsigned long)(regs)) -#define regs_return_value(regs) ((regs)->ax) - -extern unsigned long profile_pc(struct pt_regs *regs); #endif /* __KERNEL__ */ #else /* __i386__ */ @@ -162,26 +122,94 @@ struct pt_regs { /* top of stack page */ }; -#define user_mode(regs) (!!((regs)->cs & 3)) -#define user_mode_vm(regs) user_mode(regs) -#define v8086_mode(regs) 0 /* No V86 mode support in long mode */ -#define instruction_pointer(regs) ((regs)->ip) -#define frame_pointer(regs) ((regs)->bp) -#define stack_pointer(regs) ((regs)->sp) -#define regs_return_value(regs) ((regs)->ax) +#endif /* __KERNEL__ */ +#endif /* !__i386__ */ -extern unsigned long profile_pc(struct pt_regs *regs); -void signal_fault(struct pt_regs *regs, void __user *frame, char *where); +#ifdef __KERNEL__ + +/* the DS BTS struct is used for ptrace as well */ +#include struct task_struct; +extern void ptrace_bts_take_timestamp(struct task_struct *, enum bts_qualifier); + +extern unsigned long profile_pc(struct pt_regs *regs); + extern unsigned long -convert_rip_to_linear(struct task_struct *child, struct pt_regs *regs); +convert_ip_to_linear(struct task_struct *child, struct pt_regs *regs); -#endif /* __KERNEL__ */ -#endif /* !__i386__ */ +#ifdef CONFIG_X86_32 +extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, + int error_code); +#else +void signal_fault(struct pt_regs *regs, void __user *frame, char *where); +#endif -#ifdef __KERNEL__ +static inline unsigned long regs_return_value(struct pt_regs *regs) +{ + return regs->ax; +} + +/* + * user_mode_vm(regs) determines whether a register set came from user mode. + * This is true if V8086 mode was enabled OR if the register set was from + * protected mode with RPL-3 CS value. This tricky test checks that with + * one comparison. Many places in the kernel can bypass this full check + * if they have already ruled out V8086 mode, so user_mode(regs) can be used. + */ +static inline int user_mode(struct pt_regs *regs) +{ +#ifdef CONFIG_X86_32 + return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL; +#else + return !!(regs->cs & 3); +#endif +} + +static inline int user_mode_vm(struct pt_regs *regs) +{ +#ifdef CONFIG_X86_32 + return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >= + USER_RPL; +#else + return user_mode(regs); +#endif +} + +static inline int v8086_mode(struct pt_regs *regs) +{ +#ifdef CONFIG_X86_32 + return (regs->flags & X86_VM_MASK); +#else + return 0; /* No V86 mode support in long mode */ +#endif +} + +/* + * X86_32 CPUs don't save ss and esp if the CPU is already in kernel mode + * when it traps. So regs will be the current sp. + * + * This is valid only for kernel mode traps. + */ +static inline unsigned long kernel_trap_sp(struct pt_regs *regs) +{ +#ifdef CONFIG_X86_32 + return (unsigned long)regs; +#else + return regs->sp; +#endif +} + +static inline unsigned long instruction_pointer(struct pt_regs *regs) +{ + return regs->ip; +} + +static inline unsigned long frame_pointer(struct pt_regs *regs) +{ + return regs->bp; +} /* * These are defined as per linux/ptrace.h, which see. @@ -203,6 +231,8 @@ extern int do_get_thread_area(struct task_struct *p, int idx, extern int do_set_thread_area(struct task_struct *p, int idx, struct user_desc __user *info, int can_allocate); +#define __ARCH_WANT_COMPAT_SYS_PTRACE + #endif /* __KERNEL__ */ #endif /* !__ASSEMBLY__ */