]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/x86/kernel/step.c
Merge git://git.infradead.org/mtd-2.6
[linux-2.6-omap-h63xx.git] / arch / x86 / kernel / step.c
index f55c003f5b6392737be0adea0733c9f1970b9a13..2ef1a5f8d6758043b6ce2204da47cb71e5cc1614 100644 (file)
@@ -5,10 +5,7 @@
 #include <linux/mm.h>
 #include <linux/ptrace.h>
 
-#ifdef CONFIG_X86_32
-static
-#endif
-unsigned long convert_rip_to_linear(struct task_struct *child, struct pt_regs *regs)
+unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *regs)
 {
        unsigned long addr, seg;
 
@@ -55,7 +52,7 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
 {
        int i, copied;
        unsigned char opcode[15];
-       unsigned long addr = convert_rip_to_linear(child, regs);
+       unsigned long addr = convert_ip_to_linear(child, regs);
 
        copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
        for (i = 0; i < copied; i++) {
@@ -148,11 +145,7 @@ static void write_debugctlmsr(struct task_struct *child, unsigned long val)
        if (child != current)
                return;
 
-#ifdef CONFIG_X86_64
        wrmsrl(MSR_IA32_DEBUGCTLMSR, val);
-#else
-       wrmsr(MSR_IA32_DEBUGCTLMSR, val, 0);
-#endif
 }
 
 /*
@@ -169,9 +162,14 @@ static void enable_step(struct task_struct *child, bool block)
         */
        if (enable_single_step(child) && block) {
                set_tsk_thread_flag(child, TIF_DEBUGCTLMSR);
-               write_debugctlmsr(child, DEBUGCTLMSR_BTF);
-       } else if (test_and_clear_tsk_thread_flag(child, TIF_DEBUGCTLMSR)) {
-               write_debugctlmsr(child, 0);
+               write_debugctlmsr(child,
+                                 child->thread.debugctlmsr | DEBUGCTLMSR_BTF);
+       } else {
+           write_debugctlmsr(child,
+                             child->thread.debugctlmsr & ~TIF_DEBUGCTLMSR);
+
+           if (!child->thread.debugctlmsr)
+                   clear_tsk_thread_flag(child, TIF_DEBUGCTLMSR);
        }
 }
 
@@ -190,8 +188,11 @@ void user_disable_single_step(struct task_struct *child)
        /*
         * Make sure block stepping (BTF) is disabled.
         */
-       if (test_and_clear_tsk_thread_flag(child, TIF_DEBUGCTLMSR))
-               write_debugctlmsr(child, 0);
+       write_debugctlmsr(child,
+                         child->thread.debugctlmsr & ~TIF_DEBUGCTLMSR);
+
+       if (!child->thread.debugctlmsr)
+               clear_tsk_thread_flag(child, TIF_DEBUGCTLMSR);
 
        /* Always clear TIF_SINGLESTEP... */
        clear_tsk_thread_flag(child, TIF_SINGLESTEP);