system/xen: Constify various MemoryRegion arguments
Mark the MemoryRegion structure const when is only accessed read-only. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Link: https://lore.kernel.org/r/20260309183536.88976-4-philmd@linaro.org Signed-off-by: Peter Xu <peterx@redhat.com>
Philippe Mathieu-Daudé committed
Mar 9, 2026 at 19:35 UTC
5eedbf49b96ed6d0b6ae994b70a1ea2485fe2a99
5 files changed
+12
-12
hw/xen/xen-hvm-common.c
+4
-4
@@ -23,19 +23,19 @@
23
MemoryRegion xen_memory, xen_grants;
24
25
/* Check for any kind of xen memory, foreign mappings or grants. */
26
-bool xen_mr_is_memory(MemoryRegion *mr)
26
+bool xen_mr_is_memory(const MemoryRegion *mr)
27
{
28
return mr == &xen_memory || mr == &xen_grants;
29
}
30
31
/* Check specifically for grants. */
32
-bool xen_mr_is_grants(MemoryRegion *mr)
32
+bool xen_mr_is_grants(const MemoryRegion *mr)
33
{
34
return mr == &xen_grants;
35
}
36
37
-void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr,
38
- Error **errp)
37
+void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size,
38
+ const MemoryRegion *mr, Error **errp)
39
{
40
unsigned target_page_bits = qemu_target_page_bits();
41
unsigned long nr_pfn;
hw/xen/xen-mapcache.c
+1
-1
@@ -460,7 +460,7 @@ tryagain:
460
return mc->last_entry->vaddr_base + address_offset;
461
}
462
463
-uint8_t *xen_map_cache(MemoryRegion *mr,
463
+uint8_t *xen_map_cache(const MemoryRegion *mr,
464
hwaddr phys_addr, hwaddr size,
465
ram_addr_t ram_addr_offset,
466
uint8_t lock, bool dma,
hw/xen/xen_stubs.c
+3
-3
@@ -19,12 +19,12 @@ void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length)
19
}
20
21
void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size,
22
- struct MemoryRegion *mr, Error **errp)
22
+ const MemoryRegion *mr, Error **errp)
23
{
24
g_assert_not_reached();
25
}
26
27
-bool xen_mr_is_memory(MemoryRegion *mr)
27
+bool xen_mr_is_memory(const MemoryRegion *mr)
28
{
29
g_assert_not_reached();
30
}
@@ -44,7 +44,7 @@ ram_addr_t xen_ram_addr_from_mapcache(void *ptr)
44
g_assert_not_reached();
45
}
46
47
-uint8_t *xen_map_cache(MemoryRegion *mr,
47
+uint8_t *xen_map_cache(const MemoryRegion *mr,
48
hwaddr phys_addr,
49
hwaddr size,
50
ram_addr_t ram_addr_offset,
include/system/xen-mapcache.h
+1
-1
@@ -16,7 +16,7 @@ typedef hwaddr (*phys_offset_to_gaddr_t)(hwaddr phys_offset,
16
bool xen_map_cache_enabled(void);
17
void xen_map_cache_init(phys_offset_to_gaddr_t f,
18
void *opaque);
19
-uint8_t *xen_map_cache(MemoryRegion *mr, hwaddr phys_addr, hwaddr size,
19
+uint8_t *xen_map_cache(const MemoryRegion *mr, hwaddr phys_addr, hwaddr size,
20
ram_addr_t ram_addr_offset,
21
uint8_t lock, bool dma,
22
bool is_write);
include/system/xen.h
+3
-3
@@ -30,7 +30,7 @@ extern bool xen_allowed;
30
31
void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length);
32
void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size,
33
- struct MemoryRegion *mr, Error **errp);
34
-bool xen_mr_is_memory(MemoryRegion *mr);
35
-bool xen_mr_is_grants(MemoryRegion *mr);
33
+ const MemoryRegion *mr, Error **errp);
34
+bool xen_mr_is_memory(const MemoryRegion *mr);
35
+bool xen_mr_is_grants(const MemoryRegion *mr);
36
#endif