mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:46:17 +00:00
system/memory: constify section arguments
The sections shouldn't be modified. Reviewed-by: Peter Xu <peterx@redhat.com> Reviewed-by: Cédric Le Goater <clg@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Acked-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com> # for CPR Acked-by: David Hildenbrand (Arm) <david@kernel.org> Link: https://lore.kernel.org/r/20260604-rdm5-v5-3-5768e6a0943d@redhat.com Signed-off-by: Peter Xu <peterx@redhat.com>
This commit is contained in:
committed by
Peter Xu
parent
d444e348b1
commit
49a159baae
@@ -226,7 +226,7 @@ void vfio_cpr_giommu_remap(VFIOContainer *bcontainer,
|
||||
memory_region_iommu_replay(giommu->iommu_mr, &giommu->n);
|
||||
}
|
||||
|
||||
static int vfio_cpr_rdm_remap(MemoryRegionSection *section, void *opaque)
|
||||
static int vfio_cpr_rdm_remap(const MemoryRegionSection *section, void *opaque)
|
||||
{
|
||||
RamDiscardListener *rdl = opaque;
|
||||
|
||||
@@ -242,7 +242,7 @@ static int vfio_cpr_rdm_remap(MemoryRegionSection *section, void *opaque)
|
||||
* directly, which calls vfio_legacy_cpr_dma_map.
|
||||
*/
|
||||
bool vfio_cpr_ram_discard_replay_populated(VFIOContainer *bcontainer,
|
||||
MemoryRegionSection *section)
|
||||
const MemoryRegionSection *section)
|
||||
{
|
||||
RamDiscardManager *rdm = memory_region_get_ram_discard_manager(section->mr);
|
||||
VFIORamDiscardListener *vrdl =
|
||||
|
||||
@@ -201,7 +201,7 @@ out:
|
||||
}
|
||||
|
||||
static void vfio_ram_discard_notify_discard(RamDiscardListener *rdl,
|
||||
MemoryRegionSection *section)
|
||||
const MemoryRegionSection *section)
|
||||
{
|
||||
VFIORamDiscardListener *vrdl = container_of(rdl, VFIORamDiscardListener,
|
||||
listener);
|
||||
@@ -219,7 +219,7 @@ static void vfio_ram_discard_notify_discard(RamDiscardListener *rdl,
|
||||
}
|
||||
|
||||
static int vfio_ram_discard_notify_populate(RamDiscardListener *rdl,
|
||||
MemoryRegionSection *section)
|
||||
const MemoryRegionSection *section)
|
||||
{
|
||||
VFIORamDiscardListener *vrdl = container_of(rdl, VFIORamDiscardListener,
|
||||
listener);
|
||||
@@ -461,7 +461,7 @@ static void vfio_device_error_append(VFIODevice *vbasedev, Error **errp)
|
||||
}
|
||||
|
||||
VFIORamDiscardListener *vfio_find_ram_discard_listener(
|
||||
VFIOContainer *bcontainer, MemoryRegionSection *section)
|
||||
VFIOContainer *bcontainer, const MemoryRegionSection *section)
|
||||
{
|
||||
VFIORamDiscardListener *vrdl;
|
||||
|
||||
@@ -1149,8 +1149,8 @@ out:
|
||||
}
|
||||
}
|
||||
|
||||
static int vfio_ram_discard_query_dirty_bitmap(MemoryRegionSection *section,
|
||||
void *opaque)
|
||||
static int vfio_ram_discard_query_dirty_bitmap(const MemoryRegionSection *section,
|
||||
void *opaque)
|
||||
{
|
||||
const hwaddr size = int128_get64(section->size);
|
||||
const hwaddr iova = section->offset_within_address_space;
|
||||
|
||||
@@ -262,7 +262,7 @@ static int virtio_mem_for_each_plugged_range(VirtIOMEM *vmem, void *arg,
|
||||
typedef int (*virtio_mem_section_cb)(MemoryRegionSection *s, void *arg);
|
||||
|
||||
static int virtio_mem_for_each_plugged_section(const VirtIOMEM *vmem,
|
||||
MemoryRegionSection *s,
|
||||
const MemoryRegionSection *s,
|
||||
void *arg,
|
||||
virtio_mem_section_cb cb)
|
||||
{
|
||||
@@ -294,7 +294,7 @@ static int virtio_mem_for_each_plugged_section(const VirtIOMEM *vmem,
|
||||
}
|
||||
|
||||
static int virtio_mem_for_each_unplugged_section(const VirtIOMEM *vmem,
|
||||
MemoryRegionSection *s,
|
||||
const MemoryRegionSection *s,
|
||||
void *arg,
|
||||
virtio_mem_section_cb cb)
|
||||
{
|
||||
@@ -1680,7 +1680,7 @@ static int virtio_mem_rds_replay_cb(MemoryRegionSection *s, void *arg)
|
||||
}
|
||||
|
||||
static int virtio_mem_rds_replay_populated(const RamDiscardSource *rds,
|
||||
MemoryRegionSection *s,
|
||||
const MemoryRegionSection *s,
|
||||
ReplayRamDiscardState replay_fn,
|
||||
void *opaque)
|
||||
{
|
||||
@@ -1692,11 +1692,11 @@ static int virtio_mem_rds_replay_populated(const RamDiscardSource *rds,
|
||||
|
||||
g_assert(s->mr == &vmem->memdev->mr);
|
||||
return virtio_mem_for_each_plugged_section(vmem, s, &data,
|
||||
virtio_mem_rds_replay_cb);
|
||||
virtio_mem_rds_replay_cb);
|
||||
}
|
||||
|
||||
static int virtio_mem_rds_replay_discarded(const RamDiscardSource *rds,
|
||||
MemoryRegionSection *s,
|
||||
const MemoryRegionSection *s,
|
||||
ReplayRamDiscardState replay_fn,
|
||||
void *opaque)
|
||||
{
|
||||
|
||||
@@ -277,7 +277,7 @@ struct VFIOIOMMUClass {
|
||||
};
|
||||
|
||||
VFIORamDiscardListener *vfio_find_ram_discard_listener(
|
||||
VFIOContainer *bcontainer, MemoryRegionSection *section);
|
||||
VFIOContainer *bcontainer, const MemoryRegionSection *section);
|
||||
|
||||
void vfio_container_region_add(VFIOContainer *bcontainer,
|
||||
MemoryRegionSection *section, bool cpr_remap);
|
||||
|
||||
@@ -69,7 +69,7 @@ void vfio_cpr_giommu_remap(struct VFIOContainer *bcontainer,
|
||||
MemoryRegionSection *section);
|
||||
|
||||
bool vfio_cpr_ram_discard_replay_populated(
|
||||
struct VFIOContainer *bcontainer, MemoryRegionSection *section);
|
||||
struct VFIOContainer *bcontainer, const MemoryRegionSection *section);
|
||||
|
||||
void vfio_cpr_save_vector_fd(struct VFIOPCIDevice *vdev, const char *name,
|
||||
int nr, int fd);
|
||||
|
||||
@@ -26,9 +26,9 @@ DECLARE_OBJ_CHECKERS(RamDiscardSource, RamDiscardSourceClass,
|
||||
|
||||
typedef struct RamDiscardListener RamDiscardListener;
|
||||
typedef int (*NotifyRamPopulate)(RamDiscardListener *rdl,
|
||||
MemoryRegionSection *section);
|
||||
const MemoryRegionSection *section);
|
||||
typedef void (*NotifyRamDiscard)(RamDiscardListener *rdl,
|
||||
MemoryRegionSection *section);
|
||||
const MemoryRegionSection *section);
|
||||
|
||||
struct RamDiscardListener {
|
||||
/*
|
||||
@@ -86,7 +86,7 @@ static inline void ram_discard_listener_init(RamDiscardListener *rdl,
|
||||
*
|
||||
* Returns 0 on success, or a negative error if failed.
|
||||
*/
|
||||
typedef int (*ReplayRamDiscardState)(MemoryRegionSection *section,
|
||||
typedef int (*ReplayRamDiscardState)(const MemoryRegionSection *section,
|
||||
void *opaque);
|
||||
|
||||
/*
|
||||
@@ -151,7 +151,7 @@ struct RamDiscardSourceClass {
|
||||
* Returns 0 on success, or a negative error if any notification failed.
|
||||
*/
|
||||
int (*replay_populated)(const RamDiscardSource *rds,
|
||||
MemoryRegionSection *section,
|
||||
const MemoryRegionSection *section,
|
||||
ReplayRamDiscardState replay_fn, void *opaque);
|
||||
|
||||
/**
|
||||
@@ -168,7 +168,7 @@ struct RamDiscardSourceClass {
|
||||
* Returns 0 on success, or a negative error if any notification failed.
|
||||
*/
|
||||
int (*replay_discarded)(const RamDiscardSource *rds,
|
||||
MemoryRegionSection *section,
|
||||
const MemoryRegionSection *section,
|
||||
ReplayRamDiscardState replay_fn, void *opaque);
|
||||
};
|
||||
|
||||
@@ -237,7 +237,7 @@ bool ram_discard_manager_is_populated(const RamDiscardManager *rdm,
|
||||
* Returns 0 on success, or a negative error if any notification failed.
|
||||
*/
|
||||
int ram_discard_manager_replay_populated(const RamDiscardManager *rdm,
|
||||
MemoryRegionSection *section,
|
||||
const MemoryRegionSection *section,
|
||||
ReplayRamDiscardState replay_fn,
|
||||
void *opaque);
|
||||
|
||||
@@ -255,7 +255,7 @@ int ram_discard_manager_replay_populated(const RamDiscardManager *rdm,
|
||||
* Returns 0 on success, or a negative error if any notification failed.
|
||||
*/
|
||||
int ram_discard_manager_replay_discarded(const RamDiscardManager *rdm,
|
||||
MemoryRegionSection *section,
|
||||
const MemoryRegionSection *section,
|
||||
ReplayRamDiscardState replay_fn,
|
||||
void *opaque);
|
||||
|
||||
|
||||
@@ -860,7 +860,7 @@ static inline bool migration_bitmap_clear_dirty(RAMState *rs,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int dirty_bitmap_clear_section(MemoryRegionSection *section,
|
||||
static int dirty_bitmap_clear_section(const MemoryRegionSection *section,
|
||||
void *opaque)
|
||||
{
|
||||
const hwaddr offset = section->offset_within_region;
|
||||
@@ -1588,7 +1588,7 @@ static inline void populate_read_range(RAMBlock *block, ram_addr_t offset,
|
||||
}
|
||||
}
|
||||
|
||||
static inline int populate_read_section(MemoryRegionSection *section,
|
||||
static inline int populate_read_section(const MemoryRegionSection *section,
|
||||
void *opaque)
|
||||
{
|
||||
const hwaddr size = int128_get64(section->size);
|
||||
@@ -1663,7 +1663,7 @@ void ram_write_tracking_prepare(void)
|
||||
}
|
||||
}
|
||||
|
||||
static inline int uffd_protect_section(MemoryRegionSection *section,
|
||||
static inline int uffd_protect_section(const MemoryRegionSection *section,
|
||||
void *opaque)
|
||||
{
|
||||
const hwaddr size = int128_get64(section->size);
|
||||
|
||||
@@ -196,7 +196,7 @@ typedef struct GuestPhysListener {
|
||||
} GuestPhysListener;
|
||||
|
||||
static void guest_phys_block_add_section(GuestPhysListener *g,
|
||||
MemoryRegionSection *section)
|
||||
const MemoryRegionSection *section)
|
||||
{
|
||||
const hwaddr target_start = section->offset_within_address_space;
|
||||
const hwaddr target_end = target_start + int128_get64(section->size);
|
||||
@@ -248,7 +248,7 @@ static void guest_phys_block_add_section(GuestPhysListener *g,
|
||||
#endif
|
||||
}
|
||||
|
||||
static int guest_phys_ram_populate_cb(MemoryRegionSection *section,
|
||||
static int guest_phys_ram_populate_cb(const MemoryRegionSection *section,
|
||||
void *opaque)
|
||||
{
|
||||
GuestPhysListener *g = opaque;
|
||||
|
||||
@@ -37,7 +37,7 @@ typedef int (*ram_block_attributes_section_cb)(MemoryRegionSection *s,
|
||||
|
||||
static int
|
||||
ram_block_attributes_for_each_populated_section(const RamBlockAttributes *attr,
|
||||
MemoryRegionSection *section,
|
||||
const MemoryRegionSection *section,
|
||||
void *arg,
|
||||
ram_block_attributes_section_cb cb)
|
||||
{
|
||||
@@ -78,7 +78,7 @@ ram_block_attributes_for_each_populated_section(const RamBlockAttributes *attr,
|
||||
|
||||
static int
|
||||
ram_block_attributes_for_each_discarded_section(const RamBlockAttributes *attr,
|
||||
MemoryRegionSection *section,
|
||||
const MemoryRegionSection *section,
|
||||
void *arg,
|
||||
ram_block_attributes_section_cb cb)
|
||||
{
|
||||
@@ -161,7 +161,7 @@ ram_block_attributes_rds_is_populated(const RamDiscardSource *rds,
|
||||
|
||||
static int
|
||||
ram_block_attributes_rds_replay_populated(const RamDiscardSource *rds,
|
||||
MemoryRegionSection *section,
|
||||
const MemoryRegionSection *section,
|
||||
ReplayRamDiscardState replay_fn,
|
||||
void *opaque)
|
||||
{
|
||||
@@ -175,7 +175,7 @@ ram_block_attributes_rds_replay_populated(const RamDiscardSource *rds,
|
||||
|
||||
static int
|
||||
ram_block_attributes_rds_replay_discarded(const RamDiscardSource *rds,
|
||||
MemoryRegionSection *section,
|
||||
const MemoryRegionSection *section,
|
||||
ReplayRamDiscardState replay_fn,
|
||||
void *opaque)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ static bool ram_discard_source_is_populated(const RamDiscardSource *rds,
|
||||
}
|
||||
|
||||
static int ram_discard_source_replay_populated(const RamDiscardSource *rds,
|
||||
MemoryRegionSection *section,
|
||||
const MemoryRegionSection *section,
|
||||
ReplayRamDiscardState replay_fn,
|
||||
void *opaque)
|
||||
{
|
||||
@@ -39,7 +39,7 @@ static int ram_discard_source_replay_populated(const RamDiscardSource *rds,
|
||||
}
|
||||
|
||||
static int ram_discard_source_replay_discarded(const RamDiscardSource *rds,
|
||||
MemoryRegionSection *section,
|
||||
const MemoryRegionSection *section,
|
||||
ReplayRamDiscardState replay_fn,
|
||||
void *opaque)
|
||||
{
|
||||
@@ -74,7 +74,7 @@ bool ram_discard_manager_is_populated(const RamDiscardManager *rdm,
|
||||
}
|
||||
|
||||
int ram_discard_manager_replay_populated(const RamDiscardManager *rdm,
|
||||
MemoryRegionSection *section,
|
||||
const MemoryRegionSection *section,
|
||||
ReplayRamDiscardState replay_fn,
|
||||
void *opaque)
|
||||
{
|
||||
@@ -83,7 +83,7 @@ int ram_discard_manager_replay_populated(const RamDiscardManager *rdm,
|
||||
}
|
||||
|
||||
int ram_discard_manager_replay_discarded(const RamDiscardManager *rdm,
|
||||
MemoryRegionSection *section,
|
||||
const MemoryRegionSection *section,
|
||||
ReplayRamDiscardState replay_fn,
|
||||
void *opaque)
|
||||
{
|
||||
@@ -164,7 +164,7 @@ void ram_discard_manager_notify_discard_all(RamDiscardManager *rdm)
|
||||
}
|
||||
}
|
||||
|
||||
static int rdm_populate_cb(MemoryRegionSection *section, void *opaque)
|
||||
static int rdm_populate_cb(const MemoryRegionSection *section, void *opaque)
|
||||
{
|
||||
RamDiscardListener *rdl = opaque;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user