]> Pileus Git - ~andy/linux/blobdiff - include/asm-x86/ptrace.h
Merge branch 'task_killable' of git://git.kernel.org/pub/scm/linux/kernel/git/willy...
[~andy/linux] / include / asm-x86 / ptrace.h
index cc4456667d89547d75ed99af552a3f9fd229dc95..d9e04b46a44069a56565729085fc11b67399696d 100644 (file)
@@ -7,17 +7,6 @@
 
 #ifndef __ASSEMBLY__
 
-#ifdef __KERNEL__
-
-/* the DS BTS struct is used for ptrace as well */
-#include <asm/ds.h>
-
-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. */
@@ -69,36 +58,6 @@ struct pt_regs {
 #include <asm/vm86.h>
 #include <asm/segment.h>
 
-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__ */
@@ -163,28 +122,90 @@ 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 <asm/ds.h>
 
 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__
+#define regs_return_value(regs) ((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 & 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 & VM_MASK);
+#else
+       return 0;       /* No V86 mode support in long mode */
+#endif
+}
 
-unsigned long get_segment_eip(struct pt_regs *regs, unsigned long *eip_limit);
+/*
+ * 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.