Skip to contentSkip to conversation

systemtap: Add initial support for ppc32

PATCH In review Anton Vorontsov 4 participants 14 messages Nov 27, 2009 – Dec 9, 2009

lore
Share & tools
lore
#0 lore raw

cover systemtap: Add initial support for ppc32

Hi all,

Here are some patches that add systemtap support for ppc32 machines.

This is all pretty straightforward, though I didn't test it much, only run few 'hello world' taps and decided that it's good enough. ;-)

I plan to test it more thoughtfully sometime next week, and fix missing things (if any). But so far I'm interested in the feedback on this initial support.

Thanks!

p.s. I though it would be a good idea to cc linuxppc-dev. At least kexec-tools guys tend to do it as well.

Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2
#1 lore raw

PATCH 1/8 Rename uprobes_ppc64.c to uprobes_ppc.c, use it for ppc32

The code *looks* generic enough, so I think it can be used for ppc32 without modifications.

---
 runtime/uprobes/uprobes_arch.c  |    4 +-
 runtime/uprobes/uprobes_arch.h  |    4 +-
 runtime/uprobes/uprobes_ppc.c   |  147 +++++++++++++++++++++++++++++++++++++++
 runtime/uprobes/uprobes_ppc.h   |   82 ++++++++++++++++++++++
 runtime/uprobes/uprobes_ppc64.c |  147 ---------------------------------------
 runtime/uprobes/uprobes_ppc64.h |   82 ----------------------
 runtime/uprobes2/uprobes_arch.c |    4 +-
 runtime/uprobes2/uprobes_arch.h |    4 +-
 8 files changed, 237 insertions(+), 237 deletions(-)
 create mode 100644 runtime/uprobes/uprobes_ppc.c
 create mode 100644 runtime/uprobes/uprobes_ppc.h
 delete mode 100644 runtime/uprobes/uprobes_ppc64.c
 delete mode 100644 runtime/uprobes/uprobes_ppc64.h
runtime/uprobes/uprobes_arch.c +2 -2
index 99ef54c..6c58d5f 100644
@@ -2,8 +2,8 @@
 #include "uprobes_x86_64.c"
 #elif defined (__i386__)
 #include "uprobes_i386.c"
-#elif defined (__powerpc64__)
-#include "uprobes_ppc64.c"
+#elif defined (__powerpc__)
+#include "uprobes_ppc.c"
 #elif defined (__s390__) || defined (__s390x__)
 #include "uprobes_s390.c"
 #else
runtime/uprobes/uprobes_arch.h +2 -2
index 0223e28..f642f52 100644
@@ -2,8 +2,8 @@
 #include "uprobes_x86_64.h"
 #elif defined (__i386__)
 #include "uprobes_i386.h"
-#elif defined (__powerpc64__)
-#include "uprobes_ppc64.h"
+#elif defined (__powerpc__)
+#include "uprobes_ppc.h"
 #elif defined (__s390__) || defined (__s390x__)
 #include "uprobes_s390.h"
 #else
runtime/uprobes/uprobes_ppc.c new file +147 -0

147 lines not on this page · raw message

runtime/uprobes/uprobes_ppc.h new file +82 -0

82 lines not on this page · raw message

runtime/uprobes/uprobes_ppc64.c deleted +0 -147

147 lines not on this page · raw message

runtime/uprobes/uprobes_ppc64.h deleted +0 -82

82 lines not on this page · raw message

runtime/uprobes2/uprobes_arch.c +2 -2
index 3c86804..a91d5b6 100644
@@ -1,7 +1,7 @@
 #if defined (__x86_64__) || defined(__i386)
 #include "uprobes_x86.c"
-#elif defined (__powerpc64__)
-#include "../uprobes/uprobes_ppc64.c"
+#elif defined (__powerpc__)
+#include "../uprobes/uprobes_ppc.c"
 #elif defined (__s390__) || defined (__s390x__)
 #include "../uprobes/uprobes_s390.c"
 #elif defined (__ia64__)
runtime/uprobes2/uprobes_arch.h +2 -2
index 87e0cc8..cce5775 100644
@@ -1,7 +1,7 @@
 #if defined (__x86_64__) || defined(__i386)
 #include "uprobes_x86.h"
-#elif defined (__powerpc64__)
-#include "../uprobes/uprobes_ppc64.h"
+#elif defined (__powerpc__)
+#include "../uprobes/uprobes_ppc.h"
 #elif defined (__s390__) || defined (__s390x__)
 #include "../uprobes/uprobes_s390.h"
 #elif defined (__ia64__)
Signature · 1 line
1.6.3.3
#2 lore raw

PATCH 2/8 Rename stack-ppc64.c to stack-ppc.c

In reply to Anton Vorontsov

There should be no functional changes in this patch.

---
 runtime/stack-ppc.c   |   62 +++++++++++++++++++++++++++++++++++++++++++++++++
 runtime/stack-ppc64.c |   62 -------------------------------------------------
 runtime/stack.c       |    2 +-
 3 files changed, 63 insertions(+), 63 deletions(-)
 create mode 100644 runtime/stack-ppc.c
 delete mode 100644 runtime/stack-ppc64.c
runtime/stack-ppc.c new file +62 -0
new file mode 100644
index 0000000..3267194
@@ -0,0 +1,62 @@
+/* -*- linux-c -*-
+ * ppc64 stack tracing functions
+ *
+ * This file is part of systemtap, and is free software.  You can
+ * redistribute it and/or modify it under the terms of the GNU General
+ * Public License (GPL); either version 2, or (at your option) any
+ * later version.
+ */
+
+static void __stp_stack_print (struct pt_regs *regs, int verbose, int levels,
+                               struct task_struct *tsk)
+{
+	unsigned long ip, newsp, lr = 0;
+	int count = 0;
+	int firstframe = 1;
+	unsigned long *_sp = (unsigned long *)&REG_SP(regs);	
+	unsigned long sp = (unsigned long)_sp;
+	lr = 0;
+	do {
+		if (sp < KERNELBASE)
+			return;
+		_sp = (unsigned long *) sp;
+		newsp = _sp[0];
+		ip = _sp[2];
+		if (!firstframe || ip != lr) {
+			if (verbose) {
+				_stp_printf("[0x%016lx] [0x%016lx] ", sp, ip);
+				_stp_symbol_print(ip);
+				if (firstframe)
+					_stp_print(" (unreliable)");
+				_stp_print_char('\n');
+			}
+			else
+				_stp_printf("0x%016lx ", ip);
+		}
+		firstframe = 0;
+		/*
+		 * See if this is an exception frame.
+		 * We look for the "regshere" marker in the current frame.
+		 */
+		if ( _sp[12] == 0x7265677368657265ul) {
+			struct pt_regs *regs = (struct pt_regs *)
+				(sp + STACK_FRAME_OVERHEAD);
+			if (verbose) {
+				_stp_printf("--- Exception: %lx at ",regs->trap);
+				_stp_symbol_print(regs->nip);
+				_stp_print_char('\n');
+				lr = regs->link;
+				_stp_print("    LR =");
+				_stp_symbol_print(lr);
+				_stp_print_char('\n');
+				firstframe = 1;
+			}
+			else {
+				_stp_printf("0x%016lx ",regs->nip);
+				_stp_printf("0x%016lx ",regs->link);
+			}
+		}
+
+		sp = newsp;
+	} while (count++ < MAXBACKTRACE);
+}
runtime/stack-ppc64.c deleted +0 -62

62 lines not on this page · raw message

runtime/stack.c +1 -1
index 042f44c..ae89995 100644
@@ -41,7 +41,7 @@ static void _stp_stack_print_fallback(unsigned long, int, int);
 #elif  defined (__i386__)
 #include "stack-i386.c"
 #elif defined (__powerpc64__)
-#include "stack-ppc64.c"
+#include "stack-ppc.c"
 #elif defined (__arm__)
 #include "stack-arm.c"
 #elif defined (__s390__) || defined (__s390x__)
Signature · 1 line
1.6.3.3
#3 lore raw

PATCH 3/8 stack-ppc: Adjust for ppc32

In reply to Anton Vorontsov

Get rid of magic numbers, use appropriate defines from ptrace.h.

Quoted 1 line

From now on stack-ppc.c should be suitable for ppc32.

---
 runtime/stack-ppc.c |    4 ++--
 runtime/stack.c     |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
runtime/stack-ppc.c +2 -2
index 3267194..df2db15 100644
@@ -21,7 +21,7 @@ static void __stp_stack_print (struct pt_regs *regs, int verbose, int levels,
 			return;
 		_sp = (unsigned long *) sp;
 		newsp = _sp[0];
-		ip = _sp[2];
+		ip = _sp[STACK_FRAME_LR_SAVE];
 		if (!firstframe || ip != lr) {
 			if (verbose) {
 				_stp_printf("[0x%016lx] [0x%016lx] ", sp, ip);
@@ -38,7 +38,7 @@ static void __stp_stack_print (struct pt_regs *regs, int verbose, int levels,
 		 * See if this is an exception frame.
 		 * We look for the "regshere" marker in the current frame.
 		 */
-		if ( _sp[12] == 0x7265677368657265ul) {
+		if (_sp[STACK_FRAME_MARKER] == STACK_FRAME_REGS_MARKER) {
 			struct pt_regs *regs = (struct pt_regs *)
 				(sp + STACK_FRAME_OVERHEAD);
 			if (verbose) {
runtime/stack.c +1 -1
index ae89995..25dbdbb 100644
@@ -40,7 +40,7 @@ static void _stp_stack_print_fallback(unsigned long, int, int);
 #include "stack-ia64.c"
 #elif  defined (__i386__)
 #include "stack-i386.c"
-#elif defined (__powerpc64__)
+#elif defined (__powerpc__)
 #include "stack-ppc.c"
 #elif defined (__arm__)
 #include "stack-arm.c"
Signature · 1 line
1.6.3.3
#4 lore raw

PATCH 4/8 Implement ppc32 variant of __is_user_regs

In reply to Anton Vorontsov

* tapset/nd_syscalls.stp: Implement ppc32 variant of __is_user_regs.
* tapset/syscalls.stp: Ditto.

---
 tapset/nd_syscalls.stp |    3 +++
 tapset/syscalls.stp    |    3 +++
 2 files changed, 6 insertions(+), 0 deletions(-)
tapset/nd_syscalls.stp +3 -0
index f9a6ffc..e7492a1 100644
@@ -1320,6 +1320,9 @@ function __is_user_regs:long (regs:long)
 #elif defined(__powerpc64__)
 	unsigned long msr = kread(&regs->msr);
 	THIS->__retvalue = ((msr >> MSR_PR_LG) & 0x1);
+#elif defined(__powerpc__)
+	unsigned long msr = kread(&regs->msr);
+	THIS->__retvalue = ((msr >> MSR_PR) != 0);
 #elif defined(__arm__)
 	long cpsr = kread(&regs->ARM_cpsr);
 	THIS->__retvalue = ((cpsr & 0xf) == 0);
tapset/syscalls.stp +3 -0
index dde0ca9..430d37f 100644
@@ -1093,6 +1093,9 @@ function __is_user_regs:long (regs:long)
 #elif defined(__powerpc64__)
 	unsigned long msr = kread(&regs->msr);
 	THIS->__retvalue = ((msr >> MSR_PR_LG) & 0x1);
+#elif defined(__powerpc__)
+	unsigned long msr = kread(&regs->msr);
+	THIS->__retvalue = ((msr >> MSR_PR) != 0);
 #elif defined(__arm__)
 	long cpsr = kread(&regs->ARM_cpsr);
 	THIS->__retvalue = ((cpsr & 0xf) == 0);
Signature · 1 line
1.6.3.3
#5 lore raw

PATCH 5/8 Share ppc64 and ppc32 code where possible

In reply to Anton Vorontsov

* runtime/copy.c: Can use ppc64's code.
* runtime/regs.h: Ditto.
* runtime/string.h: Ditto.
* tapset/context.stp: Ditto.
* tapset/errno.stp: Ditto.

---
 runtime/copy.c     |    2 +-
 runtime/regs.h     |    2 +-
 runtime/string.h   |    6 +++---
 tapset/context.stp |    2 +-
 tapset/errno.stp   |    2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)
runtime/copy.c +1 -1
index 4fb8725..40f1511 100644
@@ -105,7 +105,7 @@ do {									   \
 		: "i"(-EFAULT), "0"(count), "1"(count), "3"(src), "4"(dst) \
 		: "memory");						   \
 } while (0)
-#elif defined (__powerpc64__) || defined (__ia64__) || defined (__arm__)
+#elif defined (__powerpc__) || defined (__ia64__) || defined (__arm__)
 #define __stp_strncpy_from_user(dst,src,count,res) \
 	do { res = __strncpy_from_user(dst, src, count); } while(0)
 
runtime/regs.h +1 -1
index dc6b50a..08449aa 100644
@@ -36,7 +36,7 @@
   (((regs)->cr_iip = (x) & ~3UL), (ia64_psr(regs)->ri = (x) & 3UL))
 
 
-#elif defined (__powerpc64__)
+#elif defined (__powerpc__)
 
 #define REG_IP(regs) regs->nip
 #define REG_SP(regs) regs->gpr[1]
runtime/string.h +3 -3
index f4d4cc0..b08304e 100644
@@ -19,14 +19,14 @@ static void _stp_text_str(char *out, char *in, int len, int quoted, int user);
  * is provided without the paranoid check. Use it if available, fall back
  * to __get_user() if not. Other archs can use __get_user() as is
  */
-#ifdef __powerpc64__
+#if defined(__powerpc__)
 #ifdef __get_user_inatomic
 #define __stp_get_user(x, ptr) __get_user_inatomic(x, ptr)
 #else /* __get_user_inatomic */
 #define __stp_get_user(x, ptr) __get_user(x, ptr)
 #endif /* __get_user_inatomic */
-#else /* __powerpc64__ */
+#else /* defined(__powerpc__) */
 #define __stp_get_user(x, ptr) __get_user(x, ptr)
-#endif /* __powerpc64__ */
+#endif /* defined(__powerpc__) */
 
 #endif /* _STRING_H_ */
tapset/context.stp +1 -1
index 36701e6..b30f7dc 100644
@@ -15,7 +15,7 @@
 %{
 #include <asm/processor.h>
 
-#if defined(__powerpc64__)
+#if defined(__powerpc__)
 #if !defined(task_pt_regs)
 #define task_pt_regs(tsk)       ((struct pt_regs *)(tsk)->thread.regs)
 #endif
tapset/errno.stp +1 -1
index 011ff7e..d4d571b 100644
@@ -369,7 +369,7 @@ static long _stp_returnval(struct pt_regs *regs) {
 #elif defined (__x86_64__)
 		// TODO: Handle -m32 apps.
 		return regs->rax;
-#elif defined (__powerpc64__)
+#elif defined (__powerpc__)
 		return regs->gpr[3];
 #elif defined (__ia64__)
 		return regs->r8;
Signature · 1 line
1.6.3.3
#6 lore raw

PATCH 6/8 Use proper types for do_div

In reply to Anton Vorontsov

do_div accepts unsigned 64-bit integer type for dividend, signed types would cause do_div's typecheck fail:

stat-common.c: In function 'needed_space':
stat-common.c:50: error: comparison of distinct pointer types lacks a cast ...same errors in time.c and tapset-timers.cxx's generated code...

A fix for time.c is special, on ppc32 cycles_t is 32-bit, so technically we don't need do_div, but since the whole _stp_gettimeofday_ns() operates on 64-bit types we'd better be safe and use uint64_t for the math.

---
 runtime/stat-common.c |    8 ++++----
 runtime/time.c        |    3 ++-
 tapset-timers.cxx     |    2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)
runtime/stat-common.c +4 -4
index 7123dc8..f970304 100644
@@ -34,7 +34,7 @@ static int _stp_stat_calc_buckets(int stop, int start, int interval)
 	return buckets;
 }
 
-static int needed_space(int64_t v)
+static int needed_space(uint64_t v)
 {
 	int space = 0;
 
@@ -134,7 +134,7 @@ static void _stp_stat_print_histogram_buf(char *buf, size_t size, Hist st, stat
 {
 	int scale, i, j, val_space, cnt_space;
 	int low_bucket = -1, high_bucket = 0, over = 0, under = 0;
-	int64_t val, v, valmax = 0;
+	uint64_t val, v, valmax = 0;
 	int eliding = 0;
 	char *cur_buf = buf, *fake = buf;
 	char **bufptr = (buf == NULL ? &fake : &cur_buf);
@@ -186,7 +186,7 @@ static void _stp_stat_print_histogram_buf(char *buf, size_t size, Hist st, stat
 	if (valmax <= HIST_WIDTH)
 		scale = 1;
 	else {
-		int64_t tmp = valmax;
+		uint64_t tmp = valmax;
 		int rem = do_div(tmp, HIST_WIDTH);
 		scale = tmp;
 		if (rem) scale++;
@@ -282,7 +282,7 @@ static void _stp_stat_print_histogram(Hist st, stat *sd)
 	_stp_print_flush();
 }
 
-static void __stp_stat_add (Hist st, stat *sd, int64_t val)
+static void __stp_stat_add (Hist st, stat *sd, uint64_t val)
 {
 	int n;
 	if (sd->count == 0) {
runtime/time.c +2 -1
index 58c23e5..d588370 100644
@@ -275,7 +275,8 @@ static int64_t
 _stp_gettimeofday_ns(void)
 {
     int64_t base;
-    cycles_t last, delta;
+    cycles_t last;
+    uint64_t delta;
     unsigned int freq;
     unsigned int seq;
     stp_time_t *time;
tapset-timers.cxx +1 -1
index 6574626..7195cfa 100644
@@ -241,7 +241,7 @@ hrtimer_derived_probe_group::emit_interval (translator_output* o)
 {
   o->line() << "({";
   o->newline(1) << "unsigned long nsecs;";
-  o->newline() << "int64_t i = stp->intrv;";
+  o->newline() << "uint64_t i = stp->intrv;";
   o->newline() << "if (stp->rnd != 0) {";
   // XXX: why not use stp_random_pm instead of this?
   o->newline(1) << "int64_t r;";
Signature · 1 line
1.6.3.3
#7 lore raw

Re: [PATCH 6/8] Use proper types for do_div

Hi Anton,

Quoted 11 lines · Anton Vorontsov

do_div accepts unsigned 64-bit integer type for dividend, signed types would cause do_div's typecheck fail:

stat-common.c: In function 'needed_space':
stat-common.c:50: error: comparison of distinct pointer types lacks a cast ...same errors in time.c and tapset-timers.cxx's generated code...

A fix for time.c is special, on ppc32 cycles_t is 32-bit, so technically we don't need do_div, but since the whole _stp_gettimeofday_ns() operates on 64-bit types we'd better be safe and use uint64_t for the math.

Quoted 6 lines
---
 runtime/stat-common.c |    8 ++++----
 runtime/time.c        |    3 ++-
 tapset-timers.cxx     |    2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

I don't immediately see anything wrong with the code. But on x86_64 this does cause some regression test failures in testsuite/systemtap.maps. In particular the following tests now fail (they all pass with this one patch reverted):

Running /home/mark/src/systemtap/testsuite/systemtap.maps/elision.exp ...
FAIL: elision-1
FAIL: elision0
FAIL: elision1
FAIL: elision2
FAIL: elision3
Running /home/mark/src/systemtap/testsuite/systemtap.maps/ix.exp ...
FAIL: systemtap.maps/ix.stp
Running /home/mark/src/systemtap/testsuite/systemtap.maps/linear_large_neg.exp ...
FAIL: systemtap.maps/linear_large_neg.stp
Running /home/mark/src/systemtap/testsuite/systemtap.maps/linear_overunder.exp ...
FAIL: systemtap.maps/linear_overunder.stp
Running /home/mark/src/systemtap/testsuite/systemtap.maps/linear_under.exp ...
FAIL: systemtap.maps/linear_under.stp
Running /home/mark/src/systemtap/testsuite/systemtap.maps/log.exp ...
FAIL: systemtap.maps/log.stp
Running /home/mark/src/systemtap/testsuite/systemtap.maps/log_edge.exp ...
FAIL: systemtap.maps/log_edge.stp

Could you have a look?

Thanks,

Mark

#8 lore raw

Re: [PATCH 6/8] Use proper types for do_div

Quoted 15 lines · Mark Wielaard
Quoted 7 lines · Anton Vorontsov

do_div accepts unsigned 64-bit integer type for dividend, signed types would cause do_div's typecheck fail:

stat-common.c: In function 'needed_space':
stat-common.c:50: error: comparison of distinct pointer types lacks a cast ...same errors in time.c and tapset-timers.cxx's generated code...

I don't immediately see anything wrong with the code. But on x86_64 this does cause some regression test failures in testsuite/systemtap.maps. In particular the following tests now fail (they all pass with this one patch reverted):

Running /home/mark/src/systemtap/testsuite/systemtap.maps/elision.exp ...
FAIL: elision-1

[...]

Quoted 4 lines

Running /home/mark/src/systemtap/testsuite/systemtap.maps/log_edge.exp ...
FAIL: systemtap.maps/log_edge.stp

Could you have a look?

I think this should be fixed by this patch:

http://sourceware.org/ml/systemtap/2009-q4/msg00800.html

Can you try it? With this patch I see no new regressions on x86_64.

Thanks!

Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2
#9 lore raw

Re: [PATCH 6/8] Use proper types for do_div

Hi Anton,

Quoted 5 lines · Anton Vorontsov

I think this should be fixed by this patch:

http://sourceware.org/ml/systemtap/2009-q4/msg00800.html

Can you try it? With this patch I see no new regressions on x86_64.

Yes, that fixes everything. Sorry I didn't see that patch earlier. I see Wenji also tested it already. I have pushed it for you.

Thanks,

Mark

#10 lore raw

PATCH 7/8 Implement _div64 and _mod64 for ppc32

In reply to Anton Vorontsov

_div64 and _mod64 arch-specific details were taken from gcc/longlong.h, just as it was done for i386.

---
 runtime/arith.c |   42 +++++++++++++++++++++++++++++++++++++++---
 1 files changed, 39 insertions(+), 3 deletions(-)
runtime/arith.c +39 -3
index 4c818a7..a032e9c 100644
@@ -20,7 +20,8 @@
 /* 64-bit division for 64-bit cpus and i386 */
 /* Other 32-bit cpus will need to modify this file. */
 
-#if defined (__i386__) || defined(__arm__)
+#if defined (__i386__) || defined(__arm__) || \
+	(defined(__powerpc__) && !defined(__powerpc64__))
 static long long _div64 (long long u, long long v);
 static long long _mod64 (long long u, long long v);
 #endif
@@ -114,7 +115,8 @@ static int _stp_random_pm (unsigned n)
 
 
 
-#if defined (__i386__) || defined (__arm__)
+#if defined (__i386__) || defined (__arm__) || \
+	(defined(__powerpc__) && !defined(__powerpc64__))
 
 /* 64-bit division functions extracted from libgcc */
 typedef long long DWtype;
@@ -181,6 +183,40 @@ typedef union
 		(count) = __cbtmp ^ 31;					\
 	} while (0)
 
+#elif defined (__powerpc__)
+/* these are the ppc versions of these macros from gcc/longlong.h */
+
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+  do {									\
+    if (__builtin_constant_p (ah) && (ah) == 0)				\
+      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfze|subfze} %0,%2"	\
+	       : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
+    else if (__builtin_constant_p (ah) && (ah) == ~(USItype) 0)		\
+      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfme|subfme} %0,%2"	\
+	       : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
+    else if (__builtin_constant_p (bh) && (bh) == 0)			\
+      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{ame|addme} %0,%2"		\
+	       : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
+    else if (__builtin_constant_p (bh) && (bh) == ~(USItype) 0)		\
+      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{aze|addze} %0,%2"		\
+	       : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
+    else								\
+      __asm__ ("{sf%I4|subf%I4c} %1,%5,%4\n\t{sfe|subfe} %0,%3,%2"	\
+	       : "=r" (sh), "=&r" (sl)					\
+	       : "r" (ah), "r" (bh), "rI" (al), "r" (bl));		\
+  } while (0)
+
+#define count_leading_zeros(count, x) \
+  __asm__ ("{cntlz|cntlzw} %0,%1" : "=r" (count) : "r" (x))
+#define COUNT_LEADING_ZEROS_0 32
+
+#define umul_ppmm(ph, pl, m0, m1) \
+  do {									\
+    USItype __m0 = (m0), __m1 = (m1);					\
+    __asm__ ("mulhwu %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1));	\
+    (pl) = __m0 * __m1;							\
+  } while (0)
+
 #elif defined (__arm__)
 
 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
@@ -548,6 +584,6 @@ static long long _mod64 (long long u, long long v)
 	return w;
 }
 
-#endif /* __i386__ || __arm__ */
+#endif /* __i386__ || __arm__ || (__powerpc__ && !__powerpc64__) */
 
 #endif /* _ARITH_C_ */
Signature · 1 line
1.6.3.3
#11 lore raw

PATCH 8/8 Change KERNEL_RELOC_SYMBOL to "_stext" on ppc32

In reply to Anton Vorontsov

Currently staprun fails at send_relocation_kernel(), this is because ppc32 doesn't have ".__start" symbol. I think we should use _stext, just as other arches.

---
 runtime/staprun/staprun.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
runtime/staprun/staprun.c +1 -1
index 078be4c..5bd5163 100644
@@ -372,7 +372,7 @@ int send_relocation_kernel ()
               free (line); line=NULL;
               if (symbol == NULL) continue; /* OOM? */
 
-#ifdef __powerpc__
+#ifdef __powerpc64__
 #define KERNEL_RELOC_SYMBOL ".__start"
 #else
 #define KERNEL_RELOC_SYMBOL "_stext"
Signature · 1 line
1.6.3.3
#13 lore raw
In reply to Anton Vorontsov
Quoted 7 lines · Anton Vorontsov

Hi all,

Here are some patches that add systemtap support for ppc32 machines.

This is all pretty straightforward, though I didn't test it much, only run few 'hello world' taps and decided that it's good enough. ;-)

Quoted 8 lines

I plan to test it more thoughtfully sometime next week, and fix missing things (if any). But so far I'm interested in the feedback on this initial support.

Thanks!

p.s. I though it would be a good idea to cc linuxppc-dev. At least kexec-tools guys tend to do it as well.

I think one thing that got missed was completing the support for ppc32 in tapset/powerpc/registers.stp (functions *_arg and [u_]register). A lot of the 32-bit code is already in place, having been copied over from the x86_64 version, but the _reg_offsets[] array and _stp_get_register_by_offset() work only for 64-bit contexts. A comment at the end of _stp_register_regs() suggests that you can get the correct 32-bit offsets by dividing the 64-bit offsets by 2; compare pt_regs structs to verify.

I'm cc-ing Ananth, who did the original ppc64 work on this file.

The *_arg and [u_]register functions are described in the stapfuncs man page (but not in the Language Reference doc). testsuite/systemtap.context/num_args.tcl tests some of these functions (or used to, at least).

Jim Keniston