All of lore.kernel.org
 help / color / mirror / Atom feed
From: "tip-bot2 for Peter Zijlstra" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>, Kyle Huey <me@kylehuey.com>,
	x86 <x86@kernel.org>, LKML <linux-kernel@vger.kernel.org>
Subject: [tip: x86/urgent] x86/debug: Only clear/set ->virtual_dr6 for userspace #DB
Date: Tue, 27 Oct 2020 22:19:10 -0000	[thread overview]
Message-ID: <160383715005.397.4679134647227236896.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20201027093608.028952500@infradead.org>

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     a195f3d4528a2f88d6f986f6b1101775ad4891cf
Gitweb:        https://git.kernel.org/tip/a195f3d4528a2f88d6f986f6b1101775ad4891cf
Author:        Peter Zijlstra <peterz@infradead.org>
AuthorDate:    Tue, 27 Oct 2020 10:15:06 +01:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Tue, 27 Oct 2020 23:15:23 +01:00

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@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Kyle Huey <me@kylehuey.com> 
Link: https://lore.kernel.org/r/20201027093608.028952500@infradead.org

---
 arch/x86/kernel/traps.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index b5208aa..32b2d39 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -793,12 +793,6 @@ static __always_inline unsigned long debug_read_clear_dr6(void)
 	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_user(struct pt_regs *regs,
 	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.

  reply	other threads:[~2020-10-27 22:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-27  9:15 [PATCH 0/3] x86/debug: Fixes Peter Zijlstra
2020-10-27  9:15 ` [PATCH 1/3] x86/debug: Fix BTF handling Peter Zijlstra
2020-10-27 19:41   ` Peter Zijlstra
2020-10-28  9:20     ` Masami Hiramatsu
2020-10-28  9:59       ` Peter Zijlstra
2020-10-28 12:11         ` Masami Hiramatsu
2020-10-28 14:31           ` [PATCH] x86/kprobes: Restore BTF if the single-stepping is cancelled Masami Hiramatsu
2020-12-07 23:22             ` Steven Rostedt
2020-12-09 18:44             ` [tip: perf/core] " tip-bot2 for Masami Hiramatsu
2020-10-27 22:19   ` [tip: x86/urgent] x86/debug: Fix BTF handling tip-bot2 for Peter Zijlstra
2020-10-27  9:15 ` [PATCH 2/3] x86/debug: Only clear/set ->virtual_dr6 for userspace #DB Peter Zijlstra
2020-10-27 22:19   ` tip-bot2 for Peter Zijlstra [this message]
2020-10-27  9:15 ` [PATCH 3/3] x86/debug: Fix PTRACE_{BLOCK,SINGLE}STEP vs ptrace_get_debugreg(6) Peter Zijlstra
2020-10-27 17:22   ` Kyle Huey
2020-10-27 18:33 ` [PATCH v2 3/3] Fix DR_STEP " Peter Zijlstra
2020-10-27 22:19   ` [tip: x86/urgent] x86/debug: " tip-bot2 for Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=160383715005.397.4679134647227236896.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=me@kylehuey.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.