Skip to content

Commit c182487

Browse files
Peter ZijlstraKAGA-KOKO
authored andcommitted
x86/debug: Sync BTF earlier
Move the BTF sync near the DR6 load, as this will be the only common code guaranteed to run on every #DB. 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> Acked-by: Andy Lutomirski <luto@kernel.org> Link: https://lore.kernel.org/r/20200902133200.786888252@infradead.org
1 parent d5c678a commit c182487

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

arch/x86/kernel/traps.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,13 @@ static __always_inline unsigned long debug_read_clear_dr6(void)
749749
/* Filter out all the reserved bits which are preset to 1 */
750750
dr6 &= ~DR6_RESERVED;
751751

752+
/*
753+
* The SDM says "The processor clears the BTF flag when it
754+
* generates a debug exception." Clear TIF_BLOCKSTEP to keep
755+
* TIF_BLOCKSTEP in sync with the hardware BTF flag.
756+
*/
757+
clear_thread_flag(TIF_BLOCKSTEP);
758+
752759
return dr6;
753760
}
754761

@@ -782,13 +789,6 @@ static void handle_debug(struct pt_regs *regs, unsigned long dr6, bool user)
782789
bool user_icebp;
783790
int si_code;
784791

785-
/*
786-
* The SDM says "The processor clears the BTF flag when it
787-
* generates a debug exception." Clear TIF_BLOCKSTEP to keep
788-
* TIF_BLOCKSTEP in sync with the hardware BTF flag.
789-
*/
790-
clear_thread_flag(TIF_BLOCKSTEP);
791-
792792
/*
793793
* If DR6 is zero, no point in trying to handle it. The kernel is
794794
* not using INT1.

0 commit comments

Comments
 (0)