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>
---
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 bad034937a9..bc26b39d708 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)) {
--
2.53.0
On 3/23/26 2:50 AM, Philippe Mathieu-Daudé wrote:
> 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>
> ---
> monitor/hmp-cmds.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
On Mon, 23 Mar 2026, Philippe Mathieu-Daudé wrote:
> 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>
> ---
> 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 bad034937a9..bc26b39d708 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);
Thanks, that should help, haven't tried yet. But is_physical used
HWADDR_FMT_plx before which is "%016" PRIx64 so should that be 16 here to
preserve previous behaviour? (Both 8 or 16 seem arbitrary, it should
really depend on the physical address width of target but 64 bits for
physical seems better as even 32 bit CPUs might have larger phys
addresses.)
Regards,
BALATON Zoltan
> const bool big_endian = target_big_endian();
>
> if (!cs && (format == 'i' || !is_physical)) {
>
On 23/3/26 12:51, BALATON Zoltan wrote:
> On Mon, 23 Mar 2026, Philippe Mathieu-Daudé wrote:
>> 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>
>> ---
>> 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 bad034937a9..bc26b39d708 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);
>
> Thanks, that should help, haven't tried yet. But is_physical used
> HWADDR_FMT_plx before which is "%016" PRIx64 so should that be 16 here
> to preserve previous behaviour? (Both 8 or 16 seem arbitrary, it should
> really depend on the physical address width of target but 64 bits for
> physical seems better as even 32 bit CPUs might have larger phys
> addresses.)
This patch only fixes the virtual path, restoring the
behavior prior commit 6ad593a75a8.
For physical path previous format indeed used 16 chars,
overkill IMHO, still I neglected to comment I reduced
16 -> 8 in commit 6ad593a75a8. Nobody complained so far
but if you rather I can restore that too, as a "fix".
Long term my plan is to use mr_addr_fmt_width() here
for physical addresses:
https://lore.kernel.org/qemu-devel/20260226220226.20164-8-philmd@linaro.org/
>
> Regards,
> BALATON Zoltan
>
>> const bool big_endian = target_big_endian();
>>
>> if (!cs && (format == 'i' || !is_physical)) {
>>
On Mon, 23 Mar 2026, Philippe Mathieu-Daudé wrote:
> On 23/3/26 12:51, BALATON Zoltan wrote:
>> On Mon, 23 Mar 2026, Philippe Mathieu-Daudé wrote:
>>> 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>
>>> ---
>>> 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 bad034937a9..bc26b39d708 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);
>>
>> Thanks, that should help, haven't tried yet. But is_physical used
>> HWADDR_FMT_plx before which is "%016" PRIx64 so should that be 16 here to
>> preserve previous behaviour? (Both 8 or 16 seem arbitrary, it should really
>> depend on the physical address width of target but 64 bits for physical
>> seems better as even 32 bit CPUs might have larger phys addresses.)
>
> This patch only fixes the virtual path, restoring the
> behavior prior commit 6ad593a75a8.
>
> For physical path previous format indeed used 16 chars,
> overkill IMHO, still I neglected to comment I reduced
> 16 -> 8 in commit 6ad593a75a8. Nobody complained so far
> but if you rather I can restore that too, as a "fix".
Considering that e.g. PPC440 or i386 with PAE could have larger physical
addresses even if target long bits is 32 (and 64 bit CPUs surely have
larger physical addresses) I don't think just 8 chars would be enough.
Even if nobody complained yet maybe it's safest to match the original
output for the freeze now and try to rewrite it for next version.
Regards,
BALATON Zoltan
On 23/3/26 14:45, BALATON Zoltan wrote:
> On Mon, 23 Mar 2026, Philippe Mathieu-Daudé wrote:
>> On 23/3/26 12:51, BALATON Zoltan wrote:
>>> On Mon, 23 Mar 2026, Philippe Mathieu-Daudé wrote:
>>>> 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>
>>>> ---
>>>> 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 bad034937a9..bc26b39d708 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);
>>>
>>> Thanks, that should help, haven't tried yet. But is_physical used
>>> HWADDR_FMT_plx before which is "%016" PRIx64 so should that be 16
>>> here to preserve previous behaviour? (Both 8 or 16 seem arbitrary, it
>>> should really depend on the physical address width of target but 64
>>> bits for physical seems better as even 32 bit CPUs might have larger
>>> phys addresses.)
>>
>> This patch only fixes the virtual path, restoring the
>> behavior prior commit 6ad593a75a8.
>>
>> For physical path previous format indeed used 16 chars,
>> overkill IMHO, still I neglected to comment I reduced
>> 16 -> 8 in commit 6ad593a75a8. Nobody complained so far
>> but if you rather I can restore that too, as a "fix".
>
> Considering that e.g. PPC440 or i386 with PAE could have larger physical
> addresses even if target long bits is 32 (and 64 bit CPUs surely have
> larger physical addresses) I don't think just 8 chars would be enough.
> Even if nobody complained yet maybe it's safest to match the original
> output for the freeze now and try to rewrite it for next version.
The physical address isn't trucated at 8 chars, it is just not
zero-expanded.
So for example 0000000100000000 is displayed as 100000000.
On Mon, 23 Mar 2026, Philippe Mathieu-Daudé wrote:
> On 23/3/26 14:45, BALATON Zoltan wrote:
>> On Mon, 23 Mar 2026, Philippe Mathieu-Daudé wrote:
>>> On 23/3/26 12:51, BALATON Zoltan wrote:
>>>> On Mon, 23 Mar 2026, Philippe Mathieu-Daudé wrote:
>>>>> 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>
>>>>> ---
>>>>> 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 bad034937a9..bc26b39d708 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);
>>>>
>>>> Thanks, that should help, haven't tried yet. But is_physical used
>>>> HWADDR_FMT_plx before which is "%016" PRIx64 so should that be 16 here to
>>>> preserve previous behaviour? (Both 8 or 16 seem arbitrary, it should
>>>> really depend on the physical address width of target but 64 bits for
>>>> physical seems better as even 32 bit CPUs might have larger phys
>>>> addresses.)
>>>
>>> This patch only fixes the virtual path, restoring the
>>> behavior prior commit 6ad593a75a8.
>>>
>>> For physical path previous format indeed used 16 chars,
>>> overkill IMHO, still I neglected to comment I reduced
>>> 16 -> 8 in commit 6ad593a75a8. Nobody complained so far
>>> but if you rather I can restore that too, as a "fix".
>>
>> Considering that e.g. PPC440 or i386 with PAE could have larger physical
>> addresses even if target long bits is 32 (and 64 bit CPUs surely have
>> larger physical addresses) I don't think just 8 chars would be enough. Even
>> if nobody complained yet maybe it's safest to match the original output for
>> the freeze now and try to rewrite it for next version.
>
> The physical address isn't trucated at 8 chars, it is just not
> zero-expanded.
> So for example 0000000100000000 is displayed as 100000000.
Which means it will not align if you do x/8x 0xfffffff0 and you get odd
looking output. That could or could not be desired but matching the
behaviour so far seems the least problematic.
Regards,
BALATON Zoltan
On 23/03/2026 10.50, Philippe Mathieu-Daudé wrote:
> 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>
> ---
> monitor/hmp-cmds.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Thomas Huth <thuth@redhat.com>
© 2016 - 2026 Red Hat, Inc.