Skip to contentSkip to conversation

Changes to PowerPC ptrace flags using watchpoints - v2

PATCH In review K.Prasad 3 participants 8 messages Dec 8, 2011 – Feb 15, 2012

Subsystems (3)
lore
Share & tools
lore

K.Prasad

author
#0 lore raw

cover Changes to PowerPC ptrace flags using watchpoints - v2

Hi David,
Please find a revised version of the patchset which have
incorporated the various suggestions made by you.

Kindly review the patches and let me know if they look fine.

Changelog - v2
--------------
v1 posted at
http://lists.ozlabs.org/pipermail/linuxppc-dev/2011-August/092463.html

- Introduction of a new version number for the hw-breakpoint structures dropped.
- The ptrace flag operations are expected to make more precise requests and suitable error return codes have been added for incorrect requests.
- Modification of an existing breakpoint is not possible. Request an delete, followed by set breakpoint request instead.

Thanks,
K.Prasad

author
#1 lore raw

PATCH 1/2 Use generic hw-breakpoint interfaces for new PPC ptrace flags

PPC_PTRACE_GETHWDBGINFO, PPC_PTRACE_SETHWDEBUG and PPC_PTRACE_DELHWDEBUG are PowerPC specific ptrace flags that use the watchpoint register. While they are targeted primarily towards BookE users, user-space applications such as GDB have started using them for BookS too. This patch enables the use of generic hardware breakpoint interfaces for these new flags.

Apart from the usual benefits of using generic hw-breakpoint interfaces, these changes allow debuggers (such as GDB) to use a common set of ptrace flags for their watchpoint needs and allow more precise breakpoint specification (length of the variable can be specified).

---
 Documentation/powerpc/ptrace.txt |   16 ++++++++
 arch/powerpc/kernel/ptrace.c     |   77 +++++++++++++++++++++++++++++++++++---
 2 files changed, 87 insertions(+), 6 deletions(-)
Documentation/powerpc/ptrace.txt +16 -0
index f4a5499..f2a7a39 100644
@@ -127,6 +127,22 @@ Some examples of using the structure to:
   p.addr2           = (uint64_t) end_range;
   p.condition_value = 0;
 
+- set a watchpoint in server processors (BookS)
+
+  p.version         = 1;
+  p.trigger_type    = PPC_BREAKPOINT_TRIGGER_RW;
+  p.addr_mode       = PPC_BREAKPOINT_MODE_RANGE_INCLUSIVE;
+  or
+  p.addr_mode       = PPC_BREAKPOINT_MODE_EXACT;
+
+  p.condition_mode  = PPC_BREAKPOINT_CONDITION_NONE;
+  p.addr            = (uint64_t) begin_range;
+  /* For PPC_BREAKPOINT_MODE_RANGE_INCLUSIVE addr2 needs to be specified, where
+   * addr2 - addr <= 8 Bytes.
+   */
+  p.addr2           = (uint64_t) end_range;
+  p.condition_value = 0;
+
 3. PTRACE_DELHWDEBUG
 
 Takes an integer which identifies an existing breakpoint or watchpoint
arch/powerpc/kernel/ptrace.c +71 -6

122 lines not on this page · raw message

Signature · 1 line
1.7.4.1
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] [hw-breakpoint] Use generic hw-breakpoint interfaces for new PPC ptrace flags

Quoted 6 lines · K.Prasad

PPC_PTRACE_GETHWDBGINFO, PPC_PTRACE_SETHWDEBUG and PPC_PTRACE_DELHWDEBUG are PowerPC specific ptrace flags that use the watchpoint register. While they are targeted primarily towards BookE users, user-space applications such as GDB have started using them for BookS too. This patch enables the use of generic hardware breakpoint interfaces for these new flags.

Quoted 6 lines

Apart from the usual benefits of using generic hw-breakpoint interfaces, these changes allow debuggers (such as GDB) to use a common set of ptrace flags for their watchpoint needs and allow more precise breakpoint specification (length of the variable can be specified).

Ok, I think it's finally ready to go.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
author
#3 lore raw

PATCH 2/2 Introduce new ptrace debug feature flag

In reply to K.Prasad

While PPC_PTRACE_SETHWDEBUG ptrace flag in PowerPC accepts PPC_BREAKPOINT_MODE_EXACT mode of breakpoint, the same is not intimated to the user-space debuggers (like GDB) who may want to use it. Hence we introduce a new PPC_DEBUG_FEATURE_DATA_BP_EXACT flag which will be populated on the "features" member of "struct ppc_debug_info" to advertise support for the same on Book3E PowerPC processors.

---
 arch/powerpc/include/asm/ptrace.h |    1 +
 arch/powerpc/kernel/ptrace.c      |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/ptrace.h +1 -0
index 48223f9..cf014f9 100644
@@ -380,6 +380,7 @@ struct ppc_debug_info {
 #define PPC_DEBUG_FEATURE_INSN_BP_MASK		0x0000000000000002
 #define PPC_DEBUG_FEATURE_DATA_BP_RANGE		0x0000000000000004
 #define PPC_DEBUG_FEATURE_DATA_BP_MASK		0x0000000000000008
+#define PPC_DEBUG_FEATURE_DATA_BP_EXACT		0x0000000000000010
 
 #ifndef __ASSEMBLY__
 
arch/powerpc/kernel/ptrace.c +1 -0
index 18d28b6..71db5a6 100644
@@ -1636,6 +1636,7 @@ long arch_ptrace(struct task_struct *child, long request,
 #ifdef CONFIG_PPC_ADV_DEBUG_DAC_RANGE
 		dbginfo.features |=
 				   PPC_DEBUG_FEATURE_DATA_BP_RANGE |
+				   PPC_DEBUG_FEATURE_DATA_BP_EXACT |
 				   PPC_DEBUG_FEATURE_DATA_BP_MASK;
 #endif
 #else /* !CONFIG_PPC_ADV_DEBUG_REGS */
#4 lore raw

Re: [PATCH 2/2] [PowerPC Book3E] Introduce new ptrace debug feature flag

Quoted 6 lines · K.Prasad

While PPC_PTRACE_SETHWDEBUG ptrace flag in PowerPC accepts PPC_BREAKPOINT_MODE_EXACT mode of breakpoint, the same is not intimated to the user-space debuggers (like GDB) who may want to use it. Hence we introduce a new PPC_DEBUG_FEATURE_DATA_BP_EXACT flag which will be populated on the "features" member of "struct ppc_debug_info" to advertise support for the same on Book3E PowerPC processors.

Hrm. I had assumed the reason there wasn't a feature bit for EXACT originally was that EXACT breakpoints were *always* supposed to be supported by the new interface.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
author
#5 lore raw

Re: [PATCH 2/2] [PowerPC Book3E] Introduce new ptrace debug feature flag

Quoted 8 lines · David Gibson
Quoted 6 lines · K.Prasad

While PPC_PTRACE_SETHWDEBUG ptrace flag in PowerPC accepts PPC_BREAKPOINT_MODE_EXACT mode of breakpoint, the same is not intimated to the user-space debuggers (like GDB) who may want to use it. Hence we introduce a new PPC_DEBUG_FEATURE_DATA_BP_EXACT flag which will be populated on the "features" member of "struct ppc_debug_info" to advertise support for the same on Book3E PowerPC processors.

Quoted 4 lines

Hrm. I had assumed the reason there wasn't a feature bit for EXACT originally was that EXACT breakpoints were *always* supposed to be supported by the new interface.

Okay. Although BookS doesn't support EXACT breakpoints, it is possible (after the introduction of new hw-breakpoint interfaces) to request for a breakpoint of length 1 Byte.

The hw-breakpoint infrastructure would take care of filtering the extraneous interrupts arising out of accesses in the neighbourhood, in such a case.

David,
Can you Ack this patch too, if you find the changes acceptable?

Thanks,
K.Prasad

#6 lore raw

Re: [PATCH 2/2] [PowerPC Book3E] Introduce new ptrace debug feature flag

Quoted 9 lines · K.Prasad
Quoted 8 lines · David Gibson
Quoted 6 lines · K.Prasad

While PPC_PTRACE_SETHWDEBUG ptrace flag in PowerPC accepts PPC_BREAKPOINT_MODE_EXACT mode of breakpoint, the same is not intimated to the user-space debuggers (like GDB) who may want to use it. Hence we introduce a new PPC_DEBUG_FEATURE_DATA_BP_EXACT flag which will be populated on the "features" member of "struct ppc_debug_info" to advertise support for the same on Book3E PowerPC processors.

Quoted 8 lines
Quoted 4 lines

Hrm. I had assumed the reason there wasn't a feature bit for EXACT originally was that EXACT breakpoints were *always* supposed to be supported by the new interface.

Okay. Although BookS doesn't support EXACT breakpoints, it is possible (after the introduction of new hw-breakpoint interfaces) to request for a breakpoint of length 1 Byte.

Hrm. An EXACT breakpoint is not exactly the same as a range breakpoint of length 1 (consider unaligned accesses). But despite that, it should be possible to implement exact breakpoints on Book3S server hardware with some software filtering.

And since that leaves no hardware that *can't* implement exact breakpoints (directly or indirectly), I'm not yet convinced of the need for a flag bit.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#7 lore raw

Re: [PATCH 2/2] [PowerPC Book3E] Introduce new ptrace debug feature flag

Quoted 8 lines · David Gibson

Hrm. An EXACT breakpoint is not exactly the same as a range breakpoint of length 1 (consider unaligned accesses). But despite that, it should be possible to implement exact breakpoints on Book3S server hardware with some software filtering.

And since that leaves no hardware that *can't* implement exact breakpoints (directly or indirectly), I'm not yet convinced of the need for a flag bit.

I agree.

Signature · 3 lines
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center