* [PATCH 0/7] system/memory: Improve 'info mtree' readability
@ 2026-02-26 22:02 Philippe Mathieu-Daudé
2026-02-26 22:02 ` [PATCH 1/7] stubs: Merge physmem.c within ram-block.c Philippe Mathieu-Daudé
` (6 more replies)
0 siblings, 7 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-02-26 22:02 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Mark Cave-Ayland, Paolo Bonzini,
Philippe Mathieu-Daudé, Peter Xu, Akihiko Odaki
Cleaning dust, I had forgotten about this branch. In short,
it improves 'info mtree' readability of addresses.
Currently with Q35:
address-space: I/O
0000000000000000-000000000000ffff (prio 0, i/o): io
0000000000000000-0000000000000003 (prio 0, i/o): acpi-evt
0000000000000004-0000000000000005 (prio 0, i/o): acpi-cnt
0000000000000008-000000000000000b (prio 0, i/o): acpi-tmr
0000000000000020-000000000000002f (prio 0, i/o): acpi-gpe0
0000000000000030-0000000000000037 (prio 0, i/o): acpi-smi
0000000000000060-000000000000007f (prio 0, i/o): sm-tco
0000000000000000-0000000000000007 (prio 0, i/o): dma-chan
0000000000000008-000000000000000f (prio 0, i/o): dma-cont
0000000000000020-0000000000000021 (prio 0, i/o): pic
0000000000000040-0000000000000043 (prio 0, i/o): pit
...
memory-region: pc.ram
0000000000000000-0000000007ffffff (prio 0, ram): pc.ram
memory-region: pc.bios
00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios
memory-region: pci
0000000000000000-ffffffffffffffff (prio -1, i/o): pci
00000000000a0000-00000000000bffff (prio 1, i/o): vga-lowmem
00000000000c0000-00000000000dffff (prio 1, rom): pc.rom
00000000000e0000-00000000000fffff (prio 1, rom): alias isa-bios @pc.bios 0000000000020000-000000000003ffff
00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios
...
With this series:
address-space: I/O
0000-ffff (prio 0, container): io
0000-0003 (prio 0, i/o): acpi-evt
0004-0005 (prio 0, i/o): acpi-cnt
0008-000b (prio 0, i/o): acpi-tmr
0020-002f (prio 0, i/o): acpi-gpe0
0030-0037 (prio 0, i/o): acpi-smi
0060-007f (prio 0, i/o): sm-tco
0000-0007 (prio 0, i/o): dma-chan
0008-000f (prio 0, i/o): dma-cont
0020-0021 (prio 0, i/o): pic
0040-0043 (prio 0, i/o): pit
...
memory-region: pc.ram
00000000-07ffffff (prio 0, ram): pc.ram
memory-region: pc.bios
fffc0000-ffffffff (prio 0, rom): pc.bios
memory-region: pci
0000000000000000-ffffffffffffffff (prio -1, i/o): pci
00000000000a0000-00000000000bffff (prio 1, i/o): vga-lowmem
00000000000c0000-00000000000dffff (prio 1, rom): pc.rom
00000000000e0000-00000000000fffff (prio 1, rom): alias isa-bios @pc.bios 0000000000020000-000000000003ffff
00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios
...
Philippe Mathieu-Daudé (7):
stubs: Merge physmem.c within ram-block.c
system/ramblock: Constify various RAMBlock arguments
system/memory: Constify various MemoryRegion arguments
system/memory: Have memory_region_type() correctly describe containers
system/memory: Display address spaces starting at 0x0000.0000
system/memory: Allow mtree_print_mr() to display distinct address
width
system/memory: Have 'info mtree' display addresses nicely
include/system/memory.h | 28 +++++-----
include/system/ramblock.h | 26 ++++-----
stubs/physmem.c | 13 -----
stubs/ram-block.c | 17 ++++--
system/memory.c | 108 ++++++++++++++++++++++++--------------
system/physmem.c | 26 ++++-----
stubs/meson.build | 1 -
7 files changed, 123 insertions(+), 96 deletions(-)
delete mode 100644 stubs/physmem.c
--
2.52.0
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 1/7] stubs: Merge physmem.c within ram-block.c
2026-02-26 22:02 [PATCH 0/7] system/memory: Improve 'info mtree' readability Philippe Mathieu-Daudé
@ 2026-02-26 22:02 ` Philippe Mathieu-Daudé
2026-02-26 22:21 ` Pierrick Bouvier
` (2 more replies)
2026-02-26 22:02 ` [PATCH 2/7] system/ramblock: Constify various RAMBlock arguments Philippe Mathieu-Daudé
` (5 subsequent siblings)
6 siblings, 3 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-02-26 22:02 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Mark Cave-Ayland, Paolo Bonzini,
Philippe Mathieu-Daudé, Peter Xu, Akihiko Odaki
physmem.c defines 2 stubs which are related to ram-block:
qemu_ram_block_from_host() and qemu_ram_get_fd().
Move them with the other ram-block stubs.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
stubs/physmem.c | 13 -------------
stubs/ram-block.c | 11 +++++++++++
stubs/meson.build | 1 -
3 files changed, 11 insertions(+), 14 deletions(-)
delete mode 100644 stubs/physmem.c
diff --git a/stubs/physmem.c b/stubs/physmem.c
deleted file mode 100644
index 14667f2bd8f..00000000000
--- a/stubs/physmem.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "qemu/osdep.h"
-#include "system/ramblock.h"
-
-RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
- ram_addr_t *offset)
-{
- return NULL;
-}
-
-int qemu_ram_get_fd(RAMBlock *rb)
-{
- return -1;
-}
diff --git a/stubs/ram-block.c b/stubs/ram-block.c
index 8790a59593e..f0650b19ac6 100644
--- a/stubs/ram-block.c
+++ b/stubs/ram-block.c
@@ -35,3 +35,14 @@ int ram_block_discard_disable(bool state)
{
return 0;
}
+
+RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
+ ram_addr_t *offset)
+{
+ return NULL;
+}
+
+int qemu_ram_get_fd(RAMBlock *rb)
+{
+ return -1;
+}
diff --git a/stubs/meson.build b/stubs/meson.build
index 8a07059500d..0171f531523 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -20,7 +20,6 @@ if have_block
stub_ss.add(files('get-vm-name.c'))
stub_ss.add(files('iothread-lock-block.c'))
stub_ss.add(files('migr-blocker.c'))
- stub_ss.add(files('physmem.c'))
stub_ss.add(files('ram-block.c'))
stub_ss.add(files('runstate-check.c'))
stub_ss.add(files('uuid.c'))
--
2.52.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 2/7] system/ramblock: Constify various RAMBlock arguments
2026-02-26 22:02 [PATCH 0/7] system/memory: Improve 'info mtree' readability Philippe Mathieu-Daudé
2026-02-26 22:02 ` [PATCH 1/7] stubs: Merge physmem.c within ram-block.c Philippe Mathieu-Daudé
@ 2026-02-26 22:02 ` Philippe Mathieu-Daudé
2026-02-26 22:22 ` Pierrick Bouvier
2026-03-04 18:33 ` Peter Xu
2026-02-26 22:02 ` [PATCH 3/7] system/memory: Constify various MemoryRegion arguments Philippe Mathieu-Daudé
` (4 subsequent siblings)
6 siblings, 2 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-02-26 22:02 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Mark Cave-Ayland, Paolo Bonzini,
Philippe Mathieu-Daudé, Peter Xu, Akihiko Odaki
Mark the RAMBlock structure const when is only accessed read-only.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/system/ramblock.h | 26 +++++++++++++-------------
stubs/ram-block.c | 8 ++++----
system/physmem.c | 26 +++++++++++++-------------
3 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/include/system/ramblock.h b/include/system/ramblock.h
index e9f58ac0457..221e8e5d03e 100644
--- a/include/system/ramblock.h
+++ b/include/system/ramblock.h
@@ -154,24 +154,24 @@ RAMBlock *qemu_ram_block_by_name(const char *name);
*/
RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
ram_addr_t *offset);
-ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host);
+ram_addr_t qemu_ram_block_host_offset(const RAMBlock *rb, void *host);
void qemu_ram_set_idstr(RAMBlock *block, const char *name, DeviceState *dev);
void qemu_ram_unset_idstr(RAMBlock *block);
-const char *qemu_ram_get_idstr(RAMBlock *rb);
-void *qemu_ram_get_host_addr(RAMBlock *rb);
-ram_addr_t qemu_ram_get_offset(RAMBlock *rb);
-ram_addr_t qemu_ram_get_fd_offset(RAMBlock *rb);
-ram_addr_t qemu_ram_get_used_length(RAMBlock *rb);
-ram_addr_t qemu_ram_get_max_length(RAMBlock *rb);
-bool qemu_ram_is_shared(RAMBlock *rb);
-bool qemu_ram_is_noreserve(RAMBlock *rb);
-bool qemu_ram_is_uf_zeroable(RAMBlock *rb);
+const char *qemu_ram_get_idstr(const RAMBlock *rb);
+void *qemu_ram_get_host_addr(const RAMBlock *rb);
+ram_addr_t qemu_ram_get_offset(const RAMBlock *rb);
+ram_addr_t qemu_ram_get_fd_offset(const RAMBlock *rb);
+ram_addr_t qemu_ram_get_used_length(const RAMBlock *rb);
+ram_addr_t qemu_ram_get_max_length(const RAMBlock *rb);
+bool qemu_ram_is_shared(const RAMBlock *rb);
+bool qemu_ram_is_noreserve(const RAMBlock *rb);
+bool qemu_ram_is_uf_zeroable(const RAMBlock *rb);
void qemu_ram_set_uf_zeroable(RAMBlock *rb);
-bool qemu_ram_is_migratable(RAMBlock *rb);
+bool qemu_ram_is_migratable(const RAMBlock *rb);
void qemu_ram_set_migratable(RAMBlock *rb);
void qemu_ram_unset_migratable(RAMBlock *rb);
-bool qemu_ram_is_named_file(RAMBlock *rb);
-int qemu_ram_get_fd(RAMBlock *rb);
+bool qemu_ram_is_named_file(const RAMBlock *rb);
+int qemu_ram_get_fd(const RAMBlock *rb);
size_t qemu_ram_pagesize(RAMBlock *block);
size_t qemu_ram_pagesize_largest(void);
diff --git a/stubs/ram-block.c b/stubs/ram-block.c
index f0650b19ac6..3ca47214a0c 100644
--- a/stubs/ram-block.c
+++ b/stubs/ram-block.c
@@ -3,17 +3,17 @@
#include "system/ramblock.h"
#include "system/memory.h"
-void *qemu_ram_get_host_addr(RAMBlock *rb)
+void *qemu_ram_get_host_addr(const RAMBlock *rb)
{
return 0;
}
-ram_addr_t qemu_ram_get_offset(RAMBlock *rb)
+ram_addr_t qemu_ram_get_offset(const RAMBlock *rb)
{
return 0;
}
-ram_addr_t qemu_ram_get_used_length(RAMBlock *rb)
+ram_addr_t qemu_ram_get_used_length(const RAMBlock *rb)
{
return 0;
}
@@ -42,7 +42,7 @@ RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
return NULL;
}
-int qemu_ram_get_fd(RAMBlock *rb)
+int qemu_ram_get_fd(const RAMBlock *rb)
{
return -1;
}
diff --git a/system/physmem.c b/system/physmem.c
index 2fb0c25c93b..2384c6dbba4 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -1857,48 +1857,48 @@ static void qemu_ram_setup_dump(void *addr, ram_addr_t size)
}
}
-const char *qemu_ram_get_idstr(RAMBlock *rb)
+const char *qemu_ram_get_idstr(const RAMBlock *rb)
{
return rb->idstr;
}
-void *qemu_ram_get_host_addr(RAMBlock *rb)
+void *qemu_ram_get_host_addr(const RAMBlock *rb)
{
return rb->host;
}
-ram_addr_t qemu_ram_get_offset(RAMBlock *rb)
+ram_addr_t qemu_ram_get_offset(const RAMBlock *rb)
{
return rb->offset;
}
-ram_addr_t qemu_ram_get_fd_offset(RAMBlock *rb)
+ram_addr_t qemu_ram_get_fd_offset(const RAMBlock *rb)
{
return rb->fd_offset;
}
-ram_addr_t qemu_ram_get_used_length(RAMBlock *rb)
+ram_addr_t qemu_ram_get_used_length(const RAMBlock *rb)
{
return rb->used_length;
}
-ram_addr_t qemu_ram_get_max_length(RAMBlock *rb)
+ram_addr_t qemu_ram_get_max_length(const RAMBlock *rb)
{
return rb->max_length;
}
-bool qemu_ram_is_shared(RAMBlock *rb)
+bool qemu_ram_is_shared(const RAMBlock *rb)
{
return rb->flags & RAM_SHARED;
}
-bool qemu_ram_is_noreserve(RAMBlock *rb)
+bool qemu_ram_is_noreserve(const RAMBlock *rb)
{
return rb->flags & RAM_NORESERVE;
}
/* Note: Only set at the start of postcopy */
-bool qemu_ram_is_uf_zeroable(RAMBlock *rb)
+bool qemu_ram_is_uf_zeroable(const RAMBlock *rb)
{
return rb->flags & RAM_UF_ZEROPAGE;
}
@@ -1908,7 +1908,7 @@ void qemu_ram_set_uf_zeroable(RAMBlock *rb)
rb->flags |= RAM_UF_ZEROPAGE;
}
-bool qemu_ram_is_migratable(RAMBlock *rb)
+bool qemu_ram_is_migratable(const RAMBlock *rb)
{
return rb->flags & RAM_MIGRATABLE;
}
@@ -1923,12 +1923,12 @@ void qemu_ram_unset_migratable(RAMBlock *rb)
rb->flags &= ~RAM_MIGRATABLE;
}
-bool qemu_ram_is_named_file(RAMBlock *rb)
+bool qemu_ram_is_named_file(const RAMBlock *rb)
{
return rb->flags & RAM_NAMED_FILE;
}
-int qemu_ram_get_fd(RAMBlock *rb)
+int qemu_ram_get_fd(const RAMBlock *rb)
{
return rb->fd;
}
@@ -2770,7 +2770,7 @@ void *qemu_map_ram_ptr(RAMBlock *ram_block, ram_addr_t addr)
}
/* Return the offset of a hostpointer within a ramblock */
-ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host)
+ram_addr_t qemu_ram_block_host_offset(const RAMBlock *rb, void *host)
{
ram_addr_t res = (uint8_t *)host - (uint8_t *)rb->host;
assert((uintptr_t)host >= (uintptr_t)rb->host);
--
2.52.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 3/7] system/memory: Constify various MemoryRegion arguments
2026-02-26 22:02 [PATCH 0/7] system/memory: Improve 'info mtree' readability Philippe Mathieu-Daudé
2026-02-26 22:02 ` [PATCH 1/7] stubs: Merge physmem.c within ram-block.c Philippe Mathieu-Daudé
2026-02-26 22:02 ` [PATCH 2/7] system/ramblock: Constify various RAMBlock arguments Philippe Mathieu-Daudé
@ 2026-02-26 22:02 ` Philippe Mathieu-Daudé
2026-02-26 22:22 ` Pierrick Bouvier
2026-03-04 18:33 ` Peter Xu
2026-02-26 22:02 ` [PATCH 4/7] system/memory: Have memory_region_type() correctly describe containers Philippe Mathieu-Daudé
` (3 subsequent siblings)
6 siblings, 2 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-02-26 22:02 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Mark Cave-Ayland, Paolo Bonzini,
Philippe Mathieu-Daudé, Peter Xu, Akihiko Odaki
Mark the MemoryRegion structure const when is only accessed read-only.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/system/memory.h | 28 ++++++++++++++--------------
system/memory.c | 34 ++++++++++++++++++----------------
2 files changed, 32 insertions(+), 30 deletions(-)
diff --git a/include/system/memory.h b/include/system/memory.h
index 0562af31361..baa6a840375 100644
--- a/include/system/memory.h
+++ b/include/system/memory.h
@@ -1749,14 +1749,14 @@ bool memory_region_init_rom_device(MemoryRegion *mr,
*
* @mr: the memory region being queried.
*/
-Object *memory_region_owner(MemoryRegion *mr);
+Object *memory_region_owner(const MemoryRegion *mr);
/**
* memory_region_size: get a memory region's size.
*
* @mr: the memory region being queried.
*/
-uint64_t memory_region_size(MemoryRegion *mr);
+uint64_t memory_region_size(const MemoryRegion *mr);
/**
* memory_region_is_ram: check whether a memory region is random access
@@ -1765,7 +1765,7 @@ uint64_t memory_region_size(MemoryRegion *mr);
*
* @mr: the memory region being queried
*/
-static inline bool memory_region_is_ram(MemoryRegion *mr)
+static inline bool memory_region_is_ram(const MemoryRegion *mr)
{
return mr->ram;
}
@@ -1777,7 +1777,7 @@ static inline bool memory_region_is_ram(MemoryRegion *mr)
*
* @mr: the memory region being queried
*/
-bool memory_region_is_ram_device(MemoryRegion *mr);
+bool memory_region_is_ram_device(const MemoryRegion *mr);
/**
* memory_region_is_romd: check whether a memory region is in ROMD mode
@@ -1787,7 +1787,7 @@ bool memory_region_is_ram_device(MemoryRegion *mr);
*
* @mr: the memory region being queried
*/
-static inline bool memory_region_is_romd(MemoryRegion *mr)
+static inline bool memory_region_is_romd(const MemoryRegion *mr)
{
return mr->rom_device && mr->romd_mode;
}
@@ -1800,7 +1800,7 @@ static inline bool memory_region_is_romd(MemoryRegion *mr)
*
* @mr: the memory region being queried
*/
-bool memory_region_is_protected(MemoryRegion *mr);
+bool memory_region_is_protected(const MemoryRegion *mr);
/**
* memory_region_has_guest_memfd: check whether a memory region has guest_memfd
@@ -1810,7 +1810,7 @@ bool memory_region_is_protected(MemoryRegion *mr);
*
* @mr: the memory region being queried
*/
-bool memory_region_has_guest_memfd(MemoryRegion *mr);
+bool memory_region_has_guest_memfd(const MemoryRegion *mr);
/**
* memory_region_get_iommu: check whether a memory region is an iommu
@@ -1820,7 +1820,7 @@ bool memory_region_has_guest_memfd(MemoryRegion *mr);
*
* @mr: the memory region being queried
*/
-static inline IOMMUMemoryRegion *memory_region_get_iommu(MemoryRegion *mr)
+static inline IOMMUMemoryRegion *memory_region_get_iommu(const MemoryRegion *mr)
{
if (mr->alias) {
return memory_region_get_iommu(mr->alias);
@@ -1991,7 +1991,7 @@ const char *memory_region_name(const MemoryRegion *mr);
* @mr: the memory region being queried
* @client: the client being queried
*/
-bool memory_region_is_logging(MemoryRegion *mr, uint8_t client);
+bool memory_region_is_logging(const MemoryRegion *mr, uint8_t client);
/**
* memory_region_get_dirty_log_mask: return the clients for which a
@@ -2002,7 +2002,7 @@ bool memory_region_is_logging(MemoryRegion *mr, uint8_t client);
*
* @mr: the memory region being queried
*/
-uint8_t memory_region_get_dirty_log_mask(MemoryRegion *mr);
+uint8_t memory_region_get_dirty_log_mask(const MemoryRegion *mr);
/**
* memory_region_is_rom: check whether a memory region is ROM
@@ -2011,7 +2011,7 @@ uint8_t memory_region_get_dirty_log_mask(MemoryRegion *mr);
*
* @mr: the memory region being queried
*/
-static inline bool memory_region_is_rom(MemoryRegion *mr)
+static inline bool memory_region_is_rom(const MemoryRegion *mr)
{
return mr->ram && mr->readonly;
}
@@ -2023,7 +2023,7 @@ static inline bool memory_region_is_rom(MemoryRegion *mr)
*
* @mr: the memory region being queried
*/
-static inline bool memory_region_is_nonvolatile(MemoryRegion *mr)
+static inline bool memory_region_is_nonvolatile(const MemoryRegion *mr)
{
return mr->nonvolatile;
}
@@ -2036,7 +2036,7 @@ static inline bool memory_region_is_nonvolatile(MemoryRegion *mr)
*
* @mr: the RAM or alias memory region being queried.
*/
-int memory_region_get_fd(MemoryRegion *mr);
+int memory_region_get_fd(const MemoryRegion *mr);
/**
* memory_region_from_host: Convert a pointer into a RAM memory region
@@ -2521,7 +2521,7 @@ bool memory_region_present(MemoryRegion *container, hwaddr addr);
*
* @mr: a #MemoryRegion which should be checked if it's mapped
*/
-bool memory_region_is_mapped(MemoryRegion *mr);
+bool memory_region_is_mapped(const MemoryRegion *mr);
/**
* memory_region_get_ram_discard_manager: get the #RamDiscardManager for a
diff --git a/system/memory.c b/system/memory.c
index c51d0798a84..eeb0d19484f 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -1819,9 +1819,9 @@ static void memory_region_finalize(Object *obj)
g_free(mr->ioeventfds);
}
-Object *memory_region_owner(MemoryRegion *mr)
+Object *memory_region_owner(const MemoryRegion *mr)
{
- Object *obj = OBJECT(mr);
+ const Object *obj = OBJECT(mr);
return obj->parent;
}
@@ -1849,7 +1849,7 @@ void memory_region_unref(MemoryRegion *mr)
}
}
-uint64_t memory_region_size(MemoryRegion *mr)
+uint64_t memory_region_size(const MemoryRegion *mr)
{
if (int128_eq(mr->size, int128_2_64())) {
return UINT64_MAX;
@@ -1866,25 +1866,25 @@ const char *memory_region_name(const MemoryRegion *mr)
return mr->name;
}
-bool memory_region_is_ram_device(MemoryRegion *mr)
+bool memory_region_is_ram_device(const MemoryRegion *mr)
{
return mr->ram_device;
}
-bool memory_region_is_protected(MemoryRegion *mr)
+bool memory_region_is_protected(const MemoryRegion *mr)
{
return mr->ram && (mr->ram_block->flags & RAM_PROTECTED);
}
-bool memory_region_has_guest_memfd(MemoryRegion *mr)
+bool memory_region_has_guest_memfd(const MemoryRegion *mr)
{
return mr->ram_block && mr->ram_block->guest_memfd >= 0;
}
-uint8_t memory_region_get_dirty_log_mask(MemoryRegion *mr)
+uint8_t memory_region_get_dirty_log_mask(const MemoryRegion *mr)
{
uint8_t mask = mr->dirty_log_mask;
- RAMBlock *rb = mr->ram_block;
+ const RAMBlock *rb = mr->ram_block;
if (global_dirty_tracking && ((rb && qemu_ram_is_migratable(rb)) ||
memory_region_is_iommu(mr))) {
@@ -1898,7 +1898,7 @@ uint8_t memory_region_get_dirty_log_mask(MemoryRegion *mr)
return mask;
}
-bool memory_region_is_logging(MemoryRegion *mr, uint8_t client)
+bool memory_region_is_logging(const MemoryRegion *mr, uint8_t client)
{
return memory_region_get_dirty_log_mask(mr) & (1 << client);
}
@@ -2406,7 +2406,7 @@ void memory_region_reset_dirty(MemoryRegion *mr, hwaddr addr,
memory_region_get_ram_addr(mr) + addr, size, client, NULL);
}
-int memory_region_get_fd(MemoryRegion *mr)
+int memory_region_get_fd(const MemoryRegion *mr)
{
RCU_READ_LOCK_GUARD();
while (mr->alias) {
@@ -2806,7 +2806,7 @@ static FlatRange *flatview_lookup(FlatView *view, AddrRange addr)
sizeof(FlatRange), cmp_flatrange_addr);
}
-bool memory_region_is_mapped(MemoryRegion *mr)
+bool memory_region_is_mapped(const MemoryRegion *mr)
{
return !!mr->container || mr->mapped_via_alias;
}
@@ -3290,7 +3290,7 @@ void address_space_destroy_free(AddressSpace *as)
call_rcu(as, do_address_space_destroy_free, rcu);
}
-static const char *memory_region_type(MemoryRegion *mr)
+static const char *memory_region_type(const MemoryRegion *mr)
{
if (mr->alias) {
return memory_region_type(mr->alias);
@@ -3483,7 +3483,6 @@ static void mtree_print_flatview(gpointer key, gpointer value,
GArray *fv_address_spaces = value;
struct FlatViewInfo *fvi = user_data;
FlatRange *range = &view->ranges[0];
- MemoryRegion *mr;
int n = view->nr;
int i;
AddressSpace *as;
@@ -3510,7 +3509,8 @@ static void mtree_print_flatview(gpointer key, gpointer value,
}
while (n--) {
- mr = range->mr;
+ const MemoryRegion *mr = range->mr;
+
if (range->offset_in_region) {
qemu_printf(MTREE_INDENT HWADDR_FMT_plx "-" HWADDR_FMT_plx
" (prio %d, %s%s): %s @" HWADDR_FMT_plx,
@@ -3683,8 +3683,10 @@ static void mtree_info_as(bool dispatch_tree, bool owner, bool disabled)
/* print aliased regions */
QTAILQ_FOREACH(ml, &ml_head, mrqueue) {
- qemu_printf("memory-region: %s\n", memory_region_name(ml->mr));
- mtree_print_mr(ml->mr, 1, 0, &ml_head, owner, disabled);
+ const MemoryRegion *mr = ml->mr;
+
+ qemu_printf("memory-region: %s\n", memory_region_name(mr));
+ mtree_print_mr(mr, 1, 0, &ml_head, owner, disabled);
qemu_printf("\n");
}
--
2.52.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 4/7] system/memory: Have memory_region_type() correctly describe containers
2026-02-26 22:02 [PATCH 0/7] system/memory: Improve 'info mtree' readability Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2026-02-26 22:02 ` [PATCH 3/7] system/memory: Constify various MemoryRegion arguments Philippe Mathieu-Daudé
@ 2026-02-26 22:02 ` Philippe Mathieu-Daudé
2026-02-26 22:22 ` Pierrick Bouvier
2026-03-04 18:33 ` Peter Xu
2026-02-26 22:02 ` [PATCH 5/7] system/memory: Display address spaces starting at 0x0000.0000 Philippe Mathieu-Daudé
` (2 subsequent siblings)
6 siblings, 2 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-02-26 22:02 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Mark Cave-Ayland, Paolo Bonzini,
Philippe Mathieu-Daudé, Peter Xu, Akihiko Odaki
MemoryRegion containers are not I/O regions,
describe them as 'container'.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
system/memory.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/system/memory.c b/system/memory.c
index eeb0d19484f..d5060774834 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -3303,6 +3303,8 @@ static const char *memory_region_type(const MemoryRegion *mr)
return "rom";
} else if (memory_region_is_ram(mr)) {
return "ram";
+ } else if (!mr->container) {
+ return "container";
} else {
return "i/o";
}
--
2.52.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 5/7] system/memory: Display address spaces starting at 0x0000.0000
2026-02-26 22:02 [PATCH 0/7] system/memory: Improve 'info mtree' readability Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2026-02-26 22:02 ` [PATCH 4/7] system/memory: Have memory_region_type() correctly describe containers Philippe Mathieu-Daudé
@ 2026-02-26 22:02 ` Philippe Mathieu-Daudé
2026-02-26 22:23 ` Pierrick Bouvier
2026-03-04 18:24 ` Peter Xu
2026-02-26 22:02 ` [PATCH 6/7] system/memory: Allow mtree_print_mr() to display distinct address width Philippe Mathieu-Daudé
2026-02-26 22:02 ` [PATCH 7/7] system/memory: Have 'info mtree' display addresses nicely Philippe Mathieu-Daudé
6 siblings, 2 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-02-26 22:02 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Mark Cave-Ayland, Paolo Bonzini,
Philippe Mathieu-Daudé, Peter Xu, Akihiko Odaki
Since AddressSpace root MemoryRegion can be remapped, it is
bogus to use the MemoryRegion address as the AddressSpace
absolute address. Besides, the AddressSpace APIs take an
@addr argument expecting AddressSpaces start at 0x0000.0000.
Substract the MemoryRegion address in mtree_print_mr() to
display AddressSpaces starting at 0x0000.0000.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
system/memory.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/system/memory.c b/system/memory.c
index d5060774834..1106f48d0d5 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -3360,7 +3360,7 @@ static void mtree_print_mr_owner(const MemoryRegion *mr)
}
static void mtree_print_mr(const MemoryRegion *mr, unsigned int level,
- hwaddr base,
+ hwaddr offset, bool detect_overflow,
MemoryRegionListHead *alias_print_queue,
bool owner, bool display_disabled)
{
@@ -3374,7 +3374,7 @@ static void mtree_print_mr(const MemoryRegion *mr, unsigned int level,
return;
}
- cur_start = base + mr->addr;
+ cur_start = mr->addr + offset;
cur_end = cur_start + MR_SIZE(mr->size);
/*
@@ -3382,7 +3382,7 @@ static void mtree_print_mr(const MemoryRegion *mr, unsigned int level,
* happen normally. When it happens, we dump something to warn the
* user who is observing this.
*/
- if (cur_start < base || cur_end < cur_start) {
+ if (detect_overflow && (cur_start < offset || cur_end < cur_start)) {
qemu_printf("[DETECTED OVERFLOW!] ");
}
@@ -3462,7 +3462,7 @@ static void mtree_print_mr(const MemoryRegion *mr, unsigned int level,
}
QTAILQ_FOREACH(ml, &submr_print_queue, mrqueue) {
- mtree_print_mr(ml->mr, level + 1, cur_start,
+ mtree_print_mr(ml->mr, level + 1, cur_start, true,
alias_print_queue, owner, display_disabled);
}
@@ -3641,7 +3641,8 @@ static void mtree_print_as(gpointer key, gpointer value, gpointer user_data)
struct AddressSpaceInfo *asi = user_data;
g_slist_foreach(as_same_root_mr_list, mtree_print_as_name, NULL);
- mtree_print_mr(mr, 1, 0, asi->ml_head, asi->owner, asi->disabled);
+ mtree_print_mr(mr, 1, -mr->addr, false,
+ asi->ml_head, asi->owner, asi->disabled);
qemu_printf("\n");
}
@@ -3688,7 +3689,7 @@ static void mtree_info_as(bool dispatch_tree, bool owner, bool disabled)
const MemoryRegion *mr = ml->mr;
qemu_printf("memory-region: %s\n", memory_region_name(mr));
- mtree_print_mr(mr, 1, 0, &ml_head, owner, disabled);
+ mtree_print_mr(mr, 1, 0, false, &ml_head, owner, disabled);
qemu_printf("\n");
}
--
2.52.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 6/7] system/memory: Allow mtree_print_mr() to display distinct address width
2026-02-26 22:02 [PATCH 0/7] system/memory: Improve 'info mtree' readability Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2026-02-26 22:02 ` [PATCH 5/7] system/memory: Display address spaces starting at 0x0000.0000 Philippe Mathieu-Daudé
@ 2026-02-26 22:02 ` Philippe Mathieu-Daudé
2026-02-26 22:24 ` Pierrick Bouvier
2026-03-04 18:34 ` Peter Xu
2026-02-26 22:02 ` [PATCH 7/7] system/memory: Have 'info mtree' display addresses nicely Philippe Mathieu-Daudé
6 siblings, 2 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-02-26 22:02 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Mark Cave-Ayland, Paolo Bonzini,
Philippe Mathieu-Daudé, Peter Xu, Akihiko Odaki
mtree_print_mr() display addresses using 16 chars on 64-bit
binaries, and 8 chars on 32-bit ones. Some MR / AS don't
always benefit of 16 chars, for example the ISA I/O region
fits in 16 bits, and displaying 12 extra '0' in 64-bit
binaries isn't really a good user experience.
Add an extra @width argument to mtree_print_mr(). Next
commit will make use of it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
system/memory.c | 48 +++++++++++++++++++++++++++---------------------
1 file changed, 27 insertions(+), 21 deletions(-)
diff --git a/system/memory.c b/system/memory.c
index 1106f48d0d5..4d276307da5 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -3321,6 +3321,7 @@ typedef QTAILQ_HEAD(, MemoryRegionList) MemoryRegionListHead;
#define MR_SIZE(size) (int128_nz(size) ? (hwaddr)int128_get64( \
int128_sub((size), int128_one())) : 0)
+#define MR_ADDR_WIDTH 16
#define MTREE_INDENT " "
static void mtree_expand_owner(const char *label, Object *obj)
@@ -3360,6 +3361,7 @@ static void mtree_print_mr_owner(const MemoryRegion *mr)
}
static void mtree_print_mr(const MemoryRegion *mr, unsigned int level,
+ unsigned int width,
hwaddr offset, bool detect_overflow,
MemoryRegionListHead *alias_print_queue,
bool owner, bool display_disabled)
@@ -3405,17 +3407,17 @@ static void mtree_print_mr(const MemoryRegion *mr, unsigned int level,
for (i = 0; i < level; i++) {
qemu_printf(MTREE_INDENT);
}
- qemu_printf(HWADDR_FMT_plx "-" HWADDR_FMT_plx
- " (prio %d, %s%s): alias %s @%s " HWADDR_FMT_plx
- "-" HWADDR_FMT_plx "%s",
- cur_start, cur_end,
+ qemu_printf("%0*" PRIx64 "-" "%0*" PRIx64
+ " (prio %d, %s%s): alias %s @%s "
+ "%0*" PRIx64"-" "%0*" PRIx64 "%s",
+ width, cur_start, width, cur_end,
mr->priority,
mr->nonvolatile ? "nv-" : "",
memory_region_type((MemoryRegion *)mr),
memory_region_name(mr),
memory_region_name(mr->alias),
- mr->alias_offset,
- mr->alias_offset + MR_SIZE(mr->size),
+ width, mr->alias_offset,
+ width, mr->alias_offset + MR_SIZE(mr->size),
mr->enabled ? "" : " [disabled]");
if (owner) {
mtree_print_mr_owner(mr);
@@ -3427,9 +3429,9 @@ static void mtree_print_mr(const MemoryRegion *mr, unsigned int level,
for (i = 0; i < level; i++) {
qemu_printf(MTREE_INDENT);
}
- qemu_printf(HWADDR_FMT_plx "-" HWADDR_FMT_plx
+ qemu_printf("%0*" PRIx64 "-" "%0*" PRIx64
" (prio %d, %s%s): %s%s",
- cur_start, cur_end,
+ width, cur_start, width, cur_end,
mr->priority,
mr->nonvolatile ? "nv-" : "",
memory_region_type((MemoryRegion *)mr),
@@ -3462,7 +3464,7 @@ static void mtree_print_mr(const MemoryRegion *mr, unsigned int level,
}
QTAILQ_FOREACH(ml, &submr_print_queue, mrqueue) {
- mtree_print_mr(ml->mr, level + 1, cur_start, true,
+ mtree_print_mr(ml->mr, level + 1, width, cur_start, true,
alias_print_queue, owner, display_disabled);
}
@@ -3485,6 +3487,7 @@ static void mtree_print_flatview(gpointer key, gpointer value,
GArray *fv_address_spaces = value;
struct FlatViewInfo *fvi = user_data;
FlatRange *range = &view->ranges[0];
+ unsigned int width;
int n = view->nr;
int i;
AddressSpace *as;
@@ -3510,26 +3513,27 @@ static void mtree_print_flatview(gpointer key, gpointer value,
return;
}
+ width = MR_ADDR_WIDTH;
while (n--) {
const MemoryRegion *mr = range->mr;
if (range->offset_in_region) {
- qemu_printf(MTREE_INDENT HWADDR_FMT_plx "-" HWADDR_FMT_plx
- " (prio %d, %s%s): %s @" HWADDR_FMT_plx,
- int128_get64(range->addr.start),
- int128_get64(range->addr.start)
- + MR_SIZE(range->addr.size),
+ qemu_printf(MTREE_INDENT "%0*" PRIx64 "-" "%0*" PRIx64
+ " (prio %d, %s%s): %s @" "%0*" PRIx64,
+ width, int128_get64(range->addr.start),
+ width, int128_get64(range->addr.start)
+ + MR_SIZE(range->addr.size),
mr->priority,
range->nonvolatile ? "nv-" : "",
range->readonly ? "rom" : memory_region_type(mr),
memory_region_name(mr),
- range->offset_in_region);
+ width, range->offset_in_region);
} else {
- qemu_printf(MTREE_INDENT HWADDR_FMT_plx "-" HWADDR_FMT_plx
+ qemu_printf(MTREE_INDENT "%0*" PRIx64 "-" "%0*" PRIx64
" (prio %d, %s%s): %s",
- int128_get64(range->addr.start),
- int128_get64(range->addr.start)
- + MR_SIZE(range->addr.size),
+ width, int128_get64(range->addr.start),
+ width, int128_get64(range->addr.start)
+ + MR_SIZE(range->addr.size),
mr->priority,
range->nonvolatile ? "nv-" : "",
range->readonly ? "rom" : memory_region_type(mr),
@@ -3639,9 +3643,10 @@ static void mtree_print_as(gpointer key, gpointer value, gpointer user_data)
MemoryRegion *mr = key;
GSList *as_same_root_mr_list = value;
struct AddressSpaceInfo *asi = user_data;
+ const unsigned int width = MR_ADDR_WIDTH;
g_slist_foreach(as_same_root_mr_list, mtree_print_as_name, NULL);
- mtree_print_mr(mr, 1, -mr->addr, false,
+ mtree_print_mr(mr, 1, width, -mr->addr, false,
asi->ml_head, asi->owner, asi->disabled);
qemu_printf("\n");
}
@@ -3687,9 +3692,10 @@ static void mtree_info_as(bool dispatch_tree, bool owner, bool disabled)
/* print aliased regions */
QTAILQ_FOREACH(ml, &ml_head, mrqueue) {
const MemoryRegion *mr = ml->mr;
+ const unsigned int width = MR_ADDR_WIDTH;
qemu_printf("memory-region: %s\n", memory_region_name(mr));
- mtree_print_mr(mr, 1, 0, false, &ml_head, owner, disabled);
+ mtree_print_mr(mr, 1, width, 0, false, &ml_head, owner, disabled);
qemu_printf("\n");
}
--
2.52.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 7/7] system/memory: Have 'info mtree' display addresses nicely
2026-02-26 22:02 [PATCH 0/7] system/memory: Improve 'info mtree' readability Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2026-02-26 22:02 ` [PATCH 6/7] system/memory: Allow mtree_print_mr() to display distinct address width Philippe Mathieu-Daudé
@ 2026-02-26 22:02 ` Philippe Mathieu-Daudé
2026-02-26 22:26 ` Pierrick Bouvier
` (2 more replies)
6 siblings, 3 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-02-26 22:02 UTC (permalink / raw)
To: qemu-devel
Cc: Richard Henderson, Mark Cave-Ayland, Paolo Bonzini,
Philippe Mathieu-Daudé, Peter Xu, Akihiko Odaki
Use the size of a MR / AS to decide how many address chars
need to be used.
For example, using 'qemu-system-x86_64 -M q35 -S -monitor stdio'
to run 'info mtree' displays before:
address-space: I/O
0000000000000000-000000000000ffff (prio 0, i/o): io
0000000000000000-0000000000000003 (prio 0, i/o): acpi-evt
0000000000000004-0000000000000005 (prio 0, i/o): acpi-cnt
0000000000000008-000000000000000b (prio 0, i/o): acpi-tmr
0000000000000020-000000000000002f (prio 0, i/o): acpi-gpe0
0000000000000030-0000000000000037 (prio 0, i/o): acpi-smi
0000000000000060-000000000000007f (prio 0, i/o): sm-tco
0000000000000000-0000000000000007 (prio 0, i/o): dma-chan
0000000000000008-000000000000000f (prio 0, i/o): dma-cont
0000000000000020-0000000000000021 (prio 0, i/o): pic
0000000000000040-0000000000000043 (prio 0, i/o): pit
...
memory-region: pc.ram
0000000000000000-0000000007ffffff (prio 0, ram): pc.ram
memory-region: pc.bios
00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios
memory-region: pci
0000000000000000-ffffffffffffffff (prio -1, i/o): pci
00000000000a0000-00000000000bffff (prio 1, i/o): vga-lowmem
00000000000c0000-00000000000dffff (prio 1, rom): pc.rom
00000000000e0000-00000000000fffff (prio 1, rom): alias isa-bios @pc.bios 0000000000020000-000000000003ffff
00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios
...
and after:
address-space: I/O
0000-ffff (prio 0, container): io
0000-0003 (prio 0, i/o): acpi-evt
0004-0005 (prio 0, i/o): acpi-cnt
0008-000b (prio 0, i/o): acpi-tmr
0020-002f (prio 0, i/o): acpi-gpe0
0030-0037 (prio 0, i/o): acpi-smi
0060-007f (prio 0, i/o): sm-tco
0000-0007 (prio 0, i/o): dma-chan
0008-000f (prio 0, i/o): dma-cont
0020-0021 (prio 0, i/o): pic
0040-0043 (prio 0, i/o): pit
...
memory-region: pc.ram
00000000-07ffffff (prio 0, ram): pc.ram
memory-region: pc.bios
fffc0000-ffffffff (prio 0, rom): pc.bios
memory-region: pci
0000000000000000-ffffffffffffffff (prio -1, i/o): pci
00000000000a0000-00000000000bffff (prio 1, i/o): vga-lowmem
00000000000c0000-00000000000dffff (prio 1, rom): pc.rom
00000000000e0000-00000000000fffff (prio 1, rom): alias isa-bios @pc.bios 0000000000020000-000000000003ffff
00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios
...
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
system/memory.c | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/system/memory.c b/system/memory.c
index 4d276307da5..abcbdaadcd7 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -3321,7 +3321,26 @@ typedef QTAILQ_HEAD(, MemoryRegionList) MemoryRegionListHead;
#define MR_SIZE(size) (int128_nz(size) ? (hwaddr)int128_get64( \
int128_sub((size), int128_one())) : 0)
-#define MR_ADDR_WIDTH 16
+
+static unsigned mr_addr_fmt_width(const MemoryRegion *mr)
+{
+ const unsigned int bits = 127 - clz128(mr->size);
+ unsigned int width;
+
+ if (bits <= 8) {
+ width = 2;
+ } else if (bits <= 16) {
+ width = 4;
+ } else if (bits <= 32) {
+ width = 8;
+ } else if (bits <= 64) {
+ width = 16;
+ } else {
+ width = 20;
+ }
+ return width;
+}
+
#define MTREE_INDENT " "
static void mtree_expand_owner(const char *label, Object *obj)
@@ -3513,7 +3532,7 @@ static void mtree_print_flatview(gpointer key, gpointer value,
return;
}
- width = MR_ADDR_WIDTH;
+ width = mr_addr_fmt_width(view->root);
while (n--) {
const MemoryRegion *mr = range->mr;
@@ -3643,7 +3662,7 @@ static void mtree_print_as(gpointer key, gpointer value, gpointer user_data)
MemoryRegion *mr = key;
GSList *as_same_root_mr_list = value;
struct AddressSpaceInfo *asi = user_data;
- const unsigned int width = MR_ADDR_WIDTH;
+ const unsigned int width = mr_addr_fmt_width(mr);
g_slist_foreach(as_same_root_mr_list, mtree_print_as_name, NULL);
mtree_print_mr(mr, 1, width, -mr->addr, false,
@@ -3692,7 +3711,7 @@ static void mtree_info_as(bool dispatch_tree, bool owner, bool disabled)
/* print aliased regions */
QTAILQ_FOREACH(ml, &ml_head, mrqueue) {
const MemoryRegion *mr = ml->mr;
- const unsigned int width = MR_ADDR_WIDTH;
+ const unsigned int width = mr_addr_fmt_width(mr);
qemu_printf("memory-region: %s\n", memory_region_name(mr));
mtree_print_mr(mr, 1, width, 0, false, &ml_head, owner, disabled);
--
2.52.0
^ permalink raw reply related [flat|nested] 30+ messages in thread
* Re: [PATCH 1/7] stubs: Merge physmem.c within ram-block.c
2026-02-26 22:02 ` [PATCH 1/7] stubs: Merge physmem.c within ram-block.c Philippe Mathieu-Daudé
@ 2026-02-26 22:21 ` Pierrick Bouvier
2026-02-26 22:22 ` BALATON Zoltan
2026-03-04 18:32 ` Peter Xu
2 siblings, 0 replies; 30+ messages in thread
From: Pierrick Bouvier @ 2026-02-26 22:21 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Richard Henderson, Mark Cave-Ayland, Paolo Bonzini, Peter Xu,
Akihiko Odaki
On 2/26/26 2:02 PM, Philippe Mathieu-Daudé wrote:
> physmem.c defines 2 stubs which are related to ram-block:
> qemu_ram_block_from_host() and qemu_ram_get_fd().
> Move them with the other ram-block stubs.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> stubs/physmem.c | 13 -------------
> stubs/ram-block.c | 11 +++++++++++
> stubs/meson.build | 1 -
> 3 files changed, 11 insertions(+), 14 deletions(-)
> delete mode 100644 stubs/physmem.c
>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 2/7] system/ramblock: Constify various RAMBlock arguments
2026-02-26 22:02 ` [PATCH 2/7] system/ramblock: Constify various RAMBlock arguments Philippe Mathieu-Daudé
@ 2026-02-26 22:22 ` Pierrick Bouvier
2026-03-04 18:33 ` Peter Xu
1 sibling, 0 replies; 30+ messages in thread
From: Pierrick Bouvier @ 2026-02-26 22:22 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Richard Henderson, Mark Cave-Ayland, Paolo Bonzini, Peter Xu,
Akihiko Odaki
On 2/26/26 2:02 PM, Philippe Mathieu-Daudé wrote:
> Mark the RAMBlock structure const when is only accessed read-only.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/system/ramblock.h | 26 +++++++++++++-------------
> stubs/ram-block.c | 8 ++++----
> system/physmem.c | 26 +++++++++++++-------------
> 3 files changed, 30 insertions(+), 30 deletions(-)
>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 3/7] system/memory: Constify various MemoryRegion arguments
2026-02-26 22:02 ` [PATCH 3/7] system/memory: Constify various MemoryRegion arguments Philippe Mathieu-Daudé
@ 2026-02-26 22:22 ` Pierrick Bouvier
2026-03-04 18:33 ` Peter Xu
1 sibling, 0 replies; 30+ messages in thread
From: Pierrick Bouvier @ 2026-02-26 22:22 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Richard Henderson, Mark Cave-Ayland, Paolo Bonzini, Peter Xu,
Akihiko Odaki
On 2/26/26 2:02 PM, Philippe Mathieu-Daudé wrote:
> Mark the MemoryRegion structure const when is only accessed read-only.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/system/memory.h | 28 ++++++++++++++--------------
> system/memory.c | 34 ++++++++++++++++++----------------
> 2 files changed, 32 insertions(+), 30 deletions(-)
>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 4/7] system/memory: Have memory_region_type() correctly describe containers
2026-02-26 22:02 ` [PATCH 4/7] system/memory: Have memory_region_type() correctly describe containers Philippe Mathieu-Daudé
@ 2026-02-26 22:22 ` Pierrick Bouvier
2026-03-04 18:33 ` Peter Xu
1 sibling, 0 replies; 30+ messages in thread
From: Pierrick Bouvier @ 2026-02-26 22:22 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Richard Henderson, Mark Cave-Ayland, Paolo Bonzini, Peter Xu,
Akihiko Odaki
On 2/26/26 2:02 PM, Philippe Mathieu-Daudé wrote:
> MemoryRegion containers are not I/O regions,
> describe them as 'container'.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> system/memory.c | 2 ++
> 1 file changed, 2 insertions(+)
>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 1/7] stubs: Merge physmem.c within ram-block.c
2026-02-26 22:02 ` [PATCH 1/7] stubs: Merge physmem.c within ram-block.c Philippe Mathieu-Daudé
2026-02-26 22:21 ` Pierrick Bouvier
@ 2026-02-26 22:22 ` BALATON Zoltan
2026-03-02 6:21 ` Akihiko Odaki
2026-03-04 18:32 ` Peter Xu
2 siblings, 1 reply; 30+ messages in thread
From: BALATON Zoltan @ 2026-02-26 22:22 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Richard Henderson, Mark Cave-Ayland, Paolo Bonzini,
Peter Xu, Akihiko Odaki
[-- Attachment #1: Type: text/plain, Size: 2072 bytes --]
On Thu, 26 Feb 2026, Philippe Mathieu-Daudé wrote:
> physmem.c defines 2 stubs which are related to ram-block:
> qemu_ram_block_from_host() and qemu_ram_get_fd().
> Move them with the other ram-block stubs.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> stubs/physmem.c | 13 -------------
> stubs/ram-block.c | 11 +++++++++++
Maybe should be the other way around moving what's in subs/ram-block.c to
stubs/physmem.c considering the the functions these stub out are in
system/physmem.c and there's no system/ram-block.c.
Regards,
BALATON Zoltan
> stubs/meson.build | 1 -
> 3 files changed, 11 insertions(+), 14 deletions(-)
> delete mode 100644 stubs/physmem.c
>
> diff --git a/stubs/physmem.c b/stubs/physmem.c
> deleted file mode 100644
> index 14667f2bd8f..00000000000
> --- a/stubs/physmem.c
> +++ /dev/null
> @@ -1,13 +0,0 @@
> -#include "qemu/osdep.h"
> -#include "system/ramblock.h"
> -
> -RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
> - ram_addr_t *offset)
> -{
> - return NULL;
> -}
> -
> -int qemu_ram_get_fd(RAMBlock *rb)
> -{
> - return -1;
> -}
> diff --git a/stubs/ram-block.c b/stubs/ram-block.c
> index 8790a59593e..f0650b19ac6 100644
> --- a/stubs/ram-block.c
> +++ b/stubs/ram-block.c
> @@ -35,3 +35,14 @@ int ram_block_discard_disable(bool state)
> {
> return 0;
> }
> +
> +RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
> + ram_addr_t *offset)
> +{
> + return NULL;
> +}
> +
> +int qemu_ram_get_fd(RAMBlock *rb)
> +{
> + return -1;
> +}
> diff --git a/stubs/meson.build b/stubs/meson.build
> index 8a07059500d..0171f531523 100644
> --- a/stubs/meson.build
> +++ b/stubs/meson.build
> @@ -20,7 +20,6 @@ if have_block
> stub_ss.add(files('get-vm-name.c'))
> stub_ss.add(files('iothread-lock-block.c'))
> stub_ss.add(files('migr-blocker.c'))
> - stub_ss.add(files('physmem.c'))
> stub_ss.add(files('ram-block.c'))
> stub_ss.add(files('runstate-check.c'))
> stub_ss.add(files('uuid.c'))
>
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 5/7] system/memory: Display address spaces starting at 0x0000.0000
2026-02-26 22:02 ` [PATCH 5/7] system/memory: Display address spaces starting at 0x0000.0000 Philippe Mathieu-Daudé
@ 2026-02-26 22:23 ` Pierrick Bouvier
2026-03-04 18:24 ` Peter Xu
1 sibling, 0 replies; 30+ messages in thread
From: Pierrick Bouvier @ 2026-02-26 22:23 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Richard Henderson, Mark Cave-Ayland, Paolo Bonzini, Peter Xu,
Akihiko Odaki
On 2/26/26 2:02 PM, Philippe Mathieu-Daudé wrote:
> Since AddressSpace root MemoryRegion can be remapped, it is
> bogus to use the MemoryRegion address as the AddressSpace
> absolute address. Besides, the AddressSpace APIs take an
> @addr argument expecting AddressSpaces start at 0x0000.0000.
>
> Substract the MemoryRegion address in mtree_print_mr() to
> display AddressSpaces starting at 0x0000.0000.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> system/memory.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 6/7] system/memory: Allow mtree_print_mr() to display distinct address width
2026-02-26 22:02 ` [PATCH 6/7] system/memory: Allow mtree_print_mr() to display distinct address width Philippe Mathieu-Daudé
@ 2026-02-26 22:24 ` Pierrick Bouvier
2026-03-04 18:34 ` Peter Xu
1 sibling, 0 replies; 30+ messages in thread
From: Pierrick Bouvier @ 2026-02-26 22:24 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Richard Henderson, Mark Cave-Ayland, Paolo Bonzini, Peter Xu,
Akihiko Odaki
On 2/26/26 2:02 PM, Philippe Mathieu-Daudé wrote:
> mtree_print_mr() display addresses using 16 chars on 64-bit
> binaries, and 8 chars on 32-bit ones. Some MR / AS don't
> always benefit of 16 chars, for example the ISA I/O region
> fits in 16 bits, and displaying 12 extra '0' in 64-bit
> binaries isn't really a good user experience.
>
> Add an extra @width argument to mtree_print_mr(). Next
> commit will make use of it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> system/memory.c | 48 +++++++++++++++++++++++++++---------------------
> 1 file changed, 27 insertions(+), 21 deletions(-)
>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 7/7] system/memory: Have 'info mtree' display addresses nicely
2026-02-26 22:02 ` [PATCH 7/7] system/memory: Have 'info mtree' display addresses nicely Philippe Mathieu-Daudé
@ 2026-02-26 22:26 ` Pierrick Bouvier
2026-02-26 22:35 ` BALATON Zoltan
2026-03-04 18:35 ` Peter Xu
2 siblings, 0 replies; 30+ messages in thread
From: Pierrick Bouvier @ 2026-02-26 22:26 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Richard Henderson, Mark Cave-Ayland, Paolo Bonzini, Peter Xu,
Akihiko Odaki
On 2/26/26 2:02 PM, Philippe Mathieu-Daudé wrote:
> Use the size of a MR / AS to decide how many address chars
> need to be used.
>
> For example, using 'qemu-system-x86_64 -M q35 -S -monitor stdio'
> to run 'info mtree' displays before:
>
> address-space: I/O
> 0000000000000000-000000000000ffff (prio 0, i/o): io
> 0000000000000000-0000000000000003 (prio 0, i/o): acpi-evt
> 0000000000000004-0000000000000005 (prio 0, i/o): acpi-cnt
> 0000000000000008-000000000000000b (prio 0, i/o): acpi-tmr
> 0000000000000020-000000000000002f (prio 0, i/o): acpi-gpe0
> 0000000000000030-0000000000000037 (prio 0, i/o): acpi-smi
> 0000000000000060-000000000000007f (prio 0, i/o): sm-tco
> 0000000000000000-0000000000000007 (prio 0, i/o): dma-chan
> 0000000000000008-000000000000000f (prio 0, i/o): dma-cont
> 0000000000000020-0000000000000021 (prio 0, i/o): pic
> 0000000000000040-0000000000000043 (prio 0, i/o): pit
> ...
> memory-region: pc.ram
> 0000000000000000-0000000007ffffff (prio 0, ram): pc.ram
> memory-region: pc.bios
> 00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios
> memory-region: pci
> 0000000000000000-ffffffffffffffff (prio -1, i/o): pci
> 00000000000a0000-00000000000bffff (prio 1, i/o): vga-lowmem
> 00000000000c0000-00000000000dffff (prio 1, rom): pc.rom
> 00000000000e0000-00000000000fffff (prio 1, rom): alias isa-bios @pc.bios 0000000000020000-000000000003ffff
> 00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios
> ...
>
> and after:
>
> address-space: I/O
> 0000-ffff (prio 0, container): io
> 0000-0003 (prio 0, i/o): acpi-evt
> 0004-0005 (prio 0, i/o): acpi-cnt
> 0008-000b (prio 0, i/o): acpi-tmr
> 0020-002f (prio 0, i/o): acpi-gpe0
> 0030-0037 (prio 0, i/o): acpi-smi
> 0060-007f (prio 0, i/o): sm-tco
> 0000-0007 (prio 0, i/o): dma-chan
> 0008-000f (prio 0, i/o): dma-cont
> 0020-0021 (prio 0, i/o): pic
> 0040-0043 (prio 0, i/o): pit
> ...
> memory-region: pc.ram
> 00000000-07ffffff (prio 0, ram): pc.ram
> memory-region: pc.bios
> fffc0000-ffffffff (prio 0, rom): pc.bios
> memory-region: pci
> 0000000000000000-ffffffffffffffff (prio -1, i/o): pci
> 00000000000a0000-00000000000bffff (prio 1, i/o): vga-lowmem
> 00000000000c0000-00000000000dffff (prio 1, rom): pc.rom
> 00000000000e0000-00000000000fffff (prio 1, rom): alias isa-bios @pc.bios 0000000000020000-000000000003ffff
> 00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios
> ...
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> system/memory.c | 27 +++++++++++++++++++++++----
> 1 file changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/system/memory.c b/system/memory.c
> index 4d276307da5..abcbdaadcd7 100644
> --- a/system/memory.c
> +++ b/system/memory.c
> @@ -3321,7 +3321,26 @@ typedef QTAILQ_HEAD(, MemoryRegionList) MemoryRegionListHead;
>
> #define MR_SIZE(size) (int128_nz(size) ? (hwaddr)int128_get64( \
> int128_sub((size), int128_one())) : 0)
> -#define MR_ADDR_WIDTH 16
> +
> +static unsigned mr_addr_fmt_width(const MemoryRegion *mr)
> +{
> + const unsigned int bits = 127 - clz128(mr->size);
> + unsigned int width;
> +
> + if (bits <= 8) {
> + width = 2;
> + } else if (bits <= 16) {
> + width = 4;
> + } else if (bits <= 32) {
> + width = 8;
> + } else if (bits <= 64) {
> + width = 16;
> + } else {
> + width = 20;
> + }
> + return width;
> +}
> +
> #define MTREE_INDENT " "
>
> static void mtree_expand_owner(const char *label, Object *obj)
> @@ -3513,7 +3532,7 @@ static void mtree_print_flatview(gpointer key, gpointer value,
> return;
> }
>
> - width = MR_ADDR_WIDTH;
> + width = mr_addr_fmt_width(view->root);
> while (n--) {
> const MemoryRegion *mr = range->mr;
>
> @@ -3643,7 +3662,7 @@ static void mtree_print_as(gpointer key, gpointer value, gpointer user_data)
> MemoryRegion *mr = key;
> GSList *as_same_root_mr_list = value;
> struct AddressSpaceInfo *asi = user_data;
> - const unsigned int width = MR_ADDR_WIDTH;
> + const unsigned int width = mr_addr_fmt_width(mr);
>
> g_slist_foreach(as_same_root_mr_list, mtree_print_as_name, NULL);
> mtree_print_mr(mr, 1, width, -mr->addr, false,
> @@ -3692,7 +3711,7 @@ static void mtree_info_as(bool dispatch_tree, bool owner, bool disabled)
> /* print aliased regions */
> QTAILQ_FOREACH(ml, &ml_head, mrqueue) {
> const MemoryRegion *mr = ml->mr;
> - const unsigned int width = MR_ADDR_WIDTH;
> + const unsigned int width = mr_addr_fmt_width(mr);
>
> qemu_printf("memory-region: %s\n", memory_region_name(mr));
> mtree_print_mr(mr, 1, width, 0, false, &ml_head, owner, disabled);
That is so neat!
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 7/7] system/memory: Have 'info mtree' display addresses nicely
2026-02-26 22:02 ` [PATCH 7/7] system/memory: Have 'info mtree' display addresses nicely Philippe Mathieu-Daudé
2026-02-26 22:26 ` Pierrick Bouvier
@ 2026-02-26 22:35 ` BALATON Zoltan
2026-02-27 16:20 ` Philippe Mathieu-Daudé
2026-03-04 18:35 ` Peter Xu
2 siblings, 1 reply; 30+ messages in thread
From: BALATON Zoltan @ 2026-02-26 22:35 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Richard Henderson, Mark Cave-Ayland, Paolo Bonzini,
Peter Xu, Akihiko Odaki
[-- Attachment #1: Type: text/plain, Size: 4981 bytes --]
On Thu, 26 Feb 2026, Philippe Mathieu-Daudé wrote:
> Use the size of a MR / AS to decide how many address chars
> need to be used.
>
> For example, using 'qemu-system-x86_64 -M q35 -S -monitor stdio'
> to run 'info mtree' displays before:
>
> address-space: I/O
> 0000000000000000-000000000000ffff (prio 0, i/o): io
> 0000000000000000-0000000000000003 (prio 0, i/o): acpi-evt
> 0000000000000004-0000000000000005 (prio 0, i/o): acpi-cnt
> 0000000000000008-000000000000000b (prio 0, i/o): acpi-tmr
> 0000000000000020-000000000000002f (prio 0, i/o): acpi-gpe0
> 0000000000000030-0000000000000037 (prio 0, i/o): acpi-smi
> 0000000000000060-000000000000007f (prio 0, i/o): sm-tco
> 0000000000000000-0000000000000007 (prio 0, i/o): dma-chan
> 0000000000000008-000000000000000f (prio 0, i/o): dma-cont
> 0000000000000020-0000000000000021 (prio 0, i/o): pic
> 0000000000000040-0000000000000043 (prio 0, i/o): pit
> ...
> memory-region: pc.ram
> 0000000000000000-0000000007ffffff (prio 0, ram): pc.ram
> memory-region: pc.bios
> 00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios
> memory-region: pci
> 0000000000000000-ffffffffffffffff (prio -1, i/o): pci
> 00000000000a0000-00000000000bffff (prio 1, i/o): vga-lowmem
> 00000000000c0000-00000000000dffff (prio 1, rom): pc.rom
> 00000000000e0000-00000000000fffff (prio 1, rom): alias isa-bios @pc.bios 0000000000020000-000000000003ffff
> 00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios
> ...
>
> and after:
>
> address-space: I/O
> 0000-ffff (prio 0, container): io
> 0000-0003 (prio 0, i/o): acpi-evt
> 0004-0005 (prio 0, i/o): acpi-cnt
> 0008-000b (prio 0, i/o): acpi-tmr
> 0020-002f (prio 0, i/o): acpi-gpe0
> 0030-0037 (prio 0, i/o): acpi-smi
> 0060-007f (prio 0, i/o): sm-tco
> 0000-0007 (prio 0, i/o): dma-chan
> 0008-000f (prio 0, i/o): dma-cont
> 0020-0021 (prio 0, i/o): pic
> 0040-0043 (prio 0, i/o): pit
> ...
> memory-region: pc.ram
> 00000000-07ffffff (prio 0, ram): pc.ram
> memory-region: pc.bios
> fffc0000-ffffffff (prio 0, rom): pc.bios
> memory-region: pci
> 0000000000000000-ffffffffffffffff (prio -1, i/o): pci
> 00000000000a0000-00000000000bffff (prio 1, i/o): vga-lowmem
> 00000000000c0000-00000000000dffff (prio 1, rom): pc.rom
> 00000000000e0000-00000000000fffff (prio 1, rom): alias isa-bios @pc.bios 0000000000020000-000000000003ffff
> 00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios
> ...
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> system/memory.c | 27 +++++++++++++++++++++++----
> 1 file changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/system/memory.c b/system/memory.c
> index 4d276307da5..abcbdaadcd7 100644
> --- a/system/memory.c
> +++ b/system/memory.c
> @@ -3321,7 +3321,26 @@ typedef QTAILQ_HEAD(, MemoryRegionList) MemoryRegionListHead;
>
> #define MR_SIZE(size) (int128_nz(size) ? (hwaddr)int128_get64( \
> int128_sub((size), int128_one())) : 0)
> -#define MR_ADDR_WIDTH 16
> +
> +static unsigned mr_addr_fmt_width(const MemoryRegion *mr)
> +{
> + const unsigned int bits = 127 - clz128(mr->size);
> + unsigned int width;
> +
> + if (bits <= 8) {
> + width = 2;
> + } else if (bits <= 16) {
> + width = 4;
> + } else if (bits <= 32) {
> + width = 8;
> + } else if (bits <= 64) {
> + width = 16;
> + } else {
> + width = 20;
Why 20? HWADDR_FMT_plx this seems to replace is "%016" PRIx64
Regards,
BALATON Zoltan
> + }
> + return width;
> +}
> +
> #define MTREE_INDENT " "
>
> static void mtree_expand_owner(const char *label, Object *obj)
> @@ -3513,7 +3532,7 @@ static void mtree_print_flatview(gpointer key, gpointer value,
> return;
> }
>
> - width = MR_ADDR_WIDTH;
> + width = mr_addr_fmt_width(view->root);
> while (n--) {
> const MemoryRegion *mr = range->mr;
>
> @@ -3643,7 +3662,7 @@ static void mtree_print_as(gpointer key, gpointer value, gpointer user_data)
> MemoryRegion *mr = key;
> GSList *as_same_root_mr_list = value;
> struct AddressSpaceInfo *asi = user_data;
> - const unsigned int width = MR_ADDR_WIDTH;
> + const unsigned int width = mr_addr_fmt_width(mr);
>
> g_slist_foreach(as_same_root_mr_list, mtree_print_as_name, NULL);
> mtree_print_mr(mr, 1, width, -mr->addr, false,
> @@ -3692,7 +3711,7 @@ static void mtree_info_as(bool dispatch_tree, bool owner, bool disabled)
> /* print aliased regions */
> QTAILQ_FOREACH(ml, &ml_head, mrqueue) {
> const MemoryRegion *mr = ml->mr;
> - const unsigned int width = MR_ADDR_WIDTH;
> + const unsigned int width = mr_addr_fmt_width(mr);
>
> qemu_printf("memory-region: %s\n", memory_region_name(mr));
> mtree_print_mr(mr, 1, width, 0, false, &ml_head, owner, disabled);
>
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 7/7] system/memory: Have 'info mtree' display addresses nicely
2026-02-26 22:35 ` BALATON Zoltan
@ 2026-02-27 16:20 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-02-27 16:20 UTC (permalink / raw)
To: BALATON Zoltan
Cc: qemu-devel, Richard Henderson, Mark Cave-Ayland, Paolo Bonzini,
Peter Xu, Akihiko Odaki
Hi Zoltan,
On 26/2/26 23:35, BALATON Zoltan wrote:
> On Thu, 26 Feb 2026, Philippe Mathieu-Daudé wrote:
>> Use the size of a MR / AS to decide how many address chars
>> need to be used.
>>
>> For example, using 'qemu-system-x86_64 -M q35 -S -monitor stdio'
>> to run 'info mtree' displays before:
>>
>> address-space: I/O
>> 0000000000000000-000000000000ffff (prio 0, i/o): io
>> 0000000000000000-0000000000000003 (prio 0, i/o): acpi-evt
>> 0000000000000004-0000000000000005 (prio 0, i/o): acpi-cnt
>> 0000000000000008-000000000000000b (prio 0, i/o): acpi-tmr
>> 0000000000000020-000000000000002f (prio 0, i/o): acpi-gpe0
>> 0000000000000030-0000000000000037 (prio 0, i/o): acpi-smi
>> 0000000000000060-000000000000007f (prio 0, i/o): sm-tco
>> 0000000000000000-0000000000000007 (prio 0, i/o): dma-chan
>> 0000000000000008-000000000000000f (prio 0, i/o): dma-cont
>> 0000000000000020-0000000000000021 (prio 0, i/o): pic
>> 0000000000000040-0000000000000043 (prio 0, i/o): pit
>> ...
>> memory-region: pc.ram
>> 0000000000000000-0000000007ffffff (prio 0, ram): pc.ram
>> memory-region: pc.bios
>> 00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios
>> memory-region: pci
>> 0000000000000000-ffffffffffffffff (prio -1, i/o): pci
>> 00000000000a0000-00000000000bffff (prio 1, i/o): vga-lowmem
>> 00000000000c0000-00000000000dffff (prio 1, rom): pc.rom
>> 00000000000e0000-00000000000fffff (prio 1, rom): alias isa-bios
>> @pc.bios 0000000000020000-000000000003ffff
>> 00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios
>> ...
>>
>> and after:
>>
>> address-space: I/O
>> 0000-ffff (prio 0, container): io
>> 0000-0003 (prio 0, i/o): acpi-evt
>> 0004-0005 (prio 0, i/o): acpi-cnt
>> 0008-000b (prio 0, i/o): acpi-tmr
>> 0020-002f (prio 0, i/o): acpi-gpe0
>> 0030-0037 (prio 0, i/o): acpi-smi
>> 0060-007f (prio 0, i/o): sm-tco
>> 0000-0007 (prio 0, i/o): dma-chan
>> 0008-000f (prio 0, i/o): dma-cont
>> 0020-0021 (prio 0, i/o): pic
>> 0040-0043 (prio 0, i/o): pit
>> ...
>> memory-region: pc.ram
>> 00000000-07ffffff (prio 0, ram): pc.ram
>> memory-region: pc.bios
>> fffc0000-ffffffff (prio 0, rom): pc.bios
>> memory-region: pci
>> 0000000000000000-ffffffffffffffff (prio -1, i/o): pci
>> 00000000000a0000-00000000000bffff (prio 1, i/o): vga-lowmem
>> 00000000000c0000-00000000000dffff (prio 1, rom): pc.rom
>> 00000000000e0000-00000000000fffff (prio 1, rom): alias isa-bios
>> @pc.bios 0000000000020000-000000000003ffff
>> 00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios
>> ...
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>> system/memory.c | 27 +++++++++++++++++++++++----
>> 1 file changed, 23 insertions(+), 4 deletions(-)
>>
>> diff --git a/system/memory.c b/system/memory.c
>> index 4d276307da5..abcbdaadcd7 100644
>> --- a/system/memory.c
>> +++ b/system/memory.c
>> @@ -3321,7 +3321,26 @@ typedef QTAILQ_HEAD(, MemoryRegionList)
>> MemoryRegionListHead;
>>
>> #define MR_SIZE(size) (int128_nz(size) ? (hwaddr)int128_get64( \
>> int128_sub((size), int128_one())) : 0)
>> -#define MR_ADDR_WIDTH 16
>> +
>> +static unsigned mr_addr_fmt_width(const MemoryRegion *mr)
>> +{
>> + const unsigned int bits = 127 - clz128(mr->size);
>> + unsigned int width;
>> +
>> + if (bits <= 8) {
>> + width = 2;
>> + } else if (bits <= 16) {
>> + width = 4;
>> + } else if (bits <= 32) {
>> + width = 8;
>> + } else if (bits <= 64) {
>> + width = 16;
>> + } else {
>> + width = 20;
>
> Why 20? HWADDR_FMT_plx this seems to replace is "%016" PRIx64
HWADDR_FMT_plx predates support for int128_t and 128-bit wide
addresses. Using 20 chars is sufficient to align our current
uses.
I'll precise that in the patch description.
Regards,
Phil.
>
> Regards,
> BALATON Zoltan
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 1/7] stubs: Merge physmem.c within ram-block.c
2026-02-26 22:22 ` BALATON Zoltan
@ 2026-03-02 6:21 ` Akihiko Odaki
2026-03-03 16:15 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 30+ messages in thread
From: Akihiko Odaki @ 2026-03-02 6:21 UTC (permalink / raw)
To: BALATON Zoltan, Philippe Mathieu-Daudé
Cc: qemu-devel, Richard Henderson, Mark Cave-Ayland, Paolo Bonzini,
Peter Xu
On 2026/02/27 7:22, BALATON Zoltan wrote:
> On Thu, 26 Feb 2026, Philippe Mathieu-Daudé wrote:
>> physmem.c defines 2 stubs which are related to ram-block:
>> qemu_ram_block_from_host() and qemu_ram_get_fd().
>> Move them with the other ram-block stubs.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>> stubs/physmem.c | 13 -------------
>> stubs/ram-block.c | 11 +++++++++++
>
> Maybe should be the other way around moving what's in subs/ram-block.c
> to stubs/physmem.c considering the the functions these stub out are in
> system/physmem.c and there's no system/ram-block.c.
But this stubs out functions in "ramblock.h" (though it's not
"ram-block.h")
Regards,
Akihiko Odaki
>
> Regards,
> BALATON Zoltan
>
>> stubs/meson.build | 1 -
>> 3 files changed, 11 insertions(+), 14 deletions(-)
>> delete mode 100644 stubs/physmem.c
>>
>> diff --git a/stubs/physmem.c b/stubs/physmem.c
>> deleted file mode 100644
>> index 14667f2bd8f..00000000000
>> --- a/stubs/physmem.c
>> +++ /dev/null
>> @@ -1,13 +0,0 @@
>> -#include "qemu/osdep.h"
>> -#include "system/ramblock.h"
>> -
>> -RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
>> - ram_addr_t *offset)
>> -{
>> - return NULL;
>> -}
>> -
>> -int qemu_ram_get_fd(RAMBlock *rb)
>> -{
>> - return -1;
>> -}
>> diff --git a/stubs/ram-block.c b/stubs/ram-block.c
>> index 8790a59593e..f0650b19ac6 100644
>> --- a/stubs/ram-block.c
>> +++ b/stubs/ram-block.c
>> @@ -35,3 +35,14 @@ int ram_block_discard_disable(bool state)
>> {
>> return 0;
>> }
>> +
>> +RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
>> + ram_addr_t *offset)
>> +{
>> + return NULL;
>> +}
>> +
>> +int qemu_ram_get_fd(RAMBlock *rb)
>> +{
>> + return -1;
>> +}
>> diff --git a/stubs/meson.build b/stubs/meson.build
>> index 8a07059500d..0171f531523 100644
>> --- a/stubs/meson.build
>> +++ b/stubs/meson.build
>> @@ -20,7 +20,6 @@ if have_block
>> stub_ss.add(files('get-vm-name.c'))
>> stub_ss.add(files('iothread-lock-block.c'))
>> stub_ss.add(files('migr-blocker.c'))
>> - stub_ss.add(files('physmem.c'))
>> stub_ss.add(files('ram-block.c'))
>> stub_ss.add(files('runstate-check.c'))
>> stub_ss.add(files('uuid.c'))
>>
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 1/7] stubs: Merge physmem.c within ram-block.c
2026-03-02 6:21 ` Akihiko Odaki
@ 2026-03-03 16:15 ` Philippe Mathieu-Daudé
2026-03-03 17:20 ` BALATON Zoltan
0 siblings, 1 reply; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-03-03 16:15 UTC (permalink / raw)
To: Akihiko Odaki, BALATON Zoltan
Cc: qemu-devel, Richard Henderson, Mark Cave-Ayland, Paolo Bonzini,
Peter Xu
On 2/3/26 07:21, Akihiko Odaki wrote:
> On 2026/02/27 7:22, BALATON Zoltan wrote:
>> On Thu, 26 Feb 2026, Philippe Mathieu-Daudé wrote:
>>> physmem.c defines 2 stubs which are related to ram-block:
>>> qemu_ram_block_from_host() and qemu_ram_get_fd().
>>> Move them with the other ram-block stubs.
>>>
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> ---
>>> stubs/physmem.c | 13 -------------
>>> stubs/ram-block.c | 11 +++++++++++
>>
>> Maybe should be the other way around moving what's in subs/ram-block.c
>> to stubs/physmem.c considering the the functions these stub out are in
>> system/physmem.c and there's no system/ram-block.c.
Fine, I'll drop this patch if you think it is not worthwhile.
>
> But this stubs out functions in "ramblock.h" (though it's not
> "ram-block.h")
>
> Regards,
> Akihiko Odaki
>
>>
>> Regards,
>> BALATON Zoltan
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 1/7] stubs: Merge physmem.c within ram-block.c
2026-03-03 16:15 ` Philippe Mathieu-Daudé
@ 2026-03-03 17:20 ` BALATON Zoltan
2026-03-04 6:27 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 30+ messages in thread
From: BALATON Zoltan @ 2026-03-03 17:20 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Akihiko Odaki, qemu-devel, Richard Henderson, Mark Cave-Ayland,
Paolo Bonzini, Peter Xu
[-- Attachment #1: Type: text/plain, Size: 1099 bytes --]
On Tue, 3 Mar 2026, Philippe Mathieu-Daudé wrote:
> On 2/3/26 07:21, Akihiko Odaki wrote:
>> On 2026/02/27 7:22, BALATON Zoltan wrote:
>>> On Thu, 26 Feb 2026, Philippe Mathieu-Daudé wrote:
>>>> physmem.c defines 2 stubs which are related to ram-block:
>>>> qemu_ram_block_from_host() and qemu_ram_get_fd().
>>>> Move them with the other ram-block stubs.
>>>>
>>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>>> ---
>>>> stubs/physmem.c | 13 -------------
>>>> stubs/ram-block.c | 11 +++++++++++
>>>
>>> Maybe should be the other way around moving what's in subs/ram-block.c to
>>> stubs/physmem.c considering the the functions these stub out are in
>>> system/physmem.c and there's no system/ram-block.c.
>
> Fine, I'll drop this patch if you think it is not worthwhile.
I did not say that, only that the functions are in system/physmem.c so why
not put the stubs in stubs/physmem.c to match? Since there's no
system/ram-block.c I think it makes more sense to merge these into
stubs/physmem.c instead. But just leaving it as it is is also OK.
Regards,
BALATON Zoltan
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 1/7] stubs: Merge physmem.c within ram-block.c
2026-03-03 17:20 ` BALATON Zoltan
@ 2026-03-04 6:27 ` Philippe Mathieu-Daudé
2026-03-04 11:41 ` BALATON Zoltan
0 siblings, 1 reply; 30+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-03-04 6:27 UTC (permalink / raw)
To: BALATON Zoltan
Cc: Akihiko Odaki, qemu-devel, Richard Henderson, Mark Cave-Ayland,
Paolo Bonzini, Peter Xu
On 3/3/26 18:20, BALATON Zoltan wrote:
> On Tue, 3 Mar 2026, Philippe Mathieu-Daudé wrote:
>> On 2/3/26 07:21, Akihiko Odaki wrote:
>>> On 2026/02/27 7:22, BALATON Zoltan wrote:
>>>> On Thu, 26 Feb 2026, Philippe Mathieu-Daudé wrote:
>>>>> physmem.c defines 2 stubs which are related to ram-block:
>>>>> qemu_ram_block_from_host() and qemu_ram_get_fd().
>>>>> Move them with the other ram-block stubs.
>>>>>
>>>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>>>> ---
>>>>> stubs/physmem.c | 13 -------------
>>>>> stubs/ram-block.c | 11 +++++++++++
>>>>
>>>> Maybe should be the other way around moving what's in subs/ram-
>>>> block.c to stubs/physmem.c considering the the functions these stub
>>>> out are in system/physmem.c and there's no system/ram-block.c.
>>
>> Fine, I'll drop this patch if you think it is not worthwhile.
>
> I did not say that, only that the functions are in system/physmem.c so
> why not put the stubs in stubs/physmem.c to match? Since there's no
> system/ram-block.c I think it makes more sense to merge these into
> stubs/physmem.c instead.
Unfortunately I won't have time to address this change before
soft-freeze, do you mind posting the patch?
Thanks for your review and help here,
Phil.
> But just leaving it as it is is also OK.
>
> Regards,
> BALATON Zoltan
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 1/7] stubs: Merge physmem.c within ram-block.c
2026-03-04 6:27 ` Philippe Mathieu-Daudé
@ 2026-03-04 11:41 ` BALATON Zoltan
0 siblings, 0 replies; 30+ messages in thread
From: BALATON Zoltan @ 2026-03-04 11:41 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Akihiko Odaki, qemu-devel, Richard Henderson, Mark Cave-Ayland,
Paolo Bonzini, Peter Xu
[-- Attachment #1: Type: text/plain, Size: 1549 bytes --]
On Wed, 4 Mar 2026, Philippe Mathieu-Daudé wrote:
> On 3/3/26 18:20, BALATON Zoltan wrote:
>> On Tue, 3 Mar 2026, Philippe Mathieu-Daudé wrote:
>>> On 2/3/26 07:21, Akihiko Odaki wrote:
>>>> On 2026/02/27 7:22, BALATON Zoltan wrote:
>>>>> On Thu, 26 Feb 2026, Philippe Mathieu-Daudé wrote:
>>>>>> physmem.c defines 2 stubs which are related to ram-block:
>>>>>> qemu_ram_block_from_host() and qemu_ram_get_fd().
>>>>>> Move them with the other ram-block stubs.
>>>>>>
>>>>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>>>>> ---
>>>>>> stubs/physmem.c | 13 -------------
>>>>>> stubs/ram-block.c | 11 +++++++++++
>>>>>
>>>>> Maybe should be the other way around moving what's in subs/ram- block.c
>>>>> to stubs/physmem.c considering the the functions these stub out are in
>>>>> system/physmem.c and there's no system/ram-block.c.
>>>
>>> Fine, I'll drop this patch if you think it is not worthwhile.
>>
>> I did not say that, only that the functions are in system/physmem.c so why
>> not put the stubs in stubs/physmem.c to match? Since there's no
>> system/ram-block.c I think it makes more sense to merge these into
>> stubs/physmem.c instead.
>
> Unfortunately I won't have time to address this change before
> soft-freeze, do you mind posting the patch?
I don't think this is a big issue to put much effort in so as I said
dropping the patch and not changing it is probably the simplest.
> Thanks for your review and help here,
>
> Phil.
>
>> But just leaving it as it is is also OK.
Regards,
BALATON Zoltan
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 5/7] system/memory: Display address spaces starting at 0x0000.0000
2026-02-26 22:02 ` [PATCH 5/7] system/memory: Display address spaces starting at 0x0000.0000 Philippe Mathieu-Daudé
2026-02-26 22:23 ` Pierrick Bouvier
@ 2026-03-04 18:24 ` Peter Xu
1 sibling, 0 replies; 30+ messages in thread
From: Peter Xu @ 2026-03-04 18:24 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Richard Henderson, Mark Cave-Ayland, Paolo Bonzini,
Akihiko Odaki
Hi, Phil!
On Thu, Feb 26, 2026 at 11:02:23PM +0100, Philippe Mathieu-Daudé wrote:
> Since AddressSpace root MemoryRegion can be remapped, it is
> bogus to use the MemoryRegion address as the AddressSpace
> absolute address. Besides, the AddressSpace APIs take an
> @addr argument expecting AddressSpaces start at 0x0000.0000.
Could you share an example where a root MR can have addr!=0, and be
remapped while being the root MR of an AS?
Thanks,
>
> Substract the MemoryRegion address in mtree_print_mr() to
> display AddressSpaces starting at 0x0000.0000.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> system/memory.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/system/memory.c b/system/memory.c
> index d5060774834..1106f48d0d5 100644
> --- a/system/memory.c
> +++ b/system/memory.c
> @@ -3360,7 +3360,7 @@ static void mtree_print_mr_owner(const MemoryRegion *mr)
> }
>
> static void mtree_print_mr(const MemoryRegion *mr, unsigned int level,
> - hwaddr base,
> + hwaddr offset, bool detect_overflow,
> MemoryRegionListHead *alias_print_queue,
> bool owner, bool display_disabled)
> {
> @@ -3374,7 +3374,7 @@ static void mtree_print_mr(const MemoryRegion *mr, unsigned int level,
> return;
> }
>
> - cur_start = base + mr->addr;
> + cur_start = mr->addr + offset;
> cur_end = cur_start + MR_SIZE(mr->size);
>
> /*
> @@ -3382,7 +3382,7 @@ static void mtree_print_mr(const MemoryRegion *mr, unsigned int level,
> * happen normally. When it happens, we dump something to warn the
> * user who is observing this.
> */
> - if (cur_start < base || cur_end < cur_start) {
> + if (detect_overflow && (cur_start < offset || cur_end < cur_start)) {
> qemu_printf("[DETECTED OVERFLOW!] ");
> }
>
> @@ -3462,7 +3462,7 @@ static void mtree_print_mr(const MemoryRegion *mr, unsigned int level,
> }
>
> QTAILQ_FOREACH(ml, &submr_print_queue, mrqueue) {
> - mtree_print_mr(ml->mr, level + 1, cur_start,
> + mtree_print_mr(ml->mr, level + 1, cur_start, true,
> alias_print_queue, owner, display_disabled);
> }
>
> @@ -3641,7 +3641,8 @@ static void mtree_print_as(gpointer key, gpointer value, gpointer user_data)
> struct AddressSpaceInfo *asi = user_data;
>
> g_slist_foreach(as_same_root_mr_list, mtree_print_as_name, NULL);
> - mtree_print_mr(mr, 1, 0, asi->ml_head, asi->owner, asi->disabled);
> + mtree_print_mr(mr, 1, -mr->addr, false,
> + asi->ml_head, asi->owner, asi->disabled);
> qemu_printf("\n");
> }
>
> @@ -3688,7 +3689,7 @@ static void mtree_info_as(bool dispatch_tree, bool owner, bool disabled)
> const MemoryRegion *mr = ml->mr;
>
> qemu_printf("memory-region: %s\n", memory_region_name(mr));
> - mtree_print_mr(mr, 1, 0, &ml_head, owner, disabled);
> + mtree_print_mr(mr, 1, 0, false, &ml_head, owner, disabled);
> qemu_printf("\n");
> }
>
> --
> 2.52.0
>
--
Peter Xu
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 1/7] stubs: Merge physmem.c within ram-block.c
2026-02-26 22:02 ` [PATCH 1/7] stubs: Merge physmem.c within ram-block.c Philippe Mathieu-Daudé
2026-02-26 22:21 ` Pierrick Bouvier
2026-02-26 22:22 ` BALATON Zoltan
@ 2026-03-04 18:32 ` Peter Xu
2 siblings, 0 replies; 30+ messages in thread
From: Peter Xu @ 2026-03-04 18:32 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Richard Henderson, Mark Cave-Ayland, Paolo Bonzini,
Akihiko Odaki
On Thu, Feb 26, 2026 at 11:02:19PM +0100, Philippe Mathieu-Daudé wrote:
> physmem.c defines 2 stubs which are related to ram-block:
> qemu_ram_block_from_host() and qemu_ram_get_fd().
> Move them with the other ram-block stubs.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Xu <peterx@redhat.com>
--
Peter Xu
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 2/7] system/ramblock: Constify various RAMBlock arguments
2026-02-26 22:02 ` [PATCH 2/7] system/ramblock: Constify various RAMBlock arguments Philippe Mathieu-Daudé
2026-02-26 22:22 ` Pierrick Bouvier
@ 2026-03-04 18:33 ` Peter Xu
1 sibling, 0 replies; 30+ messages in thread
From: Peter Xu @ 2026-03-04 18:33 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Richard Henderson, Mark Cave-Ayland, Paolo Bonzini,
Akihiko Odaki
On Thu, Feb 26, 2026 at 11:02:20PM +0100, Philippe Mathieu-Daudé wrote:
> Mark the RAMBlock structure const when is only accessed read-only.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Xu <peterx@redhat.com>
--
Peter Xu
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 3/7] system/memory: Constify various MemoryRegion arguments
2026-02-26 22:02 ` [PATCH 3/7] system/memory: Constify various MemoryRegion arguments Philippe Mathieu-Daudé
2026-02-26 22:22 ` Pierrick Bouvier
@ 2026-03-04 18:33 ` Peter Xu
1 sibling, 0 replies; 30+ messages in thread
From: Peter Xu @ 2026-03-04 18:33 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Richard Henderson, Mark Cave-Ayland, Paolo Bonzini,
Akihiko Odaki
On Thu, Feb 26, 2026 at 11:02:21PM +0100, Philippe Mathieu-Daudé wrote:
> Mark the MemoryRegion structure const when is only accessed read-only.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Xu <peterx@redhat.com>
--
Peter Xu
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 4/7] system/memory: Have memory_region_type() correctly describe containers
2026-02-26 22:02 ` [PATCH 4/7] system/memory: Have memory_region_type() correctly describe containers Philippe Mathieu-Daudé
2026-02-26 22:22 ` Pierrick Bouvier
@ 2026-03-04 18:33 ` Peter Xu
1 sibling, 0 replies; 30+ messages in thread
From: Peter Xu @ 2026-03-04 18:33 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Richard Henderson, Mark Cave-Ayland, Paolo Bonzini,
Akihiko Odaki
On Thu, Feb 26, 2026 at 11:02:22PM +0100, Philippe Mathieu-Daudé wrote:
> MemoryRegion containers are not I/O regions,
> describe them as 'container'.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Xu <peterx@redhat.com>
--
Peter Xu
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 6/7] system/memory: Allow mtree_print_mr() to display distinct address width
2026-02-26 22:02 ` [PATCH 6/7] system/memory: Allow mtree_print_mr() to display distinct address width Philippe Mathieu-Daudé
2026-02-26 22:24 ` Pierrick Bouvier
@ 2026-03-04 18:34 ` Peter Xu
1 sibling, 0 replies; 30+ messages in thread
From: Peter Xu @ 2026-03-04 18:34 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Richard Henderson, Mark Cave-Ayland, Paolo Bonzini,
Akihiko Odaki
On Thu, Feb 26, 2026 at 11:02:24PM +0100, Philippe Mathieu-Daudé wrote:
> mtree_print_mr() display addresses using 16 chars on 64-bit
> binaries, and 8 chars on 32-bit ones. Some MR / AS don't
> always benefit of 16 chars, for example the ISA I/O region
> fits in 16 bits, and displaying 12 extra '0' in 64-bit
> binaries isn't really a good user experience.
>
> Add an extra @width argument to mtree_print_mr(). Next
> commit will make use of it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Xu <peterx@redhat.com>
--
Peter Xu
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 7/7] system/memory: Have 'info mtree' display addresses nicely
2026-02-26 22:02 ` [PATCH 7/7] system/memory: Have 'info mtree' display addresses nicely Philippe Mathieu-Daudé
2026-02-26 22:26 ` Pierrick Bouvier
2026-02-26 22:35 ` BALATON Zoltan
@ 2026-03-04 18:35 ` Peter Xu
2 siblings, 0 replies; 30+ messages in thread
From: Peter Xu @ 2026-03-04 18:35 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, Richard Henderson, Mark Cave-Ayland, Paolo Bonzini,
Akihiko Odaki
On Thu, Feb 26, 2026 at 11:02:25PM +0100, Philippe Mathieu-Daudé wrote:
> Use the size of a MR / AS to decide how many address chars
> need to be used.
>
> For example, using 'qemu-system-x86_64 -M q35 -S -monitor stdio'
> to run 'info mtree' displays before:
>
> address-space: I/O
> 0000000000000000-000000000000ffff (prio 0, i/o): io
> 0000000000000000-0000000000000003 (prio 0, i/o): acpi-evt
> 0000000000000004-0000000000000005 (prio 0, i/o): acpi-cnt
> 0000000000000008-000000000000000b (prio 0, i/o): acpi-tmr
> 0000000000000020-000000000000002f (prio 0, i/o): acpi-gpe0
> 0000000000000030-0000000000000037 (prio 0, i/o): acpi-smi
> 0000000000000060-000000000000007f (prio 0, i/o): sm-tco
> 0000000000000000-0000000000000007 (prio 0, i/o): dma-chan
> 0000000000000008-000000000000000f (prio 0, i/o): dma-cont
> 0000000000000020-0000000000000021 (prio 0, i/o): pic
> 0000000000000040-0000000000000043 (prio 0, i/o): pit
> ...
> memory-region: pc.ram
> 0000000000000000-0000000007ffffff (prio 0, ram): pc.ram
> memory-region: pc.bios
> 00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios
> memory-region: pci
> 0000000000000000-ffffffffffffffff (prio -1, i/o): pci
> 00000000000a0000-00000000000bffff (prio 1, i/o): vga-lowmem
> 00000000000c0000-00000000000dffff (prio 1, rom): pc.rom
> 00000000000e0000-00000000000fffff (prio 1, rom): alias isa-bios @pc.bios 0000000000020000-000000000003ffff
> 00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios
> ...
>
> and after:
>
> address-space: I/O
> 0000-ffff (prio 0, container): io
> 0000-0003 (prio 0, i/o): acpi-evt
> 0004-0005 (prio 0, i/o): acpi-cnt
> 0008-000b (prio 0, i/o): acpi-tmr
> 0020-002f (prio 0, i/o): acpi-gpe0
> 0030-0037 (prio 0, i/o): acpi-smi
> 0060-007f (prio 0, i/o): sm-tco
> 0000-0007 (prio 0, i/o): dma-chan
> 0008-000f (prio 0, i/o): dma-cont
> 0020-0021 (prio 0, i/o): pic
> 0040-0043 (prio 0, i/o): pit
> ...
> memory-region: pc.ram
> 00000000-07ffffff (prio 0, ram): pc.ram
> memory-region: pc.bios
> fffc0000-ffffffff (prio 0, rom): pc.bios
> memory-region: pci
> 0000000000000000-ffffffffffffffff (prio -1, i/o): pci
> 00000000000a0000-00000000000bffff (prio 1, i/o): vga-lowmem
> 00000000000c0000-00000000000dffff (prio 1, rom): pc.rom
> 00000000000e0000-00000000000fffff (prio 1, rom): alias isa-bios @pc.bios 0000000000020000-000000000003ffff
> 00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios
> ...
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> system/memory.c | 27 +++++++++++++++++++++++----
> 1 file changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/system/memory.c b/system/memory.c
> index 4d276307da5..abcbdaadcd7 100644
> --- a/system/memory.c
> +++ b/system/memory.c
> @@ -3321,7 +3321,26 @@ typedef QTAILQ_HEAD(, MemoryRegionList) MemoryRegionListHead;
>
> #define MR_SIZE(size) (int128_nz(size) ? (hwaddr)int128_get64( \
> int128_sub((size), int128_one())) : 0)
> -#define MR_ADDR_WIDTH 16
> +
> +static unsigned mr_addr_fmt_width(const MemoryRegion *mr)
> +{
> + const unsigned int bits = 127 - clz128(mr->size);
> + unsigned int width;
> +
> + if (bits <= 8) {
> + width = 2;
> + } else if (bits <= 16) {
> + width = 4;
> + } else if (bits <= 32) {
> + width = 8;
> + } else if (bits <= 64) {
> + width = 16;
> + } else {
> + width = 20;
Is there any case this can happen? I thought we don't have MR larger than
1<<64. Not a huge deal, though.
Reviewed-by: Peter Xu <peterx@redhat.com>
> + }
> + return width;
> +}
> +
> #define MTREE_INDENT " "
>
> static void mtree_expand_owner(const char *label, Object *obj)
> @@ -3513,7 +3532,7 @@ static void mtree_print_flatview(gpointer key, gpointer value,
> return;
> }
>
> - width = MR_ADDR_WIDTH;
> + width = mr_addr_fmt_width(view->root);
> while (n--) {
> const MemoryRegion *mr = range->mr;
>
> @@ -3643,7 +3662,7 @@ static void mtree_print_as(gpointer key, gpointer value, gpointer user_data)
> MemoryRegion *mr = key;
> GSList *as_same_root_mr_list = value;
> struct AddressSpaceInfo *asi = user_data;
> - const unsigned int width = MR_ADDR_WIDTH;
> + const unsigned int width = mr_addr_fmt_width(mr);
>
> g_slist_foreach(as_same_root_mr_list, mtree_print_as_name, NULL);
> mtree_print_mr(mr, 1, width, -mr->addr, false,
> @@ -3692,7 +3711,7 @@ static void mtree_info_as(bool dispatch_tree, bool owner, bool disabled)
> /* print aliased regions */
> QTAILQ_FOREACH(ml, &ml_head, mrqueue) {
> const MemoryRegion *mr = ml->mr;
> - const unsigned int width = MR_ADDR_WIDTH;
> + const unsigned int width = mr_addr_fmt_width(mr);
>
> qemu_printf("memory-region: %s\n", memory_region_name(mr));
> mtree_print_mr(mr, 1, width, 0, false, &ml_head, owner, disabled);
> --
> 2.52.0
>
--
Peter Xu
^ permalink raw reply [flat|nested] 30+ messages in thread
end of thread, other threads:[~2026-03-04 18:36 UTC | newest]
Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-26 22:02 [PATCH 0/7] system/memory: Improve 'info mtree' readability Philippe Mathieu-Daudé
2026-02-26 22:02 ` [PATCH 1/7] stubs: Merge physmem.c within ram-block.c Philippe Mathieu-Daudé
2026-02-26 22:21 ` Pierrick Bouvier
2026-02-26 22:22 ` BALATON Zoltan
2026-03-02 6:21 ` Akihiko Odaki
2026-03-03 16:15 ` Philippe Mathieu-Daudé
2026-03-03 17:20 ` BALATON Zoltan
2026-03-04 6:27 ` Philippe Mathieu-Daudé
2026-03-04 11:41 ` BALATON Zoltan
2026-03-04 18:32 ` Peter Xu
2026-02-26 22:02 ` [PATCH 2/7] system/ramblock: Constify various RAMBlock arguments Philippe Mathieu-Daudé
2026-02-26 22:22 ` Pierrick Bouvier
2026-03-04 18:33 ` Peter Xu
2026-02-26 22:02 ` [PATCH 3/7] system/memory: Constify various MemoryRegion arguments Philippe Mathieu-Daudé
2026-02-26 22:22 ` Pierrick Bouvier
2026-03-04 18:33 ` Peter Xu
2026-02-26 22:02 ` [PATCH 4/7] system/memory: Have memory_region_type() correctly describe containers Philippe Mathieu-Daudé
2026-02-26 22:22 ` Pierrick Bouvier
2026-03-04 18:33 ` Peter Xu
2026-02-26 22:02 ` [PATCH 5/7] system/memory: Display address spaces starting at 0x0000.0000 Philippe Mathieu-Daudé
2026-02-26 22:23 ` Pierrick Bouvier
2026-03-04 18:24 ` Peter Xu
2026-02-26 22:02 ` [PATCH 6/7] system/memory: Allow mtree_print_mr() to display distinct address width Philippe Mathieu-Daudé
2026-02-26 22:24 ` Pierrick Bouvier
2026-03-04 18:34 ` Peter Xu
2026-02-26 22:02 ` [PATCH 7/7] system/memory: Have 'info mtree' display addresses nicely Philippe Mathieu-Daudé
2026-02-26 22:26 ` Pierrick Bouvier
2026-02-26 22:35 ` BALATON Zoltan
2026-02-27 16:20 ` Philippe Mathieu-Daudé
2026-03-04 18:35 ` Peter Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox