[RFC][PATCH 2/7] x86/debug: Sync BTF earlier

From: Peter Zijlstra
Date: Thu Aug 20 2020 - 06:54:59 EST



Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
arch/x86/kernel/traps.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -749,6 +749,13 @@ static __always_inline unsigned long deb
/* 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;
}

@@ -783,13 +790,6 @@ static void handle_debug(struct pt_regs
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.
*/