Skip to contentSkip to conversation

powerpc: Fix xmon ml command to work with 64 bit values.

PATCH In review Rashmica Gupta 3 participants 4 messages Nov 24, 2015 – Feb 4, 2022 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: Fix xmon ml command to work with 64 bit values.

The ml command in xmon currently only works for 32-bit values and so fails to find 64-bit values on a ppc64 machine. So change to work for 64-bit values.

This is based off a patch by Josh Boyer.

---

Based off this patch: http://patchwork.ozlabs.org/patch/90309/

 arch/powerpc/xmon/xmon.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
arch/powerpc/xmon/xmon.c +15 -8
index 786bf01691c9..df05bd2fca07 100644
@@ -184,6 +184,12 @@ extern void xmon_leave(void);
 #define GETWORD(v)	(((v)[0] << 24) + ((v)[1] << 16) + ((v)[2] << 8) + (v)[3])
 #endif
 
+#if BITS_PER_LONG == 64
+#define GETLONG(v)	(((unsigned long) GETWORD(v)) << 32 | GETWORD(v+4))
+#else
+#define GETLONG(v)	GETWORD(v)
+#endif
+
 static char *help_string = "\
 Commands:\n\
   b	show breakpoints\n\
@@ -2447,14 +2453,15 @@ memdiffs(unsigned char *p1, unsigned char *p2, unsigned nb, unsigned maxpr)
 		printf("Total of %d differences\n", prt);
 }
 
-static unsigned mend;
-static unsigned mask;
+static unsigned long mend;
+static unsigned long mask;
 
 static void
 memlocate(void)
 {
-	unsigned a, n;
-	unsigned char val[4];
+	unsigned long a, n;
+	int size = sizeof(unsigned long);
+	unsigned char val[size];
 
 	last_cmd = "ml";
 	scanhex((void *)&mdest);
@@ -2470,10 +2477,10 @@ memlocate(void)
 		}
 	}
 	n = 0;
-	for (a = mdest; a < mend; a += 4) {
-		if (mread(a, val, 4) == 4
-			&& ((GETWORD(val) ^ mval) & mask) == 0) {
-			printf("%.16x:  %.16x\n", a, GETWORD(val));
+	for (a = mdest; a < mend; a += size) {
+		if (mread(a, val, size) == size
+			&& ((GETLONG(val) ^ mval) & mask) == 0){
+			printf("%.16lx:  %.16lx\n", a, GETLONG(val));
 			if (++n >= 10)
 				break;
 		}
Signature · 1 line
2.5.0
#1 lore raw
Quoted 3 lines · Rashmica Gupta

The ml command in xmon currently only works for 32-bit values and so fails to find 64-bit values on a ppc64 machine. So change to work for 64-bit values.

Please add xmon to the subject line

Quoted 2 lines

This is based off a patch by Josh Boyer.

based on

Quoted 70 lines

---

Based off this patch: http://patchwork.ozlabs.org/patch/90309/

 arch/powerpc/xmon/xmon.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
arch/powerpc/xmon/xmon.c +6 -0
index 786bf01691c9..df05bd2fca07 100644
@@ -184,6 +184,12 @@ extern void xmon_leave(void);
 #define GETWORD(v)	(((v)[0] << 24) + ((v)[1] << 16) + ((v)[2] << 8) +
 (v)[3])
 #endif
 
+#if BITS_PER_LONG == 64
+#define GETLONG(v)	(((unsigned long) GETWORD(v)) << 32 | GETWORD(v+4))
+#else
+#define GETLONG(v)	GETWORD(v)
+#endif
+
 static char *help_string = "\
 Commands:\n\
   b	show breakpoints\n\
arch/powerpc/xmon/xmon.c +5 -4
@@ -2447,14 +2453,15 @@ memdiffs(unsigned char *p1, unsigned char *p2,
 unsigned nb, unsigned maxpr)
 		printf("Total of %d differences\n", prt);
 }
 
-static unsigned mend;
-static unsigned mask;
+static unsigned long mend;
+static unsigned long mask;
 
 static void
 memlocate(void)
 {
-	unsigned a, n;
-	unsigned char val[4];
+	unsigned long a, n;
+	int size = sizeof(unsigned long);
+	unsigned char val[size];
 
 	last_cmd = "ml";
arch/powerpc/xmon/xmon.c +4 -5
 	scanhex((void *)&mdest);
@@ -2470,10 +2477,10 @@ memlocate(void)
 		}
 	}
 	n = 0;
-	for (a = mdest; a < mend; a += 4) {
-		if (mread(a, val, 4) == 4
-			&& ((GETWORD(val) ^ mval) & mask) == 0) {
-			printf("%.16x:  %.16x\n", a, GETWORD(val));
+	for (a = mdest; a < mend; a += size) {
+		if (mread(a, val, size) == size
+			&& ((GETLONG(val) ^ mval) & mask) == 0){
+			printf("%.16lx:  %.16lx\n", a, GETLONG(val));
 			if (++n >= 10)
 				break;
 		}
--

2.5.0

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev

#2 lore raw
In reply to Rashmica Gupta
Quoted 8 lines · Rashmica Gupta

The ml command in xmon currently only works for 32-bit values and so fails to find 64-bit values on a ppc64 machine. So change to work for 64-bit values.

This is based off a patch by Josh Boyer.

---

Please remove(update?) Josh Boyer from CC, the address bounces back.

Quoted 67 lines

Based off this patch: http://patchwork.ozlabs.org/patch/90309/

 arch/powerpc/xmon/xmon.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
arch/powerpc/xmon/xmon.c +6 -0
index 786bf01691c9..df05bd2fca07 100644
@@ -184,6 +184,12 @@ extern void xmon_leave(void);
 #define GETWORD(v)	(((v)[0] << 24) + ((v)[1] << 16) + ((v)[2] << 8) +
 (v)[3])
 #endif
 
+#if BITS_PER_LONG == 64
+#define GETLONG(v)	(((unsigned long) GETWORD(v)) << 32 | GETWORD(v+4))
+#else
+#define GETLONG(v)	GETWORD(v)
+#endif
+
 static char *help_string = "\
 Commands:\n\
   b	show breakpoints\n\
arch/powerpc/xmon/xmon.c +5 -4
@@ -2447,14 +2453,15 @@ memdiffs(unsigned char *p1, unsigned char *p2,
 unsigned nb, unsigned maxpr)
 		printf("Total of %d differences\n", prt);
 }
 
-static unsigned mend;
-static unsigned mask;
+static unsigned long mend;
+static unsigned long mask;
 
 static void
 memlocate(void)
 {
-	unsigned a, n;
-	unsigned char val[4];
+	unsigned long a, n;
+	int size = sizeof(unsigned long);
+	unsigned char val[size];
 
 	last_cmd = "ml";
arch/powerpc/xmon/xmon.c +4 -5
 	scanhex((void *)&mdest);
@@ -2470,10 +2477,10 @@ memlocate(void)
 		}
 	}
 	n = 0;
-	for (a = mdest; a < mend; a += 4) {
-		if (mread(a, val, 4) == 4
-			&& ((GETWORD(val) ^ mval) & mask) == 0) {
-			printf("%.16x:  %.16x\n", a, GETWORD(val));
+	for (a = mdest; a < mend; a += size) {
+		if (mread(a, val, size) == size
+			&& ((GETLONG(val) ^ mval) & mask) == 0){
+			printf("%.16lx:  %.16lx\n", a, GETLONG(val));
 			if (++n >= 10)
 				break;
 		}
--

2.5.0

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev

#3 lore raw
In reply to Rashmica Gupta

Le 25/11/2015 à 00:16, Rashmica Gupta a écrit :

Quoted 19 lines

The ml command in xmon currently only works for 32-bit values and so fails to find 64-bit values on a ppc64 machine. So change to work for 64-bit values.

This is based off a patch by Josh Boyer.

---

Based off this patch: http://patchwork.ozlabs.org/patch/90309/

  arch/powerpc/xmon/xmon.c | 23 +++++++++++++++--------
  1 file changed, 15 insertions(+), 8 deletions(-)
arch/powerpc/xmon/xmon.c +0 -0
index 786bf01691c9..df05bd2fca07 100644

arch/powerpc/xmon/xmon.c extern void xmon_leave(void); · line 192

Quoted 9 lines
arch/powerpc/xmon/xmon.c +6 -0
@@ -184,6 +184,12 @@ extern void xmon_leave(void);
  #define GETWORD(v)	(((v)[0] << 24) + ((v)[1] << 16) + ((v)[2] << 8) + (v)[3])
  #endif
 
+#if BITS_PER_LONG == 64
+#define GETLONG(v)	(((unsigned long) GETWORD(v)) << 32 | GETWORD(v+4))
+#else
+#define GETLONG(v)	GETWORD(v)
+#endif
+

memlocate() is the only place when GETWORD() is used. Shouldn't we just replace GETWORD() by GETLONG() instead of doing a GETLONG() with GETWORD() ?

Also, can we use CONFIG_PPC64 instead of BITS_PER_LONG == 64 ?

Quoted 38 lines
arch/powerpc/xmon/xmon.c +9 -8
  static char *help_string = "\
  Commands:\n\
    b	show breakpoints\n\
@@ -2447,14 +2453,15 @@ memdiffs(unsigned char *p1, unsigned char *p2, unsigned nb, unsigned maxpr)
  		printf("Total of %d differences\n", prt);
  }
 
-static unsigned mend;
-static unsigned mask;
+static unsigned long mend;
+static unsigned long mask;
 
  static void
  memlocate(void)
  {
-	unsigned a, n;
-	unsigned char val[4];
+	unsigned long a, n;
+	int size = sizeof(unsigned long);
+	unsigned char val[size];
 
  	last_cmd = "ml";
  	scanhex((void *)&mdest);
@@ -2470,10 +2477,10 @@ memlocate(void)
  		}
  	}
  	n = 0;
-	for (a = mdest; a < mend; a += 4) {
-		if (mread(a, val, 4) == 4
-			&& ((GETWORD(val) ^ mval) & mask) == 0) {
-			printf("%.16x:  %.16x\n", a, GETWORD(val));
+	for (a = mdest; a < mend; a += size) {
+		if (mread(a, val, size) == size
+			&& ((GETLONG(val) ^ mval) & mask) == 0){
+			printf("%.16lx:  %.16lx\n", a, GETLONG(val));
  			if (++n >= 10)
  				break;
  		}