softmmu/memory: Pass ram_flags to memory_region_init_ram_shared_nomigrate()

Let's forward ram_flags instead, renaming
memory_region_init_ram_shared_nomigrate() into
memory_region_init_ram_flags_nomigrate().

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Acked-by: Eduardo Habkost <ehabkost@redhat.com> for memory backend and machine core
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20210510114328.21835-6-david@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
David Hildenbrand 2021-05-10 13:43:18 +02:00 committed by Paolo Bonzini
parent d5015b8013
commit 7f863cba4d
5 changed files with 31 additions and 29 deletions

View File

@ -19,6 +19,7 @@
static void static void
ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
{ {
uint32_t ram_flags;
char *name; char *name;
if (!backend->size) { if (!backend->size) {
@ -27,8 +28,9 @@ ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
} }
name = host_memory_backend_get_name(backend); name = host_memory_backend_get_name(backend);
memory_region_init_ram_shared_nomigrate(&backend->mr, OBJECT(backend), name, ram_flags = backend->share ? RAM_SHARED : 0;
backend->size, backend->share, errp); memory_region_init_ram_flags_nomigrate(&backend->mr, OBJECT(backend), name,
backend->size, ram_flags, errp);
g_free(name); g_free(name);
} }

View File

@ -984,8 +984,8 @@ static void next_cube_init(MachineState *machine)
sysbus_mmio_map(SYS_BUS_DEVICE(pcdev), 1, 0x02100000); sysbus_mmio_map(SYS_BUS_DEVICE(pcdev), 1, 0x02100000);
/* BMAP memory */ /* BMAP memory */
memory_region_init_ram_shared_nomigrate(bmapm1, NULL, "next.bmapmem", 64, memory_region_init_ram_flags_nomigrate(bmapm1, NULL, "next.bmapmem", 64,
true, &error_fatal); RAM_SHARED, &error_fatal);
memory_region_add_subregion(sysmem, 0x020c0000, bmapm1); memory_region_add_subregion(sysmem, 0x020c0000, bmapm1);
/* The Rev_2.5_v66.bin firmware accesses it at 0x820c0020, too */ /* The Rev_2.5_v66.bin firmware accesses it at 0x820c0020, too */
memory_region_init_alias(bmapm2, NULL, "next.bmapmem2", bmapm1, 0x0, 64); memory_region_init_alias(bmapm2, NULL, "next.bmapmem2", bmapm1, 0x0, 64);

View File

@ -940,7 +940,7 @@ void memory_region_init_ram_nomigrate(MemoryRegion *mr,
Error **errp); Error **errp);
/** /**
* memory_region_init_ram_shared_nomigrate: Initialize RAM memory region. * memory_region_init_ram_flags_nomigrate: Initialize RAM memory region.
* Accesses into the region will * Accesses into the region will
* modify memory directly. * modify memory directly.
* *
@ -949,17 +949,17 @@ void memory_region_init_ram_nomigrate(MemoryRegion *mr,
* @name: Region name, becomes part of RAMBlock name used in migration stream * @name: Region name, becomes part of RAMBlock name used in migration stream
* must be unique within any device * must be unique within any device
* @size: size of the region. * @size: size of the region.
* @share: allow remapping RAM to different addresses * @ram_flags: RamBlock flags. Supported flags: RAM_SHARED.
* @errp: pointer to Error*, to store an error if it happens. * @errp: pointer to Error*, to store an error if it happens.
* *
* Note that this function is similar to memory_region_init_ram_nomigrate. * Note that this function does not do anything to cause the data in the
* The only difference is part of the RAM region can be remapped. * RAM memory region to be migrated; that is the responsibility of the caller.
*/ */
void memory_region_init_ram_shared_nomigrate(MemoryRegion *mr, void memory_region_init_ram_flags_nomigrate(MemoryRegion *mr,
Object *owner, Object *owner,
const char *name, const char *name,
uint64_t size, uint64_t size,
bool share, uint32_t ram_flags,
Error **errp); Error **errp);
/** /**

View File

@ -127,8 +127,8 @@ static void device_fn(DeviceState *dev, ...)
- memory_region_init_rom(E1, NULL, E2, E3, E4); - memory_region_init_rom(E1, NULL, E2, E3, E4);
+ memory_region_init_rom(E1, obj, E2, E3, E4); + memory_region_init_rom(E1, obj, E2, E3, E4);
| |
- memory_region_init_ram_shared_nomigrate(E1, NULL, E2, E3, E4, E5); - memory_region_init_ram_flags_nomigrate(E1, NULL, E2, E3, E4, E5);
+ memory_region_init_ram_shared_nomigrate(E1, obj, E2, E3, E4, E5); + memory_region_init_ram_flags_nomigrate(E1, obj, E2, E3, E4, E5);
) )
...+> ...+>
} }
@ -152,8 +152,8 @@ static void device_fn(DeviceState *dev, ...)
- memory_region_init_rom(E1, NULL, E2, E3, E4); - memory_region_init_rom(E1, NULL, E2, E3, E4);
+ memory_region_init_rom(E1, OBJECT(dev), E2, E3, E4); + memory_region_init_rom(E1, OBJECT(dev), E2, E3, E4);
| |
- memory_region_init_ram_shared_nomigrate(E1, NULL, E2, E3, E4, E5); - memory_region_init_ram_flags_nomigrate(E1, NULL, E2, E3, E4, E5);
+ memory_region_init_ram_shared_nomigrate(E1, OBJECT(dev), E2, E3, E4, E5); + memory_region_init_ram_flags_nomigrate(E1, OBJECT(dev), E2, E3, E4, E5);
) )
...+> ...+>
} }

View File

@ -1531,14 +1531,14 @@ void memory_region_init_ram_nomigrate(MemoryRegion *mr,
uint64_t size, uint64_t size,
Error **errp) Error **errp)
{ {
memory_region_init_ram_shared_nomigrate(mr, owner, name, size, false, errp); memory_region_init_ram_flags_nomigrate(mr, owner, name, size, 0, errp);
} }
void memory_region_init_ram_shared_nomigrate(MemoryRegion *mr, void memory_region_init_ram_flags_nomigrate(MemoryRegion *mr,
Object *owner, Object *owner,
const char *name, const char *name,
uint64_t size, uint64_t size,
bool share, uint32_t ram_flags,
Error **errp) Error **errp)
{ {
Error *err = NULL; Error *err = NULL;
@ -1546,7 +1546,7 @@ void memory_region_init_ram_shared_nomigrate(MemoryRegion *mr,
mr->ram = true; mr->ram = true;
mr->terminates = true; mr->terminates = true;
mr->destructor = memory_region_destructor_ram; mr->destructor = memory_region_destructor_ram;
mr->ram_block = qemu_ram_alloc(size, share, mr, &err); mr->ram_block = qemu_ram_alloc(size, ram_flags & RAM_SHARED, mr, &err);
if (err) { if (err) {
mr->size = int128_zero(); mr->size = int128_zero();
object_unparent(OBJECT(mr)); object_unparent(OBJECT(mr));
@ -1682,7 +1682,7 @@ void memory_region_init_rom_nomigrate(MemoryRegion *mr,
uint64_t size, uint64_t size,
Error **errp) Error **errp)
{ {
memory_region_init_ram_shared_nomigrate(mr, owner, name, size, false, errp); memory_region_init_ram_flags_nomigrate(mr, owner, name, size, 0, errp);
mr->readonly = true; mr->readonly = true;
} }