All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Peter Xu" <peterx@redhat.com>,
	"David Hildenbrand" <david@redhat.com>
Subject: [PULL 22/33] softmmu/memory: Pass ram_flags to memory_region_init_ram_shared_nomigrate()
Date: Tue, 15 Jun 2021 15:38:44 +0200	[thread overview]
Message-ID: <20210615133855.775687-23-pbonzini@redhat.com> (raw)
In-Reply-To: <20210615133855.775687-1-pbonzini@redhat.com>

From: David Hildenbrand <david@redhat.com>

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>
---
 backends/hostmem-ram.c                        |  6 +++--
 hw/m68k/next-cube.c                           |  4 ++--
 include/exec/memory.h                         | 24 +++++++++----------
 .../memory-region-housekeeping.cocci          |  8 +++----
 softmmu/memory.c                              | 18 +++++++-------
 5 files changed, 31 insertions(+), 29 deletions(-)

diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c
index 5cc53e76c9..741e701062 100644
--- a/backends/hostmem-ram.c
+++ b/backends/hostmem-ram.c
@@ -19,6 +19,7 @@
 static void
 ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
 {
+    uint32_t ram_flags;
     char *name;
 
     if (!backend->size) {
@@ -27,8 +28,9 @@ ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
     }
 
     name = host_memory_backend_get_name(backend);
-    memory_region_init_ram_shared_nomigrate(&backend->mr, OBJECT(backend), name,
-                           backend->size, backend->share, errp);
+    ram_flags = backend->share ? RAM_SHARED : 0;
+    memory_region_init_ram_flags_nomigrate(&backend->mr, OBJECT(backend), name,
+                                           backend->size, ram_flags, errp);
     g_free(name);
 }
 
diff --git a/hw/m68k/next-cube.c b/hw/m68k/next-cube.c
index de951ffe5d..e0d4a94f9d 100644
--- a/hw/m68k/next-cube.c
+++ b/hw/m68k/next-cube.c
@@ -984,8 +984,8 @@ static void next_cube_init(MachineState *machine)
     sysbus_mmio_map(SYS_BUS_DEVICE(pcdev), 1, 0x02100000);
 
     /* BMAP memory */
-    memory_region_init_ram_shared_nomigrate(bmapm1, NULL, "next.bmapmem", 64,
-                                            true, &error_fatal);
+    memory_region_init_ram_flags_nomigrate(bmapm1, NULL, "next.bmapmem", 64,
+                                           RAM_SHARED, &error_fatal);
     memory_region_add_subregion(sysmem, 0x020c0000, bmapm1);
     /* The Rev_2.5_v66.bin firmware accesses it at 0x820c0020, too */
     memory_region_init_alias(bmapm2, NULL, "next.bmapmem2", bmapm1, 0x0, 64);
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 8aa69a10d7..b1f8fa1df0 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -940,27 +940,27 @@ void memory_region_init_ram_nomigrate(MemoryRegion *mr,
                                       Error **errp);
 
 /**
- * memory_region_init_ram_shared_nomigrate:  Initialize RAM memory region.
- *                                           Accesses into the region will
- *                                           modify memory directly.
+ * memory_region_init_ram_flags_nomigrate:  Initialize RAM memory region.
+ *                                          Accesses into the region will
+ *                                          modify memory directly.
  *
  * @mr: the #MemoryRegion to be initialized.
  * @owner: the object that tracks the region's reference count
  * @name: Region name, becomes part of RAMBlock name used in migration stream
  *        must be unique within any device
  * @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.
  *
- * Note that this function is similar to memory_region_init_ram_nomigrate.
- * The only difference is part of the RAM region can be remapped.
+ * Note that this function does not do anything to cause the data in the
+ * RAM memory region to be migrated; that is the responsibility of the caller.
  */
-void memory_region_init_ram_shared_nomigrate(MemoryRegion *mr,
-                                             Object *owner,
-                                             const char *name,
-                                             uint64_t size,
-                                             bool share,
-                                             Error **errp);
+void memory_region_init_ram_flags_nomigrate(MemoryRegion *mr,
+                                            Object *owner,
+                                            const char *name,
+                                            uint64_t size,
+                                            uint32_t ram_flags,
+                                            Error **errp);
 
 /**
  * memory_region_init_resizeable_ram:  Initialize memory region with resizeable
diff --git a/scripts/coccinelle/memory-region-housekeeping.cocci b/scripts/coccinelle/memory-region-housekeeping.cocci
index c768d8140a..29651ebde9 100644
--- a/scripts/coccinelle/memory-region-housekeeping.cocci
+++ b/scripts/coccinelle/memory-region-housekeeping.cocci
@@ -127,8 +127,8 @@ static void device_fn(DeviceState *dev, ...)
 - memory_region_init_rom(E1, NULL, 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_shared_nomigrate(E1, obj, E2, E3, E4, E5);
+- memory_region_init_ram_flags_nomigrate(E1, NULL, 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, OBJECT(dev), E2, E3, E4);
 |
-- memory_region_init_ram_shared_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, NULL, E2, E3, E4, E5);
++ memory_region_init_ram_flags_nomigrate(E1, OBJECT(dev), E2, E3, E4, E5);
 )
   ...+>
 }
diff --git a/softmmu/memory.c b/softmmu/memory.c
index f777504ac5..5c0ff76c06 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -1531,22 +1531,22 @@ void memory_region_init_ram_nomigrate(MemoryRegion *mr,
                                       uint64_t size,
                                       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,
-                                             Object *owner,
-                                             const char *name,
-                                             uint64_t size,
-                                             bool share,
-                                             Error **errp)
+void memory_region_init_ram_flags_nomigrate(MemoryRegion *mr,
+                                            Object *owner,
+                                            const char *name,
+                                            uint64_t size,
+                                            uint32_t ram_flags,
+                                            Error **errp)
 {
     Error *err = NULL;
     memory_region_init(mr, owner, name, size);
     mr->ram = true;
     mr->terminates = true;
     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) {
         mr->size = int128_zero();
         object_unparent(OBJECT(mr));
@@ -1682,7 +1682,7 @@ void memory_region_init_rom_nomigrate(MemoryRegion *mr,
                                       uint64_t size,
                                       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;
 }
 
-- 
2.31.1




  parent reply	other threads:[~2021-06-15 14:06 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-15 13:38 [PULL 00/33] Misc patches for 2021-06-15 Paolo Bonzini
2021-06-15 13:38 ` [PULL 01/33] vnc: avoid deprecation warnings for SASL on OS X Paolo Bonzini
2021-06-15 13:38 ` [PULL 02/33] vl: Fix an assert failure in error path Paolo Bonzini
2021-06-15 13:38 ` [PULL 03/33] qemu-config: use qemu_opts_from_qdict Paolo Bonzini
2021-06-15 13:38 ` [PULL 04/33] block/scsi: correctly emulate the VPD block limits page Paolo Bonzini
2021-06-15 13:38 ` [PULL 05/33] runstate: Initialize Error * to NULL Paolo Bonzini
2021-06-15 13:38 ` [PULL 06/33] esp: only assert INTR_DC interrupt flag if selection fails Paolo Bonzini
2021-06-15 13:38 ` [PULL 07/33] esp: only set ESP_RSEQ at the start of the select sequence Paolo Bonzini
2021-06-15 13:38 ` [PULL 08/33] esp: allow non-DMA callback in esp_transfer_data() initial transfer Paolo Bonzini
2021-06-15 13:38 ` [PULL 09/33] esp: handle non-DMA transfers from the target one byte at a time Paolo Bonzini
2021-06-15 13:38 ` [PULL 10/33] esp: ensure PDMA write transfers are flushed from the FIFO to the target immediately Paolo Bonzini
2021-06-15 13:38 ` [PULL 11/33] esp: revert 75ef849696 "esp: correctly fill bus id with requested lun" Paolo Bonzini
2021-06-15 13:38 ` [PULL 12/33] esp: correctly accumulate extended messages for PDMA Paolo Bonzini
2021-06-15 13:38 ` [PULL 13/33] esp: fix migration version check in esp_is_version_5() Paolo Bonzini
2021-06-15 13:38 ` [PULL 14/33] esp: store lun coming from the MESSAGE OUT phase Paolo Bonzini
2021-06-15 13:38 ` [PULL 15/33] softmmu/physmem: Mark shared anonymous memory RAM_SHARED Paolo Bonzini
2021-06-15 13:38 ` [PULL 16/33] softmmu/physmem: Fix ram_block_discard_range() to handle shared anonymous memory Paolo Bonzini
2021-06-15 13:38 ` [PULL 17/33] softmmu/physmem: Fix qemu_ram_remap() " Paolo Bonzini
2021-06-15 13:38 ` [PULL 18/33] util/mmap-alloc: Factor out calculation of the pagesize for the guard page Paolo Bonzini
2021-06-15 13:38 ` [PULL 19/33] util/mmap-alloc: Factor out reserving of a memory region to mmap_reserve() Paolo Bonzini
2021-06-15 13:38 ` [PULL 20/33] util/mmap-alloc: Factor out activating of memory to mmap_activate() Paolo Bonzini
2021-06-15 13:38 ` [PULL 21/33] softmmu/memory: Pass ram_flags to qemu_ram_alloc_from_fd() Paolo Bonzini
2021-06-15 13:38 ` Paolo Bonzini [this message]
2021-06-15 13:38 ` [PULL 23/33] softmmu/memory: Pass ram_flags to qemu_ram_alloc() and qemu_ram_alloc_internal() Paolo Bonzini
2021-06-15 13:38 ` [PULL 24/33] util/mmap-alloc: Pass flags instead of separate bools to qemu_ram_mmap() Paolo Bonzini
2021-06-15 13:38 ` [PULL 25/33] memory: Introduce RAM_NORESERVE and wire it up in qemu_ram_mmap() Paolo Bonzini
2021-06-15 13:38 ` [PULL 26/33] util/mmap-alloc: Support RAM_NORESERVE via MAP_NORESERVE under Linux Paolo Bonzini
2021-06-15 13:38 ` [PULL 27/33] hostmem: Wire up RAM_NORESERVE via "reserve" property Paolo Bonzini
2021-06-15 13:38 ` [PULL 28/33] qmp: Clarify memory backend properties returned via query-memdev Paolo Bonzini
2021-06-15 13:38 ` [PULL 29/33] qmp: Include "share" property of memory backends Paolo Bonzini
2021-06-15 13:38 ` [PULL 30/33] hmp: Print "share" property of memory backends with "info memdev" Paolo Bonzini
2021-06-15 13:38 ` [PULL 31/33] qmp: Include "reserve" property of memory backends Paolo Bonzini
2021-06-15 13:38 ` [PULL 32/33] hmp: Print "reserve" property of memory backends with "info memdev" Paolo Bonzini
2021-06-15 13:38 ` [PULL 33/33] configure: map x32 to cpu_family x86_64 for meson Paolo Bonzini
2021-06-15 14:17 ` [PULL 00/33] Misc patches for 2021-06-15 Peter Maydell
2021-06-15 16:52   ` Philippe Mathieu-Daudé
2021-06-17 10:06     ` Alex Bennée
2021-06-17 12:55       ` Paolo Bonzini
2021-06-17 15:34       ` Thomas Huth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210615133855.775687-23-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=david@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=peterx@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.