From 083072dba096e03f86db8962c83101b679bcc533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 23 Mar 2026 10:44:07 +0100 Subject: [PATCH] monitor: Correctly display virtual addresses while dumping memory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth Message-Id: <20260323095020.66658-1-philmd@linaro.org> --- monitor/hmp-cmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)) {