[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201027093608.028952500@infradead.org>
Date: Tue, 27 Oct 2020 10:15:06 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: tglx@...utronix.de, luto@...nel.org, me@...ehuey.com
Cc: x86@...nel.org, linux-kernel@...r.kernel.org,
torvalds@...ux-foundation.org, rocallahan@...il.com,
alexandre.chartre@...cle.com, paulmck@...nel.org,
frederic@...nel.org, pbonzini@...hat.com,
sean.j.christopherson@...el.com, mhiramat@...nel.org,
pmladek@...e.com, joel@...lfernandes.org, rostedt@...dmis.org,
boris.ostrovsky@...cle.com, jgross@...e.com, brgerst@...il.com,
jpoimboe@...hat.com, daniel.thompson@...aro.org,
julliard@...ehq.org, pgofman@...eweavers.com, peterz@...radead.org
Subject: [PATCH 2/3] x86/debug: Only clear/set ->virtual_dr6 for userspace #DB
The ->virtual_dr6 is the value used by ptrace_{get,set}_debugreg(6). A
kernel #DB clearing it could mean spurious malfunction of ptrace()
expectations.
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
---
arch/x86/kernel/traps.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -793,12 +793,6 @@ static __always_inline unsigned long deb
set_debugreg(DR6_RESERVED, 6);
dr6 ^= DR6_RESERVED; /* Flip to positive polarity */
- /*
- * Clear the virtual DR6 value, ptrace routines will set bits here for
- * things we want signals for.
- */
- current->thread.virtual_dr6 = 0;
-
return dr6;
}
@@ -943,6 +937,12 @@ static __always_inline void exc_debug_us
instrumentation_begin();
/*
+ * Clear the virtual DR6 value, ptrace() routines will set bits here
+ * for things it wants signals for.
+ */
+ current->thread.virtual_dr6 = 0;
+
+ /*
* 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.
Powered by blists - more mailing lists