aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorAndy Lutomirski <luto@kernel.org>2016-03-09 22:00:28 -0500
committerIngo Molnar <mingo@kernel.org>2016-03-10 03:48:13 -0500
commit81edd9f69a6fd214fdbe66b43de6aa1610c84c63 (patch)
treec93d1ac792c7864ff0836b159e69f30c5032bf17 /arch/x86/kernel
parentc2c9b52fab0d0cf993476ed4c34f24da5a1205ae (diff)
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>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/traps.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 410e8e2700c5..1af56217fb5d 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -598,6 +598,13 @@ dotraplinkage void do_debug(struct pt_regs *regs, long error_code)
598 dr6 &= ~DR6_RESERVED; 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 * If dr6 has no reason to give us about the origin of this trap, 608 * If dr6 has no reason to give us about the origin of this trap,
602 * then it's very likely the result of an icebp/int01 trap. 609 * then it's very likely the result of an icebp/int01 trap.
603 * User wants a sigtrap for that. 610 * User wants a sigtrap for that.
@@ -612,11 +619,6 @@ dotraplinkage void do_debug(struct pt_regs *regs, long error_code)
612 /* DR6 may or may not be cleared by the CPU */ 619 /* DR6 may or may not be cleared by the CPU */
613 set_debugreg(0, 6); 620 set_debugreg(0, 6);
614 621
615 /*
616 * The processor cleared BTF, so don't mark that we need it set.
617 */
618 clear_tsk_thread_flag(tsk, TIF_BLOCKSTEP);
619
620 /* Store the virtualized DR6 value */ 622 /* Store the virtualized DR6 value */
621 tsk->thread.debugreg6 = dr6; 623 tsk->thread.debugreg6 = dr6;
622 624