Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/entry/traps: Clear TIF_BLOCKSTEP on all debug exceptions

The SDM says that debug exceptions clear BTF, and we need to keep
TIF_BLOCKSTEP in sync with BTF. Clear it unconditionally and improve
the comment.

I suspect that the fact that kmemcheck could cause TIF_BLOCKSTEP not
to be cleared was just an oversight.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/fa86e55d196e6dde5b38839595bde2a292c52fdc.1457578375.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Andy Lutomirski and committed by
Ingo Molnar
81edd9f6 c2c9b52f

+7 -5
+7 -5
arch/x86/kernel/traps.c
··· 598 598 dr6 &= ~DR6_RESERVED; 599 599 600 600 /* 601 + * The SDM says "The processor clears the BTF flag when it 602 + * generates a debug exception." Clear TIF_BLOCKSTEP to keep 603 + * TIF_BLOCKSTEP in sync with the hardware BTF flag. 604 + */ 605 + clear_tsk_thread_flag(tsk, TIF_BLOCKSTEP); 606 + 607 + /* 601 608 * If dr6 has no reason to give us about the origin of this trap, 602 609 * then it's very likely the result of an icebp/int01 trap. 603 610 * User wants a sigtrap for that. ··· 618 611 619 612 /* DR6 may or may not be cleared by the CPU */ 620 613 set_debugreg(0, 6); 621 - 622 - /* 623 - * The processor cleared BTF, so don't mark that we need it set. 624 - */ 625 - clear_tsk_thread_flag(tsk, TIF_BLOCKSTEP); 626 614 627 615 /* Store the virtualized DR6 value */ 628 616 tsk->thread.debugreg6 = dr6;