Skip to content

Commit 389cd0c

Browse files
Peter ZijlstraKAGA-KOKO
authored andcommitted
x86/debug: Remove the historical junk
Remove the historical junk and replace it with a WARN and a comment. The problem is that even though the kernel only uses TF single-step in kprobes and KGDB, both of which consume the event before this, QEMU/KVM has bugs in this area that can trigger this state so it has to be dealt with. Suggested-by: Brian Gerst <brgerst@gmail.com> Suggested-by: Andy Lutomirski <luto@amacapital.net> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Daniel Thompson <daniel.thompson@linaro.org> Link: https://lore.kernel.org/r/20200902133201.170216274@infradead.org
1 parent f0b67c3 commit 389cd0c

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

arch/x86/kernel/traps.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -843,18 +843,19 @@ static __always_inline void exc_debug_kernel(struct pt_regs *regs,
843843
if (notify_debug(regs, &dr6))
844844
goto out;
845845

846-
if (WARN_ON_ONCE(dr6 & DR_STEP)) {
847-
/*
848-
* Historical junk that used to handle SYSENTER single-stepping.
849-
* This should be unreachable now. If we survive for a while
850-
* without anyone hitting this warning, we'll turn this into
851-
* an oops.
852-
*/
853-
dr6 &= ~DR_STEP;
854-
set_thread_flag(TIF_SINGLESTEP);
846+
/*
847+
* The kernel doesn't use TF single-step outside of:
848+
*
849+
* - Kprobes, consumed through kprobe_debug_handler()
850+
* - KGDB, consumed through notify_debug()
851+
*
852+
* So if we get here with DR_STEP set, something is wonky.
853+
*
854+
* A known way to trigger this is through QEMU's GDB stub,
855+
* which leaks #DB into the guest and causes IST recursion.
856+
*/
857+
if (WARN_ON_ONCE(current->thread.debugreg6 & DR_STEP))
855858
regs->flags &= ~X86_EFLAGS_TF;
856-
}
857-
858859
out:
859860
instrumentation_end();
860861
idtentry_exit_nmi(regs, irq_state);

0 commit comments

Comments
 (0)