[PATCH 4/5] arm: enable support for software perf events

Jamie Iles jamie.iles at picochip.com
Mon Jan 4 07:26:24 EST 2010


On Mon, Jan 04, 2010 at 11:11:37AM +0000, Russell King - ARM Linux wrote:
> On Mon, Jan 04, 2010 at 10:48:41AM +0000, Jamie Iles wrote:
> > +/* Get the PC. Make sure that we have a 64bit value with the upper 32 cleared.
> > + */
> > +#define perf_instruction_pointer(_regs) \
> > +	((u64)instruction_pointer(regs) & 0xFFFFFFFFLU)
> 
> Maybe we should make pt_regs entries be unsigned instead of having this?
> Nothing should be affected by that change - and it looks like x86 went
> through this change, making two pt_regs structures, one for userspace
> with signed ints/longs, and one for kernel space with unsigned ints/longs.
> 
> I think it would make more sense to do that rather than litter the kernel
> with casts like the above.
Ok, how about this?

Jamie

[PATCH] arm ptrace: use unsigned types for kernel pt_regs

Make registers unsigned for kernel space. This is important for
example in the perf events where the PC is stored into a u64. We
don't want it sign extended so make the regs unsigned to prevent
casts throughout the kernel.

Signed-off-by: Jamie Iles <jamie.iles at picochip.com>
Cc: Russell King - ARM Linux <linux at arm.linux.org.uk>
---
 arch/arm/include/asm/ptrace.h |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/arm/include/asm/ptrace.h b/arch/arm/include/asm/ptrace.h
index bbecccd..eec6e89 100644
--- a/arch/arm/include/asm/ptrace.h
+++ b/arch/arm/include/asm/ptrace.h
@@ -97,9 +97,15 @@
  * stack during a system call.  Note that sizeof(struct pt_regs)
  * has to be a multiple of 8.
  */
+#ifndef __KERNEL__
 struct pt_regs {
 	long uregs[18];
 };
+#else /* __KERNEL__ */
+struct pt_regs {
+	unsigned long uregs[18];
+};
+#endif /* __KERNEL__ */
 
 #define ARM_cpsr	uregs[16]
 #define ARM_pc		uregs[15]
-- 
1.6.5.4



More information about the linux-arm-kernel mailing list