[PATCH] Remove leftover MCE/EISA support
[pandora-kernel.git] / arch / x86_64 / kernel / ptrace.c
index a87b6ce..d35ec1b 100644 (file)
  * in exit.c or in signal.c.
  */
 
-/* determines which flags the user has access to. */
-/* 1 = access 0 = no access */
-#define FLAG_MASK 0x44dd5UL
+/*
+ * Determines which flags the user has access to [1 = access, 0 = no access].
+ * Prohibits changing ID(21), VIP(20), VIF(19), VM(17), IOPL(12-13), IF(9).
+ * Also masks reserved bits (63-22, 15, 5, 3, 1).
+ */
+#define FLAG_MASK 0x54dd5UL
 
 /* set's the trap flag. */
 #define TRAP_FLAG 0x100UL
@@ -64,12 +67,6 @@ static inline unsigned long get_stack_long(struct task_struct *task, int offset)
        return (*((unsigned long *)stack));
 }
 
-static inline struct pt_regs *get_child_regs(struct task_struct *task)
-{
-       struct pt_regs *regs = (void *)task->thread.rsp0;
-       return regs - 1;
-}
-
 /*
  * this routine will put a word on the processes privileged stack. 
  * the offset is how far from the base addr as stored in the TSS.  
@@ -167,7 +164,7 @@ static int is_at_popf(struct task_struct *child, struct pt_regs *regs)
 
 static void set_singlestep(struct task_struct *child)
 {
-       struct pt_regs *regs = get_child_regs(child);
+       struct pt_regs *regs = task_pt_regs(child);
 
        /*
         * Always set TIF_SINGLESTEP - this guarantees that
@@ -205,7 +202,7 @@ static void clear_singlestep(struct task_struct *child)
 
        /* But touch TF only if it was set by us.. */
        if (child->ptrace & PT_DTRACE) {
-               struct pt_regs *regs = get_child_regs(child);
+               struct pt_regs *regs = task_pt_regs(child);
                regs->eflags &= ~TRAP_FLAG;
                child->ptrace &= ~PT_DTRACE;
        }
@@ -277,11 +274,6 @@ static int putreg(struct task_struct *child,
                                return -EIO;
                        value &= 0xffff;
                        break;
-               case offsetof(struct user_regs_struct, rip):
-                       /* Check if the new RIP address is canonical */
-                       if (value >= TASK_SIZE_OF(child))
-                               return -EIO;
-                       break;
        }
        put_stack_long(child, regno - sizeof(struct pt_regs), value);
        return 0;
@@ -423,14 +415,18 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
                case offsetof(struct user, u_debugreg[7]):
                        /* See arch/i386/kernel/ptrace.c for an explanation of
                         * this awkward check.*/
-                                 data &= ~DR_CONTROL_RESERVED;
-                                 for(i=0; i<4; i++)
-                                         if ((0x5454 >> ((data >> (16 + 4*i)) & 0xf)) & 1)
+                       data &= ~DR_CONTROL_RESERVED;
+                       for(i=0; i<4; i++)
+                               if ((0x5554 >> ((data >> (16 + 4*i)) & 0xf)) & 1)
                                        break;
                        if (i == 4) {
-                               child->thread.debugreg7 = data;
+                         child->thread.debugreg7 = data;
+                         if (data)
+                               set_tsk_thread_flag(child, TIF_DEBUG);
+                         else
+                               clear_tsk_thread_flag(child, TIF_DEBUG);
                          ret = 0;
-                 }
+                       }
                  break;
                }
                break;
@@ -608,12 +604,12 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
 
        if (unlikely(current->audit_context)) {
                if (test_thread_flag(TIF_IA32)) {
-                       audit_syscall_entry(current, AUDIT_ARCH_I386,
+                       audit_syscall_entry(AUDIT_ARCH_I386,
                                            regs->orig_rax,
                                            regs->rbx, regs->rcx,
                                            regs->rdx, regs->rsi);
                } else {
-                       audit_syscall_entry(current, AUDIT_ARCH_X86_64,
+                       audit_syscall_entry(AUDIT_ARCH_X86_64,
                                            regs->orig_rax,
                                            regs->rdi, regs->rsi,
                                            regs->rdx, regs->r10);
@@ -624,7 +620,7 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
 {
        if (unlikely(current->audit_context))
-               audit_syscall_exit(current, AUDITSC_RESULT(regs->rax), regs->rax);
+               audit_syscall_exit(AUDITSC_RESULT(regs->rax), regs->rax);
 
        if ((test_thread_flag(TIF_SYSCALL_TRACE)
             || test_thread_flag(TIF_SINGLESTEP))