linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Michael Stefaniuc <mstefani@redhat.com>,
	"Rafael J. Wysocki" <rjw@sisk.pl>,
	Maciej Rutecki <maciej.rutecki@gmail.com>,
	Alexandre Julliard <julliard@winehq.org>,
	Jason Wessel <jason.wessel@windriver.com>,
	"All since 2.6.33.x" <stable@kernel.org>
Subject: [PATCH 1/2] x86: Ignore trap bits on single step exceptions
Date: Sat, 13 Nov 2010 22:37:52 +0100	[thread overview]
Message-ID: <1289684273-26770-2-git-send-regression-fweisbec@gmail.com> (raw)
In-Reply-To: <1289684273-26770-1-git-send-regression-fweisbec@gmail.com>

When a single step exception fires, the trap bits, used to
signal hardware breakpoints, are in a random state.

These trap bits might be set if another exception will follow,
like a breakpoint in the next instruction, or a watchpoint in the
previous one. Or there can be any junk there.

So if we handle these trap bits during the single step exception,
we are going to handle an exception twice, or we are going to
handle junk.

Just ignore them in this case.

This fixes https://bugzilla.kernel.org/show_bug.cgi?id=21332

Reported-by: Michael Stefaniuc <mstefani@redhat.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Maciej Rutecki <maciej.rutecki@gmail.com>
Cc: Alexandre Julliard <julliard@winehq.org>
Cc: Jason Wessel <jason.wessel@windriver.com>
Cc: All since 2.6.33.x <stable@kernel.org>
---
 arch/x86/kernel/hw_breakpoint.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/hw_breakpoint.c b/arch/x86/kernel/hw_breakpoint.c
index ff15c9d..42c5942 100644
--- a/arch/x86/kernel/hw_breakpoint.c
+++ b/arch/x86/kernel/hw_breakpoint.c
@@ -433,6 +433,10 @@ static int __kprobes hw_breakpoint_handler(struct die_args *args)
 	dr6_p = (unsigned long *)ERR_PTR(args->err);
 	dr6 = *dr6_p;
 
+	/* If it's a single step, TRAP bits are random */
+	if (dr6 & DR_STEP)
+		return NOTIFY_DONE;
+
 	/* Do an early return if no trap bits are set in DR6 */
 	if ((dr6 & DR_TRAP_BITS) == 0)
 		return NOTIFY_DONE;
-- 
1.6.2.3


  reply	other threads:[~2010-11-13 21:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-13 21:37 [GIT PULL] hw-breakpoint fixes Frederic Weisbecker
2010-11-13 21:37 ` Frederic Weisbecker [this message]
2010-11-24 20:32   ` [PATCH 1/2] x86: Ignore trap bits on single step exceptions Michael Stefaniuc
2010-11-25  7:47     ` Frederic Weisbecker
2010-11-13 21:37 ` [PATCH 2/2] perf,hw_breakpoint: Initialize hardware api earlier Frederic Weisbecker
2010-11-13 21:46   ` Peter Zijlstra
2010-11-14 13:33     ` Jason Wessel
2010-11-16 21:24       ` Peter Zijlstra
2010-11-18 16:09         ` Jason Wessel
2010-11-18  9:39 ` [GIT PULL] hw-breakpoint fixes Ingo Molnar

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=1289684273-26770-2-git-send-regression-fweisbec@gmail.com \
    --to=fweisbec@gmail.com \
    --cc=jason.wessel@windriver.com \
    --cc=julliard@winehq.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maciej.rutecki@gmail.com \
    --cc=mingo@elte.hu \
    --cc=mstefani@redhat.com \
    --cc=rjw@sisk.pl \
    --cc=stable@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).