From: Peter Zijlstra Date: Wed, 2 Sep 2020 13:25:52 +0000 (+0200) Subject: x86/debug: Sync BTF earlier X-Git-Tag: Ubuntu-5.13.0-19.19~4927^2~10 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=c182487da1b5281463f2255d2347885dba219c08;p=mirror_ubuntu-jammy-kernel.git 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) Signed-off-by: Thomas Gleixner Tested-by: Daniel Thompson Acked-by: Andy Lutomirski Link: https://lore.kernel.org/r/20200902133200.786888252@infradead.org --- diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 81a2fb711091..99456428fb98 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -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; } @@ -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.