linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/xmon: Fix disassembly since printf changes
@ 2018-07-17  0:50 Michael Ellerman
  2018-07-19  6:06 ` Michael Ellerman
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Ellerman @ 2018-07-17  0:50 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: malat

The recent change to add printf annotations to xmon inadvertently made
the disassembly output ugly, eg:

  c00000002001e058  7ee00026      mfcr    r23
  c00000002001e05c  fffffffffae101a0      std     r23,416(r1)
  c00000002001e060  fffffffff8230000      std     r1,0(r3)

The problem being that negative 32-bit values are being displayed in
full 64-bits.

The printf conversion was actually correct, we are passing unsigned
long so it should use "lx". But powerpc instructions are only 4 bytes
and the code only reads 4 bytes, so inst should really just be
unsigned int, and that also fixes the printing to look the way we
want:

  c00000002001e058  7ee00026      mfcr    r23
  c00000002001e05c  fae101a0      std     r23,416(r1)
  c00000002001e060  f8230000      std     r1,0(r3)

Fixes: e70d8f55268b ("powerpc/xmon: Add __printf annotation to xmon_printf()")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/xmon/xmon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 47166ad2a669..196978733e64 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -2734,7 +2734,7 @@ generic_inst_dump(unsigned long adr, long count, int praddr,
 {
 	int nr, dotted;
 	unsigned long first_adr;
-	unsigned long inst, last_inst = 0;
+	unsigned int inst, last_inst = 0;
 	unsigned char val[4];
 
 	dotted = 0;
@@ -2758,7 +2758,7 @@ generic_inst_dump(unsigned long adr, long count, int praddr,
 		dotted = 0;
 		last_inst = inst;
 		if (praddr)
-			printf(REG"  %.8lx", adr, inst);
+			printf(REG"  %.8x", adr, inst);
 		printf("\t");
 		dump_func(inst, adr);
 		printf("\n");
-- 
2.14.1

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

* Re: powerpc/xmon: Fix disassembly since printf changes
  2018-07-17  0:50 [PATCH] powerpc/xmon: Fix disassembly since printf changes Michael Ellerman
@ 2018-07-19  6:06 ` Michael Ellerman
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2018-07-19  6:06 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev; +Cc: malat

On Tue, 2018-07-17 at 00:50:38 UTC, Michael Ellerman wrote:
> The recent change to add printf annotations to xmon inadvertently made
> the disassembly output ugly, eg:
> 
>   c00000002001e058  7ee00026      mfcr    r23
>   c00000002001e05c  fffffffffae101a0      std     r23,416(r1)
>   c00000002001e060  fffffffff8230000      std     r1,0(r3)
> 
> The problem being that negative 32-bit values are being displayed in
> full 64-bits.
> 
> The printf conversion was actually correct, we are passing unsigned
> long so it should use "lx". But powerpc instructions are only 4 bytes
> and the code only reads 4 bytes, so inst should really just be
> unsigned int, and that also fixes the printing to look the way we
> want:
> 
>   c00000002001e058  7ee00026      mfcr    r23
>   c00000002001e05c  fae101a0      std     r23,416(r1)
>   c00000002001e060  f8230000      std     r1,0(r3)
> 
> Fixes: e70d8f55268b ("powerpc/xmon: Add __printf annotation to xmon_printf()")
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

Applied to powerpc fixes.

https://git.kernel.org/powerpc/c/941d810725ad48cc21948f4cff8cf7

cheers

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

end of thread, other threads:[~2018-07-19  6:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-17  0:50 [PATCH] powerpc/xmon: Fix disassembly since printf changes Michael Ellerman
2018-07-19  6:06 ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).