Skip to content

Commit

Permalink
x86/debug: Sync BTF earlier
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Peter Zijlstra authored and Thomas Gleixner committed Sep 4, 2020
1 parent d5c678a commit c182487
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions arch/x86/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,13 @@ static __always_inline unsigned long debug_read_clear_dr6(void)
/* Filter out all the reserved bits which are preset to 1 */
dr6 &= ~DR6_RESERVED;

/*
* The SDM says "The processor clears the BTF flag when it
* generates a debug exception." Clear TIF_BLOCKSTEP to keep
* TIF_BLOCKSTEP in sync with the hardware BTF flag.
*/
clear_thread_flag(TIF_BLOCKSTEP);

return dr6;
}

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

/*
* The SDM says "The processor clears the BTF flag when it
* generates a debug exception." Clear TIF_BLOCKSTEP to keep
* TIF_BLOCKSTEP in sync with the hardware BTF flag.
*/
clear_thread_flag(TIF_BLOCKSTEP);

/*
* If DR6 is zero, no point in trying to handle it. The kernel is
* not using INT1.
Expand Down

0 comments on commit c182487

Please sign in to comment.