mirror of
https://github.com/qemu/qemu.git
synced 2026-04-05 22:00:58 +00:00
system/memory: 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> Reviewed-by: Peter Xu <peterx@redhat.com> Link: https://lore.kernel.org/r/20260309183536.88976-3-philmd@linaro.org Signed-off-by: Peter Xu <peterx@redhat.com>
This commit is contained in:
committed by
Peter Xu
parent
f016021ff5
commit
5a525dcb4d
@@ -1750,9 +1750,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;
|
||||
}
|
||||
|
||||
@@ -1780,7 +1780,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;
|
||||
@@ -1797,25 +1797,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))) {
|
||||
@@ -1829,7 +1829,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);
|
||||
}
|
||||
@@ -2337,7 +2337,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) {
|
||||
@@ -2346,7 +2346,7 @@ int memory_region_get_fd(MemoryRegion *mr)
|
||||
return mr->ram_block->fd;
|
||||
}
|
||||
|
||||
void *memory_region_get_ram_ptr(MemoryRegion *mr)
|
||||
void *memory_region_get_ram_ptr(const MemoryRegion *mr)
|
||||
{
|
||||
uint64_t offset = 0;
|
||||
|
||||
@@ -2371,7 +2371,7 @@ MemoryRegion *memory_region_from_host(void *ptr, ram_addr_t *offset)
|
||||
return block->mr;
|
||||
}
|
||||
|
||||
ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr)
|
||||
ram_addr_t memory_region_get_ram_addr(const MemoryRegion *mr)
|
||||
{
|
||||
return mr->ram_block ? mr->ram_block->offset : RAM_ADDR_INVALID;
|
||||
}
|
||||
@@ -2737,7 +2737,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;
|
||||
}
|
||||
@@ -3221,7 +3221,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);
|
||||
@@ -3414,7 +3414,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;
|
||||
@@ -3441,7 +3440,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,
|
||||
@@ -3614,8 +3614,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");
|
||||
}
|
||||
|
||||
|
||||
@@ -1975,7 +1975,7 @@ void qemu_ram_unset_idstr(RAMBlock *block)
|
||||
}
|
||||
}
|
||||
|
||||
static char *cpr_name(MemoryRegion *mr)
|
||||
static char *cpr_name(const MemoryRegion *mr)
|
||||
{
|
||||
const char *mr_name = memory_region_name(mr);
|
||||
g_autofree char *id = mr->dev ? qdev_get_dev_path(mr->dev) : NULL;
|
||||
|
||||
Reference in New Issue
Block a user