Commit 083072dba0 for qemu.org
commit 083072dba096e03f86db8962c83101b679bcc533
Author: Philippe Mathieu-Daudé <philmd@linaro.org>
Date: Mon Mar 23 10:44:07 2026 +0100
monitor: Correctly display virtual addresses while dumping memory
While reworking the address format width in commit 6ad593a75a8 we
introduce a bug, leading to addresses being displayed with too many
zeroes:
$ qemu-system-ppc -monitor stdio -S
QEMU 10.2.90 monitor - type 'help' for more information
(qemu) x/x 0
0000000000000000000000000000000000000000000000000000000000000000: 0x00000000
(qemu) x/x 0xfff00000
00000000000000000000000000000000000000000000000000000000fff00000: 0x60000000
$ qemu-system-ppc64 -monitor stdio -S
QEMU 10.2.90 monitor - type 'help' for more information
(qemu) x/x 0
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000: 0x00000000
Correct the format width to restore the previous behavior:
$ qemu-system-ppc -monitor stdio -S
QEMU 10.2.90 monitor - type 'help' for more information
(qemu) x/x 0
00000000: 0x00000000
$ qemu-system-ppc64 -monitor stdio -S
QEMU 10.2.90 monitor - type 'help' for more information
(qemu) x/x 0
0000000000000000: 0x00000000
Fixes: 6ad593a75a8 ("monitor/hmp: Use plain uint64_t @addr argument in memory_dump()")
Reported-by: BALATON Zoltan <balaton@eik.bme.hu>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20260323095020.66658-1-philmd@linaro.org>
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index bad034937a..bc26b39d70 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -537,7 +537,7 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize,
uint8_t buf[16];
uint64_t v;
CPUState *cs = mon_get_cpu(mon);
- const unsigned int addr_width = is_physical ? 8 : (target_long_bits() * 2);
+ const unsigned int addr_width = is_physical ? 8 : (target_long_bits() / 4);
const bool big_endian = target_big_endian();
if (!cs && (format == 'i' || !is_physical)) {