x86/debug: Remove the historical junk
[linux-2.6-microblaze.git] / arch / x86 / kernel / traps.c
index 682af24..1e89001 100644 (file)
@@ -843,18 +843,19 @@ static __always_inline void exc_debug_kernel(struct pt_regs *regs,
        if (notify_debug(regs, &dr6))
                goto out;
 
-       if (WARN_ON_ONCE(dr6 & DR_STEP)) {
-               /*
-                * Historical junk that used to handle SYSENTER single-stepping.
-                * This should be unreachable now.  If we survive for a while
-                * without anyone hitting this warning, we'll turn this into
-                * an oops.
-                */
-               dr6 &= ~DR_STEP;
-               set_thread_flag(TIF_SINGLESTEP);
+       /*
+        * The kernel doesn't use TF single-step outside of:
+        *
+        *  - Kprobes, consumed through kprobe_debug_handler()
+        *  - KGDB, consumed through notify_debug()
+        *
+        * So if we get here with DR_STEP set, something is wonky.
+        *
+        * A known way to trigger this is through QEMU's GDB stub,
+        * which leaks #DB into the guest and causes IST recursion.
+        */
+       if (WARN_ON_ONCE(current->thread.debugreg6 & DR_STEP))
                regs->flags &= ~X86_EFLAGS_TF;
-       }
-
 out:
        instrumentation_end();
        idtentry_exit_nmi(regs, irq_state);