All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch 1/2 v2] Clear reserved bits of DR6 in do_debug()
       [not found] <20100128110936.399448739@linux.vnet.ibm.com>
@ 2010-01-28 11:14 ` K.Prasad
  2010-01-29  9:25   ` [tip:perf/core] x86/debug: " tip-bot for K.Prasad
  2010-01-28 11:14 ` [Patch 2/2 v2] Return proper code to notifier chain in hw_breakpoint_handler K.Prasad
  1 sibling, 1 reply; 4+ messages in thread
From: K.Prasad @ 2010-01-28 11:14 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Frederic Weisbecker, Roland McGrath, Alan Stern,
	Jan Kiszka, K.Prasad

[-- Attachment #1: fix_dr6_reserved_01 --]
[-- Type: text/plain, Size: 1470 bytes --]

Clear the reserved bits from the stored copy of debug status register (DR6).
This will help easy bitwise operations.

Signed-off-by: K.Prasad <prasad@linux.vnet.ibm.com>
---
 arch/x86/include/asm/debugreg.h |    3 +++
 arch/x86/kernel/traps.c         |    3 +++
 2 files changed, 6 insertions(+)

Index: linux-2.6-tip.bugfix_perf_hbkpt/arch/x86/include/asm/debugreg.h
===================================================================
--- linux-2.6-tip.bugfix_perf_hbkpt.orig/arch/x86/include/asm/debugreg.h
+++ linux-2.6-tip.bugfix_perf_hbkpt/arch/x86/include/asm/debugreg.h
@@ -14,6 +14,9 @@
    which debugging register was responsible for the trap.  The other bits
    are either reserved or not of interest to us. */
 
+/* Define reserved bits in DR6 which are always set to 1 */
+#define DR6_RESERVED	(0xFFFF0FF0)
+
 #define DR_TRAP0	(0x1)		/* db0 */
 #define DR_TRAP1	(0x2)		/* db1 */
 #define DR_TRAP2	(0x4)		/* db2 */
Index: linux-2.6-tip.bugfix_perf_hbkpt/arch/x86/kernel/traps.c
===================================================================
--- linux-2.6-tip.bugfix_perf_hbkpt.orig/arch/x86/kernel/traps.c
+++ linux-2.6-tip.bugfix_perf_hbkpt/arch/x86/kernel/traps.c
@@ -534,6 +534,9 @@ dotraplinkage void __kprobes do_debug(st
 
 	get_debugreg(dr6, 6);
 
+	/* Filter out all the reserved bits which are preset to 1 */
+	dr6 &= ~DR6_RESERVED;
+
 	/* Catch kmemcheck conditions first of all! */
 	if ((dr6 & DR_STEP) && kmemcheck_trap(regs))
 		return;


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Patch 2/2 v2] Return proper code to notifier chain in hw_breakpoint_handler
       [not found] <20100128110936.399448739@linux.vnet.ibm.com>
  2010-01-28 11:14 ` [Patch 1/2 v2] Clear reserved bits of DR6 in do_debug() K.Prasad
@ 2010-01-28 11:14 ` K.Prasad
  2010-01-29  9:26   ` [tip:perf/core] x86/hw-breakpoints: Optimize return code from " tip-bot for K.Prasad
  1 sibling, 1 reply; 4+ messages in thread
From: K.Prasad @ 2010-01-28 11:14 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Frederic Weisbecker, Roland McGrath, Alan Stern,
	Jan Kiszka, K.Prasad

[-- Attachment #1: fix_notify_code_02 --]
[-- Type: text/plain, Size: 1519 bytes --]

Processing of debug exceptions (in do_debug()) can stop if it originated from
a hw-breakpoint exception (return NOTIFY_STOP). For certain cases such as
a) user-space breakpoints with pending SIGTRAP signal delivery (as in the case
of ptrace induced breakpoints) and b) exceptions due to multiple causes (other
than breakpoints) we will continue to process the exception (by returning
NOTIFY_DONE).

Signed-off-by: K.Prasad <prasad@linux.vnet.ibm.com>
---
 arch/x86/kernel/hw_breakpoint.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Index: linux-2.6-tip.bugfix_perf_hbkpt/arch/x86/kernel/hw_breakpoint.c
===================================================================
--- linux-2.6-tip.bugfix_perf_hbkpt.orig/arch/x86/kernel/hw_breakpoint.c
+++ linux-2.6-tip.bugfix_perf_hbkpt/arch/x86/kernel/hw_breakpoint.c
@@ -502,8 +502,6 @@ static int __kprobes hw_breakpoint_handl
 		rcu_read_lock();
 
 		bp = per_cpu(bp_per_reg[i], cpu);
-		if (bp)
-			rc = NOTIFY_DONE;
 		/*
 		 * Reset the 'i'th TRAP bit in dr6 to denote completion of
 		 * exception handling
@@ -522,7 +520,13 @@ static int __kprobes hw_breakpoint_handl
 
 		rcu_read_unlock();
 	}
-	if (dr6 & (~DR_TRAP_BITS))
+	/*
+	 * Further processing in do_debug() is needed for a) user-space
+	 * breakpoints (to generate signals) and b) when the system has
+	 * taken exception due to multiple causes
+	 */
+	if ((current->thread.debugreg6 & DR_TRAP_BITS) ||
+	    (dr6 & (~DR_TRAP_BITS)))
 		rc = NOTIFY_DONE;
 
 	set_debugreg(dr7, 7);


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip:perf/core] x86/debug: Clear reserved bits of DR6 in do_debug()
  2010-01-28 11:14 ` [Patch 1/2 v2] Clear reserved bits of DR6 in do_debug() K.Prasad
@ 2010-01-29  9:25   ` tip-bot for K.Prasad
  0 siblings, 0 replies; 4+ messages in thread
From: tip-bot for K.Prasad @ 2010-01-29  9:25 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, stern, jan.kiszka, fweisbec, roland,
	tglx, prasad, mingo

Commit-ID:  40f9249a73f6c251adea492b1c3d19d39e2a9bda
Gitweb:     http://git.kernel.org/tip/40f9249a73f6c251adea492b1c3d19d39e2a9bda
Author:     K.Prasad <prasad@linux.vnet.ibm.com>
AuthorDate: Thu, 28 Jan 2010 16:44:01 +0530
Committer:  Frederic Weisbecker <fweisbec@gmail.com>
CommitDate: Fri, 29 Jan 2010 02:26:10 +0100

x86/debug: Clear reserved bits of DR6 in do_debug()

Clear the reserved bits from the stored copy of debug status
register (DR6).
This will help easy bitwise operations such as quick testing
of a debug event origin.

Signed-off-by: K.Prasad <prasad@linux.vnet.ibm.com>
Cc: Roland McGrath <roland@redhat.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Ingo Molnar <mingo@elte.hu>
LKML-Reference: <20100128111401.GB13935@in.ibm.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 arch/x86/include/asm/debugreg.h |    3 +++
 arch/x86/kernel/traps.c         |    3 +++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/asm/debugreg.h b/arch/x86/include/asm/debugreg.h
index 8240f76..b81002f 100644
--- a/arch/x86/include/asm/debugreg.h
+++ b/arch/x86/include/asm/debugreg.h
@@ -14,6 +14,9 @@
    which debugging register was responsible for the trap.  The other bits
    are either reserved or not of interest to us. */
 
+/* Define reserved bits in DR6 which are always set to 1 */
+#define DR6_RESERVED	(0xFFFF0FF0)
+
 #define DR_TRAP0	(0x1)		/* db0 */
 #define DR_TRAP1	(0x2)		/* db1 */
 #define DR_TRAP2	(0x4)		/* db2 */
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 3339917..1168e44 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -534,6 +534,9 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
 
 	get_debugreg(dr6, 6);
 
+	/* Filter out all the reserved bits which are preset to 1 */
+	dr6 &= ~DR6_RESERVED;
+
 	/* Catch kmemcheck conditions first of all! */
 	if ((dr6 & DR_STEP) && kmemcheck_trap(regs))
 		return;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [tip:perf/core] x86/hw-breakpoints: Optimize return code from notifier chain in hw_breakpoint_handler
  2010-01-28 11:14 ` [Patch 2/2 v2] Return proper code to notifier chain in hw_breakpoint_handler K.Prasad
@ 2010-01-29  9:26   ` tip-bot for K.Prasad
  0 siblings, 0 replies; 4+ messages in thread
From: tip-bot for K.Prasad @ 2010-01-29  9:26 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, stern, jan.kiszka, fweisbec, roland,
	tglx, prasad, mingo

Commit-ID:  e0e53db6133c32964fd17f20b17073a402f07ed3
Gitweb:     http://git.kernel.org/tip/e0e53db6133c32964fd17f20b17073a402f07ed3
Author:     K.Prasad <prasad@linux.vnet.ibm.com>
AuthorDate: Thu, 28 Jan 2010 16:44:15 +0530
Committer:  Frederic Weisbecker <fweisbec@gmail.com>
CommitDate: Fri, 29 Jan 2010 02:44:30 +0100

x86/hw-breakpoints: Optimize return code from notifier chain in hw_breakpoint_handler

Processing of debug exceptions in do_debug() can stop if it
originated from a hw-breakpoint exception by returning NOTIFY_STOP
in most cases.

But for certain cases such as:

a) user-space breakpoints with pending SIGTRAP signal delivery (as
in the case of ptrace induced breakpoints).

b) exceptions due to other causes than breakpoints

We will continue to process the exception by returning NOTIFY_DONE.

Signed-off-by: K.Prasad <prasad@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roland McGrath <roland@redhat.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
LKML-Reference: <20100128111415.GC13935@in.ibm.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 arch/x86/kernel/hw_breakpoint.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/hw_breakpoint.c b/arch/x86/kernel/hw_breakpoint.c
index 05d5fec..ae90b47 100644
--- a/arch/x86/kernel/hw_breakpoint.c
+++ b/arch/x86/kernel/hw_breakpoint.c
@@ -502,8 +502,6 @@ static int __kprobes hw_breakpoint_handler(struct die_args *args)
 		rcu_read_lock();
 
 		bp = per_cpu(bp_per_reg[i], cpu);
-		if (bp)
-			rc = NOTIFY_DONE;
 		/*
 		 * Reset the 'i'th TRAP bit in dr6 to denote completion of
 		 * exception handling
@@ -522,7 +520,13 @@ static int __kprobes hw_breakpoint_handler(struct die_args *args)
 
 		rcu_read_unlock();
 	}
-	if (dr6 & (~DR_TRAP_BITS))
+	/*
+	 * Further processing in do_debug() is needed for a) user-space
+	 * breakpoints (to generate signals) and b) when the system has
+	 * taken exception due to multiple causes
+	 */
+	if ((current->thread.debugreg6 & DR_TRAP_BITS) ||
+	    (dr6 & (~DR_TRAP_BITS)))
 		rc = NOTIFY_DONE;
 
 	set_debugreg(dr7, 7);

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-01-29  9:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20100128110936.399448739@linux.vnet.ibm.com>
2010-01-28 11:14 ` [Patch 1/2 v2] Clear reserved bits of DR6 in do_debug() K.Prasad
2010-01-29  9:25   ` [tip:perf/core] x86/debug: " tip-bot for K.Prasad
2010-01-28 11:14 ` [Patch 2/2 v2] Return proper code to notifier chain in hw_breakpoint_handler K.Prasad
2010-01-29  9:26   ` [tip:perf/core] x86/hw-breakpoints: Optimize return code from " tip-bot for K.Prasad

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.