Re: [PATCH v6 06/11] softmmu/memory: enable automatic deallocation of memory regions

2023-12-20 Thread Akihiko Odaki

On 2023/12/21 16:35, Xenia Ragiadakou wrote:


On 21/12/23 07:45, Akihiko Odaki wrote:

On 2023/12/19 16:53, Huang Rui wrote:

From: Xenia Ragiadakou 

When the memory region has a different life-cycle from that of her 
parent,
could be automatically released, once has been unparent and once all 
of her

references have gone away, via the object's free callback.

However, currently, the address space subsystem keeps references to the
memory region without first incrementing its object's reference count.
As a result, the automatic deallocation of the object, not taking into
account those references, results in use-after-free memory corruption.

More specifically, reference to the memory region is kept in flatview
ranges. If the reference count of the memory region is not incremented,
flatview_destroy(), that is asynchronous, may be called after memory
region's destruction. If the reference count of the memory region is
incremented, memory region's destruction will take place after
flatview_destroy() has released its references.

This patch increases the reference count of an owned memory region 
object
on each memory_region_ref() and decreases it on each 
memory_region_unref().


Why not pass the memory region itself as the owner parameter of 
memory_region_init_ram_ptr()?


Hmm, in that case, how will it be guaranteed that the VirtIOGPU won't 
disappear while the memory region is still in use?


You can object_ref() when you do memory_region_init_ram_ptr() and 
object_unref() when the memory region is being destroyed.




Re: [PATCH v6 06/11] softmmu/memory: enable automatic deallocation of memory regions

2023-12-20 Thread Xenia Ragiadakou



On 21/12/23 07:45, Akihiko Odaki wrote:

On 2023/12/19 16:53, Huang Rui wrote:

From: Xenia Ragiadakou 

When the memory region has a different life-cycle from that of her 
parent,
could be automatically released, once has been unparent and once all 
of her

references have gone away, via the object's free callback.

However, currently, the address space subsystem keeps references to the
memory region without first incrementing its object's reference count.
As a result, the automatic deallocation of the object, not taking into
account those references, results in use-after-free memory corruption.

More specifically, reference to the memory region is kept in flatview
ranges. If the reference count of the memory region is not incremented,
flatview_destroy(), that is asynchronous, may be called after memory
region's destruction. If the reference count of the memory region is
incremented, memory region's destruction will take place after
flatview_destroy() has released its references.

This patch increases the reference count of an owned memory region object
on each memory_region_ref() and decreases it on each 
memory_region_unref().


Why not pass the memory region itself as the owner parameter of 
memory_region_init_ram_ptr()?


Hmm, in that case, how will it be guaranteed that the VirtIOGPU won't 
disappear while the memory region is still in use?




Re: [PATCH v6 07/11] virtio-gpu: Handle resource blob commands

2023-12-20 Thread Xenia Ragiadakou



On 21/12/23 07:57, Akihiko Odaki wrote:

On 2023/12/19 16:53, Huang Rui wrote:

From: Antonio Caggiano 

Support BLOB resources creation, mapping and unmapping by calling the
new stable virglrenderer 0.10 interface. Only enabled when available and
via the blob config. E.g. -device virtio-vga-gl,blob=true

Signed-off-by: Antonio Caggiano 
Signed-off-by: Dmitry Osipenko 
Signed-off-by: Xenia Ragiadakou 
Signed-off-by: Huang Rui 
---

Changes in v6:
- Use new struct virgl_gpu_resource.
- Unmap, unref and destroy the resource only after the memory region
   has been completely removed.
- In unref check whether the resource is still mapped.
- In unmap_blob check whether the resource has been already unmapped.
- Fix coding style

  hw/display/virtio-gpu-virgl.c | 274 +-
  hw/display/virtio-gpu.c   |   4 +-
  meson.build   |   4 +
  3 files changed, 276 insertions(+), 6 deletions(-)

diff --git a/hw/display/virtio-gpu-virgl.c 
b/hw/display/virtio-gpu-virgl.c

index faab374336..5a3a292f79 100644
--- a/hw/display/virtio-gpu-virgl.c
+++ b/hw/display/virtio-gpu-virgl.c
@@ -17,6 +17,7 @@
  #include "trace.h"
  #include "hw/virtio/virtio.h"
  #include "hw/virtio/virtio-gpu.h"
+#include "hw/virtio/virtio-gpu-bswap.h"
  #include "ui/egl-helpers.h"
@@ -24,8 +25,62 @@
  struct virgl_gpu_resource {
  struct virtio_gpu_simple_resource res;
+    uint32_t ref;
+    VirtIOGPU *g;
+
+#ifdef HAVE_VIRGL_RESOURCE_BLOB
+    /* only blob resource needs this region to be mapped as guest 
mmio */

+    MemoryRegion *region;


Why not just embed MemoryRegion into struct virgl_gpu_resource instead 
of having a pointer?


To decouple memory region from the resource. Since there are different 
commands for creating and mapping maybe there is the intention to map 
the same resource multiple times. If the lifecycle of the resource is 
tightly coupled to the lifecycle of the memory region then the memory 
region could be embedded into the struct. Ray could give more insight.





+#endif
  };
+static void vres_get_ref(struct virgl_gpu_resource *vres)
+{
+    uint32_t ref;
+
+    ref = qatomic_fetch_inc(>ref);
+    g_assert(ref < INT_MAX);
+}
+
+static void virgl_resource_destroy(struct virgl_gpu_resource *vres)
+{
+    struct virtio_gpu_simple_resource *res;
+    VirtIOGPU *g;
+
+    if (!vres) {
+    return;
+    }
+
+    g = vres->g;
+    res = >res;
+    QTAILQ_REMOVE(>reslist, res, next);
+    virtio_gpu_cleanup_mapping(g, res);
+    g_free(vres);
+}
+
+static void virgl_resource_unref(struct virgl_gpu_resource *vres)
+{
+    struct virtio_gpu_simple_resource *res;
+
+    if (!vres) {
+    return;
+    }
+
+    res = >res;
+    virgl_renderer_resource_detach_iov(res->resource_id, NULL, NULL);
+    virgl_renderer_resource_unref(res->resource_id);
+}
+
+static void vres_put_ref(struct virgl_gpu_resource *vres)
+{
+    g_assert(vres->ref > 0);
+
+    if (qatomic_fetch_dec(>ref) == 1) {
+    virgl_resource_unref(vres);
+    virgl_resource_destroy(vres);
+    }
+}
+
  static struct virgl_gpu_resource *
  virgl_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id)
  {
@@ -59,6 +114,8 @@ static void virgl_cmd_create_resource_2d(VirtIOGPU *g,
 c2d.width, c2d.height);
  vres = g_new0(struct virgl_gpu_resource, 1);
+    vres_get_ref(vres);
+    vres->g = g;
  vres->res.width = c2d.width;
  vres->res.height = c2d.height;
  vres->res.format = c2d.format;
@@ -91,6 +148,8 @@ static void virgl_cmd_create_resource_3d(VirtIOGPU *g,
 c3d.width, c3d.height, 
c3d.depth);

  vres = g_new0(struct virgl_gpu_resource, 1);
+    vres_get_ref(vres);
+    vres->g = g;
  vres->res.width = c3d.width;
  vres->res.height = c3d.height;
  vres->res.format = c3d.format;
@@ -126,12 +185,21 @@ static void virgl_cmd_resource_unref(VirtIOGPU *g,
  return;
  }
-    virgl_renderer_resource_detach_iov(unref.resource_id, NULL, NULL);
-    virgl_renderer_resource_unref(unref.resource_id);
+#ifdef HAVE_VIRGL_RESOURCE_BLOB
+    if (vres->region) {
+    VirtIOGPUBase *b = VIRTIO_GPU_BASE(g);
+    MemoryRegion *mr = vres->region;
+
+    warn_report("%s: blob resource %d not unmapped",
+    __func__, unref.resource_id);
+    vres->region = NULL;
+    memory_region_set_enabled(mr, false);
+    memory_region_del_subregion(>hostmem, mr);
+    object_unparent(OBJECT(mr));
+    }
+#endif /* HAVE_VIRGL_RESOURCE_BLOB */
-    QTAILQ_REMOVE(>reslist, >res, next);
-    virtio_gpu_cleanup_mapping(g, >res);
-    g_free(vres);
+    vres_put_ref(vres);


What will happen if the guest consecutively requests 
VIRTIO_GPU_CMD_RESOURCE_UNREF twice for a mapped resource?


You are right. I think the resource needs to be removed from the list 
synchronously on first unref.




Re: [PATCH 3/6] fixup scsi: only access SCSIDevice->requests from one thread

2023-12-20 Thread Paolo Bonzini

On 12/21/23 02:49, Stefan Hajnoczi wrote:

Signed-off-by: Stefan Hajnoczi 
---
  hw/scsi/scsi-bus.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index df68a44b6a..5b08cbf60a 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -127,7 +127,8 @@ static void scsi_device_for_each_req_async_bh(void *opaque)
   */
  ctx = blk_get_aio_context(s->conf.blk);
  if (ctx != qemu_get_current_aio_context()) {
-aio_bh_schedule_oneshot(ctx, scsi_device_for_each_req_async_bh, data);
+aio_bh_schedule_oneshot(ctx, scsi_device_for_each_req_async_bh,
+g_steal_pointer());
  return;
  }
  


Reviewed-by: Paolo Bonzini 




Re: [PATCH] target/i386: Add new CPU model SierraForest

2023-12-20 Thread Xiaoyao Li

On 12/6/2023 9:19 PM, Tao Su wrote:

SierraForest is Intel's first generation E-core based Xeon server
processor, which will be released in the first half of 2024.

SierraForest mainly adds the following new features based on
GraniteRapids:

- CMPCCXADD CPUID.(EAX=7,ECX=1):EAX[bit 7]
- AVX-IFMA CPUID.(EAX=7,ECX=1):EAX[bit 23]
- AVX-VNNI-INT8 CPUID.(EAX=7,ECX=1):EDX[bit 4]
- AVX-NE-CONVERT CPUID.(EAX=7,ECX=1):EDX[bit 5]
- LAM CPUID.(EAX=7,ECX=1):EAX[bit 26]
- LASS CPUID.(EAX=7,ECX=1):EAX[bit 6]

and removes the following features based on GraniteRapids:

- HLE CPUID.(EAX=7,ECX=0):EBX[bit 4]
- RTM CPUID.(EAX=7,ECX=0):EBX[bit 11]
- AVX512F CPUID.(EAX=7,ECX=0):EBX[bit 16]
- AVX512DQ CPUID.(EAX=7,ECX=0):EBX[bit 17]
- AVX512_IFMA CPUID.(EAX=7,ECX=0):EBX[bit 21]
- AVX512CD CPUID.(EAX=7,ECX=0):EBX[bit 28]
- AVX512BW CPUID.(EAX=7,ECX=0):EBX[bit 30]
- AVX512VL CPUID.(EAX=7,ECX=0):EBX[bit 31]
- AVX512_VBMI CPUID.(EAX=7,ECX=0):ECX[bit 1]
- AVX512_VBMI2 CPUID.(EAX=7,ECX=0):ECX[bit 6]
- AVX512_VNNI CPUID.(EAX=7,ECX=0):ECX[bit 11]
- AVX512_BITALG CPUID.(EAX=7,ECX=0):ECX[bit 12]
- AVX512_VPOPCNTDQ CPUID.(EAX=7,ECX=0):ECX[bit 14]
- LA57 CPUID.(EAX=7,ECX=0):ECX[bit 16]
- TSXLDTRK CPUID.(EAX=7,ECX=0):EDX[bit 16]
- AMX-BF16 CPUID.(EAX=7,ECX=0):EDX[bit 22]
- AVX512_FP16 CPUID.(EAX=7,ECX=0):EDX[bit 23]
- AMX-TILE CPUID.(EAX=7,ECX=0):EDX[bit 24]
- AMX-INT8 CPUID.(EAX=7,ECX=0):EDX[bit 25]
- AVX512_BF16 CPUID.(EAX=7,ECX=1):EAX[bit 5]
- fast zero-length MOVSB CPUID.(EAX=7,ECX=1):EAX[bit 10]
- fast short CMPSB, SCASB CPUID.(EAX=7,ECX=1):EAX[bit 12]
- AMX-FP16 CPUID.(EAX=7,ECX=1):EAX[bit 21]
- PREFETCHI CPUID.(EAX=7,ECX=1):EDX[bit 14]
- XFD CPUID.(EAX=0xD,ECX=1):EAX[bit 4]
- EPT_PAGE_WALK_LENGTH_5 VMX_EPT_VPID_CAP(0x48c)[bit 7]

SierraForest doesn't support TSX, so TSX Async Abort(TAA) vulnerabilities
don't exist on SierraForest. On KVM side, if host doesn't enumerate RTM
or RTM gets disabled, ARCH_CAP_TAA_NO is reported as unsupported. To
avoid the confusing warning:
warning: host doesn't support requested feature: MSR(10AH).taa-no
  [bit 8]

just don't include TAA_NO in SierraForest CPU model.

Currently LAM and LASS are not enabled in KVM mainline yet,  will add
them after merged.

Signed-off-by: Tao Su 


Reviewed-by: Xiaoyao Li 


---
The new features can be found in Intel ISE[1].
LAM has just been accepted by KVM[2].

Although we would like to include all SierraForest features in the first
version of the CPU model, SierraForest will be released in the first half
of 2024[3], we would want user can have a first usable SierraForest CPU
model in the QEMU when they have the hardware in their hand.

[1] https://cdrdv2.intel.com/v1/dl/getContent/671368
[2]
https://lore.kernel.org/all/169810442917.2499338.3440694989716170017.b4...@google.com/
[3]
https://www.intel.com/content/www/us/en/newsroom/news/tackling-throughput-computing-sierra-forest.html
---
  target/i386/cpu.c | 126 ++
  1 file changed, 126 insertions(+)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index cd16cb893d..2405c9e407 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -4099,6 +4099,132 @@ static const X86CPUDefinition builtin_x86_defs[] = {
  { /* end of list */ },
  },
  },
+{
+.name = "SierraForest",
+.level = 0x23,
+.vendor = CPUID_VENDOR_INTEL,
+.family = 6,
+.model = 175,
+.stepping = 0,
+/*
+ * please keep the ascending order so that we can have a clear view of
+ * bit position of each feature.
+ */
+.features[FEAT_1_EDX] =
+CPUID_FP87 | CPUID_VME | CPUID_DE | CPUID_PSE | CPUID_TSC |
+CPUID_MSR | CPUID_PAE | CPUID_MCE | CPUID_CX8 | CPUID_APIC |
+CPUID_SEP | CPUID_MTRR | CPUID_PGE | CPUID_MCA | CPUID_CMOV |
+CPUID_PAT | CPUID_PSE36 | CPUID_CLFLUSH | CPUID_MMX | CPUID_FXSR |
+CPUID_SSE | CPUID_SSE2,
+.features[FEAT_1_ECX] =
+CPUID_EXT_SSE3 | CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSSE3 |
+CPUID_EXT_FMA | CPUID_EXT_CX16 | CPUID_EXT_PCID | CPUID_EXT_SSE41 |
+CPUID_EXT_SSE42 | CPUID_EXT_X2APIC | CPUID_EXT_MOVBE |
+CPUID_EXT_POPCNT | CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_AES |
+CPUID_EXT_XSAVE | CPUID_EXT_AVX | CPUID_EXT_F16C | 
CPUID_EXT_RDRAND,
+.features[FEAT_8000_0001_EDX] =
+CPUID_EXT2_SYSCALL | CPUID_EXT2_NX | CPUID_EXT2_PDPE1GB |
+CPUID_EXT2_RDTSCP | CPUID_EXT2_LM,
+.features[FEAT_8000_0001_ECX] =
+CPUID_EXT3_LAHF_LM | CPUID_EXT3_ABM | CPUID_EXT3_3DNOWPREFETCH,
+.features[FEAT_8000_0008_EBX] =
+CPUID_8000_0008_EBX_WBNOINVD,
+.features[FEAT_7_0_EBX] =
+CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 | CPUID_7_0_EBX_AVX2 |
+CPUID_7_0_EBX_SMEP | CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ERMS |
+CPUID_7_0_EBX_INVPCID | CPUID_7_0_EBX_RDSEED | 

Re: [PATCH v2 09/17] hw/loongarch: Fix fdt memory node wrong 'reg'

2023-12-20 Thread maobibo




On 2023/12/18 下午5:00, Song Gao wrote:

The right fdt memory node like [1], not [2]

   [1]
 memory@0 {
 device_type = "memory";
 reg = <0x00 0x00 0x00 0x1000>;
 };
   [2]
 memory@0 {
 device_type = "memory";
 reg = <0x02 0x00 0x02 0x1000>;
 };

Signed-off-by: Song Gao 
---
  hw/loongarch/virt.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
index c45e724961..eaa0824f73 100644
--- a/hw/loongarch/virt.c
+++ b/hw/loongarch/virt.c
@@ -290,7 +290,7 @@ static void fdt_add_memory_node(MachineState *ms,
  char *nodename = g_strdup_printf("/memory@%" PRIx64, base);
  
  qemu_fdt_add_subnode(ms->fdt, nodename);

-qemu_fdt_setprop_cells(ms->fdt, nodename, "reg", 2, base, 2, size);
+qemu_fdt_setprop_cells(ms->fdt, nodename, "reg", 0, base, 0, size);
  qemu_fdt_setprop_string(ms->fdt, nodename, "device_type", "memory");
  
  if (ms->numa_state && ms->numa_state->num_nodes) {




Reviewed-by: Bibo Mao 




Re: [PATCH 6/6] nbd/server: introduce NBDClient->lock to protect fields

2023-12-20 Thread Paolo Bonzini

On 12/21/23 02:49, Stefan Hajnoczi wrote:

  nbd_client_receive_next_request(client);
+
+qemu_mutex_unlock(>lock);
+
  if (ret == -EIO) {
  goto disconnect;
  }


I think I slightly prefer if disconnect is reached with lock taken, for 
consistency with the "done" label.  It does not complicate the code,

because you can just move qio_channel_set_cork() and replace:


@@ -3024,8 +3072,10 @@ static coroutine_fn void nbd_trip(void *opaque)
  }
  
  qio_channel_set_cork(client->ioc, false);

+qemu_mutex_lock(>lock);


with:

+qio_channel_set_cork(client->ioc, false);
+qemu_mutex_lock(>lock);

 if (ret < 0) {
 error_prepend(_err, "Failed to send reply: ");
 goto disconnect;
 }

 /*
  * We must disconnect after NBD_CMD_WRITE or BLOCK_STATUS with
  * payload if we did not read the payload.
  */
 if (!req->complete) {
 error_setg(_err, "Request handling failed in 
intermediate state");

 goto disconnect;
 }
-qio_channel_set_cork(client->ioc, false);
 done:

Thanks,

Paolo


  done:
  nbd_request_put(req);
+qemu_mutex_unlock(>lock);





Re: [PATCH 4/6] nbd/server: avoid per-NBDRequest nbd_client_get/put()

2023-12-20 Thread Paolo Bonzini

On 12/21/23 02:49, Stefan Hajnoczi wrote:

nbd_trip() processes a single NBD request from start to finish and holds
an NBDClient reference throughout. NBDRequest does not outlive the scope
of nbd_trip(). Therefore it is unnecessary to ref/unref NBDClient for
each NBDRequest.

Removing these nbd_client_get()/nbd_client_put() calls will make
thread-safety easier in the commits that follow.

Signed-off-by: Stefan Hajnoczi 
---
  nbd/server.c | 3 ---
  1 file changed, 3 deletions(-)

diff --git a/nbd/server.c b/nbd/server.c
index 895cf0a752..0b09ccc8dc 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -1557,7 +1557,6 @@ static NBDRequestData *nbd_request_get(NBDClient *client)
  client->nb_requests++;
  
  req = g_new0(NBDRequestData, 1);

-nbd_client_get(client);
  req->client = client;
  return req;
  }
@@ -1578,8 +1577,6 @@ static void nbd_request_put(NBDRequestData *req)
  }
  
  nbd_client_receive_next_request(client);

-
-nbd_client_put(client);
  }
  
  static void blk_aio_attached(AioContext *ctx, void *opaque)


Reviewed-by: Paolo Bonzini 





Re: [PATCH 5/6] nbd/server: only traverse NBDExport->clients from main loop thread

2023-12-20 Thread Paolo Bonzini

On 12/21/23 02:49, Stefan Hajnoczi wrote:

The NBD clients list is currently accessed from both the export
AioContext and the main loop thread. When the AioContext lock is removed
there will be nothing protecting the clients list.

Adding a lock around the clients list is tricky because NBDClient
structs are refcounted and may be freed from the export AioContext or
the main loop thread. nbd_export_request_shutdown() -> client_close() ->
nbd_client_put() is also tricky because the list lock would be held
while indirectly dropping references to NDBClients.

A simpler approach is to only allow nbd_client_put() and client_close()
calls from the main loop thread. Then the NBD clients list is only
accessed from the main loop thread and no fancy locking is needed.

nbd_trip() just needs to reschedule itself in the main loop AioContext
before calling nbd_client_put() and client_close(). This costs more CPU
cycles per NBD request but is needed for thread-safety when the
AioContext lock is removed.

Note that nbd_client_get() can still be called from either thread, so
make NBDClient->refcount atomic.

Signed-off-by: Stefan Hajnoczi 
---
  nbd/server.c | 23 ---
  1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/nbd/server.c b/nbd/server.c
index 0b09ccc8dc..527fbdab4a 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -122,7 +122,7 @@ struct NBDMetaContexts {
  };
  
  struct NBDClient {

-int refcount;
+int refcount; /* atomic */
  void (*close_fn)(NBDClient *client, bool negotiated);
  
  NBDExport *exp;

@@ -1501,14 +1501,17 @@ static int coroutine_fn nbd_receive_request(NBDClient 
*client, NBDRequest *reque
  
  #define MAX_NBD_REQUESTS 16
  
+/* Runs in export AioContext and main loop thread */

  void nbd_client_get(NBDClient *client)
  {
-client->refcount++;
+qatomic_inc(>refcount);
  }
  
  void nbd_client_put(NBDClient *client)

  {
-if (--client->refcount == 0) {
+assert(qemu_in_main_thread());
+
+if (qatomic_fetch_dec(>refcount) == 1) {
  /* The last reference should be dropped by client->close,
   * which is called by client_close.
   */
@@ -1531,6 +1534,8 @@ void nbd_client_put(NBDClient *client)
  
  static void client_close(NBDClient *client, bool negotiated)

  {
+assert(qemu_in_main_thread());
+
  if (client->closing) {
  return;
  }
@@ -2938,8 +2943,15 @@ static coroutine_fn void nbd_trip(void *opaque)
  int ret;
  Error *local_err = NULL;
  
+/*

+ * Note that nbd_client_put() and client_close() must be called from the
+ * main loop thread. Use aio_co_reschedule_self() to switch AioContext
+ * before calling these functions.
+ */
+
  trace_nbd_trip();
  if (client->closing) {
+aio_co_reschedule_self(qemu_get_aio_context());
  nbd_client_put(client);
  return;
  }
@@ -2949,6 +2961,7 @@ static coroutine_fn void nbd_trip(void *opaque)
   * We're switching between AIO contexts. Don't attempt to receive a 
new
   * request and kick the main context which may be waiting for us.
   */
+aio_co_reschedule_self(qemu_get_aio_context());
  nbd_client_put(client);
  client->recv_coroutine = NULL;
  aio_wait_kick();
@@ -3013,6 +3026,8 @@ static coroutine_fn void nbd_trip(void *opaque)
  qio_channel_set_cork(client->ioc, false);
  done:
  nbd_request_put(req);
+
+aio_co_reschedule_self(qemu_get_aio_context());
  nbd_client_put(client);
  return;


This is very expensive to do on every NBD receive, considering that it really
can happen only when closing (see the assertion in nbd_client_put).

In Linux there is a common pattern of "if refcount could go to zero, take
a lock before doing the decrement".  We can do something similar with "if
refcount could go to zero, move to main iothread before doing the decrement":

diff --git a/nbd/server.c b/nbd/server.c
index 895cf0a7525..aec306923d8 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -1529,6 +1529,21 @@ void nbd_client_put(NBDClient *client)
 }
 }
 
+static bool nbd_client_put_nonzero(NBDClient *client)

+{
+int old = qatomic_read(>refcount);
+do {
+if (old == 1) {
+return false;
+}
+
+int expected = old;
+old = qatomic_cmpxchg(>refcount, expected, expected - 1);
+} while (old != expected);
+
+return true;
+}
+
 static void client_close(NBDClient *client, bool negotiated)
 {
 if (client->closing) {
@@ -2936,15 +2951,14 @@ static coroutine_fn int nbd_handle_request(NBDClient 
*client,
 static coroutine_fn void nbd_trip(void *opaque)
 {
 NBDClient *client = opaque;
-NBDRequestData *req;
+NBDRequestData *req = NULL;
 NBDRequest request = { 0 };/* GCC thinks it can be used uninitialized 
*/
 int ret;
 Error *local_err = NULL;
 
 trace_nbd_trip();

 if (client->closing) {
-nbd_client_put(client);
-return;

Re: [PATCH v2 04/17] hw/loongarch: Add slave cpu boot_code

2023-12-20 Thread maobibo




On 2023/12/18 下午5:00, Song Gao wrote:

Signed-off-by: Song Gao 
---
  hw/loongarch/boot.c | 65 -
  1 file changed, 64 insertions(+), 1 deletion(-)

diff --git a/hw/loongarch/boot.c b/hw/loongarch/boot.c
index 4bfe24274a..076e795714 100644
--- a/hw/loongarch/boot.c
+++ b/hw/loongarch/boot.c
@@ -14,6 +14,62 @@
  #include "qemu/error-report.h"
  #include "sysemu/reset.h"
  
+enum {

+SLAVE_BOOT,
+};
+
+static const MemMapEntry loader_rommap[] = {
+[SLAVE_BOOT] = {0xf10, 0x1},
+};

Address 0xf10 had better be defined before 0x10

Regards
Bibo Mao


+
+static unsigned int slave_boot_code[] = {
+  /* Configure reset ebase. */
+0x0400302c,   /* csrwr  $r12,0xc*/
+
+  /* Disable interrupt. */
+0x0380100c,   /* ori$r12,$r0,0x4*/
+0x04000180,   /* csrxchg$r0,$r12,0x0*/
+
+  /* Clear mailbox. */
+0x142d,   /* lu12i.w$r13,1(0x1) */
+0x038081ad,   /* ori$r13,$r13,0x20  */
+0x06481da0,   /* iocsrwr.d  $r0,$r13*/
+
+  /* Enable IPI interrupt.  */
+0x142c,   /* lu12i.w$r12,1(0x1) */
+0x0400118c,   /* csrxchg$r12,$r12,0x4   */
+0x02fffc0c,   /* addi.d $r12,$r0,-1(0xfff)  */
+0x142d,   /* lu12i.w$r13,1(0x1) */
+0x038011ad,   /* ori$r13,$r13,0x4   */
+0x064819ac,   /* iocsrwr.w  $r12,$r13   */
+0x142d,   /* lu12i.w$r13,1(0x1) */
+0x038081ad,   /* ori$r13,$r13,0x20  */
+
+  /* Wait for wakeup  <.L11>:   */
+0x06488000,   /* idle   0x0 */
+0x0340,   /* andi   $r0,$r0,0x0 */
+0x064809ac,   /* iocsrrd.w  $r12,$r13   */
+0x43fff59f,   /* beqz   $r12,-12(0x74) # 48 <.L11> */
+
+  /* Read and clear IPI interrupt.  */
+0x142d,   /* lu12i.w$r13,1(0x1) */
+0x064809ac,   /* iocsrrd.w  $r12,$r13   */
+0x142d,   /* lu12i.w$r13,1(0x1) */
+0x038031ad,   /* ori$r13,$r13,0xc   */
+0x064819ac,   /* iocsrwr.w  $r12,$r13   */
+
+  /* Disable  IPI interrupt.*/
+0x142c,   /* lu12i.w$r12,1(0x1) */
+0x04001180,   /* csrxchg$r0,$r12,0x4*/
+
+  /* Read mail buf and jump to specified entry */
+0x142d,   /* lu12i.w$r13,1(0x1) */
+0x038081ad,   /* ori$r13,$r13,0x20  */
+0x06480dac,   /* iocsrrd.d  $r12,$r13   */
+0x00150181,   /* move   $r1,$r12*/
+0x4c20,   /* jirl   $r0,$r1,0   */
+};
+
  static int init_cmdline(struct loongarch_boot_info *info)
  {
  hwaddr cmdline_addr;
@@ -145,10 +201,17 @@ static void 
loongarch_direct_kernel_boot(LoongArchMachineState *lams,
  exit(1);
  }
  
+rom_add_blob_fixed("slave_boot", slave_boot_code, sizeof(slave_boot_code),

+   loader_rommap[SLAVE_BOOT].base);
+
  for (i = 0; i < machine->smp.cpus; i++) {
  lacpu = LOONGARCH_CPU(qemu_get_cpu(i));
  lacpu->env.load_elf = true;
-lacpu->env.elf_address = kernel_addr;
+if (i == 0) {
+lacpu->env.elf_address = kernel_addr;
+} else {
+lacpu->env.elf_address = loader_rommap[SLAVE_BOOT].base;
+}
  lacpu->env.boot_info = info;
  }
  }






Re: [PATCH v2 03/17] hw/loongarch: Add init_cmdline

2023-12-20 Thread maobibo




On 2023/12/18 下午5:00, Song Gao wrote:

Add init_cmline and set boot_info->a0, a1

Signed-off-by: Song Gao 
---
  hw/loongarch/boot.c | 21 +
  include/hw/loongarch/virt.h |  2 ++
  target/loongarch/cpu.h  |  2 ++
  3 files changed, 25 insertions(+)

diff --git a/hw/loongarch/boot.c b/hw/loongarch/boot.c
index 2be6dfb037..4bfe24274a 100644
--- a/hw/loongarch/boot.c
+++ b/hw/loongarch/boot.c
@@ -14,6 +14,20 @@
  #include "qemu/error-report.h"
  #include "sysemu/reset.h"
  
+static int init_cmdline(struct loongarch_boot_info *info)

+{
+hwaddr cmdline_addr;
+cmdline_addr = 0xff0ULL;
+
+pstrcpy_targphys("cmdline", 0xff0ULL,
+ COMMAND_LINE_SIZE, info->kernel_cmdline);
There are two places using 0xff0ULL here, it had better be defined 
as macro. Also can address for cmdline be before FDT base 
address(0x10) rather than strange value 0xff0 ? -:)



+
+info->a0 = 1;
+info->a1 = cmdline_addr;
+
+return 0;
+}
+
  static uint64_t cpu_loongarch_virt_to_phys(void *opaque, uint64_t addr)
  {
  return addr & MAKE_64BIT_MASK(0, TARGET_PHYS_ADDR_SPACE_BITS);
@@ -63,6 +77,8 @@ static int64_t load_kernel_info(struct loongarch_boot_info 
*info)
  exit(1);
  }
  
+init_cmdline(info);

+
  return kernel_entry;
  }
  
@@ -73,6 +89,10 @@ static void reset_load_elf(void *opaque)
  
  cpu_reset(CPU(cpu));

  if (env->load_elf) {
+   if (cpu == LOONGARCH_CPU(first_cpu)) {
+env->gpr[4] = env->boot_info->a0;
+env->gpr[5] = env->boot_info->a1;
+}
  cpu_set_pc(CPU(cpu), env->elf_address);
  }
  }
@@ -129,6 +149,7 @@ static void 
loongarch_direct_kernel_boot(LoongArchMachineState *lams,
  lacpu = LOONGARCH_CPU(qemu_get_cpu(i));
  lacpu->env.load_elf = true;
  lacpu->env.elf_address = kernel_addr;
+lacpu->env.boot_info = info;
  }
  }
  
diff --git a/include/hw/loongarch/virt.h b/include/hw/loongarch/virt.h

index e4126dd0e7..d21de2cef4 100644
--- a/include/hw/loongarch/virt.h
+++ b/include/hw/loongarch/virt.h
@@ -31,6 +31,8 @@
  #define VIRT_GED_MEM_ADDR   (VIRT_GED_EVT_ADDR + ACPI_GED_EVT_SEL_LEN)
  #define VIRT_GED_REG_ADDR   (VIRT_GED_MEM_ADDR + MEMORY_HOTPLUG_IO_LEN)
  
+#define COMMAND_LINE_SIZE   512
The macro COMMAND_LINE_SIZE is already defined in Linux header file, 
maybe standard header file can be used.


/usr/include/asm-generic/setup.h
#define COMMAND_LINE_SIZE  512


Regards
Bibo Mao

+
  struct LoongArchMachineState {
  /*< private >*/
  MachineState parent_obj;
diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h
index 00d1fba597..c7c695138e 100644
--- a/target/loongarch/cpu.h
+++ b/target/loongarch/cpu.h
@@ -362,6 +362,8 @@ typedef struct CPUArchState {
  uint64_t elf_address;
  /* Store ipistate to access from this struct */
  DeviceState *ipistate;
+
+struct loongarch_boot_info *boot_info;
  #endif
  } CPULoongArchState;
  






Re: [PATCH v7] ui/cocoa: Use NSWindow's ability to resize

2023-12-20 Thread Akihiko Odaki

On 2023/12/20 5:06, Marek Glogowski wrote:

Hi

For me, the problem does not occur if you use the maximum screen 
resolution available.

For me it is 1680x1050 - everything works fine.
When I change the screen preference to a smaller screen resolution than 
my maximum (1440x900,1024x768 ...) the mouse starts to malfunction. The 
mouse pointer works strenuously and with a delay.


Checked on the current version with git qemu-system-ppc AOS4 with V8 and 
V7 patch and the older version qemu-system-aarch64 Linux/Fedora


Please tell me your whole command line. It is also nice if you test the 
combination of  latest QEMU with and without the patches and Fedora.




Re: [PATCH v2 02/17] hw/loongarch: Add load initrd

2023-12-20 Thread maobibo




On 2023/12/18 下午5:00, Song Gao wrote:

we load initrd ramdisk after kernel_high address

Signed-off-by: Song Gao 
---
  hw/loongarch/boot.c | 29 -
  1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/hw/loongarch/boot.c b/hw/loongarch/boot.c
index 9f25ea5847..2be6dfb037 100644
--- a/hw/loongarch/boot.c
+++ b/hw/loongarch/boot.c
@@ -21,7 +21,8 @@ static uint64_t cpu_loongarch_virt_to_phys(void *opaque, 
uint64_t addr)
  
  static int64_t load_kernel_info(struct loongarch_boot_info *info)

  {
-uint64_t kernel_entry, kernel_low, kernel_high;
+uint64_t kernel_entry, kernel_low, kernel_high, initrd_size;
+ram_addr_t initrd_offset;
  ssize_t kernel_size;
  
  kernel_size = load_elf(info->kernel_filename, NULL,

@@ -36,6 +37,32 @@ static int64_t load_kernel_info(struct loongarch_boot_info 
*info)
   load_elf_strerror(kernel_size));
  exit(1);
  }
+
+if (info->initrd_filename) {
+initrd_size = get_image_size(info->initrd_filename);
+if (initrd_size > 0) {
+initrd_offset = ROUND_UP(kernel_high, 64 * KiB);

Do you test self-compressed vmlinuz elf load?

I think that offset of initrd had better be 4 * kernel_size from 
kernel_high, else uncompressed kernel may overwrite INITRD image.

such as:
 initrd_offset = ROUND_UP(kernel_high + 4 * kernel_size, 64 * KiB);

Regards
Bibo Mao

+
+if (initrd_offset + initrd_size > info->ram_size) {
+error_report("memory too small for initial ram disk '%s'",
+ info->initrd_filename);
+exit(1);
+}
+
+initrd_size = load_image_targphys(info->initrd_filename, 
initrd_offset,
+  info->ram_size - initrd_offset);
+}
+
+if (initrd_size == (target_ulong)-1) {
+error_report("could not load initial ram disk '%s'",
+ info->initrd_filename);
+exit(1);
+}
+} else {
+error_report("Need initrd!");
+exit(1);
+}
+
  return kernel_entry;
  }
  






Re: [PATCH v2 01/17] hw/loongarch: Move boot fucntions to boot.c

2023-12-20 Thread maobibo




On 2023/12/18 下午5:00, Song Gao wrote:

Move some boot functions to boot.c and struct
loongarch_boot_info into struct LoongArchMachineState.

Signed-off-by: Song Gao 
---
  hw/loongarch/boot.c | 127 
  hw/loongarch/meson.build|   1 +
  hw/loongarch/virt.c | 118 ++---
  include/hw/loongarch/boot.h |  21 ++
  include/hw/loongarch/virt.h |   2 +
  5 files changed, 155 insertions(+), 114 deletions(-)
  create mode 100644 hw/loongarch/boot.c
  create mode 100644 include/hw/loongarch/boot.h

diff --git a/hw/loongarch/boot.c b/hw/loongarch/boot.c
new file mode 100644
index 00..9f25ea5847
--- /dev/null
+++ b/hw/loongarch/boot.c
@@ -0,0 +1,127 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * LoongArch boot helper functions.
+ *
+ * Copyright (c) 2023 Loongson Technology Corporation Limited
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/units.h"
+#include "target/loongarch/cpu.h"
+#include "hw/loongarch/virt.h"
+#include "hw/loader.h"
+#include "elf.h"
+#include "qemu/error-report.h"
+#include "sysemu/reset.h"
+
+static uint64_t cpu_loongarch_virt_to_phys(void *opaque, uint64_t addr)
+{
+return addr & MAKE_64BIT_MASK(0, TARGET_PHYS_ADDR_SPACE_BITS);
+}
+
+static int64_t load_kernel_info(struct loongarch_boot_info *info)
+{
+uint64_t kernel_entry, kernel_low, kernel_high;
+ssize_t kernel_size;
+
+kernel_size = load_elf(info->kernel_filename, NULL,
+   cpu_loongarch_virt_to_phys, NULL,
+   _entry, _low,
+   _high, NULL, 0,
+   EM_LOONGARCH, 1, 0);
+
+if (kernel_size < 0) {
+error_report("could not load kernel '%s': %s",
+ info->kernel_filename,
+ load_elf_strerror(kernel_size));
+exit(1);
+}
+return kernel_entry;
+}
+
+static void reset_load_elf(void *opaque)
+{
+LoongArchCPU *cpu = opaque;
+CPULoongArchState *env = >env;
+
+cpu_reset(CPU(cpu));
+if (env->load_elf) {
+cpu_set_pc(CPU(cpu), env->elf_address);
+}
+}
+
+static void fw_cfg_add_kernel_info(struct loongarch_boot_info *info,
+   FWCfgState *fw_cfg)
+{
+/*
+ * Expose the kernel, the command line, and the initrd in fw_cfg.
+ * We don't process them here at all, it's all left to the
+ * firmware.
+ */
+load_image_to_fw_cfg(fw_cfg,
+ FW_CFG_KERNEL_SIZE, FW_CFG_KERNEL_DATA,
+ info->kernel_filename,
+ false);
+
+if (info->initrd_filename) {
+load_image_to_fw_cfg(fw_cfg,
+ FW_CFG_INITRD_SIZE, FW_CFG_INITRD_DATA,
+ info->initrd_filename, false);
+}
+
+if (info->kernel_cmdline) {
+fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE,
+   strlen(info->kernel_cmdline) + 1);
+fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA,
+  info->kernel_cmdline);
+}
+}
+
+static void loongarch_firmware_boot(LoongArchMachineState *lams,
+struct loongarch_boot_info *info)
+{
+fw_cfg_add_kernel_info(info, lams->fw_cfg);
+}
+
+static void loongarch_direct_kernel_boot(LoongArchMachineState *lams,
+ struct loongarch_boot_info *info)
+{
+MachineState *machine = MACHINE(lams);
+int64_t kernel_addr = 0;
+LoongArchCPU *lacpu;
+int i;
+
+if (info->kernel_filename) {
+kernel_addr = load_kernel_info(info);
+} else {
+error_report("Need kernel filename\n");
+exit(1);
+}
+
+for (i = 0; i < machine->smp.cpus; i++) {
+lacpu = LOONGARCH_CPU(qemu_get_cpu(i));
+lacpu->env.load_elf = true;
+lacpu->env.elf_address = kernel_addr;
+}
+}
+
+void loongarch_load_kernel(MachineState *ms, struct loongarch_boot_info *info)
+{
+LoongArchMachineState *lams = LOONGARCH_MACHINE(ms);
+int i;
+
+/* register reset function */
+for (i = 0; i < ms->smp.cpus; i++) {
+qemu_register_reset(reset_load_elf, LOONGARCH_CPU(qemu_get_cpu(i)));
+}
+
+info->kernel_filename = ms->kernel_filename;
+info->kernel_cmdline = ms->kernel_cmdline;
+info->initrd_filename = ms->initrd_filename;
+
+if (lams->bios_loaded) {
+loongarch_firmware_boot(lams, info);
+} else {
+loongarch_direct_kernel_boot(lams, info);
+}
+}
diff --git a/hw/loongarch/meson.build b/hw/loongarch/meson.build
index c0421502ab..d306d82c2e 100644
--- a/hw/loongarch/meson.build
+++ b/hw/loongarch/meson.build
@@ -1,6 +1,7 @@
  loongarch_ss = ss.source_set()
  loongarch_ss.add(files(
  'fw_cfg.c',
+'boot.c',
  ))
  loongarch_ss.add(when: 'CONFIG_LOONGARCH_VIRT', if_true: [files('virt.c'), 
fdt])
  loongarch_ss.add(when: 'CONFIG_ACPI', if_true: files('acpi-build.c'))
diff --git 

Re: [PATCH v6 01/11] linux-headers: Update to kernel headers to add venus capset

2023-12-20 Thread Akihiko Odaki

On 2023/12/19 23:14, Peter Maydell wrote:

On Tue, 19 Dec 2023 at 13:49, Huang Rui  wrote:


On Tue, Dec 19, 2023 at 08:20:22PM +0800, Akihiko Odaki wrote:

On 2023/12/19 16:53, Huang Rui wrote:

Sync up kernel headers to update venus macro till they are merged into
mainline.


Thanks for sorting things out with the kernel and spec.



Signed-off-by: Huang Rui 
---

Changes in v6:
- Venus capset is applied in kernel, so update it in qemu for future use.

https://lore.kernel.org/lkml/b79dcf75-c9e8-490e-644f-3b97d95f7...@collabora.com/
https://cgit.freedesktop.org/drm-misc/commit/?id=216d86b9a430f3280e5b631c51e6fd1a7774cfa0

Please include the link to the upstream commit in the commit message.


So far, it's in drm maintainers' branch not in kernel mainline yet. Do I
need to wait it to be merged into kernel mainline?


For an RFC patchset, no. For patches to be merged into QEMU
the headers change must be in the kernel mainline, and the
QEMU commit that updates our copy of the headers must be a
full-sync done with scripts/update-linux-headers.sh, not a
manual edit.


Apparently the kernel change is unlikely to be merged to mainline before 
QEMU 9.0 so we need to come up with some idea to deal with this.


The release of Linux 6.7 is near and the development of 6.8 will start 
soon. So it was nice if the change made into 6.8, but unfortunately it 
missed the *probably last* drm-misc tree pull request for 6.8:

https://lore.kernel.org/all/aqpn5miejmkks7pbcfex7b6u63uwsruywxsnr3x5ljs45qatin@nbkkej2elk46/

It will still get into linux-next so we may retrieve headers from 
linux-next. Or we may add the definition to 
hw/display/virtio-gpu-virgl.c; the duplicate definition warning will 
tell when the definition becomes no longer necessary. I'm fine with 
either option.


Regards,
Akihiko Odaki



Re: [PATCH v2 38/71] hw/loongarch: Constify VMState

2023-12-20 Thread gaosong

在 2023/12/21 上午11:16, Richard Henderson 写道:

Signed-off-by: Richard Henderson 
---
  hw/loongarch/acpi-build.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Song Gao 

Thanks.
Song Gao

diff --git a/hw/loongarch/acpi-build.c b/hw/loongarch/acpi-build.c
index ae292fc543..730bc4a748 100644
--- a/hw/loongarch/acpi-build.c
+++ b/hw/loongarch/acpi-build.c
@@ -564,7 +564,7 @@ static const VMStateDescription vmstate_acpi_build = {
  .name = "acpi_build",
  .version_id = 1,
  .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
  VMSTATE_UINT8(patched, AcpiBuildState),
  VMSTATE_END_OF_LIST()
  },





Re: [PATCH v2 09/71] target/loongarch: Constify VMState in machine.c

2023-12-20 Thread gaosong

在 2023/12/21 上午11:15, Richard Henderson 写道:

Signed-off-by: Richard Henderson 
---
  target/loongarch/machine.c | 18 +-
  1 file changed, 9 insertions(+), 9 deletions(-)

Reviewed-by: Song Gao 

Thanks.
Song Gao

diff --git a/target/loongarch/machine.c b/target/loongarch/machine.c
index 1c4e01d076..c7029fb9b4 100644
--- a/target/loongarch/machine.c
+++ b/target/loongarch/machine.c
@@ -14,7 +14,7 @@ static const VMStateDescription vmstate_fpu_reg = {
  .name = "fpu_reg",
  .version_id = 1,
  .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
  VMSTATE_UINT64(UD(0), VReg),
  VMSTATE_END_OF_LIST()
  }
@@ -36,7 +36,7 @@ static const VMStateDescription vmstate_fpu = {
  .version_id = 1,
  .minimum_version_id = 1,
  .needed = fpu_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
  VMSTATE_FPU_REGS(env.fpr, LoongArchCPU, 0),
  VMSTATE_UINT32(env.fcsr0, LoongArchCPU),
  VMSTATE_BOOL_ARRAY(env.cf, LoongArchCPU, 8),
@@ -48,7 +48,7 @@ static const VMStateDescription vmstate_lsxh_reg = {
  .name = "lsxh_reg",
  .version_id = 1,
  .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
  VMSTATE_UINT64(UD(1), VReg),
  VMSTATE_END_OF_LIST()
  }
@@ -70,7 +70,7 @@ static const VMStateDescription vmstate_lsx = {
  .version_id = 1,
  .minimum_version_id = 1,
  .needed = lsx_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
  VMSTATE_LSXH_REGS(env.fpr, LoongArchCPU, 0),
  VMSTATE_END_OF_LIST()
  },
@@ -80,7 +80,7 @@ static const VMStateDescription vmstate_lasxh_reg = {
  .name = "lasxh_reg",
  .version_id = 1,
  .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
  VMSTATE_UINT64(UD(2), VReg),
  VMSTATE_UINT64(UD(3), VReg),
  VMSTATE_END_OF_LIST()
@@ -103,7 +103,7 @@ static const VMStateDescription vmstate_lasx = {
  .version_id = 1,
  .minimum_version_id = 1,
  .needed = lasx_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
  VMSTATE_LASXH_REGS(env.fpr, LoongArchCPU, 0),
  VMSTATE_END_OF_LIST()
  },
@@ -114,7 +114,7 @@ const VMStateDescription vmstate_tlb = {
  .name = "cpu/tlb",
  .version_id = 0,
  .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
  VMSTATE_UINT64(tlb_misc, LoongArchTLB),
  VMSTATE_UINT64(tlb_entry0, LoongArchTLB),
  VMSTATE_UINT64(tlb_entry1, LoongArchTLB),
@@ -127,7 +127,7 @@ const VMStateDescription vmstate_loongarch_cpu = {
  .name = "cpu",
  .version_id = 1,
  .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
  VMSTATE_UINTTL_ARRAY(env.gpr, LoongArchCPU, 32),
  VMSTATE_UINTTL(env.pc, LoongArchCPU),
  
@@ -193,7 +193,7 @@ const VMStateDescription vmstate_loongarch_cpu = {
  
  VMSTATE_END_OF_LIST()

  },
-.subsections = (const VMStateDescription*[]) {
+.subsections = (const VMStateDescription * const []) {
  _fpu,
  _lsx,
  _lasx,





Re: [PATCH v4 0/4] Support RISC-V IOPMP

2023-12-20 Thread Ethan Chen via
On Mon, Dec 18, 2023 at 02:18:58PM +1000, Alistair Francis wrote:
> On Wed, Nov 22, 2023 at 3:36 PM Ethan Chen via  wrote:
> >
> > This series implements IOPMP specification v1.0.0-draft4 rapid-k model.
> > The specification url:
> > https://github.com/riscv-non-isa/iopmp-spec/blob/main/riscv_iopmp_specification.pdf
> >
> > When IOPMP is enabled, a DMA device ATCDMAC300 is added to RISC-V virt
> > platform. This DMA device is connected to the IOPMP and has the 
> > functionalities
> 
> I don't think we want to add an Andes DMA device to the virt machine.
> 
> I can't even find the spec for the ATCDMAC300, which isn't great
> 
> Alistair

Since the IOPMP does not take effect when there is no other device connects to
IOPMP, I think it is necessary to have a DMA device for IOPMP demonstration.

Do you have any suggestions for supporting IOPMP on RISC-V virt machine?

Thanks,
Ethan Chen

> 
> > required by IOPMP, including:
> > - Support setup the connection to IOPMP
> > - Support asynchronous I/O to handle stall transactions
> > - Send transaction information
> >
> > IOPMP takes a transaction which partially match an entry as a partially hit
> > error. The transaction size is depending on source device, destination 
> > device
> > and bus.
> >
> > Source device can send a transaction_info to IOPMP. IOPMP will check 
> > partially
> > hit by transaction_info. If source device does not send a transaction_info,
> > IOPMP checks information in IOMMU and dose not check partially hit.
> >
> > Changes for v4:
> >
> >   - Add descriptions of IOPMP and ATCDMAC300
> >   - Refine coding style and comments
> >   - config XILINX_AXI does not include file stream.c but selects config 
> > STREAM
> > instead.
> >   - ATCDMAC300: INT_STATUS is write 1 clear per bit
> > Rename iopmp_address_sink to 
> > transcation_info_sink
> >   - IOPMP: Refine error message and remove unused variable
> >   - VIRT: Document new options
> > atcdmac300 is only added when iopmp is enabled
> >   serial setting should not be changed
> >
> > Ethan Chen (4):
> >   hw/core: Add config stream
> >   Add RISC-V IOPMP support
> >   hw/dma: Add Andes ATCDMAC300 support
> >   hw/riscv/virt: Add IOPMP support
> >
> >  docs/system/riscv/virt.rst|  11 +
> >  hw/Kconfig|   1 +
> >  hw/core/Kconfig   |   3 +
> >  hw/core/meson.build   |   2 +-
> >  hw/dma/Kconfig|   4 +
> >  hw/dma/atcdmac300.c   | 566 ++
> >  hw/dma/meson.build|   1 +
> >  hw/misc/Kconfig   |   4 +
> >  hw/misc/meson.build   |   1 +
> >  hw/misc/riscv_iopmp.c | 966 ++
> >  hw/riscv/Kconfig  |   2 +
> >  hw/riscv/virt.c   |  65 ++
> >  include/hw/dma/atcdmac300.h   | 180 
> >  include/hw/misc/riscv_iopmp.h | 341 +++
> >  .../hw/misc/riscv_iopmp_transaction_info.h|  28 +
> >  include/hw/riscv/virt.h   |  10 +-
> >  16 files changed, 2183 insertions(+), 2 deletions(-)
> >  create mode 100644 hw/dma/atcdmac300.c
> >  create mode 100644 hw/misc/riscv_iopmp.c
> >  create mode 100644 include/hw/dma/atcdmac300.h
> >  create mode 100644 include/hw/misc/riscv_iopmp.h
> >  create mode 100644 include/hw/misc/riscv_iopmp_transaction_info.h
> >
> > --
> > 2.34.1
> >
> >



Re: [PATCH v2] qdev: Report an error for machine without HotplugHandler

2023-12-20 Thread Akihiko Odaki

On 2023/12/21 1:46, Zhao Liu wrote:

Hi Markus,

On Wed, Dec 20, 2023 at 08:53:21AM +0100, Markus Armbruster wrote:

Date: Wed, 20 Dec 2023 08:53:21 +0100
From: Markus Armbruster 
Subject: Re: [PATCH v2] qdev: Report an error for machine without
  HotplugHandler

Akihiko Odaki  writes:


On 2023/12/18 23:02, Markus Armbruster wrote:

Akihiko Odaki  writes:


On 2023/12/11 15:51, Markus Armbruster wrote:

Akihiko Odaki  writes:


The HotplugHandler of the machine will be used when the parent bus does
not exist, but the machine may not have one. Report an error in such a
case instead of aborting.

Fixes: 7716b8ca74 ("qdev: HotplugHandler: Add support for unplugging BUS-less 
devices")
Signed-off-by: Akihiko Odaki 


Do you have a reproducer for the crash?


---
Changes in v2:
- Fixed indention.
- Link to v1: 
https://lore.kernel.org/r/20231202-bus-v1-1-f7540e3a8...@daynix.com
---
system/qdev-monitor.c | 13 ++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c
index a13db763e5..5fe5d49c20 100644
--- a/system/qdev-monitor.c
+++ b/system/qdev-monitor.c
@@ -927,9 +927,16 @@ void qdev_unplug(DeviceState *dev, Error **errp)

void qdev_unplug(DeviceState *dev, Error **errp)
{
DeviceClass *dc = DEVICE_GET_CLASS(dev);
HotplugHandler *hotplug_ctrl;
HotplugHandlerClass *hdc;
Error *local_err = NULL;
if (qdev_unplug_blocked(dev, errp)) {
return;
}
if (dev->parent_bus && !qbus_is_hotpluggable(dev->parent_bus)) {
error_setg(errp, QERR_BUS_NO_HOTPLUG, dev->parent_bus->name);
return;
}
if (!dc->hotpluggable) {
error_setg(errp, QERR_DEVICE_NO_HOTPLUG,
   object_get_typename(OBJECT(dev)));
return;
}
if (!migration_is_idle() && !dev->allow_unplug_during_migration) {
error_setg(errp, "device_del not allowed while migrating");
return;
}


   qdev_hot_removed = true;
  hotplug_ctrl = qdev_get_hotplug_handler(dev);
-/* hotpluggable device MUST have HotplugHandler, if it doesn't
- * then something is very wrong with it */
-g_assert(hotplug_ctrl);
+if (!hotplug_ctrl) {
+/*
+ * hotpluggable bus MUST have HotplugHandler, if it doesn't
+ * then something is very wrong with it
+ */
+assert(!dev->parent_bus);
+
+error_setg(errp, "The machine does not support hotplugging for a device 
without parent bus");
+return;
+}


Extended version of my question above: what are the devices where
qdev_get_hotplug_handler(dev) returns null here?


Start a VM: qemu-system-aarch64 -M virt -nographic
Run the following on its HMP: device_del /machine/unattached/device[0]

It tries to unplug cortex-a15-arm-cpu and crashes.


This device has no parent bus (dev->parent_bus is null), but is marked
hot-pluggable (dc->hotpluggable is true).  Question for somebody
familiar with the hot-plug machinery: is this sane?


Setting hotpluggable false for each device without bus_type gives the same 
effect, but is error-prone.


Having hotpluggable = true when the device cannot be hot-plugged is
*wrong*.  You might be able to paper over the wrongness so the code
works anyway, but nothing good can come out of lying to developers
trying to understand how the code works.

Three ideas to avoid the lying:

1. default hotpluggable to bus_type != NULL.


I don't have an idea to achieve that. Currently bus_type is set after 
hotpluggable.




2. assert(dc->bus_type || !dc->hotpluggable) in a suitable spot.


It results in abortion and doesn't improve the situation.



3. Change the meaning of hotpluggable, and rename it to reflect its new
meaning.  Requires a careful reading of its uses.  I wouldn't go there.


I don't have an idea for such a naming.

So I'm stuck with the current proposal. It suppresses abortion at least. 
Any alternative idea is welcome.






What about 4 (or maybe 3.1) - droping this hotpluggable flag and just use a
helper (like qbus) to check if device is hotpluggable?

This removes the confusion of that flag and also reduces the number of
configuration items for DeviceState that require developer attention.
A simple helper is as follows:


Some devices simply doesn't support hotplugging even if the bus 
supports. virtio-gpu-pci doesn't support hotplugging because the display 
infrastructure cannot handle hotplugging, for example.


Regards,
Akihiko Odaki



Re: [PATCH v2] qdev: Report an error for machine without HotplugHandler

2023-12-20 Thread Markus Armbruster
Zhao Liu  writes:

> Hi Markus,
>
> On Wed, Dec 20, 2023 at 08:53:21AM +0100, Markus Armbruster wrote:
>> Date: Wed, 20 Dec 2023 08:53:21 +0100
>> From: Markus Armbruster 
>> Subject: Re: [PATCH v2] qdev: Report an error for machine without
>>  HotplugHandler
>> 
>> Having hotpluggable = true when the device cannot be hot-plugged is
>> *wrong*.  You might be able to paper over the wrongness so the code
>> works anyway, but nothing good can come out of lying to developers
>> trying to understand how the code works.
>> 
>> Three ideas to avoid the lying:
>> 
>> 1. default hotpluggable to bus_type != NULL.
>> 
>> 2. assert(dc->bus_type || !dc->hotpluggable) in a suitable spot.
>> 
>> 3. Change the meaning of hotpluggable, and rename it to reflect its new
>> meaning.  Requires a careful reading of its uses.  I wouldn't go there.
>> 
>
> What about 4 (or maybe 3.1) - droping this hotpluggable flag and just use a
> helper (like qbus) to check if device is hotpluggable?
>
> This removes the confusion of that flag and also reduces the number of
> configuration items for DeviceState that require developer attention.
> A simple helper is as follows:
>
> static inline bool qdev_is_hotpluggable(DeviceState *dev)
> {
> /*
>  * Many Machines don't implement qdev_hotplug_allowed().
>  *
>  * TODO: Once all of them complete missing qdev_hotplug_allowed(),
>  *   use qdev_hotplug_allowed() here.
>  */
> bool hotpluggable = !!qdev_get_machine_hotplug_handler(dev);
>
> if (!hotpluggable && dev->parent_bus) {
> hotpluggable = qbus_is_hotpluggable(dev->parent_bus);
> }
>
> return hotpluggable;
> }

Worth exploring, I think.




Re: [PATCH v6 11/11] virtio-gpu: make blob scanout use dmabuf fd

2023-12-20 Thread Akihiko Odaki

On 2023/12/19 16:53, Huang Rui wrote:

From: Robert Beckett 

This relies on a virglrenderer change to include the dmabuf fd when
returning resource info.

Signed-off-by: Robert Beckett 
Signed-off-by: Huang Rui 
---

Changes in v6:
- Add scanout_blob function for virtio-gpu-virgl.
- Update for new virgl_gpu_resource.

  hw/display/virtio-gpu-virgl.c  | 104 +
  hw/display/virtio-gpu.c|   4 +-
  include/hw/virtio/virtio-gpu.h |   6 ++
  3 files changed, 112 insertions(+), 2 deletions(-)

diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
index c523a6717a..c384225a98 100644
--- a/hw/display/virtio-gpu-virgl.c
+++ b/hw/display/virtio-gpu-virgl.c
@@ -18,6 +18,7 @@
  #include "hw/virtio/virtio.h"
  #include "hw/virtio/virtio-gpu.h"
  #include "hw/virtio/virtio-gpu-bswap.h"
+#include "hw/virtio/virtio-gpu-pixman.h"
  
  #include "ui/egl-helpers.h"
  
@@ -726,6 +727,106 @@ static void virgl_cmd_resource_unmap_blob(VirtIOGPU *g,

  object_unparent(OBJECT(mr));
  }
  
+static void virgl_cmd_set_scanout_blob(VirtIOGPU *g,

+   struct virtio_gpu_ctrl_command *cmd)
+{
+struct virgl_gpu_resource *vres;
+struct virtio_gpu_framebuffer fb = { 0 };
+struct virtio_gpu_set_scanout_blob ss;
+struct virgl_renderer_resource_info info;
+uint64_t fbend;
+
+VIRTIO_GPU_FILL_CMD(ss);
+virtio_gpu_scanout_blob_bswap();
+trace_virtio_gpu_cmd_set_scanout_blob(ss.scanout_id, ss.resource_id,
+  ss.r.width, ss.r.height, ss.r.x,
+  ss.r.y);
+
+if (ss.scanout_id >= g->parent_obj.conf.max_outputs) {
+qemu_log_mask(LOG_GUEST_ERROR, "%s: illegal scanout id specified %d",
+  __func__, ss.scanout_id);
+cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_SCANOUT_ID;
+return;
+}
+
+if (ss.resource_id == 0) {
+virtio_gpu_disable_scanout(g, ss.scanout_id);
+return;
+}
+
+if (ss.width < 16 ||
+ss.height < 16 ||
+ss.r.x + ss.r.width > ss.width ||
+ss.r.y + ss.r.height > ss.height) {
+qemu_log_mask(LOG_GUEST_ERROR, "%s: illegal scanout %d bounds for"
+  " resource %d, rect (%d,%d)+%d,%d, fb %d %d\n",
+  __func__, ss.scanout_id, ss.resource_id,
+  ss.r.x, ss.r.y, ss.r.width, ss.r.height,
+  ss.width, ss.height);
+cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;
+return;
+}
+
+if (!console_has_gl(g->parent_obj.scanout[ss.scanout_id].con)) {


Shouldn't OpenGL always be available for virgl?


+qemu_log_mask(LOG_GUEST_ERROR, "%s: unable to scanout blot without 
GL!\n", __func__);
+return;
+}
+
+vres = virgl_gpu_find_resource(g, ss.resource_id);
+if (!vres) {
+qemu_log_mask(LOG_GUEST_ERROR,
+  "%s: illegal resource specified %d\n",
+  __func__, ss.resource_id);
+cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID;
+return;
+}
+if (virgl_renderer_resource_get_info(ss.resource_id, )) {
+qemu_log_mask(LOG_GUEST_ERROR,
+  "%s: illegal virgl resource specified %d\n",
+  __func__, ss.resource_id);
+cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID;
+return;
+}
+if (!vres->res.dmabuf_fd && info.fd)
+vres->res.dmabuf_fd = info.fd;
+
+fb.format = virtio_gpu_get_pixman_format(ss.format);
+if (!fb.format) {
+qemu_log_mask(LOG_GUEST_ERROR,
+  "%s: host couldn't handle guest format %d\n",
+  __func__, ss.format);
+cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;
+return;
+}
+
+fb.bytes_pp = DIV_ROUND_UP(PIXMAN_FORMAT_BPP(fb.format), 8);
+fb.width = ss.width;
+fb.height = ss.height;
+fb.stride = ss.strides[0];
+fb.offset = ss.offsets[0] + ss.r.x * fb.bytes_pp + ss.r.y * fb.stride;
+
+fbend = fb.offset;
+fbend += fb.stride * (ss.r.height - 1);
+fbend += fb.bytes_pp * ss.r.width;
+if (fbend > vres->res.blob_size) {
+qemu_log_mask(LOG_GUEST_ERROR,
+  "%s: fb end out of range\n",
+  __func__);
+cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;
+return;
+}
+
+g->parent_obj.enable = 1;
+if (virtio_gpu_update_dmabuf(g, ss.scanout_id, >res,
+ , )) {
+qemu_log_mask(LOG_GUEST_ERROR,
+  "%s: failed to update dmabuf\n", __func__);
+cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;
+return;
+}
+virtio_gpu_update_scanout(g, ss.scanout_id, >res, );
+}
+
  #endif /* HAVE_VIRGL_RESOURCE_BLOB */
  
  void virtio_gpu_virgl_process_cmd(VirtIOGPU *g,

@@ -807,6 +908,9 @@ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g,
   

Re: [PATCH v3 09/70] physmem: Introduce ram_block_convert_range() for page conversion

2023-12-20 Thread Xiaoyao Li

On 12/8/2023 7:52 PM, David Hildenbrand wrote:

On 08.12.23 08:59, Xiaoyao Li wrote:

On 11/18/2023 5:03 AM, Isaku Yamahata wrote:

On Wed, Nov 15, 2023 at 02:14:18AM -0500,
Xiaoyao Li  wrote:


It's used for discarding opposite memory after memory conversion, for
confidential guest.

When page is converted from shared to private, the original shared
memory can be discarded via ram_block_discard_range();

When page is converted from private to shared, the original private
memory is back'ed by guest_memfd. Introduce
ram_block_discard_guest_memfd_range() for discarding memory in
guest_memfd.

Originally-from: Isaku Yamahata 
Codeveloped-by: Xiaoyao Li 
Signed-off-by: Xiaoyao Li 
---
   include/exec/cpu-common.h |  2 ++
   system/physmem.c  | 50 
+++

   2 files changed, 52 insertions(+)

diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index 41115d891940..de728a18eef2 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -175,6 +175,8 @@ typedef int (RAMBlockIterFunc)(RAMBlock *rb, 
void *opaque);

   int qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque);
   int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t 
length);
+int ram_block_convert_range(RAMBlock *rb, uint64_t start, size_t 
length,

+    bool shared_to_private);
   #endif
diff --git a/system/physmem.c b/system/physmem.c
index ddfecddefcd6..cd6008fa09ad 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -3641,6 +3641,29 @@ err:
   return ret;
   }
+static int ram_block_discard_guest_memfd_range(RAMBlock *rb, 
uint64_t start,

+   size_t length)
+{
+    int ret = -1;
+
+#ifdef CONFIG_FALLOCATE_PUNCH_HOLE
+    ret = fallocate(rb->guest_memfd, FALLOC_FL_PUNCH_HOLE | 
FALLOC_FL_KEEP_SIZE,

+    start, length);
+
+    if (ret) {
+    ret = -errno;
+    error_report("%s: Failed to fallocate %s:%" PRIx64 " +%zx 
(%d)",

+ __func__, rb->idstr, start, length, ret);
+    }
+#else
+    ret = -ENOSYS;
+    error_report("%s: fallocate not available %s:%" PRIx64 " +%zx 
(%d)",

+ __func__, rb->idstr, start, length, ret);
+#endif
+
+    return ret;
+}
+
   bool ramblock_is_pmem(RAMBlock *rb)
   {
   return rb->flags & RAM_PMEM;
@@ -3828,3 +3851,30 @@ bool ram_block_discard_is_required(void)
   return qatomic_read(_block_discard_required_cnt) ||
  
qatomic_read(_block_coordinated_discard_required_cnt);

   }
+
+int ram_block_convert_range(RAMBlock *rb, uint64_t start, size_t 
length,

+    bool shared_to_private)
+{
+    if (!rb || rb->guest_memfd < 0) {
+    return -1;
+    }
+
+    if (!QEMU_PTR_IS_ALIGNED(start, qemu_host_page_size) ||
+    !QEMU_PTR_IS_ALIGNED(length, qemu_host_page_size)) {
+    return -1;
+    }
+
+    if (!length) {
+    return -1;
+    }
+
+    if (start + length > rb->max_length) {
+    return -1;
+    }
+
+    if (shared_to_private) {
+    return ram_block_discard_range(rb, start, length);
+    } else {
+    return ram_block_discard_guest_memfd_range(rb, start, length);
+    }
+}


Originally this function issued KVM_SET_MEMORY_ATTRIBUTES, the 
function name
mad sense. But now it doesn't, and it issues only punch hole. We 
should rename

it to represent what it actually does. discard_range?


ram_block_discard_range() already exists for non-guest-memfd memory 
discard.


I cannot come up with a proper name. e.g.,
ram_block_discard_opposite_range() while *opposite* seems unclear.

Do you have any better idea?


Having some indication that this is about "guest_memfd" back and forth 
switching/conversion will make sense. But I'm also not able to come up 
with a better name.


Maybe have two functions:

ram_block_activate_guest_memfd_range
ram_block_deactivate_guest_memfd_range



finally, I decide to drop this function and expose 
ram_block_discard_guest_memfd_range() instead. So caller can call the 
ram_block_discard_*() on its own.




Re: [PATCH v3 06/70] kvm: Introduce support for memory_attributes

2023-12-20 Thread Xiaoyao Li

On 12/12/2023 9:56 PM, Wang, Wei W wrote:

On Wednesday, November 15, 2023 3:14 PM, Xiaoyao Li wrote:

Introduce the helper functions to set the attributes of a range of memory to
private or shared.

This is necessary to notify KVM the private/shared attribute of each gpa range.
KVM needs the information to decide the GPA needs to be mapped at hva-
based shared memory or guest_memfd based private memory.

Signed-off-by: Xiaoyao Li 
---
  accel/kvm/kvm-all.c  | 42 ++
  include/sysemu/kvm.h |  3 +++
  2 files changed, 45 insertions(+)

diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index
69afeb47c9c0..76e2404d54d2 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -102,6 +102,7 @@ bool kvm_has_guest_debug;  static int kvm_sstep_flags;
static bool kvm_immediate_exit;  static bool kvm_guest_memfd_supported;
+static uint64_t kvm_supported_memory_attributes;
  static hwaddr kvm_max_slot_size = ~0;

  static const KVMCapabilityInfo kvm_required_capabilites[] = { @@ -1305,6
+1306,44 @@ void kvm_set_max_memslot_size(hwaddr max_slot_size)
  kvm_max_slot_size = max_slot_size;
  }

+static int kvm_set_memory_attributes(hwaddr start, hwaddr size,
+uint64_t attr) {
+struct kvm_memory_attributes attrs;
+int r;
+
+attrs.attributes = attr;
+attrs.address = start;
+attrs.size = size;
+attrs.flags = 0;
+
+r = kvm_vm_ioctl(kvm_state, KVM_SET_MEMORY_ATTRIBUTES, );
+if (r) {
+warn_report("%s: failed to set memory (0x%lx+%#zx) with attr 0x%lx
error '%s'",
+ __func__, start, size, attr, strerror(errno));
+}
+return r;
+}
+
+int kvm_set_memory_attributes_private(hwaddr start, hwaddr size) {
+if (!(kvm_supported_memory_attributes &
KVM_MEMORY_ATTRIBUTE_PRIVATE)) {
+error_report("KVM doesn't support PRIVATE memory attribute\n");
+return -EINVAL;
+}
+
+return kvm_set_memory_attributes(start, size,
+KVM_MEMORY_ATTRIBUTE_PRIVATE); }
+
+int kvm_set_memory_attributes_shared(hwaddr start, hwaddr size) {
+if (!(kvm_supported_memory_attributes &
KVM_MEMORY_ATTRIBUTE_PRIVATE)) {
+error_report("KVM doesn't support PRIVATE memory attribute\n");
+return -EINVAL;
+}


Duplicate code in kvm_set_memory_attributes_shared/private.
Why not move the check into kvm_set_memory_attributes?


Because it's not easy to put the check into there.

Both setting and clearing one bit require the capability check. If 
moving the check into kvm_set_memory_attributes(), the check of 
KVM_MEMORY_ATTRIBUTE_PRIVATE will have to become unconditionally, which 
is not aligned to the function name because the name is not restricted 
to shared/private attribute only.




Re: [PATCH v6 08/11] virtio-gpu: Resource UUID

2023-12-20 Thread Akihiko Odaki

On 2023/12/19 16:53, Huang Rui wrote:

From: Antonio Caggiano 

Enable resource UUID feature and implement command resource assign UUID.
This is done by introducing a hash table to map resource IDs to their
UUIDs.


What about putting QemuUUID in struct virtio_gpu_simple_resource?



Re: [PATCH v6 07/11] virtio-gpu: Handle resource blob commands

2023-12-20 Thread Akihiko Odaki

On 2023/12/19 16:53, Huang Rui wrote:

From: Antonio Caggiano 

Support BLOB resources creation, mapping and unmapping by calling the
new stable virglrenderer 0.10 interface. Only enabled when available and
via the blob config. E.g. -device virtio-vga-gl,blob=true

Signed-off-by: Antonio Caggiano 
Signed-off-by: Dmitry Osipenko 
Signed-off-by: Xenia Ragiadakou 
Signed-off-by: Huang Rui 
---

Changes in v6:
- Use new struct virgl_gpu_resource.
- Unmap, unref and destroy the resource only after the memory region
   has been completely removed.
- In unref check whether the resource is still mapped.
- In unmap_blob check whether the resource has been already unmapped.
- Fix coding style

  hw/display/virtio-gpu-virgl.c | 274 +-
  hw/display/virtio-gpu.c   |   4 +-
  meson.build   |   4 +
  3 files changed, 276 insertions(+), 6 deletions(-)

diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
index faab374336..5a3a292f79 100644
--- a/hw/display/virtio-gpu-virgl.c
+++ b/hw/display/virtio-gpu-virgl.c
@@ -17,6 +17,7 @@
  #include "trace.h"
  #include "hw/virtio/virtio.h"
  #include "hw/virtio/virtio-gpu.h"
+#include "hw/virtio/virtio-gpu-bswap.h"
  
  #include "ui/egl-helpers.h"
  
@@ -24,8 +25,62 @@
  
  struct virgl_gpu_resource {

  struct virtio_gpu_simple_resource res;
+uint32_t ref;
+VirtIOGPU *g;
+
+#ifdef HAVE_VIRGL_RESOURCE_BLOB
+/* only blob resource needs this region to be mapped as guest mmio */
+MemoryRegion *region;


Why not just embed MemoryRegion into struct virgl_gpu_resource instead 
of having a pointer?



+#endif
  };
  
+static void vres_get_ref(struct virgl_gpu_resource *vres)

+{
+uint32_t ref;
+
+ref = qatomic_fetch_inc(>ref);
+g_assert(ref < INT_MAX);
+}
+
+static void virgl_resource_destroy(struct virgl_gpu_resource *vres)
+{
+struct virtio_gpu_simple_resource *res;
+VirtIOGPU *g;
+
+if (!vres) {
+return;
+}
+
+g = vres->g;
+res = >res;
+QTAILQ_REMOVE(>reslist, res, next);
+virtio_gpu_cleanup_mapping(g, res);
+g_free(vres);
+}
+
+static void virgl_resource_unref(struct virgl_gpu_resource *vres)
+{
+struct virtio_gpu_simple_resource *res;
+
+if (!vres) {
+return;
+}
+
+res = >res;
+virgl_renderer_resource_detach_iov(res->resource_id, NULL, NULL);
+virgl_renderer_resource_unref(res->resource_id);
+}
+
+static void vres_put_ref(struct virgl_gpu_resource *vres)
+{
+g_assert(vres->ref > 0);
+
+if (qatomic_fetch_dec(>ref) == 1) {
+virgl_resource_unref(vres);
+virgl_resource_destroy(vres);
+}
+}
+
  static struct virgl_gpu_resource *
  virgl_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id)
  {
@@ -59,6 +114,8 @@ static void virgl_cmd_create_resource_2d(VirtIOGPU *g,
 c2d.width, c2d.height);
  
  vres = g_new0(struct virgl_gpu_resource, 1);

+vres_get_ref(vres);
+vres->g = g;
  vres->res.width = c2d.width;
  vres->res.height = c2d.height;
  vres->res.format = c2d.format;
@@ -91,6 +148,8 @@ static void virgl_cmd_create_resource_3d(VirtIOGPU *g,
 c3d.width, c3d.height, c3d.depth);
  
  vres = g_new0(struct virgl_gpu_resource, 1);

+vres_get_ref(vres);
+vres->g = g;
  vres->res.width = c3d.width;
  vres->res.height = c3d.height;
  vres->res.format = c3d.format;
@@ -126,12 +185,21 @@ static void virgl_cmd_resource_unref(VirtIOGPU *g,
  return;
  }
  
-virgl_renderer_resource_detach_iov(unref.resource_id, NULL, NULL);

-virgl_renderer_resource_unref(unref.resource_id);
+#ifdef HAVE_VIRGL_RESOURCE_BLOB
+if (vres->region) {
+VirtIOGPUBase *b = VIRTIO_GPU_BASE(g);
+MemoryRegion *mr = vres->region;
+
+warn_report("%s: blob resource %d not unmapped",
+__func__, unref.resource_id);
+vres->region = NULL;
+memory_region_set_enabled(mr, false);
+memory_region_del_subregion(>hostmem, mr);
+object_unparent(OBJECT(mr));
+}
+#endif /* HAVE_VIRGL_RESOURCE_BLOB */
  
-QTAILQ_REMOVE(>reslist, >res, next);

-virtio_gpu_cleanup_mapping(g, >res);
-g_free(vres);
+vres_put_ref(vres);


What will happen if the guest consecutively requests 
VIRTIO_GPU_CMD_RESOURCE_UNREF twice for a mapped resource?




Re: [PATCH v6 06/11] softmmu/memory: enable automatic deallocation of memory regions

2023-12-20 Thread Akihiko Odaki

On 2023/12/19 16:53, Huang Rui wrote:

From: Xenia Ragiadakou 

When the memory region has a different life-cycle from that of her parent,
could be automatically released, once has been unparent and once all of her
references have gone away, via the object's free callback.

However, currently, the address space subsystem keeps references to the
memory region without first incrementing its object's reference count.
As a result, the automatic deallocation of the object, not taking into
account those references, results in use-after-free memory corruption.

More specifically, reference to the memory region is kept in flatview
ranges. If the reference count of the memory region is not incremented,
flatview_destroy(), that is asynchronous, may be called after memory
region's destruction. If the reference count of the memory region is
incremented, memory region's destruction will take place after
flatview_destroy() has released its references.

This patch increases the reference count of an owned memory region object
on each memory_region_ref() and decreases it on each memory_region_unref().


Why not pass the memory region itself as the owner parameter of 
memory_region_init_ram_ptr()?




Re: [PATCH v6 05/11] virtio-gpu: Introduce virgl_gpu_resource structure

2023-12-20 Thread Akihiko Odaki

On 2023/12/19 22:27, Huang Rui wrote:

On Tue, Dec 19, 2023 at 08:35:27PM +0800, Akihiko Odaki wrote:

On 2023/12/19 16:53, Huang Rui wrote:

Introduce a new virgl_gpu_resource data structure and helper functions
for virgl. It's used to add new member which is specific for virgl in
following patches of blob memory support.


The name is ambigious. It should tell that it's specific for virgl.


How about "virgl_resource" which inherits virtio_gpu_simple_resource? But
this name is exactly same with the name in virglrenderer.


You can prefix it with virtio_gpu_virgl as virtio_gpu_virgl_init() and 
other functions do.


Regards,
Akihiko Odaki



Re: [PATCH for 9.0 07/12] vdpa: set backend capabilities at vhost_vdpa_init

2023-12-20 Thread Jason Wang
On Wed, Dec 20, 2023 at 3:08 PM Eugenio Perez Martin
 wrote:
>
> On Wed, Dec 20, 2023 at 5:34 AM Jason Wang  wrote:
> >
> > On Sat, Dec 16, 2023 at 1:28 AM Eugenio Pérez  wrote:
> > >
> > > The backend does not reset them until the vdpa file descriptor is closed
> > > so there is no harm in doing it only once.
> > >
> > > This allows the destination of a live migration to premap memory in
> > > batches, using VHOST_BACKEND_F_IOTLB_BATCH.
> > >
> > > Signed-off-by: Eugenio Pérez 
> > > ---
> > >  hw/virtio/vhost-vdpa.c | 50 --
> > >  1 file changed, 19 insertions(+), 31 deletions(-)
> > >
> > > diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
> > > index 449c3794b2..43f7c382b1 100644
> > > --- a/hw/virtio/vhost-vdpa.c
> > > +++ b/hw/virtio/vhost-vdpa.c
> > > @@ -587,11 +587,25 @@ static int vhost_vdpa_init(struct vhost_dev *dev, 
> > > void *opaque, Error **errp)
> > >  struct vhost_vdpa *v = opaque;
> > >  assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_VDPA);
> > >  trace_vhost_vdpa_init(dev, v->shared, opaque);
> > > +uint64_t backend_features;
> > > +uint64_t qemu_backend_features = 0x1ULL << 
> > > VHOST_BACKEND_F_IOTLB_MSG_V2 |
> > > + 0x1ULL << 
> > > VHOST_BACKEND_F_IOTLB_BATCH |
> > > + 0x1ULL << 
> > > VHOST_BACKEND_F_IOTLB_ASID |
> > > + 0x1ULL << VHOST_BACKEND_F_SUSPEND;
> > >  int ret;
> > >
> > >  v->dev = dev;
> > >  dev->opaque =  opaque ;
> > >  v->shared->listener = vhost_vdpa_memory_listener;
> > > +
> > > +if (vhost_vdpa_call(dev, VHOST_GET_BACKEND_FEATURES, 
> > > _features)) {
> > > +return -EFAULT;
> > > +}
> > > +
> > > +backend_features &= qemu_backend_features;
> > > +
> > > +dev->backend_cap = backend_features;
> > > +v->shared->backend_cap = backend_features;
> > >  vhost_vdpa_init_svq(dev, v);
> > >
> > >  error_propagate(>migration_blocker, v->migration_blocker);
> > > @@ -599,6 +613,11 @@ static int vhost_vdpa_init(struct vhost_dev *dev, 
> > > void *opaque, Error **errp)
> > >  return 0;
> > >  }
> > >
> > > +ret = vhost_vdpa_call(dev, VHOST_SET_BACKEND_FEATURES, 
> > > _features);
> > > +if (ret) {
> > > +return -EFAULT;
> > > +}
> > > +
> > >  /*
> > >   * If dev->shadow_vqs_enabled at initialization that means the 
> > > device has
> > >   * been started with x-svq=on, so don't block migration
> > > @@ -829,36 +848,6 @@ static int vhost_vdpa_set_features(struct vhost_dev 
> > > *dev,
> > >  return vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_FEATURES_OK);
> > >  }
> > >
> > > -static int vhost_vdpa_set_backend_cap(struct vhost_dev *dev)
> >
> > How about keeping this function but just calling it in vhost_vdpa_init()?
> >
>
> Sure, that is possible. I need to remove the VhostOps
> vhost_set_backend_cap = vhost_vdpa_set_backend_cap, anyway, is that ok
> for you?

Fine with me.

Thanks

>
> Thanks!
>




RE: Questions regarding the still unpublished qemu series https://github.com/yiliu1765/qemu/tree/zhenzhong/wip/iommufd_nesting_rfcv1

2023-12-20 Thread Duan, Zhenzhong
Hi Joel,

>-Original Message-
>From: Joel Granados 
>Subject: Questions regarding the still unpublished qemu series
>https://github.com/yiliu1765/qemu/tree/zhenzhong/wip/iommufd_nesting
>_rfcv1
>
>Hello Everyone
>
>While running
>https://github.com/yiliu1765/qemu/tree/zhenzhong/wip/iommufd_nesting
>_rfcv1
>I have come across particular code path that seems odd:
>
>I'm hitting an assert in softmmu/memory.c:1994 after calling a
>notification from vtd_flt_page_walk_level. The code in memory.c:1994
>makes sure that when type==IOMMU_NOTIFIER_UNMAP, the permissions
>are
>IOMMU_NONE. But the code in vtd_flt_page_walk_level sets the
>permissions to read|write. This is part of the "intel_iommu: piotlb
>invalidation should notify unmap" commit in the iommufd_nesting_rfcv1
>series.
>
>Question is: Why assert on the permissions being NONE if they might be
>read|write?
>
>Hope this makes sense. Don't hesitate to get back to me if you see that
>there is something missing in my explanation.

Thanks for your report, you are right. We had seen the same issue with
vhost device and have it fixed internally. Did you also use a vhost device
or not?

The link you used is a bit old, could you try with 
https://github.com/yiliu1765/qemu/commits/zhenzhong/iommufd_nesting_rfcv1/

Thanks
Zhenzhong



[PATCH v2 09/71] target/loongarch: Constify VMState in machine.c

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 target/loongarch/machine.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/target/loongarch/machine.c b/target/loongarch/machine.c
index 1c4e01d076..c7029fb9b4 100644
--- a/target/loongarch/machine.c
+++ b/target/loongarch/machine.c
@@ -14,7 +14,7 @@ static const VMStateDescription vmstate_fpu_reg = {
 .name = "fpu_reg",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(UD(0), VReg),
 VMSTATE_END_OF_LIST()
 }
@@ -36,7 +36,7 @@ static const VMStateDescription vmstate_fpu = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = fpu_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_FPU_REGS(env.fpr, LoongArchCPU, 0),
 VMSTATE_UINT32(env.fcsr0, LoongArchCPU),
 VMSTATE_BOOL_ARRAY(env.cf, LoongArchCPU, 8),
@@ -48,7 +48,7 @@ static const VMStateDescription vmstate_lsxh_reg = {
 .name = "lsxh_reg",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(UD(1), VReg),
 VMSTATE_END_OF_LIST()
 }
@@ -70,7 +70,7 @@ static const VMStateDescription vmstate_lsx = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = lsx_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_LSXH_REGS(env.fpr, LoongArchCPU, 0),
 VMSTATE_END_OF_LIST()
 },
@@ -80,7 +80,7 @@ static const VMStateDescription vmstate_lasxh_reg = {
 .name = "lasxh_reg",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(UD(2), VReg),
 VMSTATE_UINT64(UD(3), VReg),
 VMSTATE_END_OF_LIST()
@@ -103,7 +103,7 @@ static const VMStateDescription vmstate_lasx = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = lasx_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_LASXH_REGS(env.fpr, LoongArchCPU, 0),
 VMSTATE_END_OF_LIST()
 },
@@ -114,7 +114,7 @@ const VMStateDescription vmstate_tlb = {
 .name = "cpu/tlb",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(tlb_misc, LoongArchTLB),
 VMSTATE_UINT64(tlb_entry0, LoongArchTLB),
 VMSTATE_UINT64(tlb_entry1, LoongArchTLB),
@@ -127,7 +127,7 @@ const VMStateDescription vmstate_loongarch_cpu = {
 .name = "cpu",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINTTL_ARRAY(env.gpr, LoongArchCPU, 32),
 VMSTATE_UINTTL(env.pc, LoongArchCPU),
 
@@ -193,7 +193,7 @@ const VMStateDescription vmstate_loongarch_cpu = {
 
 VMSTATE_END_OF_LIST()
 },
-.subsections = (const VMStateDescription*[]) {
+.subsections = (const VMStateDescription * const []) {
 _fpu,
 _lsx,
 _lasx,
-- 
2.34.1




[PATCH v2 45/71] hw/pci-bridge: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/pci-bridge/gen_pcie_root_port.c | 2 +-
 hw/pci-bridge/i82801b11.c  | 2 +-
 hw/pci-bridge/ioh3420.c| 2 +-
 hw/pci-bridge/pci_bridge_dev.c | 2 +-
 hw/pci-bridge/pcie_pci_bridge.c| 2 +-
 hw/pci-bridge/xio3130_downstream.c | 2 +-
 hw/pci-bridge/xio3130_upstream.c   | 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/hw/pci-bridge/gen_pcie_root_port.c 
b/hw/pci-bridge/gen_pcie_root_port.c
index 1ce4e7beba..784507c826 100644
--- a/hw/pci-bridge/gen_pcie_root_port.c
+++ b/hw/pci-bridge/gen_pcie_root_port.c
@@ -117,7 +117,7 @@ static const VMStateDescription vmstate_rp_dev = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = pcie_cap_slot_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(parent_obj.parent_obj.parent_obj, PCIESlot),
 VMSTATE_STRUCT(parent_obj.parent_obj.parent_obj.exp.aer_log,
PCIESlot, 0, vmstate_pcie_aer_log, PCIEAERLog),
diff --git a/hw/pci-bridge/i82801b11.c b/hw/pci-bridge/i82801b11.c
index 0e83cd11b2..c140919cbc 100644
--- a/hw/pci-bridge/i82801b11.c
+++ b/hw/pci-bridge/i82801b11.c
@@ -81,7 +81,7 @@ err_bridge:
 static const VMStateDescription i82801b11_bridge_dev_vmstate = {
 .name = "i82801b11_bridge",
 .priority = MIG_PRI_PCI_BUS,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(parent_obj, PCIBridge),
 VMSTATE_END_OF_LIST()
 }
diff --git a/hw/pci-bridge/ioh3420.c b/hw/pci-bridge/ioh3420.c
index f1e16135a3..be752a4bda 100644
--- a/hw/pci-bridge/ioh3420.c
+++ b/hw/pci-bridge/ioh3420.c
@@ -88,7 +88,7 @@ static const VMStateDescription vmstate_ioh3420 = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = pcie_cap_slot_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(parent_obj.parent_obj.parent_obj, PCIESlot),
 VMSTATE_STRUCT(parent_obj.parent_obj.parent_obj.exp.aer_log,
PCIESlot, 0, vmstate_pcie_aer_log, PCIEAERLog),
diff --git a/hw/pci-bridge/pci_bridge_dev.c b/hw/pci-bridge/pci_bridge_dev.c
index 4b2696ea7f..089f91efed 100644
--- a/hw/pci-bridge/pci_bridge_dev.c
+++ b/hw/pci-bridge/pci_bridge_dev.c
@@ -199,7 +199,7 @@ static bool pci_device_shpc_present(void *opaque, int 
version_id)
 static const VMStateDescription pci_bridge_dev_vmstate = {
 .name = "pci_bridge",
 .priority = MIG_PRI_PCI_BUS,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(parent_obj, PCIBridge),
 SHPC_VMSTATE(shpc, PCIDevice, pci_device_shpc_present),
 VMSTATE_END_OF_LIST()
diff --git a/hw/pci-bridge/pcie_pci_bridge.c b/hw/pci-bridge/pcie_pci_bridge.c
index 2301b2ca0b..7646ac2397 100644
--- a/hw/pci-bridge/pcie_pci_bridge.c
+++ b/hw/pci-bridge/pcie_pci_bridge.c
@@ -132,7 +132,7 @@ static Property pcie_pci_bridge_dev_properties[] = {
 static const VMStateDescription pcie_pci_bridge_dev_vmstate = {
 .name = TYPE_PCIE_PCI_BRIDGE_DEV,
 .priority = MIG_PRI_PCI_BUS,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(parent_obj, PCIBridge),
 SHPC_VMSTATE(shpc, PCIDevice, NULL),
 VMSTATE_END_OF_LIST()
diff --git a/hw/pci-bridge/xio3130_downstream.c 
b/hw/pci-bridge/xio3130_downstream.c
index 38a2361fa2..907d5105b0 100644
--- a/hw/pci-bridge/xio3130_downstream.c
+++ b/hw/pci-bridge/xio3130_downstream.c
@@ -146,7 +146,7 @@ static const VMStateDescription vmstate_xio3130_downstream 
= {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = pcie_cap_slot_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(parent_obj.parent_obj.parent_obj, PCIESlot),
 VMSTATE_STRUCT(parent_obj.parent_obj.parent_obj.exp.aer_log,
PCIESlot, 0, vmstate_pcie_aer_log, PCIEAERLog),
diff --git a/hw/pci-bridge/xio3130_upstream.c b/hw/pci-bridge/xio3130_upstream.c
index a48bfe3bc5..2a6cff6e03 100644
--- a/hw/pci-bridge/xio3130_upstream.c
+++ b/hw/pci-bridge/xio3130_upstream.c
@@ -115,7 +115,7 @@ static const VMStateDescription vmstate_xio3130_upstream = {
 .priority = MIG_PRI_PCI_BUS,
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(parent_obj.parent_obj, PCIEPort),
 VMSTATE_STRUCT(parent_obj.parent_obj.exp.aer_log, PCIEPort, 0,
vmstate_pcie_aer_log, PCIEAERLog),
-- 
2.34.1




[PATCH v2 53/71] hw/sensor: Constify VMState

2023-12-20 Thread Richard Henderson
Tested-by: Philippe Mathieu-Daudé 
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Richard Henderson 
---
 hw/sensor/adm1266.c| 2 +-
 hw/sensor/adm1272.c| 2 +-
 hw/sensor/dps310.c | 2 +-
 hw/sensor/emc141x.c| 2 +-
 hw/sensor/lsm303dlhc_mag.c | 2 +-
 hw/sensor/max31785.c   | 2 +-
 hw/sensor/max34451.c   | 2 +-
 hw/sensor/tmp105.c | 6 +++---
 hw/sensor/tmp421.c | 2 +-
 9 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/hw/sensor/adm1266.c b/hw/sensor/adm1266.c
index 5ae4f82ba1..5454b73a63 100644
--- a/hw/sensor/adm1266.c
+++ b/hw/sensor/adm1266.c
@@ -202,7 +202,7 @@ static const VMStateDescription vmstate_adm1266 = {
 .name = "ADM1266",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]){
+.fields = (const VMStateField[]){
 VMSTATE_PMBUS_DEVICE(parent, ADM1266State),
 VMSTATE_END_OF_LIST()
 }
diff --git a/hw/sensor/adm1272.c b/hw/sensor/adm1272.c
index 8f4a1c2cd4..1f7c8abb83 100644
--- a/hw/sensor/adm1272.c
+++ b/hw/sensor/adm1272.c
@@ -457,7 +457,7 @@ static const VMStateDescription vmstate_adm1272 = {
 .name = "ADM1272",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]){
+.fields = (const VMStateField[]){
 VMSTATE_PMBUS_DEVICE(parent, ADM1272State),
 VMSTATE_UINT64(ein_ext, ADM1272State),
 VMSTATE_UINT32(pin_ext, ADM1272State),
diff --git a/hw/sensor/dps310.c b/hw/sensor/dps310.c
index addee99b19..01c776dd7a 100644
--- a/hw/sensor/dps310.c
+++ b/hw/sensor/dps310.c
@@ -188,7 +188,7 @@ static const VMStateDescription vmstate_dps310 = {
 .name = "DPS310",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(len, DPS310State),
 VMSTATE_UINT8_ARRAY(regs, DPS310State, NUM_REGISTERS),
 VMSTATE_UINT8(pointer, DPS310State),
diff --git a/hw/sensor/emc141x.c b/hw/sensor/emc141x.c
index 7ce8f4e979..95079558e8 100644
--- a/hw/sensor/emc141x.c
+++ b/hw/sensor/emc141x.c
@@ -228,7 +228,7 @@ static const VMStateDescription vmstate_emc141x = {
 .name = "EMC141X",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(len, EMC141XState),
 VMSTATE_UINT8(data, EMC141XState),
 VMSTATE_UINT8(pointer, EMC141XState),
diff --git a/hw/sensor/lsm303dlhc_mag.c b/hw/sensor/lsm303dlhc_mag.c
index bb8d48b2fd..343ff98990 100644
--- a/hw/sensor/lsm303dlhc_mag.c
+++ b/hw/sensor/lsm303dlhc_mag.c
@@ -442,7 +442,7 @@ static const VMStateDescription vmstate_lsm303dlhc_mag = {
 .name = "LSM303DLHC_MAG",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 
 VMSTATE_I2C_SLAVE(parent_obj, LSM303DLHCMagState),
 VMSTATE_UINT8(len, LSM303DLHCMagState),
diff --git a/hw/sensor/max31785.c b/hw/sensor/max31785.c
index 8b95e32481..916ed4d457 100644
--- a/hw/sensor/max31785.c
+++ b/hw/sensor/max31785.c
@@ -487,7 +487,7 @@ static const VMStateDescription vmstate_max31785 = {
 .name = TYPE_MAX31785,
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]){
+.fields = (const VMStateField[]){
 VMSTATE_PMBUS_DEVICE(parent, MAX31785State),
 VMSTATE_UINT16_ARRAY(mfr_mode, MAX31785State,
  MAX31785_TOTAL_NUM_PAGES),
diff --git a/hw/sensor/max34451.c b/hw/sensor/max34451.c
index 9db52ef677..031ae53f59 100644
--- a/hw/sensor/max34451.c
+++ b/hw/sensor/max34451.c
@@ -654,7 +654,7 @@ static const VMStateDescription vmstate_max34451 = {
 .name = TYPE_MAX34451,
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]){
+.fields = (const VMStateField[]){
 VMSTATE_PMBUS_DEVICE(parent, MAX34451State),
 VMSTATE_UINT16_ARRAY(power_good_on, MAX34451State,
  MAX34451_NUM_PWR_DEVICES),
diff --git a/hw/sensor/tmp105.c b/hw/sensor/tmp105.c
index 2056449489..a8730d0b7f 100644
--- a/hw/sensor/tmp105.c
+++ b/hw/sensor/tmp105.c
@@ -238,7 +238,7 @@ static const VMStateDescription 
vmstate_tmp105_detect_falling = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = detect_falling_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_BOOL(detect_falling, TMP105State),
 VMSTATE_END_OF_LIST()
 }
@@ -249,7 +249,7 @@ static const VMStateDescription vmstate_tmp105 = {
 .version_id = 0,
 .minimum_version_id = 0,
 .post_load = tmp105_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(len, TMP105State),
 VMSTATE_UINT8_ARRAY(buf, TMP105State, 2),
 VMSTATE_UINT8(pointer, TMP105State),
@@ -260,7 +260,7 @@ static const VMStateDescription vmstate_tmp105 = {
 

[PATCH v2 57/71] hw/tpm: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/tpm/tpm_crb.c| 2 +-
 hw/tpm/tpm_spapr.c  | 2 +-
 hw/tpm/tpm_tis_common.c | 2 +-
 hw/tpm/tpm_tis_i2c.c| 2 +-
 hw/tpm/tpm_tis_isa.c| 2 +-
 hw/tpm/tpm_tis_sysbus.c | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/tpm/tpm_crb.c b/hw/tpm/tpm_crb.c
index ea930da545..5cd5a2533b 100644
--- a/hw/tpm/tpm_crb.c
+++ b/hw/tpm/tpm_crb.c
@@ -220,7 +220,7 @@ static int tpm_crb_pre_save(void *opaque)
 static const VMStateDescription vmstate_tpm_crb = {
 .name = "tpm-crb",
 .pre_save = tpm_crb_pre_save,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(regs, CRBState, TPM_CRB_R_MAX),
 VMSTATE_END_OF_LIST(),
 }
diff --git a/hw/tpm/tpm_spapr.c b/hw/tpm/tpm_spapr.c
index dea7b1333b..e084e987e6 100644
--- a/hw/tpm/tpm_spapr.c
+++ b/hw/tpm/tpm_spapr.c
@@ -353,7 +353,7 @@ static const VMStateDescription vmstate_spapr_vtpm = {
 .name = "tpm-spapr",
 .pre_save = tpm_spapr_pre_save,
 .post_load = tpm_spapr_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_SPAPR_VIO(vdev, SpaprTpmState),
 
 VMSTATE_UINT8(state, SpaprTpmState),
diff --git a/hw/tpm/tpm_tis_common.c b/hw/tpm/tpm_tis_common.c
index 279ce436b5..1bfa28bfd9 100644
--- a/hw/tpm/tpm_tis_common.c
+++ b/hw/tpm/tpm_tis_common.c
@@ -879,7 +879,7 @@ int tpm_tis_pre_save(TPMState *s)
 const VMStateDescription vmstate_locty = {
 .name = "tpm-tis/locty",
 .version_id = 0,
-.fields  = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(state, TPMLocality),
 VMSTATE_UINT32(inte, TPMLocality),
 VMSTATE_UINT32(ints, TPMLocality),
diff --git a/hw/tpm/tpm_tis_i2c.c b/hw/tpm/tpm_tis_i2c.c
index 4ecea7fa3e..4bb09655b4 100644
--- a/hw/tpm/tpm_tis_i2c.c
+++ b/hw/tpm/tpm_tis_i2c.c
@@ -115,7 +115,7 @@ static const VMStateDescription vmstate_tpm_tis_i2c = {
 .version_id = 0,
 .pre_save  = tpm_tis_i2c_pre_save,
 .post_load  = tpm_tis_i2c_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_BUFFER(state.buffer, TPMStateI2C),
 VMSTATE_UINT16(state.rw_offset, TPMStateI2C),
 VMSTATE_UINT8(state.active_locty, TPMStateI2C),
diff --git a/hw/tpm/tpm_tis_isa.c b/hw/tpm/tpm_tis_isa.c
index 0367401586..8887b3c9c4 100644
--- a/hw/tpm/tpm_tis_isa.c
+++ b/hw/tpm/tpm_tis_isa.c
@@ -53,7 +53,7 @@ static const VMStateDescription vmstate_tpm_tis_isa = {
 .name = "tpm-tis",
 .version_id = 0,
 .pre_save  = tpm_tis_pre_save_isa,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_BUFFER(state.buffer, TPMStateISA),
 VMSTATE_UINT16(state.rw_offset, TPMStateISA),
 VMSTATE_UINT8(state.active_locty, TPMStateISA),
diff --git a/hw/tpm/tpm_tis_sysbus.c b/hw/tpm/tpm_tis_sysbus.c
index 2fc550f119..941f7f7f62 100644
--- a/hw/tpm/tpm_tis_sysbus.c
+++ b/hw/tpm/tpm_tis_sysbus.c
@@ -52,7 +52,7 @@ static const VMStateDescription vmstate_tpm_tis_sysbus = {
 .name = "tpm-tis",
 .version_id = 0,
 .pre_save  = tpm_tis_pre_save_sysbus,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_BUFFER(state.buffer, TPMStateSysBus),
 VMSTATE_UINT16(state.rw_offset, TPMStateSysBus),
 VMSTATE_UINT8(state.active_locty, TPMStateSysBus),
-- 
2.34.1




[PATCH v2 22/71] hw/adc: Constify VMState

2023-12-20 Thread Richard Henderson
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Richard Henderson 
---
 hw/adc/aspeed_adc.c| 2 +-
 hw/adc/max111x.c   | 2 +-
 hw/adc/npcm7xx_adc.c   | 2 +-
 hw/adc/stm32f2xx_adc.c | 2 +-
 hw/adc/zynq-xadc.c | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/adc/aspeed_adc.c b/hw/adc/aspeed_adc.c
index 0d29663129..68bdbc73b0 100644
--- a/hw/adc/aspeed_adc.c
+++ b/hw/adc/aspeed_adc.c
@@ -280,7 +280,7 @@ static const VMStateDescription vmstate_aspeed_adc_engine = 
{
 .name = TYPE_ASPEED_ADC,
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(regs, AspeedADCEngineState, ASPEED_ADC_NR_REGS),
 VMSTATE_END_OF_LIST(),
 }
diff --git a/hw/adc/max111x.c b/hw/adc/max111x.c
index e8bf4cccd4..957d177e1c 100644
--- a/hw/adc/max111x.c
+++ b/hw/adc/max111x.c
@@ -96,7 +96,7 @@ static const VMStateDescription vmstate_max111x = {
 .name = "max111x",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_SSI_PERIPHERAL(parent_obj, MAX111xState),
 VMSTATE_UINT8(tb1, MAX111xState),
 VMSTATE_UINT8(rb2, MAX111xState),
diff --git a/hw/adc/npcm7xx_adc.c b/hw/adc/npcm7xx_adc.c
index bc6f3f55e6..c6647eec6d 100644
--- a/hw/adc/npcm7xx_adc.c
+++ b/hw/adc/npcm7xx_adc.c
@@ -253,7 +253,7 @@ static const VMStateDescription vmstate_npcm7xx_adc = {
 .name = "npcm7xx-adc",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_TIMER(conv_timer, NPCM7xxADCState),
 VMSTATE_UINT32(con, NPCM7xxADCState),
 VMSTATE_UINT32(data, NPCM7xxADCState),
diff --git a/hw/adc/stm32f2xx_adc.c b/hw/adc/stm32f2xx_adc.c
index 01a0b14e69..e9df6ea53f 100644
--- a/hw/adc/stm32f2xx_adc.c
+++ b/hw/adc/stm32f2xx_adc.c
@@ -254,7 +254,7 @@ static const VMStateDescription vmstate_stm32f2xx_adc = {
 .name = TYPE_STM32F2XX_ADC,
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(adc_sr, STM32F2XXADCState),
 VMSTATE_UINT32(adc_cr1, STM32F2XXADCState),
 VMSTATE_UINT32(adc_cr2, STM32F2XXADCState),
diff --git a/hw/adc/zynq-xadc.c b/hw/adc/zynq-xadc.c
index 032e19cbd0..34268319a4 100644
--- a/hw/adc/zynq-xadc.c
+++ b/hw/adc/zynq-xadc.c
@@ -269,7 +269,7 @@ static const VMStateDescription vmstate_zynq_xadc = {
 .name = "zynq-xadc",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(regs, ZynqXADCState, ZYNQ_XADC_NUM_IO_REGS),
 VMSTATE_UINT16_ARRAY(xadc_regs, ZynqXADCState,
  ZYNQ_XADC_NUM_ADC_REGS),
-- 
2.34.1




[PATCH v2 41/71] hw/net: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/net/allwinner-sun8i-emac.c  |  2 +-
 hw/net/allwinner_emac.c|  4 ++--
 hw/net/cadence_gem.c   |  2 +-
 hw/net/can/can_kvaser_pci.c|  2 +-
 hw/net/can/can_mioe3680_pci.c  |  2 +-
 hw/net/can/can_pcm3680_pci.c   |  2 +-
 hw/net/can/can_sja1000.c   |  4 ++--
 hw/net/can/ctucan_core.c   |  4 ++--
 hw/net/can/ctucan_pci.c|  2 +-
 hw/net/can/xlnx-versal-canfd.c |  2 +-
 hw/net/can/xlnx-zynqmp-can.c   |  2 +-
 hw/net/dp8393x.c   |  2 +-
 hw/net/e1000.c | 10 +-
 hw/net/e1000e.c|  6 +++---
 hw/net/eepro100.c  |  2 +-
 hw/net/ftgmac100.c |  4 ++--
 hw/net/i82596.c|  2 +-
 hw/net/igb.c   |  8 
 hw/net/imx_fec.c   |  6 +++---
 hw/net/lan9118.c   |  4 ++--
 hw/net/lance.c |  2 +-
 hw/net/lasi_i82596.c   |  2 +-
 hw/net/mipsnet.c   |  2 +-
 hw/net/msf2-emac.c |  2 +-
 hw/net/mv88w8618_eth.c |  2 +-
 hw/net/ne2000-isa.c|  2 +-
 hw/net/ne2000-pci.c|  2 +-
 hw/net/ne2000.c|  2 +-
 hw/net/npcm7xx_emc.c   |  2 +-
 hw/net/pcnet-pci.c |  2 +-
 hw/net/pcnet.c |  2 +-
 hw/net/rtl8139.c   |  6 +++---
 hw/net/smc91c111.c |  2 +-
 hw/net/spapr_llan.c|  8 
 hw/net/stellaris_enet.c|  4 ++--
 hw/net/sungem.c|  2 +-
 hw/net/sunhme.c|  2 +-
 hw/net/tulip.c |  2 +-
 hw/net/virtio-net.c| 18 +-
 hw/net/vmxnet3.c   | 18 +-
 hw/net/xgmac.c |  4 ++--
 41 files changed, 80 insertions(+), 80 deletions(-)

diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c
index cc350d40e5..108ae9c853 100644
--- a/hw/net/allwinner-sun8i-emac.c
+++ b/hw/net/allwinner-sun8i-emac.c
@@ -851,7 +851,7 @@ static const VMStateDescription vmstate_aw_emac = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = allwinner_sun8i_emac_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(mii_phy_addr, AwSun8iEmacState),
 VMSTATE_UINT32(mii_cmd, AwSun8iEmacState),
 VMSTATE_UINT32(mii_data, AwSun8iEmacState),
diff --git a/hw/net/allwinner_emac.c b/hw/net/allwinner_emac.c
index e10965de14..989839784a 100644
--- a/hw/net/allwinner_emac.c
+++ b/hw/net/allwinner_emac.c
@@ -472,7 +472,7 @@ static const VMStateDescription vmstate_mii = {
 .name = "rtl8201cp",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT16(bmcr, RTL8201CPState),
 VMSTATE_UINT16(bmsr, RTL8201CPState),
 VMSTATE_UINT16(anar, RTL8201CPState),
@@ -495,7 +495,7 @@ static const VMStateDescription vmstate_aw_emac = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = aw_emac_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT(mii, AwEmacState, 1, vmstate_mii, RTL8201CPState),
 VMSTATE_UINT32(ctl, AwEmacState),
 VMSTATE_UINT32(tx_mode, AwEmacState),
diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
index 296bba238e..d7b7b134b0 100644
--- a/hw/net/cadence_gem.c
+++ b/hw/net/cadence_gem.c
@@ -1771,7 +1771,7 @@ static const VMStateDescription vmstate_cadence_gem = {
 .name = "cadence_gem",
 .version_id = 4,
 .minimum_version_id = 4,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(regs, CadenceGEMState, CADENCE_GEM_MAXREG),
 VMSTATE_UINT16_ARRAY(phy_regs, CadenceGEMState, 32),
 VMSTATE_UINT8(phy_loop, CadenceGEMState),
diff --git a/hw/net/can/can_kvaser_pci.c b/hw/net/can/can_kvaser_pci.c
index 2cd90cef1e..bf41e6b261 100644
--- a/hw/net/can/can_kvaser_pci.c
+++ b/hw/net/can/can_kvaser_pci.c
@@ -266,7 +266,7 @@ static const VMStateDescription vmstate_kvaser_pci = {
 .name = "kvaser_pci",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(dev, KvaserPCIState),
 /* Load this before sja_state.  */
 VMSTATE_UINT32(s5920_intcsr, KvaserPCIState),
diff --git a/hw/net/can/can_mioe3680_pci.c b/hw/net/can/can_mioe3680_pci.c
index b9918773b3..308b17e0c0 100644
--- a/hw/net/can/can_mioe3680_pci.c
+++ b/hw/net/can/can_mioe3680_pci.c
@@ -203,7 +203,7 @@ static const VMStateDescription vmstate_mioe3680_pci = {
 .name = "mioe3680_pci",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(dev, Mioe3680PCIState),
 VMSTATE_STRUCT(sja_state[0], Mioe3680PCIState, 0, vmstate_can_sja,

[PATCH v2 54/71] hw/sparc: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/sparc/sun4m_iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/sparc/sun4m_iommu.c b/hw/sparc/sun4m_iommu.c
index eb40f9377c..06703b1d96 100644
--- a/hw/sparc/sun4m_iommu.c
+++ b/hw/sparc/sun4m_iommu.c
@@ -331,7 +331,7 @@ static const VMStateDescription vmstate_iommu = {
 .name = "iommu",
 .version_id = 2,
 .minimum_version_id = 2,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(regs, IOMMUState, IOMMU_NREGS),
 VMSTATE_UINT64(iostart, IOMMUState),
 VMSTATE_END_OF_LIST()
-- 
2.34.1




Re: [PATCH v2 1/1] docs/system/riscv: document acpi parameter of virt machine

2023-12-20 Thread Sunil V L
On Wed, Dec 20, 2023 at 08:34:36PM +0100, Heinrich Schuchardt wrote:
> Since QEMU v8.0.0 the RISC-V virt machine has a switch to disable ACPI
> table generation. Add it to the documentation.
> 
> Fixes: 168b8c29cedb ("hw/riscv/virt: Add a switch to disable ACPI")
> Signed-off-by: Heinrich Schuchardt 
> ---
> v2:
>   mention that acpi=on is the default
> ---
>  docs/system/riscv/virt.rst | 5 +
>  1 file changed, 5 insertions(+)
> 
Reviewed-by: Sunil V L 

Thanks!
Sunil



[PATCH v2 71/71] docs: Constify VMstate in examples

2023-12-20 Thread Richard Henderson
Reviewed-by: Juan Quintela 
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Richard Henderson 
---
 docs/devel/clocks.rst| 2 +-
 docs/devel/migration.rst | 8 
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/docs/devel/clocks.rst b/docs/devel/clocks.rst
index 675fbeb6ab..c4d14bde04 100644
--- a/docs/devel/clocks.rst
+++ b/docs/devel/clocks.rst
@@ -502,7 +502,7 @@ This is typically used to migrate an input clock state. For 
example:
 
 VMStateDescription my_device_vmstate = {
 .name = "my_device",
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 [...], /* other migrated fields */
 VMSTATE_CLOCK(clk, MyDeviceState),
 VMSTATE_END_OF_LIST()
diff --git a/docs/devel/migration.rst b/docs/devel/migration.rst
index ec55089b25..95351ba51f 100644
--- a/docs/devel/migration.rst
+++ b/docs/devel/migration.rst
@@ -158,7 +158,7 @@ An example (from hw/input/pckbd.c)
   .name = "pckbd",
   .version_id = 3,
   .minimum_version_id = 3,
-  .fields = (VMStateField[]) {
+  .fields = (const VMStateField[]) {
   VMSTATE_UINT8(write_cmd, KBDState),
   VMSTATE_UINT8(status, KBDState),
   VMSTATE_UINT8(mode, KBDState),
@@ -294,7 +294,7 @@ Example:
   .pre_save = ide_drive_pio_pre_save,
   .post_load = ide_drive_pio_post_load,
   .needed = ide_drive_pio_state_needed,
-  .fields = (VMStateField[]) {
+  .fields = (const VMStateField[]) {
   VMSTATE_INT32(req_nb_sectors, IDEState),
   VMSTATE_VARRAY_INT32(io_buffer, IDEState, io_buffer_total_len, 1,
vmstate_info_uint8, uint8_t),
@@ -312,11 +312,11 @@ Example:
   .version_id = 3,
   .minimum_version_id = 0,
   .post_load = ide_drive_post_load,
-  .fields = (VMStateField[]) {
+  .fields = (const VMStateField[]) {
    several fields 
   VMSTATE_END_OF_LIST()
   },
-  .subsections = (const VMStateDescription*[]) {
+  .subsections = (const VMStateDescription * const []) {
   _ide_drive_pio_state,
   NULL
   }
-- 
2.34.1




[PATCH v2 63/71] audio: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 audio/audio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/audio/audio.c b/audio/audio.c
index 8d1e4ad922..a1097bb016 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1683,7 +1683,7 @@ static const VMStateDescription vmstate_audio = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = vmstate_audio_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_END_OF_LIST()
 }
 };
-- 
2.34.1




[PATCH v2 61/71] hw/watchdog: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/watchdog/allwinner-wdt.c  | 2 +-
 hw/watchdog/cmsdk-apb-watchdog.c | 2 +-
 hw/watchdog/sbsa_gwdt.c  | 2 +-
 hw/watchdog/spapr_watchdog.c | 2 +-
 hw/watchdog/wdt_aspeed.c | 2 +-
 hw/watchdog/wdt_diag288.c| 2 +-
 hw/watchdog/wdt_i6300esb.c   | 2 +-
 hw/watchdog/wdt_ib700.c  | 2 +-
 hw/watchdog/wdt_imx2.c   | 2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/hw/watchdog/allwinner-wdt.c b/hw/watchdog/allwinner-wdt.c
index 6205765efe..d35711c7c5 100644
--- a/hw/watchdog/allwinner-wdt.c
+++ b/hw/watchdog/allwinner-wdt.c
@@ -313,7 +313,7 @@ static const VMStateDescription allwinner_wdt_vmstate = {
 .name = "allwinner-wdt",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PTIMER(timer, AwWdtState),
 VMSTATE_UINT32_ARRAY(regs, AwWdtState, AW_WDT_REGS_NUM),
 VMSTATE_END_OF_LIST()
diff --git a/hw/watchdog/cmsdk-apb-watchdog.c b/hw/watchdog/cmsdk-apb-watchdog.c
index 5a2cd46eb7..3091e5c3d5 100644
--- a/hw/watchdog/cmsdk-apb-watchdog.c
+++ b/hw/watchdog/cmsdk-apb-watchdog.c
@@ -361,7 +361,7 @@ static const VMStateDescription cmsdk_apb_watchdog_vmstate 
= {
 .name = "cmsdk-apb-watchdog",
 .version_id = 2,
 .minimum_version_id = 2,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_CLOCK(wdogclk, CMSDKAPBWatchdog),
 VMSTATE_PTIMER(timer, CMSDKAPBWatchdog),
 VMSTATE_UINT32(control, CMSDKAPBWatchdog),
diff --git a/hw/watchdog/sbsa_gwdt.c b/hw/watchdog/sbsa_gwdt.c
index 7aa57a8c51..96895d7636 100644
--- a/hw/watchdog/sbsa_gwdt.c
+++ b/hw/watchdog/sbsa_gwdt.c
@@ -28,7 +28,7 @@ static const VMStateDescription vmstate_sbsa_gwdt = {
 .name = "sbsa-gwdt",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_TIMER_PTR(timer, SBSA_GWDTState),
 VMSTATE_UINT32(wcs, SBSA_GWDTState),
 VMSTATE_UINT32(worl, SBSA_GWDTState),
diff --git a/hw/watchdog/spapr_watchdog.c b/hw/watchdog/spapr_watchdog.c
index 55ff1f03c1..2bb1d3c532 100644
--- a/hw/watchdog/spapr_watchdog.c
+++ b/hw/watchdog/spapr_watchdog.c
@@ -226,7 +226,7 @@ static const VMStateDescription vmstate_wdt = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = watchdog_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_TIMER(timer, SpaprWatchdog),
 VMSTATE_UINT8(action, SpaprWatchdog),
 VMSTATE_UINT8(leave_others, SpaprWatchdog),
diff --git a/hw/watchdog/wdt_aspeed.c b/hw/watchdog/wdt_aspeed.c
index 273a49d360..d70b656f8e 100644
--- a/hw/watchdog/wdt_aspeed.c
+++ b/hw/watchdog/wdt_aspeed.c
@@ -218,7 +218,7 @@ static const VMStateDescription vmstate_aspeed_wdt = {
 .name = "vmstate_aspeed_wdt",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_TIMER_PTR(timer, AspeedWDTState),
 VMSTATE_UINT32_ARRAY(regs, AspeedWDTState, ASPEED_WDT_REGS_MAX),
 VMSTATE_END_OF_LIST()
diff --git a/hw/watchdog/wdt_diag288.c b/hw/watchdog/wdt_diag288.c
index 76d89fbf78..1b73b16fb3 100644
--- a/hw/watchdog/wdt_diag288.c
+++ b/hw/watchdog/wdt_diag288.c
@@ -23,7 +23,7 @@ static const VMStateDescription vmstate_diag288 = {
 .name = "vmstate_diag288",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_TIMER_PTR(timer, DIAG288State),
 VMSTATE_BOOL(enabled, DIAG288State),
 VMSTATE_END_OF_LIST()
diff --git a/hw/watchdog/wdt_i6300esb.c b/hw/watchdog/wdt_i6300esb.c
index 54c167cd35..8bce0509cd 100644
--- a/hw/watchdog/wdt_i6300esb.c
+++ b/hw/watchdog/wdt_i6300esb.c
@@ -418,7 +418,7 @@ static const VMStateDescription vmstate_i6300esb = {
  */
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(dev, I6300State),
 VMSTATE_INT32(reboot_enabled, I6300State),
 VMSTATE_INT32(clock_scale, I6300State),
diff --git a/hw/watchdog/wdt_ib700.c b/hw/watchdog/wdt_ib700.c
index a1750a4957..eea8da6059 100644
--- a/hw/watchdog/wdt_ib700.c
+++ b/hw/watchdog/wdt_ib700.c
@@ -95,7 +95,7 @@ static const VMStateDescription vmstate_ib700 = {
 .name = "ib700_wdt",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_TIMER_PTR(timer, IB700State),
 VMSTATE_END_OF_LIST()
 }
diff --git a/hw/watchdog/wdt_imx2.c b/hw/watchdog/wdt_imx2.c
index 891d7beb2a..6452fc4721 100644
--- a/hw/watchdog/wdt_imx2.c
+++ b/hw/watchdog/wdt_imx2.c
@@ -234,7 +234,7 @@ static const MemoryRegionOps imx2_wdt_ops = {
 
 static const 

[PATCH v2 56/71] hw/timer: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/timer/a9gtimer.c|  8 
 hw/timer/allwinner-a10-pit.c   |  2 +-
 hw/timer/arm_mptimer.c |  4 ++--
 hw/timer/arm_timer.c   |  4 ++--
 hw/timer/armv7m_systick.c  |  2 +-
 hw/timer/aspeed_timer.c|  4 ++--
 hw/timer/bcm2835_systmr.c  |  2 +-
 hw/timer/cadence_ttc.c |  4 ++--
 hw/timer/cmsdk-apb-dualtimer.c |  4 ++--
 hw/timer/cmsdk-apb-timer.c |  2 +-
 hw/timer/digic-timer.c |  2 +-
 hw/timer/etraxfs_timer.c   |  2 +-
 hw/timer/exynos4210_mct.c  | 12 ++--
 hw/timer/exynos4210_pwm.c  |  4 ++--
 hw/timer/hpet.c| 10 +-
 hw/timer/i8254_common.c|  4 ++--
 hw/timer/ibex_timer.c  |  2 +-
 hw/timer/imx_epit.c|  2 +-
 hw/timer/imx_gpt.c |  2 +-
 hw/timer/mss-timer.c   |  4 ++--
 hw/timer/npcm7xx_timer.c   |  8 
 hw/timer/nrf51_timer.c |  2 +-
 hw/timer/pxa2xx_timer.c|  6 +++---
 hw/timer/renesas_cmt.c |  2 +-
 hw/timer/renesas_tmr.c |  2 +-
 hw/timer/sifive_pwm.c  |  2 +-
 hw/timer/slavio_timer.c|  4 ++--
 hw/timer/sse-counter.c |  2 +-
 hw/timer/sse-timer.c   |  2 +-
 hw/timer/stellaris-gptm.c  |  2 +-
 hw/timer/stm32f2xx_timer.c |  2 +-
 31 files changed, 57 insertions(+), 57 deletions(-)

diff --git a/hw/timer/a9gtimer.c b/hw/timer/a9gtimer.c
index 5e959b6d09..a2ac5bdfb9 100644
--- a/hw/timer/a9gtimer.c
+++ b/hw/timer/a9gtimer.c
@@ -328,7 +328,7 @@ static const VMStateDescription vmstate_a9_gtimer_per_cpu = 
{
 .name = "arm.cortex-a9-global-timer.percpu",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(control, A9GTimerPerCPU),
 VMSTATE_UINT64(compare, A9GTimerPerCPU),
 VMSTATE_UINT32(status, A9GTimerPerCPU),
@@ -342,7 +342,7 @@ static const VMStateDescription vmstate_a9_gtimer_control = 
{
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = vmstate_a9_gtimer_control_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(control, A9GTimerState),
 VMSTATE_END_OF_LIST()
 }
@@ -352,7 +352,7 @@ static const VMStateDescription vmstate_a9_gtimer = {
 .name = "arm.cortex-a9-global-timer",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_TIMER_PTR(timer, A9GTimerState),
 VMSTATE_UINT64(counter, A9GTimerState),
 VMSTATE_UINT64(ref_counter, A9GTimerState),
@@ -362,7 +362,7 @@ static const VMStateDescription vmstate_a9_gtimer = {
  A9GTimerPerCPU),
 VMSTATE_END_OF_LIST()
 },
-.subsections = (const VMStateDescription*[]) {
+.subsections = (const VMStateDescription * const []) {
 _a9_gtimer_control,
 NULL
 }
diff --git a/hw/timer/allwinner-a10-pit.c b/hw/timer/allwinner-a10-pit.c
index 971f78462a..a524de1381 100644
--- a/hw/timer/allwinner-a10-pit.c
+++ b/hw/timer/allwinner-a10-pit.c
@@ -200,7 +200,7 @@ static const VMStateDescription vmstate_a10_pit = {
 .name = "a10.pit",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(irq_enable, AwA10PITState),
 VMSTATE_UINT32(irq_status, AwA10PITState),
 VMSTATE_UINT32_ARRAY(control, AwA10PITState, AW_A10_PIT_TIMER_NR),
diff --git a/hw/timer/arm_mptimer.c b/hw/timer/arm_mptimer.c
index cdfca3000b..bca4cee0e4 100644
--- a/hw/timer/arm_mptimer.c
+++ b/hw/timer/arm_mptimer.c
@@ -281,7 +281,7 @@ static const VMStateDescription vmstate_timerblock = {
 .name = "arm_mptimer_timerblock",
 .version_id = 3,
 .minimum_version_id = 3,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(control, TimerBlock),
 VMSTATE_UINT32(status, TimerBlock),
 VMSTATE_PTIMER(timer, TimerBlock),
@@ -293,7 +293,7 @@ static const VMStateDescription vmstate_arm_mptimer = {
 .name = "arm_mptimer",
 .version_id = 3,
 .minimum_version_id = 3,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT_VARRAY_UINT32(timerblock, ARMMPTimerState, num_cpu,
  3, vmstate_timerblock, TimerBlock),
 VMSTATE_END_OF_LIST()
diff --git a/hw/timer/arm_timer.c b/hw/timer/arm_timer.c
index 9afe8da831..0940e03f1d 100644
--- a/hw/timer/arm_timer.c
+++ b/hw/timer/arm_timer.c
@@ -163,7 +163,7 @@ static const VMStateDescription vmstate_arm_timer = {
 .name = "arm_timer",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(control, arm_timer_state),
 VMSTATE_UINT32(limit, 

[PATCH v2 47/71] hw/ppc: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/ppc/ppc.c|  2 +-
 hw/ppc/ppc4xx_pci.c |  6 +++---
 hw/ppc/prep_systemio.c  |  2 +-
 hw/ppc/rs6000_mc.c  |  2 +-
 hw/ppc/spapr.c  | 20 ++--
 hw/ppc/spapr_caps.c |  2 +-
 hw/ppc/spapr_cpu_core.c | 12 ++--
 hw/ppc/spapr_drc.c  |  8 
 hw/ppc/spapr_iommu.c|  6 +++---
 hw/ppc/spapr_nvdimm.c   |  4 ++--
 hw/ppc/spapr_ovec.c |  2 +-
 hw/ppc/spapr_pci.c  |  6 +++---
 hw/ppc/spapr_rtc.c  |  2 +-
 hw/ppc/spapr_vio.c  |  2 +-
 14 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c
index be167710a3..c532d79f0e 100644
--- a/hw/ppc/ppc.c
+++ b/hw/ppc/ppc.c
@@ -1066,7 +1066,7 @@ const VMStateDescription vmstate_ppc_timebase = {
 .version_id = 1,
 .minimum_version_id = 1,
 .pre_save = timebase_pre_save,
-.fields  = (VMStateField []) {
+.fields = (const VMStateField []) {
 VMSTATE_UINT64(guest_timebase, PPCTimebase),
 VMSTATE_INT64(time_of_the_day_ns, PPCTimebase),
 VMSTATE_END_OF_LIST()
diff --git a/hw/ppc/ppc4xx_pci.c b/hw/ppc/ppc4xx_pci.c
index 6652119008..0a07aab5d1 100644
--- a/hw/ppc/ppc4xx_pci.c
+++ b/hw/ppc/ppc4xx_pci.c
@@ -276,7 +276,7 @@ static const VMStateDescription vmstate_pci_master_map = {
 .name = "pci_master_map",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(la, struct PCIMasterMap),
 VMSTATE_UINT32(ma, struct PCIMasterMap),
 VMSTATE_UINT32(pcila, struct PCIMasterMap),
@@ -289,7 +289,7 @@ static const VMStateDescription vmstate_pci_target_map = {
 .name = "pci_target_map",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(ms, struct PCITargetMap),
 VMSTATE_UINT32(la, struct PCITargetMap),
 VMSTATE_END_OF_LIST()
@@ -300,7 +300,7 @@ static const VMStateDescription vmstate_ppc4xx_pci = {
 .name = "ppc4xx_pci",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT_ARRAY(pmm, PPC4xxPCIState, PPC4xx_PCI_NR_PMMS, 1,
  vmstate_pci_master_map,
  struct PCIMasterMap),
diff --git a/hw/ppc/prep_systemio.c b/hw/ppc/prep_systemio.c
index c96cefb13d..4d3a251ed8 100644
--- a/hw/ppc/prep_systemio.c
+++ b/hw/ppc/prep_systemio.c
@@ -277,7 +277,7 @@ static const VMStateDescription vmstate_prep_systemio = {
 .name = "prep_systemio",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(sreset, PrepSystemIoState),
 VMSTATE_UINT8(system_control, PrepSystemIoState),
 VMSTATE_UINT8(iomap_type, PrepSystemIoState),
diff --git a/hw/ppc/rs6000_mc.c b/hw/ppc/rs6000_mc.c
index c0bc212e92..b35f8ba112 100644
--- a/hw/ppc/rs6000_mc.c
+++ b/hw/ppc/rs6000_mc.c
@@ -202,7 +202,7 @@ static const VMStateDescription vmstate_rs6000mc = {
 .name = "rs6000-mc",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(port0820_index, RS6000MCState),
 VMSTATE_END_OF_LIST()
 },
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 9b6c1c129f..4997aa4f1d 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -152,7 +152,7 @@ static const VMStateDescription pre_2_10_vmstate_dummy_icp 
= {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = pre_2_10_vmstate_dummy_icp_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UNUSED(4), /* uint32_t xirr */
 VMSTATE_UNUSED(1), /* uint8_t pending_priority */
 VMSTATE_UNUSED(1), /* uint8_t mfrr */
@@ -1919,7 +1919,7 @@ static const VMStateDescription vmstate_spapr_event_entry 
= {
 .name = "spapr_event_log_entry",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(summary, SpaprEventLogEntry),
 VMSTATE_UINT32(extended_length, SpaprEventLogEntry),
 VMSTATE_VBUFFER_ALLOC_UINT32(extended_log, SpaprEventLogEntry, 0,
@@ -1933,7 +1933,7 @@ static const VMStateDescription 
vmstate_spapr_pending_events = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = spapr_pending_events_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_QTAILQ_V(pending_events, SpaprMachineState, 1,
  vmstate_spapr_event_entry, SpaprEventLogEntry, next),
 VMSTATE_END_OF_LIST()
@@ -1989,7 +1989,7 @@ static const VMStateDescription vmstate_spapr_ov5_cas = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = spapr_ov5_cas_needed,

[PATCH v2 66/71] migration: Constify VMState

2023-12-20 Thread Richard Henderson
Reviewed-by: Juan Quintela 
Signed-off-by: Richard Henderson 
---
 migration/global_state.c |  2 +-
 migration/savevm.c   | 10 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/migration/global_state.c b/migration/global_state.c
index 4e2a9d8ec0..8ee15dbb06 100644
--- a/migration/global_state.c
+++ b/migration/global_state.c
@@ -131,7 +131,7 @@ static const VMStateDescription vmstate_globalstate = {
 .post_load = global_state_post_load,
 .pre_save = global_state_pre_save,
 .needed = global_state_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(size, GlobalState),
 VMSTATE_BUFFER(runstate, GlobalState),
 VMSTATE_END_OF_LIST()
diff --git a/migration/savevm.c b/migration/savevm.c
index 39148636cc..3d0f459389 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -438,7 +438,7 @@ static const VMStateDescription vmstate_target_page_bits = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = vmstate_target_page_bits_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(target_page_bits, SaveState),
 VMSTATE_END_OF_LIST()
 }
@@ -454,7 +454,7 @@ static const VMStateDescription vmstate_capabilites = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = vmstate_capabilites_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_V(caps_count, SaveState, 1),
 VMSTATE_VARRAY_UINT32_ALLOC(capabilities, SaveState, caps_count, 1,
 vmstate_info_capability,
@@ -499,7 +499,7 @@ static const VMStateDescription vmstate_uuid = {
 .minimum_version_id = 1,
 .needed = vmstate_uuid_needed,
 .post_load = vmstate_uuid_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8_ARRAY_V(uuid.data, SaveState, sizeof(QemuUUID), 1),
 VMSTATE_END_OF_LIST()
 }
@@ -512,12 +512,12 @@ static const VMStateDescription vmstate_configuration = {
 .post_load = configuration_post_load,
 .pre_save = configuration_pre_save,
 .post_save = configuration_post_save,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(len, SaveState),
 VMSTATE_VBUFFER_ALLOC_UINT32(name, SaveState, 0, NULL, len),
 VMSTATE_END_OF_LIST()
 },
-.subsections = (const VMStateDescription *[]) {
+.subsections = (const VMStateDescription * const []) {
 _target_page_bits,
 _capabilites,
 _uuid,
-- 
2.34.1




[PATCH v2 42/71] hw/nvram: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/nvram/ds1225y.c| 2 +-
 hw/nvram/eeprom93xx.c | 2 +-
 hw/nvram/fw_cfg.c | 8 
 hw/nvram/mac_nvram.c  | 2 +-
 hw/nvram/npcm7xx_otp.c| 2 +-
 hw/nvram/nrf51_nvm.c  | 2 +-
 hw/nvram/spapr_nvram.c| 2 +-
 hw/nvram/xlnx-bbram.c | 2 +-
 hw/nvram/xlnx-versal-efuse-ctrl.c | 2 +-
 hw/nvram/xlnx-zynqmp-efuse.c  | 2 +-
 10 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/hw/nvram/ds1225y.c b/hw/nvram/ds1225y.c
index 3660a47c51..6d510dcc68 100644
--- a/hw/nvram/ds1225y.c
+++ b/hw/nvram/ds1225y.c
@@ -102,7 +102,7 @@ static const VMStateDescription vmstate_nvram = {
 .version_id = 0,
 .minimum_version_id = 0,
 .post_load = nvram_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_VARRAY_UINT32(contents, NvRamState, chip_size, 0,
   vmstate_info_uint8, uint8_t),
 VMSTATE_END_OF_LIST()
diff --git a/hw/nvram/eeprom93xx.c b/hw/nvram/eeprom93xx.c
index 57d63638d7..a8fd60a8fb 100644
--- a/hw/nvram/eeprom93xx.c
+++ b/hw/nvram/eeprom93xx.c
@@ -131,7 +131,7 @@ static const VMStateDescription vmstate_eeprom = {
 .name = "eeprom",
 .version_id = EEPROM_VERSION,
 .minimum_version_id = OLD_EEPROM_VERSION,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(tick, eeprom_t),
 VMSTATE_UINT8(address, eeprom_t),
 VMSTATE_UINT8(command, eeprom_t),
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 4e4524673a..e85493d513 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -656,7 +656,7 @@ static int fw_cfg_acpi_mr_restore_post_load(void *opaque, 
int version_id)
 static const VMStateDescription vmstate_fw_cfg_dma = {
 .name = "fw_cfg/dma",
 .needed = fw_cfg_dma_enabled,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(dma_addr, FWCfgState),
 VMSTATE_END_OF_LIST()
 },
@@ -668,7 +668,7 @@ static const VMStateDescription vmstate_fw_cfg_acpi_mr = {
 .minimum_version_id = 1,
 .needed = fw_cfg_acpi_mr_restore,
 .post_load = fw_cfg_acpi_mr_restore_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(table_mr_size, FWCfgState),
 VMSTATE_UINT64(linker_mr_size, FWCfgState),
 VMSTATE_UINT64(rsdp_mr_size, FWCfgState),
@@ -680,13 +680,13 @@ static const VMStateDescription vmstate_fw_cfg = {
 .name = "fw_cfg",
 .version_id = 2,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT16(cur_entry, FWCfgState),
 VMSTATE_UINT16_HACK(cur_offset, FWCfgState, is_version_1),
 VMSTATE_UINT32_V(cur_offset, FWCfgState, 2),
 VMSTATE_END_OF_LIST()
 },
-.subsections = (const VMStateDescription*[]) {
+.subsections = (const VMStateDescription * const []) {
 _fw_cfg_dma,
 _fw_cfg_acpi_mr,
 NULL,
diff --git a/hw/nvram/mac_nvram.c b/hw/nvram/mac_nvram.c
index 810e84f07e..5f9d16fb3e 100644
--- a/hw/nvram/mac_nvram.c
+++ b/hw/nvram/mac_nvram.c
@@ -79,7 +79,7 @@ static const VMStateDescription vmstate_macio_nvram = {
 .name = "macio_nvram",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_VBUFFER_UINT32(data, MacIONVRAMState, 0, NULL, size),
 VMSTATE_END_OF_LIST()
 }
diff --git a/hw/nvram/npcm7xx_otp.c b/hw/nvram/npcm7xx_otp.c
index c61f2fc1aa..f00ebfa931 100644
--- a/hw/nvram/npcm7xx_otp.c
+++ b/hw/nvram/npcm7xx_otp.c
@@ -384,7 +384,7 @@ static const VMStateDescription vmstate_npcm7xx_otp = {
 .name = "npcm7xx-otp",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(regs, NPCM7xxOTPState, NPCM7XX_OTP_NR_REGS),
 VMSTATE_UINT8_ARRAY(array, NPCM7xxOTPState, NPCM7XX_OTP_ARRAY_BYTES),
 VMSTATE_END_OF_LIST(),
diff --git a/hw/nvram/nrf51_nvm.c b/hw/nvram/nrf51_nvm.c
index 7f1db8c423..ed8b836074 100644
--- a/hw/nvram/nrf51_nvm.c
+++ b/hw/nvram/nrf51_nvm.c
@@ -366,7 +366,7 @@ static const VMStateDescription vmstate_nvm = {
 .name = "nrf51_soc.nvm",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(uicr_content, NRF51NVMState,
 NRF51_UICR_FIXTURE_SIZE),
 VMSTATE_UINT32(config, NRF51NVMState),
diff --git a/hw/nvram/spapr_nvram.c b/hw/nvram/spapr_nvram.c
index 2d72f30442..bfd8aa367e 100644
--- a/hw/nvram/spapr_nvram.c
+++ b/hw/nvram/spapr_nvram.c
@@ -245,7 +245,7 @@ static const VMStateDescription vmstate_spapr_nvram = {
 .minimum_version_id = 1,
 .pre_load = spapr_nvram_pre_load,
 

[PATCH v2 62/71] hw/misc/macio: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/misc/macio/cuda.c  | 2 +-
 hw/misc/macio/gpio.c  | 2 +-
 hw/misc/macio/mac_dbdma.c | 8 
 hw/misc/macio/macio.c | 4 ++--
 hw/misc/macio/pmu.c   | 6 +++---
 5 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c
index 6336dcb194..41934e2cf8 100644
--- a/hw/misc/macio/cuda.c
+++ b/hw/misc/macio/cuda.c
@@ -487,7 +487,7 @@ static const VMStateDescription vmstate_cuda = {
 .name = "cuda",
 .version_id = 6,
 .minimum_version_id = 6,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT(mos6522_cuda.parent_obj, CUDAState, 0, vmstate_mos6522,
MOS6522State),
 VMSTATE_UINT8(last_b, CUDAState),
diff --git a/hw/misc/macio/gpio.c b/hw/misc/macio/gpio.c
index 4deb330471..549563747d 100644
--- a/hw/misc/macio/gpio.c
+++ b/hw/misc/macio/gpio.c
@@ -168,7 +168,7 @@ static const VMStateDescription vmstate_macio_gpio = {
 .name = "macio_gpio",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8_ARRAY(gpio_levels, MacIOGPIOState, 8),
 VMSTATE_UINT8_ARRAY(gpio_regs, MacIOGPIOState, 36),
 VMSTATE_END_OF_LIST()
diff --git a/hw/misc/macio/mac_dbdma.c b/hw/misc/macio/mac_dbdma.c
index 80a789f32b..2a528ea08c 100644
--- a/hw/misc/macio/mac_dbdma.c
+++ b/hw/misc/macio/mac_dbdma.c
@@ -807,7 +807,7 @@ static const VMStateDescription vmstate_dbdma_io = {
 .name = "dbdma_io",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(addr, struct DBDMA_io),
 VMSTATE_INT32(len, struct DBDMA_io),
 VMSTATE_INT32(is_last, struct DBDMA_io),
@@ -821,7 +821,7 @@ static const VMStateDescription vmstate_dbdma_cmd = {
 .name = "dbdma_cmd",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT16(req_count, dbdma_cmd),
 VMSTATE_UINT16(command, dbdma_cmd),
 VMSTATE_UINT32(phy_addr, dbdma_cmd),
@@ -836,7 +836,7 @@ static const VMStateDescription vmstate_dbdma_channel = {
 .name = "dbdma_channel",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(regs, struct DBDMA_channel, DBDMA_REGS),
 VMSTATE_STRUCT(io, struct DBDMA_channel, 0, vmstate_dbdma_io, 
DBDMA_io),
 VMSTATE_STRUCT(current, struct DBDMA_channel, 0, vmstate_dbdma_cmd,
@@ -849,7 +849,7 @@ static const VMStateDescription vmstate_dbdma = {
 .name = "dbdma",
 .version_id = 3,
 .minimum_version_id = 3,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT_ARRAY(channels, DBDMAState, DBDMA_CHANNELS, 1,
  vmstate_dbdma_channel, DBDMA_channel),
 VMSTATE_END_OF_LIST()
diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c
index 265c0bbd8d..c9f22f8515 100644
--- a/hw/misc/macio/macio.c
+++ b/hw/misc/macio/macio.c
@@ -376,7 +376,7 @@ static const VMStateDescription vmstate_macio_oldworld = {
 .name = "macio-oldworld",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(parent_obj.parent, OldWorldMacIOState),
 VMSTATE_END_OF_LIST()
 }
@@ -396,7 +396,7 @@ static const VMStateDescription vmstate_macio_newworld = {
 .name = "macio-newworld",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(parent_obj.parent, NewWorldMacIOState),
 VMSTATE_END_OF_LIST()
 }
diff --git a/hw/misc/macio/pmu.c b/hw/misc/macio/pmu.c
index 58316d1871..e9a90da88f 100644
--- a/hw/misc/macio/pmu.c
+++ b/hw/misc/macio/pmu.c
@@ -668,7 +668,7 @@ static const VMStateDescription vmstate_pmu_adb = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = pmu_adb_state_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(adb_reply_size, PMUState),
 VMSTATE_BUFFER(adb_reply, PMUState),
 VMSTATE_END_OF_LIST()
@@ -679,7 +679,7 @@ static const VMStateDescription vmstate_pmu = {
 .name = "pmu",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT(mos6522_pmu.parent_obj, PMUState, 0, vmstate_mos6522,
MOS6522State),
 VMSTATE_UINT8(last_b, PMUState),
@@ -698,7 +698,7 @@ static const VMStateDescription vmstate_pmu = {
 VMSTATE_INT64(one_sec_target, PMUState),
 VMSTATE_END_OF_LIST()
 },
-.subsections = (const VMStateDescription * 

[PATCH v2 68/71] replay: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 replay/replay-snapshot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/replay/replay-snapshot.c b/replay/replay-snapshot.c
index 10a7cf7992..e5e39161e3 100644
--- a/replay/replay-snapshot.c
+++ b/replay/replay-snapshot.c
@@ -51,7 +51,7 @@ static const VMStateDescription vmstate_replay = {
 .minimum_version_id = 2,
 .pre_save = replay_pre_save,
 .post_load = replay_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT64_ARRAY(cached_clock, ReplayState, REPLAY_CLOCK_COUNT),
 VMSTATE_UINT64(current_icount, ReplayState),
 VMSTATE_INT32(instruction_count, ReplayState),
-- 
2.34.1




[PATCH v2 58/71] hw/usb: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/usb/bus.c|  2 +-
 hw/usb/ccid-card-passthru.c |  2 +-
 hw/usb/dev-hid.c|  4 ++--
 hw/usb/dev-hub.c|  8 
 hw/usb/dev-mtp.c|  2 +-
 hw/usb/dev-smartcard-reader.c   |  8 
 hw/usb/dev-storage.c|  2 +-
 hw/usb/dev-uas.c|  2 +-
 hw/usb/hcd-dwc2.c   |  4 ++--
 hw/usb/hcd-dwc3.c   |  2 +-
 hw/usb/hcd-ehci-pci.c   |  2 +-
 hw/usb/hcd-ehci-sysbus.c|  2 +-
 hw/usb/hcd-ehci.c   |  2 +-
 hw/usb/hcd-ohci-pci.c   |  2 +-
 hw/usb/hcd-ohci.c   |  8 
 hw/usb/hcd-uhci.c   |  4 ++--
 hw/usb/hcd-xhci-pci.c   |  2 +-
 hw/usb/hcd-xhci-sysbus.c|  2 +-
 hw/usb/hcd-xhci.c   | 12 ++--
 hw/usb/host-libusb.c|  2 +-
 hw/usb/imx-usb-phy.c|  2 +-
 hw/usb/redirect.c   | 16 
 hw/usb/u2f-passthru.c   |  2 +-
 hw/usb/u2f.c|  2 +-
 hw/usb/xlnx-versal-usb2-ctrl-regs.c |  2 +-
 25 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 92d6ed5626..59c39945dd 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -69,7 +69,7 @@ const VMStateDescription vmstate_usb_device = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = usb_device_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(addr, USBDevice),
 VMSTATE_INT32(state, USBDevice),
 VMSTATE_INT32(remote_wakeup, USBDevice),
diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c
index 07ee42f304..a515703904 100644
--- a/hw/usb/ccid-card-passthru.c
+++ b/hw/usb/ccid-card-passthru.c
@@ -378,7 +378,7 @@ static const VMStateDescription passthru_vmstate = {
 .name = "ccid-card-passthru",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_BUFFER(vscard_in_data, PassthruState),
 VMSTATE_UINT32(vscard_in_pos, PassthruState),
 VMSTATE_UINT32(vscard_in_hdr, PassthruState),
diff --git a/hw/usb/dev-hid.c b/hw/usb/dev-hid.c
index bdd6d1ffaf..9e358c934e 100644
--- a/hw/usb/dev-hid.c
+++ b/hw/usb/dev-hid.c
@@ -756,7 +756,7 @@ static const VMStateDescription vmstate_usb_ptr = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = usb_ptr_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_USB_DEVICE(dev, USBHIDState),
 VMSTATE_HID_POINTER_DEVICE(hid, USBHIDState),
 VMSTATE_END_OF_LIST()
@@ -767,7 +767,7 @@ static const VMStateDescription vmstate_usb_kbd = {
 .name = "usb-kbd",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_USB_DEVICE(dev, USBHIDState),
 VMSTATE_HID_KEYBOARD_DEVICE(hid, USBHIDState),
 VMSTATE_END_OF_LIST()
diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c
index 5703e0e826..06e9537d03 100644
--- a/hw/usb/dev-hub.c
+++ b/hw/usb/dev-hub.c
@@ -623,7 +623,7 @@ static const VMStateDescription vmstate_usb_hub_port = {
 .name = "usb-hub-port",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT16(wPortStatus, USBHubPort),
 VMSTATE_UINT16(wPortChange, USBHubPort),
 VMSTATE_END_OF_LIST()
@@ -642,7 +642,7 @@ static const VMStateDescription vmstate_usb_hub_port_timer 
= {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = usb_hub_port_timer_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_TIMER_PTR(port_timer, USBHubState),
 VMSTATE_END_OF_LIST()
 },
@@ -652,13 +652,13 @@ static const VMStateDescription vmstate_usb_hub = {
 .name = "usb-hub",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_USB_DEVICE(dev, USBHubState),
 VMSTATE_STRUCT_ARRAY(ports, USBHubState, MAX_PORTS, 0,
  vmstate_usb_hub_port, USBHubPort),
 VMSTATE_END_OF_LIST()
 },
-.subsections = (const VMStateDescription * []) {
+.subsections = (const VMStateDescription * const []) {
 _usb_hub_port_timer,
 NULL
 }
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 1cac1cd435..7e4a0765ae 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -2072,7 +2072,7 @@ static const VMStateDescription vmstate_usb_mtp = {
 .unmigratable = 1,
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 

[PATCH v2 49/71] hw/rtc: Constify VMState

2023-12-20 Thread Richard Henderson
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Richard Henderson 
---
 hw/rtc/allwinner-rtc.c   | 2 +-
 hw/rtc/aspeed_rtc.c  | 2 +-
 hw/rtc/ds1338.c  | 2 +-
 hw/rtc/exynos4210_rtc.c  | 2 +-
 hw/rtc/goldfish_rtc.c| 2 +-
 hw/rtc/ls7a_rtc.c| 2 +-
 hw/rtc/m48t59.c  | 2 +-
 hw/rtc/mc146818rtc.c | 6 +++---
 hw/rtc/pl031.c   | 6 +++---
 hw/rtc/twl92230.c| 4 ++--
 hw/rtc/xlnx-zynqmp-rtc.c | 2 +-
 11 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/hw/rtc/allwinner-rtc.c b/hw/rtc/allwinner-rtc.c
index 7e493f0e79..2ac50b30cb 100644
--- a/hw/rtc/allwinner-rtc.c
+++ b/hw/rtc/allwinner-rtc.c
@@ -305,7 +305,7 @@ static const VMStateDescription allwinner_rtc_vmstate = {
 .name = "allwinner-rtc",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(regs, AwRtcState, AW_RTC_REGS_NUM),
 VMSTATE_END_OF_LIST()
 }
diff --git a/hw/rtc/aspeed_rtc.c b/hw/rtc/aspeed_rtc.c
index fa861e2d49..589d9a5a7a 100644
--- a/hw/rtc/aspeed_rtc.c
+++ b/hw/rtc/aspeed_rtc.c
@@ -137,7 +137,7 @@ static const MemoryRegionOps aspeed_rtc_ops = {
 static const VMStateDescription vmstate_aspeed_rtc = {
 .name = TYPE_ASPEED_RTC,
 .version_id = 2,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(reg, AspeedRtcState, 0x18),
 VMSTATE_INT64(offset, AspeedRtcState),
 VMSTATE_END_OF_LIST()
diff --git a/hw/rtc/ds1338.c b/hw/rtc/ds1338.c
index 36d8121ddd..e479661c39 100644
--- a/hw/rtc/ds1338.c
+++ b/hw/rtc/ds1338.c
@@ -46,7 +46,7 @@ static const VMStateDescription vmstate_ds1338 = {
 .name = "ds1338",
 .version_id = 2,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_I2C_SLAVE(parent_obj, DS1338State),
 VMSTATE_INT64(offset, DS1338State),
 VMSTATE_UINT8_V(wday_offset, DS1338State, 2),
diff --git a/hw/rtc/exynos4210_rtc.c b/hw/rtc/exynos4210_rtc.c
index cc7101c530..319371f97d 100644
--- a/hw/rtc/exynos4210_rtc.c
+++ b/hw/rtc/exynos4210_rtc.c
@@ -122,7 +122,7 @@ static const VMStateDescription 
vmstate_exynos4210_rtc_state = {
 .name = "exynos4210.rtc",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(reg_intp, Exynos4210RTCState),
 VMSTATE_UINT32(reg_rtccon, Exynos4210RTCState),
 VMSTATE_UINT32(reg_ticcnt, Exynos4210RTCState),
diff --git a/hw/rtc/goldfish_rtc.c b/hw/rtc/goldfish_rtc.c
index 19a56402a0..01acf30b27 100644
--- a/hw/rtc/goldfish_rtc.c
+++ b/hw/rtc/goldfish_rtc.c
@@ -242,7 +242,7 @@ static const VMStateDescription goldfish_rtc_vmstate = {
 .version_id = 2,
 .pre_save = goldfish_rtc_pre_save,
 .post_load = goldfish_rtc_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(tick_offset_vmstate, GoldfishRTCState),
 VMSTATE_UINT64(alarm_next, GoldfishRTCState),
 VMSTATE_UINT32(alarm_running, GoldfishRTCState),
diff --git a/hw/rtc/ls7a_rtc.c b/hw/rtc/ls7a_rtc.c
index 1f9e38a735..ac28c1165b 100644
--- a/hw/rtc/ls7a_rtc.c
+++ b/hw/rtc/ls7a_rtc.c
@@ -454,7 +454,7 @@ static const VMStateDescription vmstate_ls7a_rtc = {
 .minimum_version_id = 1,
 .pre_save = ls7a_rtc_pre_save,
 .post_load = ls7a_rtc_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT64(offset_toy, LS7ARtcState),
 VMSTATE_INT64(offset_rtc, LS7ARtcState),
 VMSTATE_UINT32_ARRAY(toymatch, LS7ARtcState, TIMER_NUMS),
diff --git a/hw/rtc/m48t59.c b/hw/rtc/m48t59.c
index 2e2c849985..aa44c4b20c 100644
--- a/hw/rtc/m48t59.c
+++ b/hw/rtc/m48t59.c
@@ -526,7 +526,7 @@ static const VMStateDescription vmstate_m48t59 = {
 .name = "m48t59",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(lock, M48t59State),
 VMSTATE_UINT16(addr, M48t59State),
 VMSTATE_VBUFFER_UINT32(buffer, M48t59State, 0, NULL, size),
diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c
index 2d391a8396..f4c1869232 100644
--- a/hw/rtc/mc146818rtc.c
+++ b/hw/rtc/mc146818rtc.c
@@ -817,7 +817,7 @@ static const VMStateDescription 
vmstate_rtc_irq_reinject_on_ack_count = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = rtc_irq_reinject_on_ack_count_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT16(irq_reinject_on_ack_count, MC146818RtcState),
 VMSTATE_END_OF_LIST()
 }
@@ -829,7 +829,7 @@ static const VMStateDescription vmstate_rtc = {
 .minimum_version_id = 1,
 .pre_save = rtc_pre_save,
 .post_load = rtc_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 

[PATCH v2 65/71] cpu-target: Constify VMState

2023-12-20 Thread Richard Henderson
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Richard Henderson 
---
 cpu-target.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/cpu-target.c b/cpu-target.c
index 508013e23d..430dc53566 100644
--- a/cpu-target.c
+++ b/cpu-target.c
@@ -87,7 +87,7 @@ static const VMStateDescription 
vmstate_cpu_common_exception_index = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = cpu_common_exception_index_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT32(exception_index, CPUState),
 VMSTATE_END_OF_LIST()
 }
@@ -105,7 +105,7 @@ static const VMStateDescription 
vmstate_cpu_common_crash_occurred = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = cpu_common_crash_occurred_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_BOOL(crash_occurred, CPUState),
 VMSTATE_END_OF_LIST()
 }
@@ -117,12 +117,12 @@ const VMStateDescription vmstate_cpu_common = {
 .minimum_version_id = 1,
 .pre_load = cpu_common_pre_load,
 .post_load = cpu_common_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(halted, CPUState),
 VMSTATE_UINT32(interrupt_request, CPUState),
 VMSTATE_END_OF_LIST()
 },
-.subsections = (const VMStateDescription*[]) {
+.subsections = (const VMStateDescription * const []) {
 _cpu_common_exception_index,
 _cpu_common_crash_occurred,
 NULL
-- 
2.34.1




[PATCH v2 70/71] tests/unit/test-vmstate: Constify VMState

2023-12-20 Thread Richard Henderson
While const data in tests is not particularly important,
this makes a grep test clear across the tree.

Reviewed-by: Juan Quintela 
Signed-off-by: Richard Henderson 
---
 tests/unit/test-vmstate.c | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/tests/unit/test-vmstate.c b/tests/unit/test-vmstate.c
index 0b7d5ecd68..c4f9faa273 100644
--- a/tests/unit/test-vmstate.c
+++ b/tests/unit/test-vmstate.c
@@ -197,7 +197,7 @@ static const VMStateDescription vmstate_simple_primitive = {
 .name = "simple/primitive",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_BOOL(b_1, TestSimple),
 VMSTATE_BOOL(b_2, TestSimple),
 VMSTATE_UINT8(u8_1, TestSimple),
@@ -299,7 +299,7 @@ static const VMStateDescription vmstate_simple_arr = {
 .name = "simple/array",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT16_ARRAY(u16_1, TestSimpleArray, 3),
 VMSTATE_END_OF_LIST()
 }
@@ -341,7 +341,7 @@ static const VMStateDescription vmstate_versioned = {
 .name = "test/versioned",
 .version_id = 2,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(a, TestStruct),
 VMSTATE_UINT32_V(b, TestStruct, 2), /* Versioned field in the middle, 
so
  * we catch bugs more easily.
@@ -412,7 +412,7 @@ static const VMStateDescription vmstate_skipping = {
 .name = "test/skip",
 .version_id = 2,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(a, TestStruct),
 VMSTATE_UINT32(b, TestStruct),
 VMSTATE_UINT32_TEST(c, TestStruct, test_skip),
@@ -524,7 +524,7 @@ const VMStateDescription vmsd_tst = {
 .name = "test/tst",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT32(i, TestStructTriv),
 VMSTATE_END_OF_LIST()
 }
@@ -542,7 +542,7 @@ const VMStateDescription vmsd_arps = {
 .name = "test/arps",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_ARRAY_OF_POINTER_TO_STRUCT(ar, TestArrayOfPtrToStuct,
 AR_SIZE, 0, vmsd_tst, TestStructTriv),
 VMSTATE_END_OF_LIST()
@@ -630,7 +630,7 @@ const VMStateDescription vmsd_arpp = {
 .name = "test/arps",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_ARRAY_OF_POINTER(ar, TestArrayOfPtrToInt,
 AR_SIZE, 0, vmstate_info_int32, int32_t*),
 VMSTATE_END_OF_LIST()
@@ -685,7 +685,7 @@ static const VMStateDescription vmstate_q_element = {
 .name = "test/queue-element",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_BOOL(b, TestQtailqElement),
 VMSTATE_UINT8(u8, TestQtailqElement),
 VMSTATE_END_OF_LIST()
@@ -696,7 +696,7 @@ static const VMStateDescription vmstate_q = {
 .name = "test/queue",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT16(i16, TestQtailq),
 VMSTATE_QTAILQ_V(q, TestQtailq, 1, vmstate_q_element, 
TestQtailqElement,
  next),
@@ -821,7 +821,7 @@ typedef struct TestGTreeInterval {
 .name = "interval",\
 .version_id = 1,   \
 .minimum_version_id = 1,   \
-.fields = (VMStateField[]) {   \
+.fields = (const VMStateField[]) { \
 VMSTATE_UINT64(low, TestGTreeInterval),\
 VMSTATE_UINT64(high, TestGTreeInterval),   \
 VMSTATE_END_OF_LIST()  \
@@ -839,7 +839,7 @@ typedef struct TestGTreeMapping {
 .name = "mapping",\
 .version_id = 1,  \
 .minimum_version_id = 1,  \
-.fields = (VMStateField[]) {  \
+.fields = (const VMStateField[]) {\
 VMSTATE_UINT64(phys_addr, TestGTreeMapping),  \
 VMSTATE_UINT32(flags, TestGTreeMapping),  \
 VMSTATE_END_OF_LIST() \
@@ -915,7 +915,7 @@ static const VMStateDescription vmstate_domain = {
 .version_id = 1,
 .minimum_version_id = 1,
 .pre_load = domain_preload,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT32(id, TestGTreeDomain),
 

[PATCH v2 60/71] hw/virtio: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/virtio/vdpa-dev.c   |  2 +-
 hw/virtio/vhost-user-fs.c  |  6 +++---
 hw/virtio/vhost-vsock.c|  2 +-
 hw/virtio/virtio-balloon.c | 10 +-
 hw/virtio/virtio-crypto.c  |  2 +-
 hw/virtio/virtio-iommu.c   | 12 ++--
 hw/virtio/virtio-mem.c |  8 
 hw/virtio/virtio-mmio.c|  8 
 hw/virtio/virtio-pci.c |  8 
 hw/virtio/virtio-rng.c |  2 +-
 hw/virtio/virtio.c | 28 ++--
 11 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/hw/virtio/vdpa-dev.c b/hw/virtio/vdpa-dev.c
index f22d5d5bc0..e405926de0 100644
--- a/hw/virtio/vdpa-dev.c
+++ b/hw/virtio/vdpa-dev.c
@@ -341,7 +341,7 @@ static const VMStateDescription vmstate_vhost_vdpa_device = 
{
 .unmigratable = 1,
 .minimum_version_id = 1,
 .version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_VIRTIO_DEVICE,
 VMSTATE_END_OF_LIST()
 },
diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c
index eb91723855..cca2cd41be 100644
--- a/hw/virtio/vhost-user-fs.c
+++ b/hw/virtio/vhost-user-fs.c
@@ -373,11 +373,11 @@ static const VMStateDescription vuf_backend_vmstate;
 static const VMStateDescription vuf_vmstate = {
 .name = "vhost-user-fs",
 .version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_VIRTIO_DEVICE,
 VMSTATE_END_OF_LIST()
 },
-.subsections = (const VMStateDescription * []) {
+.subsections = (const VMStateDescription * const []) {
 _backend_vmstate,
 NULL,
 }
@@ -389,7 +389,7 @@ static const VMStateDescription vuf_backend_vmstate = {
 .needed = vuf_is_internal_migration,
 .pre_load = vuf_check_migration_support,
 .pre_save = vuf_check_migration_support,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 {
 .name = "back-end",
 .info = &(const VMStateInfo) {
diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c
index aa16d584ee..d5ca0b5a10 100644
--- a/hw/virtio/vhost-vsock.c
+++ b/hw/virtio/vhost-vsock.c
@@ -111,7 +111,7 @@ static const VMStateDescription vmstate_virtio_vhost_vsock 
= {
 .name = "virtio-vhost_vsock",
 .minimum_version_id = VHOST_VSOCK_SAVEVM_VERSION,
 .version_id = VHOST_VSOCK_SAVEVM_VERSION,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_VIRTIO_DEVICE,
 VMSTATE_END_OF_LIST()
 },
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index d004cf29d2..486fe3da32 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -817,7 +817,7 @@ static const VMStateDescription 
vmstate_virtio_balloon_free_page_hint = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = virtio_balloon_free_page_support,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(free_page_hint_cmd_id, VirtIOBalloon),
 VMSTATE_UINT32(free_page_hint_status, VirtIOBalloon),
 VMSTATE_END_OF_LIST()
@@ -829,7 +829,7 @@ static const VMStateDescription 
vmstate_virtio_balloon_page_poison = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = virtio_balloon_page_poison_support,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(poison_val, VirtIOBalloon),
 VMSTATE_END_OF_LIST()
 }
@@ -840,12 +840,12 @@ static const VMStateDescription 
vmstate_virtio_balloon_device = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = virtio_balloon_post_load_device,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(num_pages, VirtIOBalloon),
 VMSTATE_UINT32(actual, VirtIOBalloon),
 VMSTATE_END_OF_LIST()
 },
-.subsections = (const VMStateDescription * []) {
+.subsections = (const VMStateDescription * const []) {
 _virtio_balloon_free_page_hint,
 _virtio_balloon_page_poison,
 NULL
@@ -996,7 +996,7 @@ static const VMStateDescription vmstate_virtio_balloon = {
 .name = "virtio-balloon",
 .minimum_version_id = 1,
 .version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_VIRTIO_DEVICE,
 VMSTATE_END_OF_LIST()
 },
diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c
index 0e2cc8d5a8..fe1313f2ad 100644
--- a/hw/virtio/virtio-crypto.c
+++ b/hw/virtio/virtio-crypto.c
@@ -1122,7 +1122,7 @@ static const VMStateDescription vmstate_virtio_crypto = {
 .unmigratable = 1,
 .minimum_version_id = VIRTIO_CRYPTO_VM_VERSION,
 .version_id = VIRTIO_CRYPTO_VM_VERSION,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_VIRTIO_DEVICE,
 VMSTATE_END_OF_LIST()
 },
diff --git a/hw/virtio/virtio-iommu.c 

[PATCH v2 64/71] backends: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 backends/dbus-vmstate.c | 2 +-
 backends/tpm/tpm_emulator.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/backends/dbus-vmstate.c b/backends/dbus-vmstate.c
index a9d8cb0acd..be6c4d8e0a 100644
--- a/backends/dbus-vmstate.c
+++ b/backends/dbus-vmstate.c
@@ -393,7 +393,7 @@ static const VMStateDescription dbus_vmstate = {
 .version_id = 0,
 .pre_save = dbus_vmstate_pre_save,
 .post_load = dbus_vmstate_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(data_size, DBusVMState),
 VMSTATE_VBUFFER_ALLOC_UINT32(data, DBusVMState, 0, 0, data_size),
 VMSTATE_END_OF_LIST()
diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c
index f7f1b4ad7a..ebdd2e0a69 100644
--- a/backends/tpm/tpm_emulator.c
+++ b/backends/tpm/tpm_emulator.c
@@ -939,7 +939,7 @@ static const VMStateDescription vmstate_tpm_emulator = {
 .version_id = 0,
 .pre_save = tpm_emulator_pre_save,
 .post_load = tpm_emulator_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(state_blobs.permanent_flags, TPMEmulator),
 VMSTATE_UINT32(state_blobs.permanent.size, TPMEmulator),
 VMSTATE_VBUFFER_ALLOC_UINT32(state_blobs.permanent.buffer,
-- 
2.34.1




[PATCH v2 50/71] hw/s390x: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/s390x/ccw-device.c |  2 +-
 hw/s390x/css.c| 36 ++--
 hw/s390x/event-facility.c |  8 
 hw/s390x/ipl.c|  8 
 hw/s390x/sclpquiesce.c|  2 +-
 hw/s390x/virtio-ccw.c |  4 ++--
 6 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/hw/s390x/ccw-device.c b/hw/s390x/ccw-device.c
index 95f269ab44..fb8c1acc64 100644
--- a/hw/s390x/ccw-device.c
+++ b/hw/s390x/ccw-device.c
@@ -66,7 +66,7 @@ const VMStateDescription vmstate_ccw_dev = {
 .name = "s390_ccw_dev",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT_POINTER(sch, CcwDevice, vmstate_subch_dev, SubchDev),
 VMSTATE_END_OF_LIST()
 }
diff --git a/hw/s390x/css.c b/hw/s390x/css.c
index bcedec2fc8..295530963a 100644
--- a/hw/s390x/css.c
+++ b/hw/s390x/css.c
@@ -32,7 +32,7 @@ static const VMStateDescription vmstate_crw = {
 .name = "s390_crw",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT16(flags, CRW),
 VMSTATE_UINT16(rsid, CRW),
 VMSTATE_END_OF_LIST()
@@ -43,7 +43,7 @@ static const VMStateDescription vmstate_crw_container = {
 .name = "s390_crw_container",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT(crw, CrwContainer, 0, vmstate_crw, CRW),
 VMSTATE_END_OF_LIST()
 },
@@ -59,7 +59,7 @@ static const VMStateDescription vmstate_chp_info = {
 .name = "s390_chp_info",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(in_use, ChpInfo),
 VMSTATE_UINT8(type, ChpInfo),
 VMSTATE_UINT8(is_virtual, ChpInfo),
@@ -77,7 +77,7 @@ static const VMStateDescription vmstate_scsw = {
 .name = "s390_scsw",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT16(flags, SCSW),
 VMSTATE_UINT16(ctrl, SCSW),
 VMSTATE_UINT32(cpa, SCSW),
@@ -92,7 +92,7 @@ static const VMStateDescription vmstate_pmcw = {
 .name = "s390_pmcw",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(intparm, PMCW),
 VMSTATE_UINT16(flags, PMCW),
 VMSTATE_UINT16(devno, PMCW),
@@ -113,7 +113,7 @@ static const VMStateDescription vmstate_schib = {
 .name = "s390_schib",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT(pmcw, SCHIB, 0, vmstate_pmcw, PMCW),
 VMSTATE_STRUCT(scsw, SCHIB, 0, vmstate_scsw, SCSW),
 VMSTATE_UINT64(mba, SCHIB),
@@ -127,7 +127,7 @@ static const VMStateDescription vmstate_ccw1 = {
 .name = "s390_ccw1",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(cmd_code, CCW1),
 VMSTATE_UINT8(flags, CCW1),
 VMSTATE_UINT16(count, CCW1),
@@ -140,7 +140,7 @@ static const VMStateDescription vmstate_ciw = {
 .name = "s390_ciw",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(type, CIW),
 VMSTATE_UINT8(command, CIW),
 VMSTATE_UINT16(count, CIW),
@@ -152,7 +152,7 @@ static const VMStateDescription vmstate_sense_id = {
 .name = "s390_sense_id",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(reserved, SenseId),
 VMSTATE_UINT16(cu_type, SenseId),
 VMSTATE_UINT8(cu_model, SenseId),
@@ -168,7 +168,7 @@ static const VMStateDescription vmstate_orb = {
 .name = "s390_orb",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(intparm, ORB),
 VMSTATE_UINT16(ctrl0, ORB),
 VMSTATE_UINT8(lpm, ORB),
@@ -188,7 +188,7 @@ static const VMStateDescription vmstate_schdev_orb = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = vmstate_schdev_orb_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT(orb, SubchDev, 1, vmstate_orb, ORB),
 VMSTATE_END_OF_LIST()
 }
@@ -207,7 +207,7 @@ const VMStateDescription vmstate_subch_dev = {
 .minimum_version_id = 1,
 .post_load = subch_dev_post_load,
 .pre_save = subch_dev_pre_save,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8_EQUAL(cssid, 

[PATCH v2 52/71] hw/sd: Constify VMState

2023-12-20 Thread Richard Henderson
Tested-by: Philippe Mathieu-Daudé 
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Richard Henderson 
---
 hw/sd/allwinner-sdhost.c | 2 +-
 hw/sd/aspeed_sdhci.c | 2 +-
 hw/sd/bcm2835_sdhost.c   | 2 +-
 hw/sd/cadence_sdhci.c| 2 +-
 hw/sd/npcm7xx_sdhci.c| 2 +-
 hw/sd/pl181.c| 2 +-
 hw/sd/pxa2xx_mmci.c  | 2 +-
 hw/sd/sd.c   | 6 +++---
 hw/sd/sdhci.c| 6 +++---
 hw/sd/ssi-sd.c   | 2 +-
 10 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/hw/sd/allwinner-sdhost.c b/hw/sd/allwinner-sdhost.c
index 1a576d62ae..a1b7230633 100644
--- a/hw/sd/allwinner-sdhost.c
+++ b/hw/sd/allwinner-sdhost.c
@@ -773,7 +773,7 @@ static const VMStateDescription vmstate_allwinner_sdhost = {
 .name = "allwinner-sdhost",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(global_ctl, AwSdHostState),
 VMSTATE_UINT32(clock_ctl, AwSdHostState),
 VMSTATE_UINT32(timeout, AwSdHostState),
diff --git a/hw/sd/aspeed_sdhci.c b/hw/sd/aspeed_sdhci.c
index e53206d959..3b63926c3a 100644
--- a/hw/sd/aspeed_sdhci.c
+++ b/hw/sd/aspeed_sdhci.c
@@ -177,7 +177,7 @@ static void aspeed_sdhci_reset(DeviceState *dev)
 static const VMStateDescription vmstate_aspeed_sdhci = {
 .name = TYPE_ASPEED_SDHCI,
 .version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(regs, AspeedSDHCIState, ASPEED_SDHCI_NUM_REGS),
 VMSTATE_END_OF_LIST(),
 },
diff --git a/hw/sd/bcm2835_sdhost.c b/hw/sd/bcm2835_sdhost.c
index a600cf39e2..11c54dd4a7 100644
--- a/hw/sd/bcm2835_sdhost.c
+++ b/hw/sd/bcm2835_sdhost.c
@@ -381,7 +381,7 @@ static const VMStateDescription vmstate_bcm2835_sdhost = {
 .name = TYPE_BCM2835_SDHOST,
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(cmd, BCM2835SDHostState),
 VMSTATE_UINT32(cmdarg, BCM2835SDHostState),
 VMSTATE_UINT32(status, BCM2835SDHostState),
diff --git a/hw/sd/cadence_sdhci.c b/hw/sd/cadence_sdhci.c
index ef4e0d74e3..7c8bc5464b 100644
--- a/hw/sd/cadence_sdhci.c
+++ b/hw/sd/cadence_sdhci.c
@@ -159,7 +159,7 @@ static void cadence_sdhci_realize(DeviceState *dev, Error 
**errp)
 static const VMStateDescription vmstate_cadence_sdhci = {
 .name = TYPE_CADENCE_SDHCI,
 .version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(regs, CadenceSDHCIState, CADENCE_SDHCI_NUM_REGS),
 VMSTATE_END_OF_LIST(),
 },
diff --git a/hw/sd/npcm7xx_sdhci.c b/hw/sd/npcm7xx_sdhci.c
index 9958680090..e93dab8dbd 100644
--- a/hw/sd/npcm7xx_sdhci.c
+++ b/hw/sd/npcm7xx_sdhci.c
@@ -142,7 +142,7 @@ static void npcm7xx_sdhci_reset(DeviceState *dev)
 static const VMStateDescription vmstate_npcm7xx_sdhci = {
 .name = TYPE_NPCM7XX_SDHCI,
 .version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(regs.boottoctrl, NPCM7xxSDHCIState),
 VMSTATE_END_OF_LIST(),
 },
diff --git a/hw/sd/pl181.c b/hw/sd/pl181.c
index 2b33814d83..e3633c2e6f 100644
--- a/hw/sd/pl181.c
+++ b/hw/sd/pl181.c
@@ -63,7 +63,7 @@ static const VMStateDescription vmstate_pl181 = {
 .name = "pl181",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(clock, PL181State),
 VMSTATE_UINT32(power, PL181State),
 VMSTATE_UINT32(cmdarg, PL181State),
diff --git a/hw/sd/pxa2xx_mmci.c b/hw/sd/pxa2xx_mmci.c
index 5e8ea69188..82529708c8 100644
--- a/hw/sd/pxa2xx_mmci.c
+++ b/hw/sd/pxa2xx_mmci.c
@@ -84,7 +84,7 @@ static const VMStateDescription vmstate_pxa2xx_mmci = {
 .name = "pxa2xx-mmci",
 .version_id = 2,
 .minimum_version_id = 2,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(status, PXA2xxMMCIState),
 VMSTATE_UINT32(clkrt, PXA2xxMMCIState),
 VMSTATE_UINT32(spi, PXA2xxMMCIState),
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 1106ff7d78..807b5d3de3 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -681,7 +681,7 @@ static const VMStateDescription sd_ocr_vmstate = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = sd_ocr_vmstate_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(ocr, SDState),
 VMSTATE_TIMER_PTR(ocr_power_timer, SDState),
 VMSTATE_END_OF_LIST()
@@ -706,7 +706,7 @@ static const VMStateDescription sd_vmstate = {
 .version_id = 2,
 .minimum_version_id = 2,
 .pre_load = sd_vmstate_pre_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(mode, SDState),
 VMSTATE_INT32(state, SDState),
 VMSTATE_UINT8_ARRAY(cid, SDState, 16),
@@ 

[PATCH v2 46/71] hw/pci-host: Constify VMState

2023-12-20 Thread Richard Henderson
Tested-by: Philippe Mathieu-Daudé 
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Richard Henderson 
---
 hw/pci-host/astro.c  |  4 ++--
 hw/pci-host/bonito.c |  2 +-
 hw/pci-host/designware.c | 10 +-
 hw/pci-host/dino.c   |  2 +-
 hw/pci-host/gpex.c   |  2 +-
 hw/pci-host/gt64120.c|  2 +-
 hw/pci-host/i440fx.c |  2 +-
 hw/pci-host/ppce500.c|  6 +++---
 hw/pci-host/q35.c|  2 +-
 hw/pci-host/raven.c  |  2 +-
 hw/pci-host/versatile.c  |  2 +-
 11 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/hw/pci-host/astro.c b/hw/pci-host/astro.c
index 7d68ccee7e..f4de70475c 100644
--- a/hw/pci-host/astro.c
+++ b/hw/pci-host/astro.c
@@ -459,7 +459,7 @@ static const VMStateDescription vmstate_elroy = {
 .name = "Elroy",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(hpa, ElroyState),
 VMSTATE_UINT32(pci_bus_num, ElroyState),
 VMSTATE_UINT64(config_address, ElroyState),
@@ -691,7 +691,7 @@ static const VMStateDescription vmstate_astro = {
 .name = "Astro",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(ioc_ctrl, AstroState),
 VMSTATE_UINT64(ioc_status_ctrl, AstroState),
 VMSTATE_UINT64_ARRAY(ioc_ranges, AstroState, (0x03d8 - 0x300) / 8),
diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c
index bab661f3ce..1f0c435348 100644
--- a/hw/pci-host/bonito.c
+++ b/hw/pci-host/bonito.c
@@ -619,7 +619,7 @@ static const VMStateDescription vmstate_bonito = {
 .name = "Bonito",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(dev, PCIBonitoState),
 VMSTATE_END_OF_LIST()
 }
diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c
index f477f97847..dd9e389c07 100644
--- a/hw/pci-host/designware.c
+++ b/hw/pci-host/designware.c
@@ -529,7 +529,7 @@ static const VMStateDescription 
vmstate_designware_pcie_msi_bank = {
 .name = "designware-pcie-msi-bank",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(enable, DesignwarePCIEMSIBank),
 VMSTATE_UINT32(mask, DesignwarePCIEMSIBank),
 VMSTATE_UINT32(status, DesignwarePCIEMSIBank),
@@ -541,7 +541,7 @@ static const VMStateDescription vmstate_designware_pcie_msi 
= {
 .name = "designware-pcie-msi",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(base, DesignwarePCIEMSI),
 VMSTATE_STRUCT_ARRAY(intr,
  DesignwarePCIEMSI,
@@ -557,7 +557,7 @@ static const VMStateDescription 
vmstate_designware_pcie_viewport = {
 .name = "designware-pcie-viewport",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(base, DesignwarePCIEViewport),
 VMSTATE_UINT64(target, DesignwarePCIEViewport),
 VMSTATE_UINT32(limit, DesignwarePCIEViewport),
@@ -570,7 +570,7 @@ static const VMStateDescription 
vmstate_designware_pcie_root = {
 .name = "designware-pcie-root",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(parent_obj, PCIBridge),
 VMSTATE_UINT32(atu_viewport, DesignwarePCIERoot),
 VMSTATE_STRUCT_2DARRAY(viewports,
@@ -718,7 +718,7 @@ static const VMStateDescription 
vmstate_designware_pcie_host = {
 .name = "designware-pcie-host",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT(root,
DesignwarePCIEHost,
1,
diff --git a/hw/pci-host/dino.c b/hw/pci-host/dino.c
index 5b0947a16c..d992c4bb69 100644
--- a/hw/pci-host/dino.c
+++ b/hw/pci-host/dino.c
@@ -287,7 +287,7 @@ static const VMStateDescription vmstate_dino = {
 .name = "Dino",
 .version_id = 2,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(iar0, DinoState),
 VMSTATE_UINT32(iar1, DinoState),
 VMSTATE_UINT32(imr, DinoState),
diff --git a/hw/pci-host/gpex.c b/hw/pci-host/gpex.c
index a6752fac5e..e117e47fa7 100644
--- a/hw/pci-host/gpex.c
+++ b/hw/pci-host/gpex.c
@@ -195,7 +195,7 @@ static const VMStateDescription vmstate_gpex_root = {
 .name = "gpex_root",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(parent_obj, GPEXRootState),
 VMSTATE_END_OF_LIST()
 }
diff 

[PATCH v2 69/71] util/fifo8: Constify VMState

2023-12-20 Thread Richard Henderson
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Richard Henderson 
---
 util/fifo8.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util/fifo8.c b/util/fifo8.c
index d4d1c135e0..de8fd0f1c5 100644
--- a/util/fifo8.c
+++ b/util/fifo8.c
@@ -109,7 +109,7 @@ const VMStateDescription vmstate_fifo8 = {
 .name = "Fifo8",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_VBUFFER_UINT32(data, Fifo8, 1, NULL, capacity),
 VMSTATE_UINT32(head, Fifo8),
 VMSTATE_UINT32(num, Fifo8),
-- 
2.34.1




[PATCH v2 44/71] hw/pci: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 include/hw/pci/shpc.h | 2 +-
 hw/pci/msix.c | 4 ++--
 hw/pci/pci.c  | 8 
 hw/pci/pci_host.c | 2 +-
 hw/pci/pcie_aer.c | 4 ++--
 hw/pci/shpc.c | 2 +-
 6 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/hw/pci/shpc.h b/include/hw/pci/shpc.h
index 89c7a3b7fa..a0789df153 100644
--- a/include/hw/pci/shpc.h
+++ b/include/hw/pci/shpc.h
@@ -52,7 +52,7 @@ void shpc_device_unplug_cb(HotplugHandler *hotplug_dev, 
DeviceState *dev,
 void shpc_device_unplug_request_cb(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp);
 
-extern VMStateInfo shpc_vmstate_info;
+extern const VMStateInfo shpc_vmstate_info;
 #define SHPC_VMSTATE(_field, _type,  _test) \
 VMSTATE_BUFFER_UNSAFE_INFO_TEST(_field, _type, _test, 0, \
 shpc_vmstate_info, 0)
diff --git a/hw/pci/msix.c b/hw/pci/msix.c
index cd817f4ca8..487e49834e 100644
--- a/hw/pci/msix.c
+++ b/hw/pci/msix.c
@@ -685,7 +685,7 @@ static int get_msix_state(QEMUFile *f, void *pv, size_t 
size,
 return 0;
 }
 
-static VMStateInfo vmstate_info_msix = {
+static const VMStateInfo vmstate_info_msix = {
 .name = "msix state",
 .get  = get_msix_state,
 .put  = put_msix_state,
@@ -693,7 +693,7 @@ static VMStateInfo vmstate_info_msix = {
 
 const VMStateDescription vmstate_msix = {
 .name = "msix",
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 {
 .name = "msix",
 .version_id   = 0,
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index c49417abb2..76080af580 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -92,7 +92,7 @@ static const VMStateDescription vmstate_pcibus = {
 .name = "PCIBUS",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT32_EQUAL(nirq, PCIBus, NULL),
 VMSTATE_VARRAY_INT32(irq_count, PCIBus,
  nirq, 0, vmstate_info_int32,
@@ -673,7 +673,7 @@ static int put_pci_config_device(QEMUFile *f, void *pv, 
size_t size,
 return 0;
 }
 
-static VMStateInfo vmstate_info_pci_config = {
+static const VMStateInfo vmstate_info_pci_config = {
 .name = "pci config",
 .get  = get_pci_config_device,
 .put  = put_pci_config_device,
@@ -714,7 +714,7 @@ static int put_pci_irq_state(QEMUFile *f, void *pv, size_t 
size,
 return 0;
 }
 
-static VMStateInfo vmstate_info_pci_irq_state = {
+static const VMStateInfo vmstate_info_pci_irq_state = {
 .name = "pci irq state",
 .get  = get_pci_irq_state,
 .put  = put_pci_irq_state,
@@ -734,7 +734,7 @@ const VMStateDescription vmstate_pci_device = {
 .name = "PCIDevice",
 .version_id = 2,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT32_POSITIVE_LE(version_id, PCIDevice),
 VMSTATE_BUFFER_UNSAFE_INFO_TEST(config, PCIDevice,
migrate_is_not_pcie,
diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c
index a18aa0a8d4..dfe6fe6184 100644
--- a/hw/pci/pci_host.c
+++ b/hw/pci/pci_host.c
@@ -234,7 +234,7 @@ const VMStateDescription vmstate_pcihost = {
 .needed = pci_host_needed,
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(config_reg, PCIHostState),
 VMSTATE_END_OF_LIST()
 }
diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c
index b68c7ecb49..2c85a78fcd 100644
--- a/hw/pci/pcie_aer.c
+++ b/hw/pci/pcie_aer.c
@@ -797,7 +797,7 @@ static const VMStateDescription vmstate_pcie_aer_err = {
 .name = "PCIE_AER_ERROR",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(status, PCIEAERErr),
 VMSTATE_UINT16(source_id, PCIEAERErr),
 VMSTATE_UINT16(flags, PCIEAERErr),
@@ -818,7 +818,7 @@ const VMStateDescription vmstate_pcie_aer_log = {
 .name = "PCIE_AER_ERROR_LOG",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT16(log_num, PCIEAERLog),
 VMSTATE_UINT16_EQUAL(log_max, PCIEAERLog, NULL),
 VMSTATE_VALIDATE("log_num <= log_max", pcie_aer_state_log_num_valid),
diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c
index df7f370111..d2a5eea69e 100644
--- a/hw/pci/shpc.c
+++ b/hw/pci/shpc.c
@@ -736,7 +736,7 @@ static int shpc_load(QEMUFile *f, void *pv, size_t size,
 return 0;
 }
 
-VMStateInfo shpc_vmstate_info = {
+const VMStateInfo shpc_vmstate_info = {
 .name = "shpc",
 .get  = shpc_load,
 .put  = shpc_save,
-- 
2.34.1




[PATCH v2 67/71] system: Constify VMState

2023-12-20 Thread Richard Henderson
Tested-by: Philippe Mathieu-Daudé 
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Richard Henderson 
---
 system/cpu-timers.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/system/cpu-timers.c b/system/cpu-timers.c
index 7452d97b67..bdf3a41dcb 100644
--- a/system/cpu-timers.c
+++ b/system/cpu-timers.c
@@ -165,7 +165,7 @@ static const VMStateDescription icount_vmstate_warp_timer = 
{
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = warp_timer_state_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT64(vm_clock_warp_start, TimersState),
 VMSTATE_TIMER_PTR(icount_warp_timer, TimersState),
 VMSTATE_END_OF_LIST()
@@ -177,7 +177,7 @@ static const VMStateDescription 
icount_vmstate_adjust_timers = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = adjust_timers_state_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_TIMER_PTR(icount_rt_timer, TimersState),
 VMSTATE_TIMER_PTR(icount_vm_timer, TimersState),
 VMSTATE_END_OF_LIST()
@@ -189,7 +189,7 @@ static const VMStateDescription icount_vmstate_shift = {
 .version_id = 2,
 .minimum_version_id = 2,
 .needed = icount_shift_state_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT16(icount_time_shift, TimersState),
 VMSTATE_INT64(last_delta, TimersState),
 VMSTATE_END_OF_LIST()
@@ -204,12 +204,12 @@ static const VMStateDescription icount_vmstate_timers = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = icount_state_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT64(qemu_icount_bias, TimersState),
 VMSTATE_INT64(qemu_icount, TimersState),
 VMSTATE_END_OF_LIST()
 },
-.subsections = (const VMStateDescription * []) {
+.subsections = (const VMStateDescription * const []) {
 _vmstate_warp_timer,
 _vmstate_adjust_timers,
 _vmstate_shift,
@@ -221,13 +221,13 @@ static const VMStateDescription vmstate_timers = {
 .name = "timer",
 .version_id = 2,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT64(cpu_ticks_offset, TimersState),
 VMSTATE_UNUSED(8),
 VMSTATE_INT64_V(cpu_clock_offset, TimersState, 2),
 VMSTATE_END_OF_LIST()
 },
-.subsections = (const VMStateDescription * []) {
+.subsections = (const VMStateDescription * const []) {
 _vmstate_timers,
 NULL
 }
-- 
2.34.1




[PATCH v2 55/71] hw/ssi: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/ssi/aspeed_smc.c   | 2 +-
 hw/ssi/ibex_spi_host.c| 2 +-
 hw/ssi/imx_spi.c  | 2 +-
 hw/ssi/mss-spi.c  | 2 +-
 hw/ssi/npcm7xx_fiu.c  | 2 +-
 hw/ssi/npcm_pspi.c| 2 +-
 hw/ssi/pl022.c| 2 +-
 hw/ssi/ssi.c  | 2 +-
 hw/ssi/stm32f2xx_spi.c| 2 +-
 hw/ssi/xilinx_spi.c   | 2 +-
 hw/ssi/xilinx_spips.c | 6 +++---
 hw/ssi/xlnx-versal-ospi.c | 4 ++--
 12 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
index 2a4001b774..3c93936fd1 100644
--- a/hw/ssi/aspeed_smc.c
+++ b/hw/ssi/aspeed_smc.c
@@ -1201,7 +1201,7 @@ static const VMStateDescription vmstate_aspeed_smc = {
 .name = "aspeed.smc",
 .version_id = 2,
 .minimum_version_id = 2,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(regs, AspeedSMCState, ASPEED_SMC_R_MAX),
 VMSTATE_UINT8(snoop_index, AspeedSMCState),
 VMSTATE_UINT8(snoop_dummies, AspeedSMCState),
diff --git a/hw/ssi/ibex_spi_host.c b/hw/ssi/ibex_spi_host.c
index c300ec294d..863b5fd60e 100644
--- a/hw/ssi/ibex_spi_host.c
+++ b/hw/ssi/ibex_spi_host.c
@@ -570,7 +570,7 @@ static const VMStateDescription vmstate_ibex = {
 .name = TYPE_IBEX_SPI_HOST,
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(regs, IbexSPIHostState, IBEX_SPI_HOST_MAX_REGS),
 VMSTATE_VARRAY_UINT32(config_opts, IbexSPIHostState,
   num_cs, 0, vmstate_info_uint32, uint32_t),
diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c
index 189423bb3a..d8a7583ff3 100644
--- a/hw/ssi/imx_spi.c
+++ b/hw/ssi/imx_spi.c
@@ -62,7 +62,7 @@ static const VMStateDescription vmstate_imx_spi = {
 .name = TYPE_IMX_SPI,
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_FIFO32(tx_fifo, IMXSPIState),
 VMSTATE_FIFO32(rx_fifo, IMXSPIState),
 VMSTATE_INT16(burst_length, IMXSPIState),
diff --git a/hw/ssi/mss-spi.c b/hw/ssi/mss-spi.c
index b2432c5a13..1d25ba23aa 100644
--- a/hw/ssi/mss-spi.c
+++ b/hw/ssi/mss-spi.c
@@ -390,7 +390,7 @@ static const VMStateDescription vmstate_mss_spi = {
 .name = TYPE_MSS_SPI,
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_FIFO32(tx_fifo, MSSSpiState),
 VMSTATE_FIFO32(rx_fifo, MSSSpiState),
 VMSTATE_UINT32_ARRAY(regs, MSSSpiState, R_SPI_MAX),
diff --git a/hw/ssi/npcm7xx_fiu.c b/hw/ssi/npcm7xx_fiu.c
index 4eedb2927e..81dd972ee8 100644
--- a/hw/ssi/npcm7xx_fiu.c
+++ b/hw/ssi/npcm7xx_fiu.c
@@ -534,7 +534,7 @@ static const VMStateDescription vmstate_npcm7xx_fiu = {
 .name = "npcm7xx-fiu",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT32(active_cs, NPCM7xxFIUState),
 VMSTATE_UINT32_ARRAY(regs, NPCM7xxFIUState, NPCM7XX_FIU_NR_REGS),
 VMSTATE_END_OF_LIST(),
diff --git a/hw/ssi/npcm_pspi.c b/hw/ssi/npcm_pspi.c
index 3fb935043a..41a5323530 100644
--- a/hw/ssi/npcm_pspi.c
+++ b/hw/ssi/npcm_pspi.c
@@ -192,7 +192,7 @@ static const VMStateDescription vmstate_npcm_pspi = {
 .name = "npcm-pspi",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT16_ARRAY(regs, NPCMPSPIState, NPCM_PSPI_NR_REGS),
 VMSTATE_END_OF_LIST(),
 },
diff --git a/hw/ssi/pl022.c b/hw/ssi/pl022.c
index 8954ffebb1..b8be8ddf0e 100644
--- a/hw/ssi/pl022.c
+++ b/hw/ssi/pl022.c
@@ -249,7 +249,7 @@ static const VMStateDescription vmstate_pl022 = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = pl022_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(cr0, PL022State),
 VMSTATE_UINT32(cr1, PL022State),
 VMSTATE_UINT32(bitmask, PL022State),
diff --git a/hw/ssi/ssi.c b/hw/ssi/ssi.c
index 1f3e540ab8..3f357e8f16 100644
--- a/hw/ssi/ssi.c
+++ b/hw/ssi/ssi.c
@@ -172,7 +172,7 @@ const VMStateDescription vmstate_ssi_peripheral = {
 .name = "SSISlave",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_BOOL(cs, SSIPeripheral),
 VMSTATE_END_OF_LIST()
 }
diff --git a/hw/ssi/stm32f2xx_spi.c b/hw/ssi/stm32f2xx_spi.c
index cd6e8443db..a37139fe5a 100644
--- a/hw/ssi/stm32f2xx_spi.c
+++ b/hw/ssi/stm32f2xx_spi.c
@@ -174,7 +174,7 @@ static const VMStateDescription vmstate_stm32f2xx_spi = {
 .name = TYPE_STM32F2XX_SPI,
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 

[PATCH v2 15/71] target/riscv: Constify VMState in machine.c

2023-12-20 Thread Richard Henderson
Acked-by: Alistair Francis 
Signed-off-by: Richard Henderson 
---
 target/riscv/machine.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/target/riscv/machine.c b/target/riscv/machine.c
index fdde243e04..72fe2374dc 100644
--- a/target/riscv/machine.c
+++ b/target/riscv/machine.c
@@ -49,7 +49,7 @@ static const VMStateDescription vmstate_pmp_entry = {
 .name = "cpu/pmp/entry",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINTTL(addr_reg, pmp_entry_t),
 VMSTATE_UINT8(cfg_reg, pmp_entry_t),
 VMSTATE_END_OF_LIST()
@@ -62,7 +62,7 @@ static const VMStateDescription vmstate_pmp = {
 .minimum_version_id = 1,
 .needed = pmp_needed,
 .post_load = pmp_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT_ARRAY(env.pmp_state.pmp, RISCVCPU, MAX_RISCV_PMPS,
  0, vmstate_pmp_entry, pmp_entry_t),
 VMSTATE_END_OF_LIST()
@@ -82,7 +82,7 @@ static const VMStateDescription vmstate_hyper = {
 .version_id = 3,
 .minimum_version_id = 3,
 .needed = hyper_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINTTL(env.hstatus, RISCVCPU),
 VMSTATE_UINTTL(env.hedeleg, RISCVCPU),
 VMSTATE_UINT64(env.hideleg, RISCVCPU),
@@ -138,7 +138,7 @@ static const VMStateDescription vmstate_vector = {
 .version_id = 2,
 .minimum_version_id = 2,
 .needed = vector_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64_ARRAY(env.vreg, RISCVCPU, 32 * RV_VLEN_MAX / 64),
 VMSTATE_UINTTL(env.vxrm, RISCVCPU),
 VMSTATE_UINTTL(env.vxsat, RISCVCPU),
@@ -163,7 +163,7 @@ static const VMStateDescription vmstate_pointermasking = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = pointermasking_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINTTL(env.mmte, RISCVCPU),
 VMSTATE_UINTTL(env.mpmmask, RISCVCPU),
 VMSTATE_UINTTL(env.mpmbase, RISCVCPU),
@@ -189,7 +189,7 @@ static const VMStateDescription vmstate_rv128 = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = rv128_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINTTL_ARRAY(env.gprh, RISCVCPU, 32),
 VMSTATE_UINT64(env.mscratchh, RISCVCPU),
 VMSTATE_UINT64(env.sscratchh, RISCVCPU),
@@ -218,7 +218,7 @@ static const VMStateDescription vmstate_kvmtimer = {
 .minimum_version_id = 1,
 .needed = kvmtimer_needed,
 .post_load = cpu_kvmtimer_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(env.kvm_timer_time, RISCVCPU),
 VMSTATE_UINT64(env.kvm_timer_compare, RISCVCPU),
 VMSTATE_UINT64(env.kvm_timer_state, RISCVCPU),
@@ -252,7 +252,7 @@ static const VMStateDescription vmstate_debug = {
 .minimum_version_id = 2,
 .needed = debug_needed,
 .post_load = debug_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINTTL(env.trigger_cur, RISCVCPU),
 VMSTATE_UINTTL_ARRAY(env.tdata1, RISCVCPU, RV_MAX_TRIGGERS),
 VMSTATE_UINTTL_ARRAY(env.tdata2, RISCVCPU, RV_MAX_TRIGGERS),
@@ -283,7 +283,7 @@ static const VMStateDescription vmstate_smstateen = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = smstateen_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64_ARRAY(env.mstateen, RISCVCPU, 4),
 VMSTATE_UINT64_ARRAY(env.hstateen, RISCVCPU, 4),
 VMSTATE_UINT64_ARRAY(env.sstateen, RISCVCPU, 4),
@@ -304,7 +304,7 @@ static const VMStateDescription vmstate_envcfg = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = envcfg_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(env.menvcfg, RISCVCPU),
 VMSTATE_UINTTL(env.senvcfg, RISCVCPU),
 VMSTATE_UINT64(env.henvcfg, RISCVCPU),
@@ -324,7 +324,7 @@ static const VMStateDescription vmstate_pmu_ctr_state = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = pmu_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINTTL(mhpmcounter_val, PMUCTRState),
 VMSTATE_UINTTL(mhpmcounterh_val, PMUCTRState),
 VMSTATE_UINTTL(mhpmcounter_prev, PMUCTRState),
@@ -346,7 +346,7 @@ static const VMStateDescription vmstate_jvt = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = jvt_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINTTL(env.jvt, RISCVCPU),
 VMSTATE_END_OF_LIST()
 }
@@ -357,7 +357,7 @@ const VMStateDescription 

[PATCH v2 43/71] hw/openrisc: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/openrisc/cputimer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/openrisc/cputimer.c b/hw/openrisc/cputimer.c
index 10163b391b..835986c4db 100644
--- a/hw/openrisc/cputimer.c
+++ b/hw/openrisc/cputimer.c
@@ -145,7 +145,7 @@ static const VMStateDescription vmstate_or1k_timer = {
 .name = "or1k_timer",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(ttcr, OR1KTimerState),
 VMSTATE_UINT64(last_clk, OR1KTimerState),
 VMSTATE_END_OF_LIST()
-- 
2.34.1




[PATCH v2 33/71] hw/input: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/input/adb-kbd.c   |  2 +-
 hw/input/adb-mouse.c |  2 +-
 hw/input/adb.c   |  4 ++--
 hw/input/ads7846.c   |  2 +-
 hw/input/hid.c   |  6 +++---
 hw/input/lasips2.c   |  4 ++--
 hw/input/lm832x.c|  2 +-
 hw/input/pckbd.c | 12 ++--
 hw/input/pl050.c |  2 +-
 hw/input/ps2.c   | 14 +++---
 hw/input/pxa2xx_keypad.c |  2 +-
 hw/input/stellaris_gamepad.c |  2 +-
 hw/input/tsc2005.c   |  2 +-
 hw/input/tsc210x.c   |  2 +-
 hw/input/virtio-input.c  |  2 +-
 15 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/hw/input/adb-kbd.c b/hw/input/adb-kbd.c
index e21edf9acd..758fa6d267 100644
--- a/hw/input/adb-kbd.c
+++ b/hw/input/adb-kbd.c
@@ -332,7 +332,7 @@ static const VMStateDescription vmstate_adb_kbd = {
 .name = "adb_kbd",
 .version_id = 2,
 .minimum_version_id = 2,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT(parent_obj, KBDState, 0, vmstate_adb_device, ADBDevice),
 VMSTATE_BUFFER(data, KBDState),
 VMSTATE_INT32(rptr, KBDState),
diff --git a/hw/input/adb-mouse.c b/hw/input/adb-mouse.c
index e6b341f028..144a0ccce7 100644
--- a/hw/input/adb-mouse.c
+++ b/hw/input/adb-mouse.c
@@ -217,7 +217,7 @@ static const VMStateDescription vmstate_adb_mouse = {
 .name = "adb_mouse",
 .version_id = 2,
 .minimum_version_id = 2,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT(parent_obj, MouseState, 0, vmstate_adb_device,
ADBDevice),
 VMSTATE_INT32(buttons_state, MouseState),
diff --git a/hw/input/adb.c b/hw/input/adb.c
index 8aed0da2cd..0f3c73d6d0 100644
--- a/hw/input/adb.c
+++ b/hw/input/adb.c
@@ -221,7 +221,7 @@ static const VMStateDescription vmstate_adb_bus = {
 .name = "adb_bus",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_TIMER_PTR(autopoll_timer, ADBBusState),
 VMSTATE_BOOL(autopoll_enabled, ADBBusState),
 VMSTATE_UINT8(autopoll_rate_ms, ADBBusState),
@@ -279,7 +279,7 @@ const VMStateDescription vmstate_adb_device = {
 .name = "adb_device",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT32(devaddr, ADBDevice),
 VMSTATE_INT32(handler, ADBDevice),
 VMSTATE_END_OF_LIST()
diff --git a/hw/input/ads7846.c b/hw/input/ads7846.c
index 91116c6bdb..cde3892216 100644
--- a/hw/input/ads7846.c
+++ b/hw/input/ads7846.c
@@ -130,7 +130,7 @@ static const VMStateDescription vmstate_ads7846 = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = ads7856_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_SSI_PERIPHERAL(ssidev, ADS7846State),
 VMSTATE_INT32_ARRAY(input, ADS7846State, 8),
 VMSTATE_INT32(noise, ADS7846State),
diff --git a/hw/input/hid.c b/hw/input/hid.c
index b8e85374ca..76bedc1844 100644
--- a/hw/input/hid.c
+++ b/hw/input/hid.c
@@ -581,7 +581,7 @@ static const VMStateDescription vmstate_hid_ptr_queue = {
 .name = "HIDPointerEventQueue",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT32(xdx, HIDPointerEvent),
 VMSTATE_INT32(ydy, HIDPointerEvent),
 VMSTATE_INT32(dz, HIDPointerEvent),
@@ -595,7 +595,7 @@ const VMStateDescription vmstate_hid_ptr_device = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = hid_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT_ARRAY(ptr.queue, HIDState, QUEUE_LENGTH, 0,
  vmstate_hid_ptr_queue, HIDPointerEvent),
 VMSTATE_UINT32(head, HIDState),
@@ -611,7 +611,7 @@ const VMStateDescription vmstate_hid_keyboard_device = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = hid_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(kbd.keycodes, HIDState, QUEUE_LENGTH),
 VMSTATE_UINT32(head, HIDState),
 VMSTATE_UINT32(n, HIDState),
diff --git a/hw/input/lasips2.c b/hw/input/lasips2.c
index 6075121b72..d9f8c36778 100644
--- a/hw/input/lasips2.c
+++ b/hw/input/lasips2.c
@@ -39,7 +39,7 @@ static const VMStateDescription vmstate_lasips2_port = {
 .name = "lasips2-port",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(control, LASIPS2Port),
 VMSTATE_UINT8(buf, LASIPS2Port),
 VMSTATE_BOOL(loopback_rbne, LASIPS2Port),
@@ -51,7 +51,7 @@ static const VMStateDescription vmstate_lasips2 = {

[PATCH v2 59/71] hw/vfio: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/vfio/display.c | 2 +-
 hw/vfio/pci.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/vfio/display.c b/hw/vfio/display.c
index 7a10fa8604..1aa440c663 100644
--- a/hw/vfio/display.c
+++ b/hw/vfio/display.c
@@ -560,7 +560,7 @@ const VMStateDescription vfio_display_vmstate = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = migrate_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT_POINTER(ramfb, VFIODisplay, ramfb_vmstate, RAMFBState),
 VMSTATE_END_OF_LIST(),
 }
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 1874ec1aba..9f838978be 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2561,7 +2561,7 @@ const VMStateDescription vmstate_vfio_display = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = vfio_display_migration_needed,
-.fields = (VMStateField[]){
+.fields = (const VMStateField[]){
 VMSTATE_STRUCT_POINTER(dpy, VFIOPCIDevice, vfio_display_vmstate,
VFIODisplay),
 VMSTATE_END_OF_LIST()
@@ -2572,12 +2572,12 @@ const VMStateDescription vmstate_vfio_pci_config = {
 .name = "VFIOPCIDevice",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(pdev, VFIOPCIDevice),
 VMSTATE_MSIX_TEST(pdev, VFIOPCIDevice, vfio_msix_present),
 VMSTATE_END_OF_LIST()
 },
-.subsections = (const VMStateDescription * []) {
+.subsections = (const VMStateDescription * const []) {
 _vfio_display,
 NULL
 }
-- 
2.34.1




[PATCH v2 34/71] hw/intc: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/intc/allwinner-a10-pic.c|  2 +-
 hw/intc/apic_common.c  |  6 +++---
 hw/intc/arm_gic_common.c   |  8 
 hw/intc/arm_gicv3_common.c | 16 
 hw/intc/arm_gicv3_its_common.c |  2 +-
 hw/intc/armv7m_nvic.c  |  8 
 hw/intc/aspeed_vic.c   |  2 +-
 hw/intc/bcm2835_ic.c   |  2 +-
 hw/intc/bcm2836_control.c  |  2 +-
 hw/intc/exynos4210_combiner.c  |  4 ++--
 hw/intc/goldfish_pic.c |  2 +-
 hw/intc/heathrow_pic.c |  4 ++--
 hw/intc/i8259_common.c |  6 +++---
 hw/intc/imx_avic.c |  2 +-
 hw/intc/imx_gpcv2.c|  2 +-
 hw/intc/ioapic_common.c|  2 +-
 hw/intc/loongarch_extioi.c |  2 +-
 hw/intc/loongarch_ipi.c|  4 ++--
 hw/intc/loongarch_pch_pic.c|  2 +-
 hw/intc/m68k_irqc.c|  2 +-
 hw/intc/nios2_vic.c|  2 +-
 hw/intc/ompic.c|  4 ++--
 hw/intc/openpic.c  | 12 ++--
 hw/intc/pl190.c|  2 +-
 hw/intc/ppc-uic.c  |  2 +-
 hw/intc/riscv_aclint.c |  2 +-
 hw/intc/riscv_aplic.c  |  2 +-
 hw/intc/riscv_imsic.c  |  2 +-
 hw/intc/rx_icu.c   |  2 +-
 hw/intc/s390_flic.c| 10 +-
 hw/intc/s390_flic_kvm.c|  8 
 hw/intc/sifive_plic.c  |  2 +-
 hw/intc/slavio_intctl.c|  4 ++--
 hw/intc/spapr_xive.c   |  6 +++---
 hw/intc/xics.c |  6 +++---
 hw/intc/xive.c |  4 ++--
 hw/intc/xlnx-pmu-iomod-intc.c  |  2 +-
 hw/intc/xlnx-zynqmp-ipi.c  |  2 +-
 38 files changed, 77 insertions(+), 77 deletions(-)

diff --git a/hw/intc/allwinner-a10-pic.c b/hw/intc/allwinner-a10-pic.c
index d0bf8d545b..cea559c39d 100644
--- a/hw/intc/allwinner-a10-pic.c
+++ b/hw/intc/allwinner-a10-pic.c
@@ -142,7 +142,7 @@ static const VMStateDescription vmstate_aw_a10_pic = {
 .name = "a10.pic",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(vector, AwA10PICState),
 VMSTATE_UINT32(base_addr, AwA10PICState),
 VMSTATE_UINT32(protect, AwA10PICState),
diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
index bccb4241c2..6c100b48d6 100644
--- a/hw/intc/apic_common.c
+++ b/hw/intc/apic_common.c
@@ -349,7 +349,7 @@ static const VMStateDescription vmstate_apic_common_sipi = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = apic_common_sipi_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT32(sipi_vector, APICCommonState),
 VMSTATE_INT32(wait_for_sipi, APICCommonState),
 VMSTATE_END_OF_LIST()
@@ -363,7 +363,7 @@ static const VMStateDescription vmstate_apic_common = {
 .pre_load = apic_pre_load,
 .pre_save = apic_dispatch_pre_save,
 .post_load = apic_dispatch_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(apicbase, APICCommonState),
 VMSTATE_UINT8(id, APICCommonState),
 VMSTATE_UINT8(arb_id, APICCommonState),
@@ -386,7 +386,7 @@ static const VMStateDescription vmstate_apic_common = {
   APICCommonState), /* open-coded timer state */
 VMSTATE_END_OF_LIST()
 },
-.subsections = (const VMStateDescription*[]) {
+.subsections = (const VMStateDescription * const []) {
 _apic_common_sipi,
 NULL
 }
diff --git a/hw/intc/arm_gic_common.c b/hw/intc/arm_gic_common.c
index 7c28504ace..94c173cb07 100644
--- a/hw/intc/arm_gic_common.c
+++ b/hw/intc/arm_gic_common.c
@@ -62,7 +62,7 @@ static const VMStateDescription vmstate_gic_irq_state = {
 .name = "arm_gic_irq_state",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(enabled, gic_irq_state),
 VMSTATE_UINT8(pending, gic_irq_state),
 VMSTATE_UINT8(active, gic_irq_state),
@@ -79,7 +79,7 @@ static const VMStateDescription vmstate_gic_virt_state = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = gic_virt_state_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 /* Virtual interface */
 VMSTATE_UINT32_ARRAY(h_hcr, GICState, GIC_NCPU),
 VMSTATE_UINT32_ARRAY(h_misr, GICState, GIC_NCPU),
@@ -104,7 +104,7 @@ static const VMStateDescription vmstate_gic = {
 .minimum_version_id = 12,
 .pre_save = gic_pre_save,
 .post_load = gic_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(ctlr, GICState),
 VMSTATE_UINT32_SUB_ARRAY(cpu_ctlr, GICState, 0, GIC_NCPU),
 VMSTATE_STRUCT_ARRAY(irq_state, GICState, GIC_MAXIRQ, 1,
@@ -122,7 +122,7 @@ static const VMStateDescription vmstate_gic = {
 VMSTATE_UINT32_2DARRAY(nsapr, GICState, 

[PATCH v2 12/71] target/mips: Constify VMState in machine.c

2023-12-20 Thread Richard Henderson
Tested-by: Philippe Mathieu-Daudé 
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Richard Henderson 
---
 target/mips/sysemu/machine.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/target/mips/sysemu/machine.c b/target/mips/sysemu/machine.c
index 80d37f9c2f..218f4c3a67 100644
--- a/target/mips/sysemu/machine.c
+++ b/target/mips/sysemu/machine.c
@@ -44,7 +44,7 @@ static int put_fpr(QEMUFile *f, void *pv, size_t size,
 return 0;
 }
 
-const VMStateInfo vmstate_info_fpr = {
+static const VMStateInfo vmstate_info_fpr = {
 .name = "fpr",
 .get  = get_fpr,
 .put  = put_fpr,
@@ -56,21 +56,21 @@ const VMStateInfo vmstate_info_fpr = {
 #define VMSTATE_FPR_ARRAY(_f, _s, _n)   \
 VMSTATE_FPR_ARRAY_V(_f, _s, _n, 0)
 
-static VMStateField vmstate_fpu_fields[] = {
+static const VMStateField vmstate_fpu_fields[] = {
 VMSTATE_FPR_ARRAY(fpr, CPUMIPSFPUContext, 32),
 VMSTATE_UINT32(fcr0, CPUMIPSFPUContext),
 VMSTATE_UINT32(fcr31, CPUMIPSFPUContext),
 VMSTATE_END_OF_LIST()
 };
 
-const VMStateDescription vmstate_fpu = {
+static const VMStateDescription vmstate_fpu = {
 .name = "cpu/fpu",
 .version_id = 1,
 .minimum_version_id = 1,
 .fields = vmstate_fpu_fields
 };
 
-const VMStateDescription vmstate_inactive_fpu = {
+static const VMStateDescription vmstate_inactive_fpu = {
 .name = "cpu/inactive_fpu",
 .version_id = 1,
 .minimum_version_id = 1,
@@ -79,7 +79,7 @@ const VMStateDescription vmstate_inactive_fpu = {
 
 /* TC state */
 
-static VMStateField vmstate_tc_fields[] = {
+static const VMStateField vmstate_tc_fields[] = {
 VMSTATE_UINTTL_ARRAY(gpr, TCState, 32),
 #if defined(TARGET_MIPS64)
 VMSTATE_UINT64_ARRAY(gpr_hi, TCState, 32),
@@ -103,14 +103,14 @@ static VMStateField vmstate_tc_fields[] = {
 VMSTATE_END_OF_LIST()
 };
 
-const VMStateDescription vmstate_tc = {
+static const VMStateDescription vmstate_tc = {
 .name = "cpu/tc",
 .version_id = 2,
 .minimum_version_id = 2,
 .fields = vmstate_tc_fields
 };
 
-const VMStateDescription vmstate_inactive_tc = {
+static const VMStateDescription vmstate_inactive_tc = {
 .name = "cpu/inactive_tc",
 .version_id = 2,
 .minimum_version_id = 2,
@@ -119,11 +119,11 @@ const VMStateDescription vmstate_inactive_tc = {
 
 /* MVP state */
 
-const VMStateDescription vmstate_mvp = {
+static const VMStateDescription vmstate_mvp = {
 .name = "cpu/mvp",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT32(CP0_MVPControl, CPUMIPSMVPContext),
 VMSTATE_INT32(CP0_MVPConf0, CPUMIPSMVPContext),
 VMSTATE_INT32(CP0_MVPConf1, CPUMIPSMVPContext),
@@ -190,7 +190,7 @@ static int put_tlb(QEMUFile *f, void *pv, size_t size,
 return 0;
 }
 
-const VMStateInfo vmstate_info_tlb = {
+static const VMStateInfo vmstate_info_tlb = {
 .name = "tlb_entry",
 .get  = get_tlb,
 .put  = put_tlb,
@@ -202,11 +202,11 @@ const VMStateInfo vmstate_info_tlb = {
 #define VMSTATE_TLB_ARRAY(_f, _s, _n)   \
 VMSTATE_TLB_ARRAY_V(_f, _s, _n, 0)
 
-const VMStateDescription vmstate_tlb = {
+static const VMStateDescription vmstate_tlb = {
 .name = "cpu/tlb",
 .version_id = 2,
 .minimum_version_id = 2,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(nb_tlb, CPUMIPSTLBContext),
 VMSTATE_UINT32(tlb_in_use, CPUMIPSTLBContext),
 VMSTATE_TLB_ARRAY(mmu.r4k.tlb, CPUMIPSTLBContext, MIPS_TLB_MAX),
@@ -221,7 +221,7 @@ const VMStateDescription vmstate_mips_cpu = {
 .version_id = 21,
 .minimum_version_id = 21,
 .post_load = cpu_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 /* Active TC */
 VMSTATE_STRUCT(env.active_tc, MIPSCPU, 1, vmstate_tc, TCState),
 
-- 
2.34.1




[PATCH v2 48/71] hw/riscv: Constify VMState

2023-12-20 Thread Richard Henderson
Acked-by: Alistair Francis 
Signed-off-by: Richard Henderson 
---
 hw/riscv/virt-acpi-build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c
index 7331248f59..d3bfaf502e 100644
--- a/hw/riscv/virt-acpi-build.c
+++ b/hw/riscv/virt-acpi-build.c
@@ -374,7 +374,7 @@ static const VMStateDescription vmstate_virt_acpi_build = {
 .name = "virt_acpi_build",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_BOOL(patched, AcpiBuildState),
 VMSTATE_END_OF_LIST()
 },
-- 
2.34.1




[PATCH v2 51/71] hw/scsi: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/scsi/esp-pci.c | 2 +-
 hw/scsi/esp.c | 8 
 hw/scsi/lsi53c895a.c  | 2 +-
 hw/scsi/megasas.c | 4 ++--
 hw/scsi/mptsas.c  | 2 +-
 hw/scsi/scsi-bus.c| 6 +++---
 hw/scsi/scsi-disk.c   | 2 +-
 hw/scsi/spapr_vscsi.c | 4 ++--
 hw/scsi/vhost-scsi.c  | 2 +-
 hw/scsi/vhost-user-scsi.c | 2 +-
 hw/scsi/virtio-scsi.c | 2 +-
 hw/scsi/vmw_pvscsi.c  | 6 +++---
 12 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
index 4e890db0e2..93b3429e0f 100644
--- a/hw/scsi/esp-pci.c
+++ b/hw/scsi/esp-pci.c
@@ -333,7 +333,7 @@ static const VMStateDescription vmstate_esp_pci_scsi = {
 .version_id = 2,
 .minimum_version_id = 1,
 .pre_save = esp_pre_save,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(parent_obj, PCIESPState),
 VMSTATE_BUFFER_UNSAFE(dma_regs, PCIESPState, 0, 8 * sizeof(uint32_t)),
 VMSTATE_UINT8_V(esp.mig_version_id, PCIESPState, 2),
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 9b11d8c573..ff90572830 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -1237,7 +1237,7 @@ static const VMStateDescription vmstate_esp_pdma = {
 .version_id = 0,
 .minimum_version_id = 0,
 .needed = esp_pdma_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(pdma_cb, ESPState),
 VMSTATE_END_OF_LIST()
 }
@@ -1248,7 +1248,7 @@ const VMStateDescription vmstate_esp = {
 .version_id = 6,
 .minimum_version_id = 3,
 .post_load = esp_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_BUFFER(rregs, ESPState),
 VMSTATE_BUFFER(wregs, ESPState),
 VMSTATE_INT32(ti_size, ESPState),
@@ -1277,7 +1277,7 @@ const VMStateDescription vmstate_esp = {
 VMSTATE_UINT8_TEST(lun, ESPState, esp_is_version_6),
 VMSTATE_END_OF_LIST()
 },
-.subsections = (const VMStateDescription * []) {
+.subsections = (const VMStateDescription * const []) {
 _esp_pdma,
 NULL
 }
@@ -1448,7 +1448,7 @@ static const VMStateDescription vmstate_sysbus_esp_scsi = 
{
 .version_id = 2,
 .minimum_version_id = 1,
 .pre_save = esp_pre_save,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8_V(esp.mig_version_id, SysBusESPState, 2),
 VMSTATE_STRUCT(esp, SysBusESPState, 0, vmstate_esp, ESPState),
 VMSTATE_END_OF_LIST()
diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
index 634ed49c2e..34e3b89287 100644
--- a/hw/scsi/lsi53c895a.c
+++ b/hw/scsi/lsi53c895a.c
@@ -2205,7 +2205,7 @@ static const VMStateDescription vmstate_lsi_scsi = {
 .minimum_version_id = 0,
 .pre_save = lsi_pre_save,
 .post_load = lsi_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(parent_obj, LSIState),
 
 VMSTATE_INT32(carry, LSIState),
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index 32c70c9e99..2d0c607177 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -2299,7 +2299,7 @@ static const VMStateDescription vmstate_megasas_gen1 = {
 .name = "megasas",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(parent_obj, MegasasState),
 VMSTATE_MSIX(parent_obj, MegasasState),
 
@@ -2317,7 +2317,7 @@ static const VMStateDescription vmstate_megasas_gen2 = {
 .name = "megasas-gen2",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields  = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(parent_obj, MegasasState),
 VMSTATE_MSIX(parent_obj, MegasasState),
 
diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c
index 75d3ab8bd1..c5d3138c93 100644
--- a/hw/scsi/mptsas.c
+++ b/hw/scsi/mptsas.c
@@ -1366,7 +1366,7 @@ static const VMStateDescription vmstate_mptsas = {
 .version_id = 0,
 .minimum_version_id = 0,
 .post_load = mptsas_post_load,
-.fields  = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(dev, MPTSASState),
 VMSTATE_BOOL(msi_in_use, MPTSASState),
 VMSTATE_UINT32(state, MPTSASState),
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index fc4b77fdb0..d27a4b354a 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -1826,7 +1826,7 @@ static const VMStateDescription vmstate_scsi_sense_state 
= {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = scsi_sense_state_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8_SUB_ARRAY(sense, SCSIDevice,
 SCSI_SENSE_BUF_SIZE_OLD,
 SCSI_SENSE_BUF_SIZE - SCSI_SENSE_BUF_SIZE_OLD),
@@ -1838,7 

[PATCH v2 05/71] target/avr: Constify VMState in machine.c

2023-12-20 Thread Richard Henderson
Tested-by: Philippe Mathieu-Daudé 
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Richard Henderson 
---
 target/avr/machine.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/avr/machine.c b/target/avr/machine.c
index 16f7a3e031..4402862fb9 100644
--- a/target/avr/machine.c
+++ b/target/avr/machine.c
@@ -100,7 +100,7 @@ const VMStateDescription vms_avr_cpu = {
 .name = "cpu",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(env.pc_w, AVRCPU),
 VMSTATE_UINT32(env.sp, AVRCPU),
 VMSTATE_UINT32(env.skip, AVRCPU),
-- 
2.34.1




[PATCH v2 27/71] hw/dma: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/dma/bcm2835_dma.c  |  4 ++--
 hw/dma/i82374.c   |  2 +-
 hw/dma/i8257.c|  4 ++--
 hw/dma/pl080.c|  4 ++--
 hw/dma/pl330.c| 10 +-
 hw/dma/pxa2xx_dma.c   |  4 ++--
 hw/dma/rc4030.c   |  2 +-
 hw/dma/sparc32_dma.c  |  2 +-
 hw/dma/xlnx-zdma.c|  2 +-
 hw/dma/xlnx-zynq-devcfg.c |  4 ++--
 hw/dma/xlnx_csu_dma.c |  2 +-
 hw/dma/xlnx_dpdma.c   |  2 +-
 12 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/hw/dma/bcm2835_dma.c b/hw/dma/bcm2835_dma.c
index 5e9306110d..9bda45072b 100644
--- a/hw/dma/bcm2835_dma.c
+++ b/hw/dma/bcm2835_dma.c
@@ -311,7 +311,7 @@ static const VMStateDescription vmstate_bcm2835_dma_chan = {
 .name = TYPE_BCM2835_DMA "-chan",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(cs, BCM2835DMAChan),
 VMSTATE_UINT32(conblk_ad, BCM2835DMAChan),
 VMSTATE_UINT32(ti, BCM2835DMAChan),
@@ -329,7 +329,7 @@ static const VMStateDescription vmstate_bcm2835_dma = {
 .name = TYPE_BCM2835_DMA,
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT_ARRAY(chan, BCM2835DMAState, BCM2835_DMA_NCHANS, 1,
  vmstate_bcm2835_dma_chan, BCM2835DMAChan),
 VMSTATE_UINT32(int_status, BCM2835DMAState),
diff --git a/hw/dma/i82374.c b/hw/dma/i82374.c
index 63734c22c9..f6ddfc51c5 100644
--- a/hw/dma/i82374.c
+++ b/hw/dma/i82374.c
@@ -58,7 +58,7 @@ static const VMStateDescription vmstate_i82374 = {
 .name = "i82374",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8_ARRAY(commands, I82374State, 8),
 VMSTATE_END_OF_LIST()
 },
diff --git a/hw/dma/i8257.c b/hw/dma/i8257.c
index de5f696919..de1d5b110c 100644
--- a/hw/dma/i8257.c
+++ b/hw/dma/i8257.c
@@ -517,7 +517,7 @@ static const VMStateDescription vmstate_i8257_regs = {
 .name = "dma_regs",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT32_ARRAY(now, I8257Regs, 2),
 VMSTATE_UINT16_ARRAY(base, I8257Regs, 2),
 VMSTATE_UINT8(mode, I8257Regs),
@@ -542,7 +542,7 @@ static const VMStateDescription vmstate_i8257 = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = i8257_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(command, I8257State),
 VMSTATE_UINT8(mask, I8257State),
 VMSTATE_UINT8(flip_flop, I8257State),
diff --git a/hw/dma/pl080.c b/hw/dma/pl080.c
index 2627307cc8..1e49c22e93 100644
--- a/hw/dma/pl080.c
+++ b/hw/dma/pl080.c
@@ -39,7 +39,7 @@ static const VMStateDescription vmstate_pl080_channel = {
 .name = "pl080_channel",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(src, pl080_channel),
 VMSTATE_UINT32(dest, pl080_channel),
 VMSTATE_UINT32(lli, pl080_channel),
@@ -53,7 +53,7 @@ static const VMStateDescription vmstate_pl080 = {
 .name = "pl080",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(tc_int, PL080State),
 VMSTATE_UINT8(tc_mask, PL080State),
 VMSTATE_UINT8(err_int, PL080State),
diff --git a/hw/dma/pl330.c b/hw/dma/pl330.c
index e7e67dd8b6..70a502d245 100644
--- a/hw/dma/pl330.c
+++ b/hw/dma/pl330.c
@@ -139,7 +139,7 @@ static const VMStateDescription vmstate_pl330_chan = {
 .name = "pl330_chan",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(src, PL330Chan),
 VMSTATE_UINT32(dst, PL330Chan),
 VMSTATE_UINT32(pc, PL330Chan),
@@ -170,7 +170,7 @@ static const VMStateDescription vmstate_pl330_fifo = {
 .name = "pl330_chan",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_VBUFFER_UINT32(buf, PL330Fifo, 1, NULL, buf_size),
 VMSTATE_VBUFFER_UINT32(tag, PL330Fifo, 1, NULL, buf_size),
 VMSTATE_UINT32(head, PL330Fifo),
@@ -194,7 +194,7 @@ static const VMStateDescription vmstate_pl330_queue_entry = 
{
 .name = "pl330_queue_entry",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(addr, PL330QueueEntry),
 VMSTATE_UINT32(len, PL330QueueEntry),
 VMSTATE_UINT8(n, PL330QueueEntry),
@@ -216,7 +216,7 @@ static const VMStateDescription vmstate_pl330_queue = {
 .name = 

[PATCH v2 14/71] target/ppc: Constify VMState in machine.c

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 target/ppc/machine.c | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/target/ppc/machine.c b/target/ppc/machine.c
index 68cbdffecd..203fe28e01 100644
--- a/target/ppc/machine.c
+++ b/target/ppc/machine.c
@@ -351,7 +351,7 @@ static const VMStateDescription vmstate_fpu = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = fpu_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_FPR_ARRAY(env.vsr, PowerPCCPU, 32),
 VMSTATE_UINTTL(env.fpscr, PowerPCCPU),
 VMSTATE_END_OF_LIST()
@@ -392,7 +392,7 @@ static const VMStateDescription vmstate_altivec = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = altivec_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_AVR_ARRAY(env.vsr, PowerPCCPU, 32),
 /*
  * Save the architecture value of the vscr, not the internally
@@ -425,7 +425,7 @@ static const VMStateDescription vmstate_vsx = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = vsx_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_VSR_ARRAY(env.vsr, PowerPCCPU, 32),
 VMSTATE_END_OF_LIST()
 },
@@ -445,7 +445,7 @@ static const VMStateDescription vmstate_tm = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = tm_needed,
-.fields  = (VMStateField []) {
+.fields = (const VMStateField []) {
 VMSTATE_UINTTL_ARRAY(env.tm_gpr, PowerPCCPU, 32),
 VMSTATE_AVR_ARRAY(env.tm_vsr, PowerPCCPU, 64),
 VMSTATE_UINT64(env.tm_cr, PowerPCCPU),
@@ -479,7 +479,7 @@ static const VMStateDescription vmstate_sr = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = sr_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINTTL_ARRAY(env.sr, PowerPCCPU, 32),
 VMSTATE_END_OF_LIST()
 },
@@ -553,7 +553,7 @@ static const VMStateDescription vmstate_slb = {
 .minimum_version_id = 1,
 .needed = slb_needed,
 .post_load = slb_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT32_TEST(mig_slb_nr, PowerPCCPU, cpu_pre_3_0_migration),
 VMSTATE_SLB_ARRAY(env.slb, PowerPCCPU, MAX_SLB_ENTRIES),
 VMSTATE_END_OF_LIST()
@@ -565,7 +565,7 @@ static const VMStateDescription vmstate_tlb6xx_entry = {
 .name = "cpu/tlb6xx_entry",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINTTL(pte0, ppc6xx_tlb_t),
 VMSTATE_UINTTL(pte1, ppc6xx_tlb_t),
 VMSTATE_UINTTL(EPN, ppc6xx_tlb_t),
@@ -586,7 +586,7 @@ static const VMStateDescription vmstate_tlb6xx = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = tlb6xx_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT32_EQUAL(env.nb_tlb, PowerPCCPU, NULL),
 VMSTATE_STRUCT_VARRAY_POINTER_INT32(env.tlb.tlb6, PowerPCCPU,
 env.nb_tlb,
@@ -601,7 +601,7 @@ static const VMStateDescription vmstate_tlbemb_entry = {
 .name = "cpu/tlbemb_entry",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(RPN, ppcemb_tlb_t),
 VMSTATE_UINTTL(EPN, ppcemb_tlb_t),
 VMSTATE_UINTTL(PID, ppcemb_tlb_t),
@@ -625,7 +625,7 @@ static const VMStateDescription vmstate_tlbemb = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = tlbemb_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT32_EQUAL(env.nb_tlb, PowerPCCPU, NULL),
 VMSTATE_STRUCT_VARRAY_POINTER_INT32(env.tlb.tlbe, PowerPCCPU,
 env.nb_tlb,
@@ -639,7 +639,7 @@ static const VMStateDescription vmstate_tlbmas_entry = {
 .name = "cpu/tlbmas_entry",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(mas8, ppcmas_tlb_t),
 VMSTATE_UINT32(mas1, ppcmas_tlb_t),
 VMSTATE_UINT64(mas2, ppcmas_tlb_t),
@@ -661,7 +661,7 @@ static const VMStateDescription vmstate_tlbmas = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = tlbmas_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT32_EQUAL(env.nb_tlb, PowerPCCPU, NULL),
 VMSTATE_STRUCT_VARRAY_POINTER_INT32(env.tlb.tlbm, PowerPCCPU,
 env.nb_tlb,
@@ -684,7 +684,7 @@ static const VMStateDescription vmstate_compat = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = compat_needed,
-.fields = (VMStateField[]) {
+.fields = (const 

[PATCH v2 37/71] hw/isa: Constify VMState

2023-12-20 Thread Richard Henderson
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Richard Henderson 
---
 hw/isa/apm.c  | 2 +-
 hw/isa/i82378.c   | 2 +-
 hw/isa/lpc_ich9.c | 8 
 hw/isa/pc87312.c  | 2 +-
 hw/isa/piix.c | 8 
 hw/isa/vt82c686.c | 4 ++--
 6 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/hw/isa/apm.c b/hw/isa/apm.c
index dfe9020d30..e34edb864c 100644
--- a/hw/isa/apm.c
+++ b/hw/isa/apm.c
@@ -68,7 +68,7 @@ const VMStateDescription vmstate_apm = {
 .name = "APM State",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(apmc, APMState),
 VMSTATE_UINT8(apms, APMState),
 VMSTATE_END_OF_LIST()
diff --git a/hw/isa/i82378.c b/hw/isa/i82378.c
index 203b92c264..cbaa152a89 100644
--- a/hw/isa/i82378.c
+++ b/hw/isa/i82378.c
@@ -40,7 +40,7 @@ static const VMStateDescription vmstate_i82378 = {
 .name = "pci-i82378",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(parent_obj, I82378State),
 VMSTATE_END_OF_LIST()
 },
diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index 23eba64f22..3924eec483 100644
--- a/hw/isa/lpc_ich9.c
+++ b/hw/isa/lpc_ich9.c
@@ -768,7 +768,7 @@ static const VMStateDescription vmstate_ich9_rst_cnt = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = ich9_rst_cnt_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(rst_cnt, ICH9LPCState),
 VMSTATE_END_OF_LIST()
 }
@@ -788,7 +788,7 @@ static const VMStateDescription vmstate_ich9_smi_feat = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = ich9_smi_feat_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8_ARRAY(smi_guest_features_le, ICH9LPCState,
 sizeof(uint64_t)),
 VMSTATE_UINT8(smi_features_ok, ICH9LPCState),
@@ -802,7 +802,7 @@ static const VMStateDescription vmstate_ich9_lpc = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = ich9_lpc_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(d, ICH9LPCState),
 VMSTATE_STRUCT(apm, ICH9LPCState, 0, vmstate_apm, APMState),
 VMSTATE_STRUCT(pm, ICH9LPCState, 0, vmstate_ich9_pm, ICH9LPCPMRegs),
@@ -810,7 +810,7 @@ static const VMStateDescription vmstate_ich9_lpc = {
 VMSTATE_UINT32(sci_level, ICH9LPCState),
 VMSTATE_END_OF_LIST()
 },
-.subsections = (const VMStateDescription*[]) {
+.subsections = (const VMStateDescription * const []) {
 _ich9_rst_cnt,
 _ich9_smi_feat,
 NULL
diff --git a/hw/isa/pc87312.c b/hw/isa/pc87312.c
index 8d7b8d3db2..ee23f3e164 100644
--- a/hw/isa/pc87312.c
+++ b/hw/isa/pc87312.c
@@ -319,7 +319,7 @@ static const VMStateDescription vmstate_pc87312 = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = pc87312_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(read_id_step, PC87312State),
 VMSTATE_UINT8(selected_index, PC87312State),
 VMSTATE_UINT8_ARRAY(regs, PC87312State, 3),
diff --git a/hw/isa/piix.c b/hw/isa/piix.c
index 04ebed5b52..344bf32e54 100644
--- a/hw/isa/piix.c
+++ b/hw/isa/piix.c
@@ -230,7 +230,7 @@ static const VMStateDescription vmstate_piix3_rcr = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = piix3_rcr_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(rcr, PIIXState),
 VMSTATE_END_OF_LIST()
 }
@@ -242,13 +242,13 @@ static const VMStateDescription vmstate_piix3 = {
 .minimum_version_id = 2,
 .post_load = piix_post_load,
 .pre_save = piix3_pre_save,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(dev, PIIXState),
 VMSTATE_INT32_ARRAY_V(pci_irq_levels_vmstate, PIIXState,
   PIIX_NUM_PIRQS, 3),
 VMSTATE_END_OF_LIST()
 },
-.subsections = (const VMStateDescription*[]) {
+.subsections = (const VMStateDescription * const []) {
 _piix3_rcr,
 NULL
 }
@@ -259,7 +259,7 @@ static const VMStateDescription vmstate_piix4 = {
 .version_id = 3,
 .minimum_version_id = 2,
 .post_load = piix4_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(dev, PIIXState),
 VMSTATE_UINT8_V(rcr, PIIXState, 3),
 VMSTATE_END_OF_LIST()
diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index 9c2333a277..d3e0f6d01f 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -82,7 +82,7 @@ static const VMStateDescription vmstate_acpi = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = 

[PATCH v2 40/71] hw/misc: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/misc/a9scu.c|  2 +-
 hw/misc/allwinner-a10-ccm.c|  2 +-
 hw/misc/allwinner-a10-dramc.c  |  2 +-
 hw/misc/allwinner-cpucfg.c |  2 +-
 hw/misc/allwinner-h3-ccu.c |  2 +-
 hw/misc/allwinner-h3-dramc.c   |  2 +-
 hw/misc/allwinner-h3-sysctrl.c |  2 +-
 hw/misc/allwinner-r40-ccu.c|  2 +-
 hw/misc/allwinner-r40-dramc.c  |  2 +-
 hw/misc/allwinner-sid.c|  2 +-
 hw/misc/allwinner-sramc.c  |  2 +-
 hw/misc/arm_l2x0.c |  2 +-
 hw/misc/arm_sysctl.c   |  2 +-
 hw/misc/armsse-cpu-pwrctrl.c   |  2 +-
 hw/misc/armsse-mhu.c   |  2 +-
 hw/misc/aspeed_hace.c  |  2 +-
 hw/misc/aspeed_i3c.c   |  4 ++--
 hw/misc/aspeed_lpc.c   |  2 +-
 hw/misc/aspeed_sbc.c   |  2 +-
 hw/misc/aspeed_scu.c   |  2 +-
 hw/misc/aspeed_sdmc.c  |  2 +-
 hw/misc/aspeed_xdma.c  |  2 +-
 hw/misc/axp2xx.c   |  2 +-
 hw/misc/bcm2835_cprman.c   | 10 +-
 hw/misc/bcm2835_mbox.c |  4 ++--
 hw/misc/bcm2835_mphi.c |  2 +-
 hw/misc/bcm2835_powermgt.c |  2 +-
 hw/misc/bcm2835_property.c |  2 +-
 hw/misc/bcm2835_rng.c  |  2 +-
 hw/misc/bcm2835_thermal.c  |  2 +-
 hw/misc/djmemc.c   |  2 +-
 hw/misc/eccmemctl.c|  2 +-
 hw/misc/exynos4210_clk.c   |  2 +-
 hw/misc/exynos4210_pmu.c   |  2 +-
 hw/misc/exynos4210_rng.c   |  2 +-
 hw/misc/imx25_ccm.c|  2 +-
 hw/misc/imx31_ccm.c|  2 +-
 hw/misc/imx6_ccm.c |  2 +-
 hw/misc/imx6_src.c |  2 +-
 hw/misc/imx6ul_ccm.c   |  2 +-
 hw/misc/imx7_ccm.c |  4 ++--
 hw/misc/imx7_snvs.c|  2 +-
 hw/misc/imx7_src.c |  2 +-
 hw/misc/imx_rngc.c |  2 +-
 hw/misc/iosb.c |  2 +-
 hw/misc/iotkit-secctl.c| 10 +-
 hw/misc/iotkit-sysctl.c|  8 
 hw/misc/ivshmem.c  |  4 ++--
 hw/misc/lasi.c |  2 +-
 hw/misc/led.c  |  2 +-
 hw/misc/mac_via.c  |  4 ++--
 hw/misc/mips_cmgcr.c   |  2 +-
 hw/misc/mips_cpc.c |  2 +-
 hw/misc/mos6522.c  |  4 ++--
 hw/misc/mps2-fpgaio.c  |  2 +-
 hw/misc/mps2-scc.c |  2 +-
 hw/misc/msf2-sysreg.c  |  2 +-
 hw/misc/mst_fpga.c |  2 +-
 hw/misc/npcm7xx_clk.c  |  8 
 hw/misc/npcm7xx_gcr.c  |  2 +-
 hw/misc/npcm7xx_mft.c  |  2 +-
 hw/misc/npcm7xx_pwm.c  |  4 ++--
 hw/misc/npcm7xx_rng.c  |  2 +-
 hw/misc/nrf51_rng.c|  2 +-
 hw/misc/pca9552.c  |  2 +-
 hw/misc/pvpanic-pci.c  |  2 +-
 hw/misc/slavio_misc.c  |  2 +-
 hw/misc/stm32f4xx_exti.c   |  2 +-
 hw/misc/stm32f4xx_syscfg.c |  2 +-
 hw/misc/tz-mpc.c   |  2 +-
 hw/misc/tz-msc.c   |  2 +-
 hw/misc/tz-ppc.c   |  2 +-
 hw/misc/virt_ctrl.c|  2 +-
 hw/misc/vmcoreinfo.c   |  2 +-
 hw/misc/xlnx-versal-cframe-reg.c   |  6 +++---
 hw/misc/xlnx-versal-cfu.c  |  6 +++---
 hw/misc/xlnx-versal-crl.c  |  2 +-
 hw/misc/xlnx-versal-pmc-iou-slcr.c |  2 +-
 hw/misc/xlnx-versal-trng.c |  2 +-
 hw/misc/xlnx-versal-xramc.c|  2 +-
 hw/misc/xlnx-zynqmp-apu-ctrl.c |  2 +-
 hw/misc/xlnx-zynqmp-crf.c  |  2 +-
 hw/misc/zynq_slcr.c|  2 +-
 83 files changed, 108 insertions(+), 108 deletions(-)

diff --git a/hw/misc/a9scu.c b/hw/misc/a9scu.c
index a375ebc987..04225dfb78 100644
--- a/hw/misc/a9scu.c
+++ b/hw/misc/a9scu.c
@@ -116,7 +116,7 @@ static const VMStateDescription vmstate_a9_scu = {
 .name = "a9-scu",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(control, A9SCUState),
 VMSTATE_UINT32(status, A9SCUState),
 VMSTATE_END_OF_LIST()
diff --git a/hw/misc/allwinner-a10-ccm.c b/hw/misc/allwinner-a10-ccm.c
index 68146ee340..575b018952 100644
--- a/hw/misc/allwinner-a10-ccm.c
+++ b/hw/misc/allwinner-a10-ccm.c
@@ -193,7 +193,7 @@ static const VMStateDescription allwinner_a10_ccm_vmstate = 
{
 .name = "allwinner-a10-ccm",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(regs, AwA10ClockCtlState, AW_A10_CCM_REGS_NUM),
 VMSTATE_END_OF_LIST()
 }
diff --git a/hw/misc/allwinner-a10-dramc.c b/hw/misc/allwinner-a10-dramc.c
index e118b0c2fd..a7c58fa6d0 100644
--- a/hw/misc/allwinner-a10-dramc.c
+++ b/hw/misc/allwinner-a10-dramc.c
@@ -147,7 +147,7 

[PATCH v2 04/71] target/alpha: Constify VMState in machine.c

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 target/alpha/machine.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/alpha/machine.c b/target/alpha/machine.c
index 2b7c8148ff..f09834f635 100644
--- a/target/alpha/machine.c
+++ b/target/alpha/machine.c
@@ -24,7 +24,7 @@ static const VMStateInfo vmstate_fpcr = {
 .put = put_fpcr,
 };
 
-static VMStateField vmstate_env_fields[] = {
+static const VMStateField vmstate_env_fields[] = {
 VMSTATE_UINTTL_ARRAY(ir, CPUAlphaState, 31),
 VMSTATE_UINTTL_ARRAY(fir, CPUAlphaState, 31),
 /* Save the architecture value of the fpcr, not the internally
@@ -73,7 +73,7 @@ static const VMStateDescription vmstate_env = {
 .fields = vmstate_env_fields,
 };
 
-static VMStateField vmstate_cpu_fields[] = {
+static const VMStateField vmstate_cpu_fields[] = {
 VMSTATE_CPU(),
 VMSTATE_STRUCT(env, AlphaCPU, 1, vmstate_env, CPUAlphaState),
 VMSTATE_END_OF_LIST()
-- 
2.34.1




[PATCH v2 16/71] target/s390x: Constify VMState in machine.c

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 target/s390x/machine.c | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/target/s390x/machine.c b/target/s390x/machine.c
index 37a076858c..a125ebcc2f 100644
--- a/target/s390x/machine.c
+++ b/target/s390x/machine.c
@@ -66,7 +66,7 @@ static const VMStateDescription vmstate_fpu = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = fpu_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(env.vregs[0][0], S390CPU),
 VMSTATE_UINT64(env.vregs[1][0], S390CPU),
 VMSTATE_UINT64(env.vregs[2][0], S390CPU),
@@ -98,7 +98,7 @@ static const VMStateDescription vmstate_vregs = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = vregs_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 /* vregs[0][0] -> vregs[15][0] and fregs are overlays */
 VMSTATE_UINT64(env.vregs[16][0], S390CPU),
 VMSTATE_UINT64(env.vregs[17][0], S390CPU),
@@ -157,12 +157,12 @@ static bool riccb_needed(void *opaque)
 return s390_has_feat(S390_FEAT_RUNTIME_INSTRUMENTATION);
 }
 
-const VMStateDescription vmstate_riccb = {
+static const VMStateDescription vmstate_riccb = {
 .name = "cpu/riccb",
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = riccb_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8_ARRAY(env.riccb, S390CPU, 64),
 VMSTATE_END_OF_LIST()
 }
@@ -174,12 +174,12 @@ static bool exval_needed(void *opaque)
 return cpu->env.ex_value != 0;
 }
 
-const VMStateDescription vmstate_exval = {
+static const VMStateDescription vmstate_exval = {
 .name = "cpu/exval",
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = exval_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(env.ex_value, S390CPU),
 VMSTATE_END_OF_LIST()
 }
@@ -190,12 +190,12 @@ static bool gscb_needed(void *opaque)
 return s390_has_feat(S390_FEAT_GUARDED_STORAGE);
 }
 
-const VMStateDescription vmstate_gscb = {
+static const VMStateDescription vmstate_gscb = {
 .name = "cpu/gscb",
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = gscb_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64_ARRAY(env.gscb, S390CPU, 4),
 VMSTATE_END_OF_LIST()
 }
@@ -206,12 +206,12 @@ static bool bpbc_needed(void *opaque)
 return s390_has_feat(S390_FEAT_BPB);
 }
 
-const VMStateDescription vmstate_bpbc = {
+static const VMStateDescription vmstate_bpbc = {
 .name = "cpu/bpbc",
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = bpbc_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_BOOL(env.bpbc, S390CPU),
 VMSTATE_END_OF_LIST()
 }
@@ -222,12 +222,12 @@ static bool etoken_needed(void *opaque)
 return s390_has_feat(S390_FEAT_ETOKEN);
 }
 
-const VMStateDescription vmstate_etoken = {
+static const VMStateDescription vmstate_etoken = {
 .name = "cpu/etoken",
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = etoken_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(env.etoken, S390CPU),
 VMSTATE_UINT64(env.etoken_extension, S390CPU),
 VMSTATE_END_OF_LIST()
@@ -239,12 +239,12 @@ static bool diag318_needed(void *opaque)
 return s390_has_feat(S390_FEAT_DIAG_318);
 }
 
-const VMStateDescription vmstate_diag318 = {
+static const VMStateDescription vmstate_diag318 = {
 .name = "cpu/diag318",
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = diag318_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(env.diag318_info, S390CPU),
 VMSTATE_END_OF_LIST()
 }
@@ -256,7 +256,7 @@ const VMStateDescription vmstate_s390_cpu = {
 .pre_save = cpu_pre_save,
 .version_id = 4,
 .minimum_version_id = 3,
-.fields  = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64_ARRAY(env.regs, S390CPU, 16),
 VMSTATE_UINT64(env.psw.mask, S390CPU),
 VMSTATE_UINT64(env.psw.addr, S390CPU),
@@ -278,7 +278,7 @@ const VMStateDescription vmstate_s390_cpu = {
irqstate_saved_size),
 VMSTATE_END_OF_LIST()
 },
-.subsections = (const VMStateDescription*[]) {
+.subsections = (const VMStateDescription * const []) {
 _fpu,
 _vregs,
 _riccb,
-- 
2.34.1




[PATCH v2 25/71] hw/char: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/char/bcm2835_aux.c   |  2 +-
 hw/char/cadence_uart.c  |  2 +-
 hw/char/cmsdk-apb-uart.c|  2 +-
 hw/char/digic-uart.c|  2 +-
 hw/char/escc.c  |  4 ++--
 hw/char/exynos4210_uart.c   |  4 ++--
 hw/char/goldfish_tty.c  |  2 +-
 hw/char/ibex_uart.c |  2 +-
 hw/char/imx_serial.c|  2 +-
 hw/char/ipoctal232.c|  6 +++---
 hw/char/mchp_pfsoc_mmuart.c |  2 +-
 hw/char/nrf51_uart.c|  2 +-
 hw/char/parallel.c  |  2 +-
 hw/char/pl011.c |  6 +++---
 hw/char/renesas_sci.c   |  2 +-
 hw/char/sclpconsole-lm.c|  2 +-
 hw/char/sclpconsole.c   |  2 +-
 hw/char/serial-isa.c|  2 +-
 hw/char/serial-pci-multi.c  |  2 +-
 hw/char/serial-pci.c|  2 +-
 hw/char/serial.c| 20 ++--
 hw/char/sifive_uart.c   |  2 +-
 hw/char/spapr_vty.c |  2 +-
 hw/char/virtio-serial-bus.c |  2 +-
 24 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/hw/char/bcm2835_aux.c b/hw/char/bcm2835_aux.c
index 96410b1ff8..83990e20f7 100644
--- a/hw/char/bcm2835_aux.c
+++ b/hw/char/bcm2835_aux.c
@@ -260,7 +260,7 @@ static const VMStateDescription vmstate_bcm2835_aux = {
 .name = TYPE_BCM2835_AUX,
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8_ARRAY(read_fifo, BCM2835AuxState,
 BCM2835_AUX_RX_FIFO_LEN),
 VMSTATE_UINT8(read_pos, BCM2835AuxState),
diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c
index a2ac062b1e..db31d7cc85 100644
--- a/hw/char/cadence_uart.c
+++ b/hw/char/cadence_uart.c
@@ -602,7 +602,7 @@ static const VMStateDescription vmstate_cadence_uart = {
 .minimum_version_id = 2,
 .pre_load = cadence_uart_pre_load,
 .post_load = cadence_uart_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(r, CadenceUARTState, CADENCE_UART_R_MAX),
 VMSTATE_UINT8_ARRAY(rx_fifo, CadenceUARTState,
 CADENCE_UART_RX_FIFO_SIZE),
diff --git a/hw/char/cmsdk-apb-uart.c b/hw/char/cmsdk-apb-uart.c
index d466cd93de..d07cca1bd4 100644
--- a/hw/char/cmsdk-apb-uart.c
+++ b/hw/char/cmsdk-apb-uart.c
@@ -366,7 +366,7 @@ static const VMStateDescription cmsdk_apb_uart_vmstate = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = cmsdk_apb_uart_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(state, CMSDKAPBUART),
 VMSTATE_UINT32(ctrl, CMSDKAPBUART),
 VMSTATE_UINT32(intstatus, CMSDKAPBUART),
diff --git a/hw/char/digic-uart.c b/hw/char/digic-uart.c
index 51d4e7db52..ef2d762726 100644
--- a/hw/char/digic-uart.c
+++ b/hw/char/digic-uart.c
@@ -165,7 +165,7 @@ static const VMStateDescription vmstate_digic_uart = {
 .name = "digic-uart",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(reg_rx, DigicUartState),
 VMSTATE_UINT32(reg_st, DigicUartState),
 VMSTATE_END_OF_LIST()
diff --git a/hw/char/escc.c b/hw/char/escc.c
index 48b30ee760..d450d70eda 100644
--- a/hw/char/escc.c
+++ b/hw/char/escc.c
@@ -766,7 +766,7 @@ static const VMStateDescription vmstate_escc_chn = {
 .name = "escc_chn",
 .version_id = 2,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(vmstate_dummy, ESCCChannelState),
 VMSTATE_UINT32(reg, ESCCChannelState),
 VMSTATE_UINT32(rxint, ESCCChannelState),
@@ -785,7 +785,7 @@ static const VMStateDescription vmstate_escc = {
 .name = "escc",
 .version_id = 2,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT_ARRAY(chn, ESCCState, 2, 2, vmstate_escc_chn,
  ESCCChannelState),
 VMSTATE_END_OF_LIST()
diff --git a/hw/char/exynos4210_uart.c b/hw/char/exynos4210_uart.c
index 7b7c56b6ef..8cdd42e54f 100644
--- a/hw/char/exynos4210_uart.c
+++ b/hw/char/exynos4210_uart.c
@@ -628,7 +628,7 @@ static const VMStateDescription 
vmstate_exynos4210_uart_fifo = {
 .name = "exynos4210.uart.fifo",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(sp, Exynos4210UartFIFO),
 VMSTATE_UINT32(rp, Exynos4210UartFIFO),
 VMSTATE_VBUFFER_UINT32(data, Exynos4210UartFIFO, 1, NULL, size),
@@ -641,7 +641,7 @@ static const VMStateDescription vmstate_exynos4210_uart = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = exynos4210_uart_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT(rx, Exynos4210UartState, 1,
  

[PATCH v2 03/71] target/arm: Constify hvf/hvf.c

2023-12-20 Thread Richard Henderson
Tested-by: Philippe Mathieu-Daudé 
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Richard Henderson 
---
 target/arm/hvf/hvf.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 757e13b0f9..203d88f80b 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -36,7 +36,7 @@
 #define MDSCR_EL1_SS_SHIFT  0
 #define MDSCR_EL1_MDE_SHIFT 15
 
-static uint16_t dbgbcr_regs[] = {
+static const uint16_t dbgbcr_regs[] = {
 HV_SYS_REG_DBGBCR0_EL1,
 HV_SYS_REG_DBGBCR1_EL1,
 HV_SYS_REG_DBGBCR2_EL1,
@@ -54,7 +54,8 @@ static uint16_t dbgbcr_regs[] = {
 HV_SYS_REG_DBGBCR14_EL1,
 HV_SYS_REG_DBGBCR15_EL1,
 };
-static uint16_t dbgbvr_regs[] = {
+
+static const uint16_t dbgbvr_regs[] = {
 HV_SYS_REG_DBGBVR0_EL1,
 HV_SYS_REG_DBGBVR1_EL1,
 HV_SYS_REG_DBGBVR2_EL1,
@@ -72,7 +73,8 @@ static uint16_t dbgbvr_regs[] = {
 HV_SYS_REG_DBGBVR14_EL1,
 HV_SYS_REG_DBGBVR15_EL1,
 };
-static uint16_t dbgwcr_regs[] = {
+
+static const uint16_t dbgwcr_regs[] = {
 HV_SYS_REG_DBGWCR0_EL1,
 HV_SYS_REG_DBGWCR1_EL1,
 HV_SYS_REG_DBGWCR2_EL1,
@@ -90,7 +92,8 @@ static uint16_t dbgwcr_regs[] = {
 HV_SYS_REG_DBGWCR14_EL1,
 HV_SYS_REG_DBGWCR15_EL1,
 };
-static uint16_t dbgwvr_regs[] = {
+
+static const uint16_t dbgwvr_regs[] = {
 HV_SYS_REG_DBGWVR0_EL1,
 HV_SYS_REG_DBGWVR1_EL1,
 HV_SYS_REG_DBGWVR2_EL1,
@@ -2010,7 +2013,7 @@ static const VMStateDescription vmstate_hvf_vtimer = {
 .name = "hvf-vtimer",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(vtimer_val, HVFVTimer),
 VMSTATE_END_OF_LIST()
 },
-- 
2.34.1




[PATCH v2 30/71] hw/i2c: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/i2c/allwinner-i2c.c  | 2 +-
 hw/i2c/aspeed_i2c.c | 4 ++--
 hw/i2c/core.c   | 4 ++--
 hw/i2c/exynos4210_i2c.c | 2 +-
 hw/i2c/imx_i2c.c| 2 +-
 hw/i2c/microbit_i2c.c   | 2 +-
 hw/i2c/mpc_i2c.c| 2 +-
 hw/i2c/npcm7xx_smbus.c  | 2 +-
 hw/i2c/pm_smbus.c   | 2 +-
 hw/i2c/pmbus_device.c   | 2 +-
 hw/i2c/smbus_eeprom.c   | 2 +-
 hw/i2c/smbus_ich9.c | 2 +-
 hw/i2c/smbus_slave.c| 2 +-
 13 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/hw/i2c/allwinner-i2c.c b/hw/i2c/allwinner-i2c.c
index 9e8efa1d63..8abcc39a5c 100644
--- a/hw/i2c/allwinner-i2c.c
+++ b/hw/i2c/allwinner-i2c.c
@@ -415,7 +415,7 @@ static const VMStateDescription allwinner_i2c_vmstate = {
 .name = TYPE_AW_I2C,
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(addr, AWI2CState),
 VMSTATE_UINT8(xaddr, AWI2CState),
 VMSTATE_UINT8(data, AWI2CState),
diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c
index 1037c22b2f..b43afd250d 100644
--- a/hw/i2c/aspeed_i2c.c
+++ b/hw/i2c/aspeed_i2c.c
@@ -945,7 +945,7 @@ static const VMStateDescription aspeed_i2c_bus_vmstate = {
 .name = TYPE_ASPEED_I2C,
 .version_id = 5,
 .minimum_version_id = 5,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(regs, AspeedI2CBus, ASPEED_I2C_NEW_NUM_REG),
 VMSTATE_END_OF_LIST()
 }
@@ -955,7 +955,7 @@ static const VMStateDescription aspeed_i2c_vmstate = {
 .name = TYPE_ASPEED_I2C,
 .version_id = 2,
 .minimum_version_id = 2,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(intr_status, AspeedI2CState),
 VMSTATE_STRUCT_ARRAY(busses, AspeedI2CState,
  ASPEED_I2C_NR_BUSSES, 1, aspeed_i2c_bus_vmstate,
diff --git a/hw/i2c/core.c b/hw/i2c/core.c
index 879a1d45cb..4cf30b2c86 100644
--- a/hw/i2c/core.c
+++ b/hw/i2c/core.c
@@ -50,7 +50,7 @@ static const VMStateDescription vmstate_i2c_bus = {
 .version_id = 1,
 .minimum_version_id = 1,
 .pre_save = i2c_bus_pre_save,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(saved_address, I2CBus),
 VMSTATE_END_OF_LIST()
 }
@@ -359,7 +359,7 @@ const VMStateDescription vmstate_i2c_slave = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = i2c_slave_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(address, I2CSlave),
 VMSTATE_END_OF_LIST()
 }
diff --git a/hw/i2c/exynos4210_i2c.c b/hw/i2c/exynos4210_i2c.c
index b65a7d0222..9445424d5f 100644
--- a/hw/i2c/exynos4210_i2c.c
+++ b/hw/i2c/exynos4210_i2c.c
@@ -273,7 +273,7 @@ static const VMStateDescription exynos4210_i2c_vmstate = {
 .name = "exynos4210.i2c",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(i2ccon, Exynos4210I2CState),
 VMSTATE_UINT8(i2cstat, Exynos4210I2CState),
 VMSTATE_UINT8(i2cds, Exynos4210I2CState),
diff --git a/hw/i2c/imx_i2c.c b/hw/i2c/imx_i2c.c
index 9792583fea..a25676f025 100644
--- a/hw/i2c/imx_i2c.c
+++ b/hw/i2c/imx_i2c.c
@@ -285,7 +285,7 @@ static const VMStateDescription imx_i2c_vmstate = {
 .name = TYPE_IMX_I2C,
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT16(address, IMXI2CState),
 VMSTATE_UINT16(iadr, IMXI2CState),
 VMSTATE_UINT16(ifdr, IMXI2CState),
diff --git a/hw/i2c/microbit_i2c.c b/hw/i2c/microbit_i2c.c
index e92f9f84ea..24d36d15b0 100644
--- a/hw/i2c/microbit_i2c.c
+++ b/hw/i2c/microbit_i2c.c
@@ -80,7 +80,7 @@ static const VMStateDescription microbit_i2c_vmstate = {
 .name = TYPE_MICROBIT_I2C,
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(regs, MicrobitI2CState, MICROBIT_I2C_NREGS),
 VMSTATE_UINT32(read_idx, MicrobitI2CState),
 VMSTATE_END_OF_LIST()
diff --git a/hw/i2c/mpc_i2c.c b/hw/i2c/mpc_i2c.c
index 219c548402..cb051a520f 100644
--- a/hw/i2c/mpc_i2c.c
+++ b/hw/i2c/mpc_i2c.c
@@ -312,7 +312,7 @@ static const VMStateDescription mpc_i2c_vmstate = {
 .name = TYPE_MPC_I2C,
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(address, MPCI2CState),
 VMSTATE_UINT8(adr, MPCI2CState),
 VMSTATE_UINT8(fdr, MPCI2CState),
diff --git a/hw/i2c/npcm7xx_smbus.c b/hw/i2c/npcm7xx_smbus.c
index e7e0ba66fe..0ea3083bb6 100644
--- a/hw/i2c/npcm7xx_smbus.c
+++ b/hw/i2c/npcm7xx_smbus.c
@@ -1046,7 +1046,7 @@ static const VMStateDescription vmstate_npcm7xx_smbus = {
 .name 

[PATCH v2 38/71] hw/loongarch: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/loongarch/acpi-build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/loongarch/acpi-build.c b/hw/loongarch/acpi-build.c
index ae292fc543..730bc4a748 100644
--- a/hw/loongarch/acpi-build.c
+++ b/hw/loongarch/acpi-build.c
@@ -564,7 +564,7 @@ static const VMStateDescription vmstate_acpi_build = {
 .name = "acpi_build",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(patched, AcpiBuildState),
 VMSTATE_END_OF_LIST()
 },
-- 
2.34.1




[PATCH v2 28/71] hw/gpio: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/gpio/aspeed_gpio.c  | 4 ++--
 hw/gpio/bcm2835_gpio.c | 2 +-
 hw/gpio/gpio_key.c | 2 +-
 hw/gpio/imx_gpio.c | 2 +-
 hw/gpio/max7310.c  | 2 +-
 hw/gpio/mpc8xxx.c  | 2 +-
 hw/gpio/npcm7xx_gpio.c | 2 +-
 hw/gpio/nrf51_gpio.c   | 2 +-
 hw/gpio/pl061.c| 2 +-
 hw/gpio/sifive_gpio.c  | 2 +-
 hw/gpio/zaurus.c   | 2 +-
 11 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c
index 1e267dd482..c1781e2ba3 100644
--- a/hw/gpio/aspeed_gpio.c
+++ b/hw/gpio/aspeed_gpio.c
@@ -1067,7 +1067,7 @@ static const VMStateDescription vmstate_gpio_regs = {
 .name = TYPE_ASPEED_GPIO"/regs",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(data_value,   GPIOSets),
 VMSTATE_UINT32(data_read,GPIOSets),
 VMSTATE_UINT32(direction,GPIOSets),
@@ -1090,7 +1090,7 @@ static const VMStateDescription vmstate_aspeed_gpio = {
 .name = TYPE_ASPEED_GPIO,
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT_ARRAY(sets, AspeedGPIOState, ASPEED_GPIO_MAX_NR_SETS,
  1, vmstate_gpio_regs, GPIOSets),
 VMSTATE_UINT32_ARRAY(debounce_regs, AspeedGPIOState,
diff --git a/hw/gpio/bcm2835_gpio.c b/hw/gpio/bcm2835_gpio.c
index c995bba1d9..6bd50bb0b6 100644
--- a/hw/gpio/bcm2835_gpio.c
+++ b/hw/gpio/bcm2835_gpio.c
@@ -284,7 +284,7 @@ static const VMStateDescription vmstate_bcm2835_gpio = {
 .name = "bcm2835_gpio",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8_ARRAY(fsel, BCM2835GpioState, 54),
 VMSTATE_UINT32(lev0, BCM2835GpioState),
 VMSTATE_UINT32(lev1, BCM2835GpioState),
diff --git a/hw/gpio/gpio_key.c b/hw/gpio/gpio_key.c
index 74f6138356..61bb587058 100644
--- a/hw/gpio/gpio_key.c
+++ b/hw/gpio/gpio_key.c
@@ -45,7 +45,7 @@ static const VMStateDescription vmstate_gpio_key = {
 .name = "gpio-key",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_TIMER_PTR(timer, GPIOKEYState),
 VMSTATE_END_OF_LIST()
 }
diff --git a/hw/gpio/imx_gpio.c b/hw/gpio/imx_gpio.c
index c7f98b7bb1..e53b00d951 100644
--- a/hw/gpio/imx_gpio.c
+++ b/hw/gpio/imx_gpio.c
@@ -277,7 +277,7 @@ static const VMStateDescription vmstate_imx_gpio = {
 .name = TYPE_IMX_GPIO,
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(dr, IMXGPIOState),
 VMSTATE_UINT32(gdir, IMXGPIOState),
 VMSTATE_UINT32(psr, IMXGPIOState),
diff --git a/hw/gpio/max7310.c b/hw/gpio/max7310.c
index 4470cfe985..86315714fb 100644
--- a/hw/gpio/max7310.c
+++ b/hw/gpio/max7310.c
@@ -155,7 +155,7 @@ static const VMStateDescription vmstate_max7310 = {
 .name = "max7310",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT32(i2c_command_byte, MAX7310State),
 VMSTATE_INT32(len, MAX7310State),
 VMSTATE_UINT8(level, MAX7310State),
diff --git a/hw/gpio/mpc8xxx.c b/hw/gpio/mpc8xxx.c
index cb42acb6da..0b3f9e516d 100644
--- a/hw/gpio/mpc8xxx.c
+++ b/hw/gpio/mpc8xxx.c
@@ -48,7 +48,7 @@ static const VMStateDescription vmstate_mpc8xxx_gpio = {
 .name = "mpc8xxx_gpio",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(dir, MPC8XXXGPIOState),
 VMSTATE_UINT32(odr, MPC8XXXGPIOState),
 VMSTATE_UINT32(dat, MPC8XXXGPIOState),
diff --git a/hw/gpio/npcm7xx_gpio.c b/hw/gpio/npcm7xx_gpio.c
index 3376901ab1..6e70ac1f24 100644
--- a/hw/gpio/npcm7xx_gpio.c
+++ b/hw/gpio/npcm7xx_gpio.c
@@ -377,7 +377,7 @@ static const VMStateDescription vmstate_npcm7xx_gpio = {
 .name = "npcm7xx-gpio",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(pin_level, NPCM7xxGPIOState),
 VMSTATE_UINT32(ext_level, NPCM7xxGPIOState),
 VMSTATE_UINT32(ext_driven, NPCM7xxGPIOState),
diff --git a/hw/gpio/nrf51_gpio.c b/hw/gpio/nrf51_gpio.c
index 08396c69a4..ffc7dff796 100644
--- a/hw/gpio/nrf51_gpio.c
+++ b/hw/gpio/nrf51_gpio.c
@@ -280,7 +280,7 @@ static const VMStateDescription vmstate_nrf51_gpio = {
 .name = TYPE_NRF51_GPIO,
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(out, NRF51GPIOState),
 VMSTATE_UINT32(in, NRF51GPIOState),
 VMSTATE_UINT32(in_mask, NRF51GPIOState),
diff --git 

[PATCH v2 32/71] hw/ide: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/ide/ahci-allwinner.c |  2 +-
 hw/ide/ahci.c   |  8 
 hw/ide/core.c   | 16 
 hw/ide/ich.c|  2 +-
 hw/ide/isa.c|  2 +-
 hw/ide/macio.c  |  2 +-
 hw/ide/microdrive.c |  2 +-
 hw/ide/mmio.c   |  2 +-
 hw/ide/pci.c| 10 +-
 9 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/hw/ide/ahci-allwinner.c b/hw/ide/ahci-allwinner.c
index 227e747ba7..b173121006 100644
--- a/hw/ide/ahci-allwinner.c
+++ b/hw/ide/ahci-allwinner.c
@@ -97,7 +97,7 @@ static const VMStateDescription vmstate_allwinner_ahci = {
 .name = "allwinner-ahci",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(regs, AllwinnerAHCIState,
  ALLWINNER_AHCI_MMIO_SIZE / 4),
 VMSTATE_END_OF_LIST()
diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index afdc44b8e0..0eb83a6d46 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -1685,7 +1685,7 @@ void ahci_reset(AHCIState *s)
 static const VMStateDescription vmstate_ncq_tfs = {
 .name = "ncq state",
 .version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(sector_count, NCQTransferState),
 VMSTATE_UINT64(lba, NCQTransferState),
 VMSTATE_UINT8(tag, NCQTransferState),
@@ -1700,7 +1700,7 @@ static const VMStateDescription vmstate_ncq_tfs = {
 static const VMStateDescription vmstate_ahci_device = {
 .name = "ahci port",
 .version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_IDE_BUS(port, AHCIDevice),
 VMSTATE_IDE_DRIVE(port.ifs[0], AHCIDevice),
 VMSTATE_UINT32(port_state, AHCIDevice),
@@ -1817,7 +1817,7 @@ const VMStateDescription vmstate_ahci = {
 .name = "ahci",
 .version_id = 1,
 .post_load = ahci_state_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT_VARRAY_POINTER_INT32(dev, AHCIState, ports,
  vmstate_ahci_device, AHCIDevice),
 VMSTATE_UINT32(control_regs.cap, AHCIState),
@@ -1833,7 +1833,7 @@ const VMStateDescription vmstate_ahci = {
 
 static const VMStateDescription vmstate_sysbus_ahci = {
 .name = "sysbus-ahci",
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_AHCI(ahci, SysbusAHCIState),
 VMSTATE_END_OF_LIST()
 },
diff --git a/hw/ide/core.c b/hw/ide/core.c
index 8a0579bff4..9c4a812902 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -2918,7 +2918,7 @@ static const VMStateDescription 
vmstate_ide_atapi_gesn_state = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = ide_atapi_gesn_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_BOOL(events.new_media, IDEState),
 VMSTATE_BOOL(events.eject_request, IDEState),
 VMSTATE_END_OF_LIST()
@@ -2930,7 +2930,7 @@ static const VMStateDescription vmstate_ide_tray_state = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = ide_tray_state_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_BOOL(tray_open, IDEState),
 VMSTATE_BOOL(tray_locked, IDEState),
 VMSTATE_END_OF_LIST()
@@ -2944,7 +2944,7 @@ static const VMStateDescription 
vmstate_ide_drive_pio_state = {
 .pre_save = ide_drive_pio_pre_save,
 .post_load = ide_drive_pio_post_load,
 .needed = ide_drive_pio_state_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT32(req_nb_sectors, IDEState),
 VMSTATE_VARRAY_INT32(io_buffer, IDEState, io_buffer_total_len, 1,
  vmstate_info_uint8, uint8_t),
@@ -2962,7 +2962,7 @@ const VMStateDescription vmstate_ide_drive = {
 .version_id = 3,
 .minimum_version_id = 0,
 .post_load = ide_drive_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT32(mult_sectors, IDEState),
 VMSTATE_INT32(identify_set, IDEState),
 VMSTATE_BUFFER_TEST(identify_data, IDEState, is_identify_set),
@@ -2985,7 +2985,7 @@ const VMStateDescription vmstate_ide_drive = {
 VMSTATE_UINT8_V(cdrom_changed, IDEState, 3),
 VMSTATE_END_OF_LIST()
 },
-.subsections = (const VMStateDescription*[]) {
+.subsections = (const VMStateDescription * const []) {
 _ide_drive_pio_state,
 _ide_tray_state,
 _ide_atapi_gesn_state,
@@ -2998,7 +2998,7 @@ static const VMStateDescription vmstate_ide_error_status 
= {
 .version_id = 2,
 .minimum_version_id = 1,
 .needed = ide_error_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT32(error_status, IDEBus),
 

[PATCH v2 17/71] target/sparc: Constify VMState in machine.c

2023-12-20 Thread Richard Henderson
Reviewed-by: Mark Cave-Ayland 
Signed-off-by: Richard Henderson 
---
 target/sparc/machine.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/target/sparc/machine.c b/target/sparc/machine.c
index 44dfc07014..2b5686c330 100644
--- a/target/sparc/machine.c
+++ b/target/sparc/machine.c
@@ -10,7 +10,7 @@ static const VMStateDescription vmstate_cpu_timer = {
 .name = "cpu_timer",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(frequency, CPUTimer),
 VMSTATE_UINT32(disabled, CPUTimer),
 VMSTATE_UINT64(disabled_mask, CPUTimer),
@@ -29,7 +29,7 @@ static const VMStateDescription vmstate_trap_state = {
 .name = "trap_state",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(tpc, trap_state),
 VMSTATE_UINT64(tnpc, trap_state),
 VMSTATE_UINT64(tstate, trap_state),
@@ -42,7 +42,7 @@ static const VMStateDescription vmstate_tlb_entry = {
 .name = "tlb_entry",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(tag, SparcTLBEntry),
 VMSTATE_UINT64(tte, SparcTLBEntry),
 VMSTATE_END_OF_LIST()
@@ -147,7 +147,7 @@ const VMStateDescription vmstate_sparc_cpu = {
 .version_id = SPARC_VMSTATE_VER,
 .minimum_version_id = SPARC_VMSTATE_VER,
 .pre_save = cpu_pre_save,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINTTL_ARRAY(env.gregs, SPARCCPU, 8),
 VMSTATE_UINT32(env.nwindows, SPARCCPU),
 VMSTATE_VARRAY_MULTIPLY(env.regbase, SPARCCPU, env.nwindows, 16,
-- 
2.34.1




[PATCH v2 18/71] hw/arm: Constify VMState

2023-12-20 Thread Richard Henderson
Tested-by: Philippe Mathieu-Daudé 
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Richard Henderson 
---
 hw/arm/armsse.c  |  2 +-
 hw/arm/armv7m.c  |  2 +-
 hw/arm/highbank.c|  2 +-
 hw/arm/integratorcp.c|  6 +++---
 hw/arm/musicpal.c| 14 +++---
 hw/arm/pxa2xx.c  | 18 +-
 hw/arm/pxa2xx_gpio.c |  2 +-
 hw/arm/pxa2xx_pic.c  |  2 +-
 hw/arm/smmuv3.c  |  8 
 hw/arm/spitz.c   |  8 
 hw/arm/stellaris.c   |  6 +++---
 hw/arm/strongarm.c   | 12 ++--
 hw/arm/versatilepb.c |  2 +-
 hw/arm/virt-acpi-build.c |  2 +-
 hw/arm/z2.c  |  4 ++--
 15 files changed, 45 insertions(+), 45 deletions(-)

diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
index 31acbf7347..02b4f6596f 100644
--- a/hw/arm/armsse.c
+++ b/hw/arm/armsse.c
@@ -1677,7 +1677,7 @@ static const VMStateDescription armsse_vmstate = {
 .name = "iotkit",
 .version_id = 2,
 .minimum_version_id = 2,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_CLOCK(mainclk, ARMSSE),
 VMSTATE_CLOCK(s32kclk, ARMSSE),
 VMSTATE_UINT32(nsccfg, ARMSSE),
diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
index d10abb36a8..375a40962f 100644
--- a/hw/arm/armv7m.c
+++ b/hw/arm/armv7m.c
@@ -559,7 +559,7 @@ static const VMStateDescription vmstate_armv7m = {
 .name = "armv7m",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_CLOCK(refclk, ARMv7MState),
 VMSTATE_CLOCK(cpuclk, ARMv7MState),
 VMSTATE_END_OF_LIST()
diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
index f12aacea6b..c21e18d08f 100644
--- a/hw/arm/highbank.c
+++ b/hw/arm/highbank.c
@@ -112,7 +112,7 @@ static const VMStateDescription vmstate_highbank_regs = {
 .name = "highbank-regs",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(regs, HighbankRegsState, NUM_REGS),
 VMSTATE_END_OF_LIST(),
 },
diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c
index d176e9af7e..e602ca5e14 100644
--- a/hw/arm/integratorcp.c
+++ b/hw/arm/integratorcp.c
@@ -63,7 +63,7 @@ static const VMStateDescription vmstate_integratorcm = {
 .name = "integratorcm",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields  = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(cm_osc, IntegratorCMState),
 VMSTATE_UINT32(cm_ctrl, IntegratorCMState),
 VMSTATE_UINT32(cm_lock, IntegratorCMState),
@@ -346,7 +346,7 @@ static const VMStateDescription vmstate_icp_pic = {
 .name = "icp_pic",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields  = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(level, icp_pic_state),
 VMSTATE_UINT32(irq_enabled, icp_pic_state),
 VMSTATE_UINT32(fiq_enabled, icp_pic_state),
@@ -488,7 +488,7 @@ static const VMStateDescription vmstate_icp_control = {
 .name = "icp_control",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields  = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(intreg_state, ICPCtrlRegsState),
 VMSTATE_END_OF_LIST()
 }
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index 9703bfb97f..3200c9f68a 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -275,7 +275,7 @@ static const VMStateDescription musicpal_lcd_vmsd = {
 .name = "musicpal_lcd",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(brightness, musicpal_lcd_state),
 VMSTATE_UINT32(mode, musicpal_lcd_state),
 VMSTATE_UINT32(irqctrl, musicpal_lcd_state),
@@ -400,7 +400,7 @@ static const VMStateDescription mv88w8618_pic_vmsd = {
 .name = "mv88w8618_pic",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(level, mv88w8618_pic_state),
 VMSTATE_UINT32(enabled, mv88w8618_pic_state),
 VMSTATE_END_OF_LIST()
@@ -583,7 +583,7 @@ static const VMStateDescription mv88w8618_timer_vmsd = {
 .name = "timer",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PTIMER(ptimer, mv88w8618_timer_state),
 VMSTATE_UINT32(limit, mv88w8618_timer_state),
 VMSTATE_END_OF_LIST()
@@ -594,7 +594,7 @@ static const VMStateDescription mv88w8618_pit_vmsd = {
 .name = "mv88w8618_pit",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT_ARRAY(timer, mv88w8618_pit_state, 4, 1,
  

[PATCH v2 39/71] hw/m68k: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/m68k/next-cube.c | 4 ++--
 hw/m68k/q800-glue.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/m68k/next-cube.c b/hw/m68k/next-cube.c
index fabd861941..baca38bf39 100644
--- a/hw/m68k/next-cube.c
+++ b/hw/m68k/next-cube.c
@@ -996,7 +996,7 @@ static const VMStateDescription next_rtc_vmstate = {
 .name = "next-rtc",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8_ARRAY(ram, NextRtc, 32),
 VMSTATE_UINT8(command, NextRtc),
 VMSTATE_UINT8(value, NextRtc),
@@ -1011,7 +1011,7 @@ static const VMStateDescription next_pc_vmstate = {
 .name = "next-pc",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(scr1, NeXTPC),
 VMSTATE_UINT32(scr2, NeXTPC),
 VMSTATE_UINT32(int_mask, NeXTPC),
diff --git a/hw/m68k/q800-glue.c b/hw/m68k/q800-glue.c
index f413b1599a..b5a7713863 100644
--- a/hw/m68k/q800-glue.c
+++ b/hw/m68k/q800-glue.c
@@ -189,7 +189,7 @@ static const VMStateDescription vmstate_glue = {
 .name = "q800-glue",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(ipr, GLUEState),
 VMSTATE_UINT8(auxmode, GLUEState),
 VMSTATE_TIMER_PTR(nmi_release, GLUEState),
-- 
2.34.1




[PATCH v2 26/71] hw/display: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/display/artist.c   |  2 +-
 hw/display/bcm2835_fb.c   |  2 +-
 hw/display/bochs-display.c|  2 +-
 hw/display/cg3.c  |  2 +-
 hw/display/cirrus_vga.c   |  4 ++--
 hw/display/dpcd.c |  2 +-
 hw/display/exynos4210_fimd.c  |  4 ++--
 hw/display/g364fb.c   |  4 ++--
 hw/display/i2c-ddc.c  |  2 +-
 hw/display/jazz_led.c |  2 +-
 hw/display/macfb.c|  6 +++---
 hw/display/pl110.c|  2 +-
 hw/display/pxa2xx_lcd.c   |  4 ++--
 hw/display/qxl.c  | 10 +-
 hw/display/ramfb-standalone.c |  2 +-
 hw/display/ramfb.c|  2 +-
 hw/display/sii9022.c  |  2 +-
 hw/display/sm501.c|  6 +++---
 hw/display/ssd0303.c  |  2 +-
 hw/display/ssd0323.c  |  2 +-
 hw/display/tcx.c  |  2 +-
 hw/display/vga-pci.c  |  2 +-
 hw/display/vga.c  |  6 +++---
 hw/display/virtio-gpu.c   |  8 
 hw/display/virtio-vga.c   |  2 +-
 hw/display/vmware_vga.c   |  4 ++--
 hw/display/xlnx_dp.c  |  2 +-
 27 files changed, 45 insertions(+), 45 deletions(-)

diff --git a/hw/display/artist.c b/hw/display/artist.c
index fde050c882..d9134532fb 100644
--- a/hw/display/artist.c
+++ b/hw/display/artist.c
@@ -1435,7 +1435,7 @@ static const VMStateDescription vmstate_artist = {
 .version_id = 2,
 .minimum_version_id = 2,
 .post_load = vmstate_artist_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT16(height, ARTISTState),
 VMSTATE_UINT16(width, ARTISTState),
 VMSTATE_UINT16(depth, ARTISTState),
diff --git a/hw/display/bcm2835_fb.c b/hw/display/bcm2835_fb.c
index a05277674f..e40ed2d2e1 100644
--- a/hw/display/bcm2835_fb.c
+++ b/hw/display/bcm2835_fb.c
@@ -355,7 +355,7 @@ static const VMStateDescription vmstate_bcm2835_fb = {
 .name = TYPE_BCM2835_FB,
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_BOOL(lock, BCM2835FBState),
 VMSTATE_BOOL(invalidate, BCM2835FBState),
 VMSTATE_BOOL(pending, BCM2835FBState),
diff --git a/hw/display/bochs-display.c b/hw/display/bochs-display.c
index 9138e98c3b..3b1d922b6e 100644
--- a/hw/display/bochs-display.c
+++ b/hw/display/bochs-display.c
@@ -61,7 +61,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(BochsDisplayState, BOCHS_DISPLAY)
 
 static const VMStateDescription vmstate_bochs_display = {
 .name = "bochs-display",
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(pci, BochsDisplayState),
 VMSTATE_UINT16_ARRAY(vbe_regs, BochsDisplayState, VBE_DISPI_INDEX_NB),
 VMSTATE_BOOL(big_endian_fb, BochsDisplayState),
diff --git a/hw/display/cg3.c b/hw/display/cg3.c
index 2e9656ae1c..b271faaa48 100644
--- a/hw/display/cg3.c
+++ b/hw/display/cg3.c
@@ -334,7 +334,7 @@ static const VMStateDescription vmstate_cg3 = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = vmstate_cg3_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT16(height, CG3State),
 VMSTATE_UINT16(width, CG3State),
 VMSTATE_UINT16(depth, CG3State),
diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
index b80f98b6c4..5dd5136a0c 100644
--- a/hw/display/cirrus_vga.c
+++ b/hw/display/cirrus_vga.c
@@ -2739,7 +2739,7 @@ const VMStateDescription vmstate_cirrus_vga = {
 .version_id = 2,
 .minimum_version_id = 1,
 .post_load = cirrus_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(vga.latch, CirrusVGAState),
 VMSTATE_UINT8(vga.sr_index, CirrusVGAState),
 VMSTATE_BUFFER(vga.sr, CirrusVGAState),
@@ -2777,7 +2777,7 @@ static const VMStateDescription vmstate_pci_cirrus_vga = {
 .name = "cirrus_vga",
 .version_id = 2,
 .minimum_version_id = 2,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(dev, PCICirrusVGAState),
 VMSTATE_STRUCT(cirrus_vga, PCICirrusVGAState, 0,
vmstate_cirrus_vga, CirrusVGAState),
diff --git a/hw/display/dpcd.c b/hw/display/dpcd.c
index 64463654a1..aab1b1a2d7 100644
--- a/hw/display/dpcd.c
+++ b/hw/display/dpcd.c
@@ -135,7 +135,7 @@ static const VMStateDescription vmstate_dpcd = {
 .name = TYPE_DPCD,
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8_ARRAY_V(dpcd_info, DPCDState, DPCD_READABLE_AREA, 0),
 VMSTATE_END_OF_LIST()
 }
diff --git a/hw/display/exynos4210_fimd.c b/hw/display/exynos4210_fimd.c
index 34a960a976..84687527d5 100644
--- a/hw/display/exynos4210_fimd.c
+++ b/hw/display/exynos4210_fimd.c
@@ -1865,7 +1865,7 @@ static const VMStateDescription 

[PATCH v2 35/71] hw/ipack: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/ipack/ipack.c   | 2 +-
 hw/ipack/tpci200.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/ipack/ipack.c b/hw/ipack/ipack.c
index ae20f36da6..c39dbb481f 100644
--- a/hw/ipack/ipack.c
+++ b/hw/ipack/ipack.c
@@ -93,7 +93,7 @@ const VMStateDescription vmstate_ipack_device = {
 .name = "ipack_device",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT32(slot, IPackDevice),
 VMSTATE_END_OF_LIST()
 }
diff --git a/hw/ipack/tpci200.c b/hw/ipack/tpci200.c
index 6b3edbf017..88eef4b830 100644
--- a/hw/ipack/tpci200.c
+++ b/hw/ipack/tpci200.c
@@ -619,7 +619,7 @@ static const VMStateDescription vmstate_tpci200 = {
 .name = "tpci200",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(dev, TPCI200State),
 VMSTATE_BOOL_ARRAY(big_endian, TPCI200State, 3),
 VMSTATE_UINT8_ARRAY(ctrl, TPCI200State, N_MODULES),
-- 
2.34.1




[PATCH v2 19/71] hw/core: Constify VMState

2023-12-20 Thread Richard Henderson
Tested-by: Philippe Mathieu-Daudé 
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Richard Henderson 
---
 hw/core/clock-vmstate.c | 6 +++---
 hw/core/or-irq.c| 6 +++---
 hw/core/ptimer.c| 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/hw/core/clock-vmstate.c b/hw/core/clock-vmstate.c
index 7eccb6d4ea..e831fc596f 100644
--- a/hw/core/clock-vmstate.c
+++ b/hw/core/clock-vmstate.c
@@ -41,7 +41,7 @@ const VMStateDescription vmstate_muldiv = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = muldiv_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(multiplier, Clock),
 VMSTATE_UINT32(divider, Clock),
 VMSTATE_END_OF_LIST()
@@ -53,11 +53,11 @@ const VMStateDescription vmstate_clock = {
 .version_id = 0,
 .minimum_version_id = 0,
 .pre_load = clock_pre_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(period, Clock),
 VMSTATE_END_OF_LIST()
 },
-.subsections = (const VMStateDescription*[]) {
+.subsections = (const VMStateDescription * const []) {
 _muldiv,
 NULL
 },
diff --git a/hw/core/or-irq.c b/hw/core/or-irq.c
index 1df4bc05a7..13907df026 100644
--- a/hw/core/or-irq.c
+++ b/hw/core/or-irq.c
@@ -94,7 +94,7 @@ static const VMStateDescription vmstate_or_irq_extras = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = vmstate_extras_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_VARRAY_UINT16_UNSAFE(levels, OrIRQState, num_lines, 0,
  vmstate_info_bool, bool),
 VMSTATE_END_OF_LIST(),
@@ -105,11 +105,11 @@ static const VMStateDescription vmstate_or_irq = {
 .name = TYPE_OR_IRQ,
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_BOOL_SUB_ARRAY(levels, OrIRQState, 0, OLD_MAX_OR_LINES),
 VMSTATE_END_OF_LIST(),
 },
-.subsections = (const VMStateDescription*[]) {
+.subsections = (const VMStateDescription * const []) {
 _or_irq_extras,
 NULL
 },
diff --git a/hw/core/ptimer.c b/hw/core/ptimer.c
index e03165febf..b1517592c6 100644
--- a/hw/core/ptimer.c
+++ b/hw/core/ptimer.c
@@ -441,7 +441,7 @@ const VMStateDescription vmstate_ptimer = {
 .name = "ptimer",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(enabled, ptimer_state),
 VMSTATE_UINT64(limit, ptimer_state),
 VMSTATE_UINT64(delta, ptimer_state),
-- 
2.34.1




[PATCH v2 10/71] target/m68k: Constify VMState in machine.c

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 target/m68k/cpu.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c
index 11c7e0a790..43b1bde21c 100644
--- a/target/m68k/cpu.c
+++ b/target/m68k/cpu.c
@@ -381,7 +381,7 @@ static const VMStateDescription vmstate_freg_tmp = {
 .name = "freg_tmp",
 .post_load = freg_post_load,
 .pre_save  = freg_pre_save,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(tmp_mant, m68k_FPReg_tmp),
 VMSTATE_UINT16(tmp_exp, m68k_FPReg_tmp),
 VMSTATE_END_OF_LIST()
@@ -390,7 +390,7 @@ static const VMStateDescription vmstate_freg_tmp = {
 
 static const VMStateDescription vmstate_freg = {
 .name = "freg",
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_WITH_TMP(FPReg, m68k_FPReg_tmp, vmstate_freg_tmp),
 VMSTATE_END_OF_LIST()
 }
@@ -411,7 +411,7 @@ const VMStateDescription vmmstate_fpu = {
 .minimum_version_id = 1,
 .needed = fpu_needed,
 .post_load = fpu_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(env.fpcr, M68kCPU),
 VMSTATE_UINT32(env.fpsr, M68kCPU),
 VMSTATE_STRUCT_ARRAY(env.fregs, M68kCPU, 8, 0, vmstate_freg, FPReg),
@@ -432,7 +432,7 @@ const VMStateDescription vmstate_cf_spregs = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = cf_spregs_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64_ARRAY(env.macc, M68kCPU, 4),
 VMSTATE_UINT32(env.macsr, M68kCPU),
 VMSTATE_UINT32(env.mac_mask, M68kCPU),
@@ -454,7 +454,7 @@ const VMStateDescription vmstate_68040_mmu = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = cpu_68040_mmu_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(env.mmu.ar, M68kCPU),
 VMSTATE_UINT32(env.mmu.ssw, M68kCPU),
 VMSTATE_UINT16(env.mmu.tcr, M68kCPU),
@@ -479,7 +479,7 @@ const VMStateDescription vmstate_68040_spregs = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = cpu_68040_spregs_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(env.vbr, M68kCPU),
 VMSTATE_UINT32(env.cacr, M68kCPU),
 VMSTATE_UINT32(env.sfc, M68kCPU),
@@ -492,7 +492,7 @@ static const VMStateDescription vmstate_m68k_cpu = {
 .name = "cpu",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields  = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(env.dregs, M68kCPU, 8),
 VMSTATE_UINT32_ARRAY(env.aregs, M68kCPU, 8),
 VMSTATE_UINT32(env.pc, M68kCPU),
@@ -509,7 +509,7 @@ static const VMStateDescription vmstate_m68k_cpu = {
 VMSTATE_INT32(env.pending_level, M68kCPU),
 VMSTATE_END_OF_LIST()
 },
-.subsections = (const VMStateDescription * []) {
+.subsections = (const VMStateDescription * const []) {
 _fpu,
 _cf_spregs,
 _68040_mmu,
-- 
2.34.1




[PATCH v2 36/71] hw/ipmi: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/ipmi/ipmi_bmc_extern.c | 2 +-
 hw/ipmi/ipmi_bmc_sim.c| 2 +-
 hw/ipmi/ipmi_bt.c | 2 +-
 hw/ipmi/ipmi_kcs.c| 2 +-
 hw/ipmi/isa_ipmi_bt.c | 2 +-
 hw/ipmi/isa_ipmi_kcs.c| 2 +-
 hw/ipmi/pci_ipmi_bt.c | 2 +-
 hw/ipmi/pci_ipmi_kcs.c| 2 +-
 hw/ipmi/smbus_ipmi.c  | 2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c
index 2117dad35a..29c5af3cc3 100644
--- a/hw/ipmi/ipmi_bmc_extern.c
+++ b/hw/ipmi/ipmi_bmc_extern.c
@@ -479,7 +479,7 @@ static const VMStateDescription vmstate_ipmi_bmc_extern = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = ipmi_bmc_extern_post_migrate,
-.fields  = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_BOOL(send_reset, IPMIBmcExtern),
 VMSTATE_BOOL(waiting_rsp, IPMIBmcExtern),
 VMSTATE_END_OF_LIST()
diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c
index 905e091094..33c839c65a 100644
--- a/hw/ipmi/ipmi_bmc_sim.c
+++ b/hw/ipmi/ipmi_bmc_sim.c
@@ -2103,7 +2103,7 @@ static const VMStateDescription vmstate_ipmi_sim = {
 .name = TYPE_IPMI_BMC_SIMULATOR,
 .version_id = 1,
 .minimum_version_id = 1,
-.fields  = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(bmc_global_enables, IPMIBmcSim),
 VMSTATE_UINT8(msg_flags, IPMIBmcSim),
 VMSTATE_BOOL(watchdog_initialized, IPMIBmcSim),
diff --git a/hw/ipmi/ipmi_bt.c b/hw/ipmi/ipmi_bt.c
index 22f94fb98d..583fc64730 100644
--- a/hw/ipmi/ipmi_bt.c
+++ b/hw/ipmi/ipmi_bt.c
@@ -396,7 +396,7 @@ const VMStateDescription vmstate_IPMIBT = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = ipmi_bt_vmstate_post_load,
-.fields  = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_BOOL(obf_irq_set, IPMIBT),
 VMSTATE_BOOL(atn_irq_set, IPMIBT),
 VMSTATE_BOOL(irqs_enabled, IPMIBT),
diff --git a/hw/ipmi/ipmi_kcs.c b/hw/ipmi/ipmi_kcs.c
index a77612946a..c15977cab4 100644
--- a/hw/ipmi/ipmi_kcs.c
+++ b/hw/ipmi/ipmi_kcs.c
@@ -379,7 +379,7 @@ const VMStateDescription vmstate_IPMIKCS = {
 .version_id = 2,
 .minimum_version_id = 1,
 .post_load = ipmi_kcs_vmstate_post_load,
-.fields  = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_BOOL(obf_irq_set, IPMIKCS),
 VMSTATE_BOOL(atn_irq_set, IPMIKCS),
 VMSTATE_UNUSED_TEST(vmstate_kcs_before_version2, 1), /* Was use_irq */
diff --git a/hw/ipmi/isa_ipmi_bt.c b/hw/ipmi/isa_ipmi_bt.c
index aec064d3cd..7b36d51494 100644
--- a/hw/ipmi/isa_ipmi_bt.c
+++ b/hw/ipmi/isa_ipmi_bt.c
@@ -77,7 +77,7 @@ static const VMStateDescription vmstate_ISAIPMIBTDevice = {
  * because it used VMSTATE_VBUFFER_UINT32, but it did not transfer
  * the buffer length, so random things would happen.
  */
-.fields  = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT(bt, ISAIPMIBTDevice, 1, vmstate_IPMIBT, IPMIBT),
 VMSTATE_END_OF_LIST()
 }
diff --git a/hw/ipmi/isa_ipmi_kcs.c b/hw/ipmi/isa_ipmi_kcs.c
index b5dcb64616..f52b32e590 100644
--- a/hw/ipmi/isa_ipmi_kcs.c
+++ b/hw/ipmi/isa_ipmi_kcs.c
@@ -76,7 +76,7 @@ static const VMStateDescription vmstate_ISAIPMIKCSDevice = {
 .name = TYPE_IPMI_INTERFACE,
 .version_id = 2,
 .minimum_version_id = 1,
-.fields  = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_VSTRUCT_TEST(kcs, ISAIPMIKCSDevice, 
vmstate_kcs_before_version2,
  0, vmstate_IPMIKCS, IPMIKCS, 1),
 VMSTATE_VSTRUCT_V(kcs, ISAIPMIKCSDevice, 2, vmstate_IPMIKCS,
diff --git a/hw/ipmi/pci_ipmi_bt.c b/hw/ipmi/pci_ipmi_bt.c
index 633931b825..afeea6f303 100644
--- a/hw/ipmi/pci_ipmi_bt.c
+++ b/hw/ipmi/pci_ipmi_bt.c
@@ -87,7 +87,7 @@ const VMStateDescription vmstate_PCIIPMIBTDevice = {
 .name = TYPE_IPMI_INTERFACE_PREFIX "pci-bt",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields  = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(dev, PCIIPMIBTDevice),
 VMSTATE_STRUCT(bt, PCIIPMIBTDevice, 1, vmstate_IPMIBT, IPMIBT),
 VMSTATE_END_OF_LIST()
diff --git a/hw/ipmi/pci_ipmi_kcs.c b/hw/ipmi/pci_ipmi_kcs.c
index 1a581413c2..05ba97ec58 100644
--- a/hw/ipmi/pci_ipmi_kcs.c
+++ b/hw/ipmi/pci_ipmi_kcs.c
@@ -87,7 +87,7 @@ const VMStateDescription vmstate_PCIIPMIKCSDevice = {
 .name = TYPE_IPMI_INTERFACE_PREFIX "pci-kcs",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields  = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(dev, PCIIPMIKCSDevice),
 VMSTATE_STRUCT(kcs, PCIIPMIKCSDevice, 1, vmstate_IPMIKCS, IPMIKCS),
 VMSTATE_END_OF_LIST()
diff --git a/hw/ipmi/smbus_ipmi.c b/hw/ipmi/smbus_ipmi.c
index d0991ab7f9..56865df7db 100644
--- a/hw/ipmi/smbus_ipmi.c
+++ 

[PATCH v2 31/71] hw/i386: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/i386/acpi-build.c   | 2 +-
 hw/i386/intel_iommu.c  | 2 +-
 hw/i386/kvm/clock.c| 6 +++---
 hw/i386/kvm/xen_evtchn.c   | 4 ++--
 hw/i386/kvm/xen_gnttab.c   | 2 +-
 hw/i386/kvm/xen_overlay.c  | 2 +-
 hw/i386/kvm/xen_xenstore.c | 2 +-
 hw/i386/kvmvapic.c | 6 +++---
 hw/i386/port92.c   | 2 +-
 hw/i386/vmmouse.c  | 2 +-
 hw/i386/xen/xen_platform.c | 2 +-
 hw/i386/xen/xen_pvdevice.c | 2 +-
 12 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 80db183b78..edc979379c 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -2770,7 +2770,7 @@ static const VMStateDescription vmstate_acpi_build = {
 .name = "acpi_build",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(patched, AcpiBuildState),
 VMSTATE_END_OF_LIST()
 },
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 5085a6fee3..ed5677c0ae 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -3289,7 +3289,7 @@ static const VMStateDescription vtd_vmstate = {
 .minimum_version_id = 1,
 .priority = MIG_PRI_IOMMU,
 .post_load = vtd_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(root, IntelIOMMUState),
 VMSTATE_UINT64(intr_root, IntelIOMMUState),
 VMSTATE_UINT64(iq, IntelIOMMUState),
diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c
index e756b0aa43..40aa9a32c3 100644
--- a/hw/i386/kvm/clock.c
+++ b/hw/i386/kvm/clock.c
@@ -245,7 +245,7 @@ static const VMStateDescription kvmclock_reliable_get_clock 
= {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = kvmclock_clock_is_reliable_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_BOOL(clock_is_reliable, KVMClockState),
 VMSTATE_END_OF_LIST()
 }
@@ -295,11 +295,11 @@ static const VMStateDescription kvmclock_vmsd = {
 .minimum_version_id = 1,
 .pre_load = kvmclock_pre_load,
 .pre_save = kvmclock_pre_save,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(clock, KVMClockState),
 VMSTATE_END_OF_LIST()
 },
-.subsections = (const VMStateDescription * []) {
+.subsections = (const VMStateDescription * const []) {
 _reliable_get_clock,
 NULL
 }
diff --git a/hw/i386/kvm/xen_evtchn.c b/hw/i386/kvm/xen_evtchn.c
index 02b8cbf8df..9a5f3caa24 100644
--- a/hw/i386/kvm/xen_evtchn.c
+++ b/hw/i386/kvm/xen_evtchn.c
@@ -240,7 +240,7 @@ static const VMStateDescription xen_evtchn_port_vmstate = {
 .name = "xen_evtchn_port",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(vcpu, XenEvtchnPort),
 VMSTATE_UINT16(type, XenEvtchnPort),
 VMSTATE_UINT16(u.val, XenEvtchnPort),
@@ -255,7 +255,7 @@ static const VMStateDescription xen_evtchn_vmstate = {
 .needed = xen_evtchn_is_needed,
 .pre_load = xen_evtchn_pre_load,
 .post_load = xen_evtchn_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(callback_param, XenEvtchnState),
 VMSTATE_UINT32(nr_ports, XenEvtchnState),
 VMSTATE_STRUCT_VARRAY_UINT32(port_table, XenEvtchnState, nr_ports, 1,
diff --git a/hw/i386/kvm/xen_gnttab.c b/hw/i386/kvm/xen_gnttab.c
index 0a24f53f20..a0cc30f619 100644
--- a/hw/i386/kvm/xen_gnttab.c
+++ b/hw/i386/kvm/xen_gnttab.c
@@ -127,7 +127,7 @@ static const VMStateDescription xen_gnttab_vmstate = {
 .minimum_version_id = 1,
 .needed = xen_gnttab_is_needed,
 .post_load = xen_gnttab_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(nr_frames, XenGnttabState),
 VMSTATE_VARRAY_UINT32(gnt_frame_gpas, XenGnttabState, nr_frames, 0,
   vmstate_info_uint64, uint64_t),
diff --git a/hw/i386/kvm/xen_overlay.c b/hw/i386/kvm/xen_overlay.c
index 39fda1b72c..526f7a6077 100644
--- a/hw/i386/kvm/xen_overlay.c
+++ b/hw/i386/kvm/xen_overlay.c
@@ -139,7 +139,7 @@ static const VMStateDescription xen_overlay_vmstate = {
 .needed = xen_overlay_is_needed,
 .pre_save = xen_overlay_pre_save,
 .post_load = xen_overlay_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(shinfo_gpa, XenOverlayState),
 VMSTATE_BOOL(long_mode, XenOverlayState),
 VMSTATE_END_OF_LIST()
diff --git a/hw/i386/kvm/xen_xenstore.c b/hw/i386/kvm/xen_xenstore.c
index 6e651960b3..c3633f7829 100644
--- a/hw/i386/kvm/xen_xenstore.c
+++ b/hw/i386/kvm/xen_xenstore.c
@@ -243,7 +243,7 @@ static const VMStateDescription xen_xenstore_vmstate = {
 .needed = xen_xenstore_is_needed,
 .pre_save = 

[PATCH v2 20/71] hw/9pfs: Constify VMState

2023-12-20 Thread Richard Henderson
Acked-by: Greg Kurz 
Acked-by: Christian Schoenebeck 
Signed-off-by: Richard Henderson 
---
 hw/9pfs/virtio-9p-device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index 5f522e68e9..efa41cfd73 100644
--- a/hw/9pfs/virtio-9p-device.c
+++ b/hw/9pfs/virtio-9p-device.c
@@ -237,7 +237,7 @@ static const VMStateDescription vmstate_virtio_9p = {
 .name = "virtio-9p",
 .minimum_version_id = 1,
 .version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_VIRTIO_DEVICE,
 VMSTATE_END_OF_LIST()
 },
-- 
2.34.1




[PATCH v2 29/71] hw/hyperv: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/hyperv/vmbus.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c
index c64eaa5a46..c86d1895ba 100644
--- a/hw/hyperv/vmbus.c
+++ b/hw/hyperv/vmbus.c
@@ -526,7 +526,7 @@ static const VMStateDescription vmstate_gpadl = {
 .name = "vmbus/gpadl",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(id, VMBusGpadl),
 VMSTATE_UINT32(child_relid, VMBusGpadl),
 VMSTATE_UINT32(num_gfns, VMBusGpadl),
@@ -1489,7 +1489,7 @@ static const VMStateDescription vmstate_channel = {
 .version_id = 0,
 .minimum_version_id = 0,
 .post_load = channel_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(id, VMBusChannel),
 VMSTATE_UINT16(subchan_idx, VMBusChannel),
 VMSTATE_UINT32(open_id, VMBusChannel),
@@ -2380,7 +2380,7 @@ const VMStateDescription vmstate_vmbus_dev = {
 .name = TYPE_VMBUS_DEVICE,
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8_ARRAY(instanceid.data, VMBusDevice, 16),
 VMSTATE_UINT16(num_channels, VMBusDevice),
 VMSTATE_STRUCT_VARRAY_POINTER_UINT16(channels, VMBusDevice,
@@ -2549,7 +2549,7 @@ static const VMStateDescription 
vmstate_post_message_input = {
 .name = "vmbus/hyperv_post_message_input",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 /*
  * skip connection_id and message_type as they are validated before
  * queueing and ignored on dequeueing
@@ -2572,7 +2572,7 @@ static const VMStateDescription vmstate_rx_queue = {
 .version_id = 0,
 .minimum_version_id = 0,
 .needed = vmbus_rx_queue_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(rx_queue_head, VMBus),
 VMSTATE_UINT8(rx_queue_size, VMBus),
 VMSTATE_STRUCT_ARRAY(rx_queue, VMBus,
@@ -2589,7 +2589,7 @@ static const VMStateDescription vmstate_vmbus = {
 .minimum_version_id = 0,
 .pre_load = vmbus_pre_load,
 .post_load = vmbus_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(state, VMBus),
 VMSTATE_UINT32(version, VMBus),
 VMSTATE_UINT32(target_vp, VMBus),
@@ -2598,7 +2598,7 @@ static const VMStateDescription vmstate_vmbus = {
  vmstate_gpadl, VMBusGpadl, link),
 VMSTATE_END_OF_LIST()
 },
-.subsections = (const VMStateDescription * []) {
+.subsections = (const VMStateDescription * const []) {
 _rx_queue,
 NULL
 }
@@ -2643,7 +2643,7 @@ static const VMStateDescription vmstate_vmbus_bridge = {
 .name = TYPE_VMBUS_BRIDGE,
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT_POINTER(bus, VMBusBridge, vmstate_vmbus, VMBus),
 VMSTATE_END_OF_LIST()
 },
-- 
2.34.1




[PATCH v2 23/71] hw/audio: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/audio/ac97.c| 4 ++--
 hw/audio/asc.c | 4 ++--
 hw/audio/cs4231.c  | 2 +-
 hw/audio/cs4231a.c | 2 +-
 hw/audio/es1370.c  | 4 ++--
 hw/audio/gus.c | 2 +-
 hw/audio/hda-codec.c   | 8 
 hw/audio/intel-hda.c   | 4 ++--
 hw/audio/lm4549.c  | 2 +-
 hw/audio/marvell_88w8618.c | 2 +-
 hw/audio/pcspk.c   | 2 +-
 hw/audio/pl041.c   | 8 
 hw/audio/sb16.c| 2 +-
 hw/audio/virtio-snd.c  | 2 +-
 hw/audio/wm8750.c  | 2 +-
 15 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c
index 6a7a2dc80c..3f0053f94d 100644
--- a/hw/audio/ac97.c
+++ b/hw/audio/ac97.c
@@ -1094,7 +1094,7 @@ static const VMStateDescription vmstate_ac97_bm_regs = {
 .name = "ac97_bm_regs",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(bdbar, AC97BusMasterRegs),
 VMSTATE_UINT8(civ, AC97BusMasterRegs),
 VMSTATE_UINT8(lvi, AC97BusMasterRegs),
@@ -1142,7 +1142,7 @@ static const VMStateDescription vmstate_ac97 = {
 .version_id = 3,
 .minimum_version_id = 2,
 .post_load = ac97_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE(dev, AC97LinkState),
 VMSTATE_UINT32(glob_cnt, AC97LinkState),
 VMSTATE_UINT32(glob_sta, AC97LinkState),
diff --git a/hw/audio/asc.c b/hw/audio/asc.c
index 0f36b4ce9b..87b5624326 100644
--- a/hw/audio/asc.c
+++ b/hw/audio/asc.c
@@ -555,7 +555,7 @@ static const VMStateDescription vmstate_asc_fifo = {
 .name = "apple-sound-chip.fifo",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8_ARRAY(fifo, ASCFIFOState, ASC_FIFO_SIZE),
 VMSTATE_UINT8(int_status, ASCFIFOState),
 VMSTATE_INT32(cnt, ASCFIFOState),
@@ -575,7 +575,7 @@ static const VMStateDescription vmstate_asc = {
 .version_id = 0,
 .minimum_version_id = 0,
 .post_load = asc_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT_ARRAY(fifos, ASCState, 2, 0, vmstate_asc_fifo,
  ASCFIFOState),
 VMSTATE_UINT8_ARRAY(regs, ASCState, ASC_REG_SIZE),
diff --git a/hw/audio/cs4231.c b/hw/audio/cs4231.c
index aefc3edea1..967caa7fcb 100644
--- a/hw/audio/cs4231.c
+++ b/hw/audio/cs4231.c
@@ -142,7 +142,7 @@ static const VMStateDescription vmstate_cs4231 = {
 .name ="cs4231",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(regs, CSState, CS_REGS),
 VMSTATE_UINT8_ARRAY(dregs, CSState, CS_DREGS),
 VMSTATE_END_OF_LIST()
diff --git a/hw/audio/cs4231a.c b/hw/audio/cs4231a.c
index 3aa105748d..9ef57f042d 100644
--- a/hw/audio/cs4231a.c
+++ b/hw/audio/cs4231a.c
@@ -637,7 +637,7 @@ static const VMStateDescription vmstate_cs4231a = {
 .minimum_version_id = 1,
 .pre_load = cs4231a_pre_load,
 .post_load = cs4231a_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY (regs, CSState, CS_REGS),
 VMSTATE_BUFFER (dregs, CSState),
 VMSTATE_INT32 (dma_running, CSState),
diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c
index fad5541211..4ab61d3b9d 100644
--- a/hw/audio/es1370.c
+++ b/hw/audio/es1370.c
@@ -765,7 +765,7 @@ static const VMStateDescription vmstate_es1370_channel = {
 .name = "es1370_channel",
 .version_id = 2,
 .minimum_version_id = 2,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32 (shift, struct chan),
 VMSTATE_UINT32 (leftover, struct chan),
 VMSTATE_UINT32 (scount, struct chan),
@@ -808,7 +808,7 @@ static const VMStateDescription vmstate_es1370 = {
 .version_id = 2,
 .minimum_version_id = 2,
 .post_load = es1370_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_PCI_DEVICE (dev, ES1370State),
 VMSTATE_STRUCT_ARRAY (chan, ES1370State, NB_CHANNELS, 2,
   vmstate_es1370_channel, struct chan),
diff --git a/hw/audio/gus.c b/hw/audio/gus.c
index 6c2b586ca7..4beb3fd74e 100644
--- a/hw/audio/gus.c
+++ b/hw/audio/gus.c
@@ -209,7 +209,7 @@ static const VMStateDescription vmstate_gus = {
 .name = "gus",
 .version_id = 2,
 .minimum_version_id = 2,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT32 (pos, GUSState),
 VMSTATE_INT32 (left, GUSState),
 VMSTATE_INT32 (shift, GUSState),
diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c
index 0bc20d49f6..b22e486fda 100644
--- a/hw/audio/hda-codec.c
+++ 

[PATCH v2 07/71] target/hppa: Constify VMState in machine.c

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 target/hppa/machine.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/hppa/machine.c b/target/hppa/machine.c
index 15cbc5e6d0..211bfcf640 100644
--- a/target/hppa/machine.c
+++ b/target/hppa/machine.c
@@ -201,7 +201,7 @@ static const VMStateField vmstate_env_fields[] = {
 VMSTATE_END_OF_LIST()
 };
 
-static const VMStateDescription *vmstate_env_subsections[] = {
+static const VMStateDescription * const vmstate_env_subsections[] = {
 _tlb,
 NULL
 };
-- 
2.34.1




[PATCH v2 24/71] hw/block: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/block/ecc.c|  2 +-
 hw/block/fdc-isa.c|  2 +-
 hw/block/fdc-sysbus.c |  2 +-
 hw/block/fdc.c| 20 ++--
 hw/block/m25p80.c | 12 ++--
 hw/block/nand.c   |  2 +-
 hw/block/onenand.c|  2 +-
 hw/block/pflash_cfi01.c   |  2 +-
 hw/block/swim.c   |  6 +++---
 hw/block/vhost-user-blk.c |  2 +-
 hw/block/virtio-blk.c |  2 +-
 11 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/hw/block/ecc.c b/hw/block/ecc.c
index 6e0d63842c..ed889a4184 100644
--- a/hw/block/ecc.c
+++ b/hw/block/ecc.c
@@ -82,7 +82,7 @@ const VMStateDescription vmstate_ecc_state = {
 .name = "ecc-state",
 .version_id = 0,
 .minimum_version_id = 0,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(cp, ECCState),
 VMSTATE_UINT16_ARRAY(lp, ECCState, 2),
 VMSTATE_UINT16(count, ECCState),
diff --git a/hw/block/fdc-isa.c b/hw/block/fdc-isa.c
index 7ec075e470..ad0921c7d3 100644
--- a/hw/block/fdc-isa.c
+++ b/hw/block/fdc-isa.c
@@ -259,7 +259,7 @@ static const VMStateDescription vmstate_isa_fdc = {
 .name = "fdc",
 .version_id = 2,
 .minimum_version_id = 2,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT(state, FDCtrlISABus, 0, vmstate_fdc, FDCtrl),
 VMSTATE_END_OF_LIST()
 }
diff --git a/hw/block/fdc-sysbus.c b/hw/block/fdc-sysbus.c
index 86ea51d003..266bc4d145 100644
--- a/hw/block/fdc-sysbus.c
+++ b/hw/block/fdc-sysbus.c
@@ -168,7 +168,7 @@ static const VMStateDescription vmstate_sysbus_fdc = {
 .name = "fdc",
 .version_id = 2,
 .minimum_version_id = 2,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT(state, FDCtrlSysBus, 0, vmstate_fdc, FDCtrl),
 VMSTATE_END_OF_LIST()
 }
diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index d7cc4d3ec1..6dd94e98bc 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -854,7 +854,7 @@ static const VMStateDescription 
vmstate_fdrive_media_changed = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = fdrive_media_changed_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(media_changed, FDrive),
 VMSTATE_END_OF_LIST()
 }
@@ -864,7 +864,7 @@ static const VMStateDescription vmstate_fdrive_media_rate = 
{
 .name = "fdrive/media_rate",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(media_rate, FDrive),
 VMSTATE_END_OF_LIST()
 }
@@ -882,7 +882,7 @@ static const VMStateDescription 
vmstate_fdrive_perpendicular = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = fdrive_perpendicular_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(perpendicular, FDrive),
 VMSTATE_END_OF_LIST()
 }
@@ -899,13 +899,13 @@ static const VMStateDescription vmstate_fdrive = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = fdrive_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(head, FDrive),
 VMSTATE_UINT8(track, FDrive),
 VMSTATE_UINT8(sect, FDrive),
 VMSTATE_END_OF_LIST()
 },
-.subsections = (const VMStateDescription*[]) {
+.subsections = (const VMStateDescription * const []) {
 _fdrive_media_changed,
 _fdrive_media_rate,
 _fdrive_perpendicular,
@@ -977,7 +977,7 @@ static const VMStateDescription vmstate_fdc_reset_sensei = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = fdc_reset_sensei_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_INT32(reset_sensei, FDCtrl),
 VMSTATE_END_OF_LIST()
 }
@@ -995,7 +995,7 @@ static const VMStateDescription vmstate_fdc_result_timer = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = fdc_result_timer_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_TIMER_PTR(result_timer, FDCtrl),
 VMSTATE_END_OF_LIST()
 }
@@ -1013,7 +1013,7 @@ static const VMStateDescription vmstate_fdc_phase = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = fdc_phase_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(phase, FDCtrl),
 VMSTATE_END_OF_LIST()
 }
@@ -1026,7 +1026,7 @@ const VMStateDescription vmstate_fdc = {
 .pre_save = fdc_pre_save,
 .pre_load = fdc_pre_load,
 .post_load = fdc_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 /* Controller State */
 VMSTATE_UINT8(sra, FDCtrl),
 VMSTATE_UINT8(srb, FDCtrl),
@@ -1057,7 +1057,7 @@ const 

[PATCH v2 13/71] target/openrisc: Constify VMState in machine.c

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 target/openrisc/machine.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/target/openrisc/machine.c b/target/openrisc/machine.c
index b7d7388640..3574e571cb 100644
--- a/target/openrisc/machine.c
+++ b/target/openrisc/machine.c
@@ -25,7 +25,7 @@ static const VMStateDescription vmstate_tlb_entry = {
 .name = "tlb_entry",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINTTL(mr, OpenRISCTLBEntry),
 VMSTATE_UINTTL(tr, OpenRISCTLBEntry),
 VMSTATE_END_OF_LIST()
@@ -36,7 +36,7 @@ static const VMStateDescription vmstate_cpu_tlb = {
 .name = "cpu_tlb",
 .version_id = 2,
 .minimum_version_id = 2,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT_ARRAY(itlb, CPUOpenRISCTLBContext, TLB_SIZE, 0,
  vmstate_tlb_entry, OpenRISCTLBEntry),
 VMSTATE_STRUCT_ARRAY(dtlb, CPUOpenRISCTLBContext, TLB_SIZE, 0,
@@ -71,7 +71,7 @@ static const VMStateDescription vmstate_env = {
 .name = "env",
 .version_id = 6,
 .minimum_version_id = 6,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINTTL_2DARRAY(shadow_gpr, CPUOpenRISCState, 16, 32),
 VMSTATE_UINTTL(pc, CPUOpenRISCState),
 VMSTATE_UINTTL(ppc, CPUOpenRISCState),
@@ -135,7 +135,7 @@ const VMStateDescription vmstate_openrisc_cpu = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = cpu_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_CPU(),
 VMSTATE_STRUCT(env, OpenRISCCPU, 1, vmstate_env, CPUOpenRISCState),
 VMSTATE_END_OF_LIST()
-- 
2.34.1




[PATCH v2 21/71] hw/acpi: Constify VMState

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 hw/acpi/cpu.c  |  4 ++--
 hw/acpi/erst.c |  2 +-
 hw/acpi/generic_event_device.c | 12 ++--
 hw/acpi/ich9.c | 12 ++--
 hw/acpi/ich9_tco.c |  2 +-
 hw/acpi/memory_hotplug.c   |  4 ++--
 hw/acpi/pcihp.c|  2 +-
 hw/acpi/piix4.c| 12 ++--
 hw/acpi/vmgenid.c  |  2 +-
 9 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c
index 011d2c6c2d..2d81c1e790 100644
--- a/hw/acpi/cpu.c
+++ b/hw/acpi/cpu.c
@@ -297,7 +297,7 @@ static const VMStateDescription vmstate_cpuhp_sts = {
 .name = "CPU hotplug device state",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields  = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_BOOL(is_inserting, AcpiCpuStatus),
 VMSTATE_BOOL(is_removing, AcpiCpuStatus),
 VMSTATE_UINT32(ost_event, AcpiCpuStatus),
@@ -310,7 +310,7 @@ const VMStateDescription vmstate_cpu_hotplug = {
 .name = "CPU hotplug state",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields  = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(selector, CPUHotplugState),
 VMSTATE_UINT8(command, CPUHotplugState),
 VMSTATE_STRUCT_VARRAY_POINTER_UINT32(devs, CPUHotplugState, dev_count,
diff --git a/hw/acpi/erst.c b/hw/acpi/erst.c
index ba751dc60e..b2f1b13630 100644
--- a/hw/acpi/erst.c
+++ b/hw/acpi/erst.c
@@ -932,7 +932,7 @@ static const VMStateDescription erst_vmstate  = {
 .version_id = 1,
 .minimum_version_id = 1,
 .post_load = erst_post_load,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(operation, ERSTDeviceState),
 VMSTATE_UINT8(busy_status, ERSTDeviceState),
 VMSTATE_UINT8(command_status, ERSTDeviceState),
diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c
index a3d31631fe..2d6e91b124 100644
--- a/hw/acpi/generic_event_device.c
+++ b/hw/acpi/generic_event_device.c
@@ -312,7 +312,7 @@ static const VMStateDescription vmstate_memhp_state = {
 .name = "acpi-ged/memhp",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields  = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_MEMORY_HOTPLUG(memhp_state, AcpiGedState),
 VMSTATE_END_OF_LIST()
 }
@@ -322,7 +322,7 @@ static const VMStateDescription vmstate_ged_state = {
 .name = "acpi-ged-state",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields  = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(sel, GEDState),
 VMSTATE_END_OF_LIST()
 }
@@ -332,7 +332,7 @@ static const VMStateDescription vmstate_ghes = {
 .name = "acpi-ghes",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(ghes_addr_le, AcpiGhesState),
 VMSTATE_END_OF_LIST()
 },
@@ -349,7 +349,7 @@ static const VMStateDescription vmstate_ghes_state = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = ghes_needed,
-.fields  = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT(ghes_state, AcpiGedState, 1,
vmstate_ghes, AcpiGhesState),
 VMSTATE_END_OF_LIST()
@@ -360,11 +360,11 @@ static const VMStateDescription vmstate_acpi_ged = {
 .name = "acpi-ged",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT(ged_state, AcpiGedState, 1, vmstate_ged_state, 
GEDState),
 VMSTATE_END_OF_LIST(),
 },
-.subsections = (const VMStateDescription * []) {
+.subsections = (const VMStateDescription * const []) {
 _memhp_state,
 _ghes_state,
 NULL
diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 25e2c7243e..573d032e8e 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -164,7 +164,7 @@ static const VMStateDescription vmstate_memhp_state = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = vmstate_test_use_memhp,
-.fields  = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_MEMORY_HOTPLUG(acpi_memory_hotplug, ICH9LPCPMRegs),
 VMSTATE_END_OF_LIST()
 }
@@ -181,7 +181,7 @@ static const VMStateDescription vmstate_tco_io_state = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = vmstate_test_use_tco,
-.fields  = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT(tco_regs, ICH9LPCPMRegs, 1, vmstate_tco_io_sts,
TCOIORegs),
 VMSTATE_END_OF_LIST()
@@ -208,7 +208,7 @@ static const VMStateDescription vmstate_cpuhp_state = {
 .minimum_version_id = 1,
 .needed = vmstate_test_use_cpuhp,
 

[PATCH v2 00/71] *: Constify VMState

2023-12-20 Thread Richard Henderson
Most of this can be done without the first patch.
But with it, we get to constify subsections as well.

For qemu-system-aarch64, this moves 472k from .data to
.data.ro and/or .rodata (mostly depending on -fpie).

For qemu-system-x86_64, 272k.
For qemu-system-ppc64, 267k.

No significant changes for v2, just rebase and incorporate r-b.


r~


Richard Henderson (71):
  migration: Make VMStateDescription.subsections const
  target/arm: Constify VMState in machine.c
  target/arm: Constify hvf/hvf.c
  target/alpha: Constify VMState in machine.c
  target/avr: Constify VMState in machine.c
  target/cris: Constify VMState in machine.c
  target/hppa: Constify VMState in machine.c
  target/i386: Constify VMState in machine.c
  target/loongarch: Constify VMState in machine.c
  target/m68k: Constify VMState in machine.c
  target/microblaze: Constify VMState in machine.c
  target/mips: Constify VMState in machine.c
  target/openrisc: Constify VMState in machine.c
  target/ppc: Constify VMState in machine.c
  target/riscv: Constify VMState in machine.c
  target/s390x: Constify VMState in machine.c
  target/sparc: Constify VMState in machine.c
  hw/arm: Constify VMState
  hw/core: Constify VMState
  hw/9pfs: Constify VMState
  hw/acpi: Constify VMState
  hw/adc: Constify VMState
  hw/audio: Constify VMState
  hw/block: Constify VMState
  hw/char: Constify VMState
  hw/display: Constify VMState
  hw/dma: Constify VMState
  hw/gpio: Constify VMState
  hw/hyperv: Constify VMState
  hw/i2c: Constify VMState
  hw/i386: Constify VMState
  hw/ide: Constify VMState
  hw/input: Constify VMState
  hw/intc: Constify VMState
  hw/ipack: Constify VMState
  hw/ipmi: Constify VMState
  hw/isa: Constify VMState
  hw/loongarch: Constify VMState
  hw/m68k: Constify VMState
  hw/misc: Constify VMState
  hw/net: Constify VMState
  hw/nvram: Constify VMState
  hw/openrisc: Constify VMState
  hw/pci: Constify VMState
  hw/pci-bridge: Constify VMState
  hw/pci-host: Constify VMState
  hw/ppc: Constify VMState
  hw/riscv: Constify VMState
  hw/rtc: Constify VMState
  hw/s390x: Constify VMState
  hw/scsi: Constify VMState
  hw/sd: Constify VMState
  hw/sensor: Constify VMState
  hw/sparc: Constify VMState
  hw/ssi: Constify VMState
  hw/timer: Constify VMState
  hw/tpm: Constify VMState
  hw/usb: Constify VMState
  hw/vfio: Constify VMState
  hw/virtio: Constify VMState
  hw/watchdog: Constify VMState
  hw/misc/macio: Constify VMState
  audio: Constify VMState
  backends: Constify VMState
  cpu-target: Constify VMState
  migration: Constify VMState
  system: Constify VMState
  replay: Constify VMState
  util/fifo8: Constify VMState
  tests/unit/test-vmstate: Constify VMState
  docs: Constify VMstate in examples

 docs/devel/clocks.rst   |   2 +-
 docs/devel/migration.rst|   8 +-
 include/hw/pci/shpc.h   |   2 +-
 include/migration/vmstate.h |   2 +-
 audio/audio.c   |   2 +-
 backends/dbus-vmstate.c |   2 +-
 backends/tpm/tpm_emulator.c |   2 +-
 cpu-target.c|   8 +-
 hw/9pfs/virtio-9p-device.c  |   2 +-
 hw/acpi/cpu.c   |   4 +-
 hw/acpi/erst.c  |   2 +-
 hw/acpi/generic_event_device.c  |  12 +--
 hw/acpi/ich9.c  |  12 +--
 hw/acpi/ich9_tco.c  |   2 +-
 hw/acpi/memory_hotplug.c|   4 +-
 hw/acpi/pcihp.c |   2 +-
 hw/acpi/piix4.c |  12 +--
 hw/acpi/vmgenid.c   |   2 +-
 hw/adc/aspeed_adc.c |   2 +-
 hw/adc/max111x.c|   2 +-
 hw/adc/npcm7xx_adc.c|   2 +-
 hw/adc/stm32f2xx_adc.c  |   2 +-
 hw/adc/zynq-xadc.c  |   2 +-
 hw/arm/armsse.c |   2 +-
 hw/arm/armv7m.c |   2 +-
 hw/arm/highbank.c   |   2 +-
 hw/arm/integratorcp.c   |   6 +-
 hw/arm/musicpal.c   |  14 +--
 hw/arm/pxa2xx.c |  18 ++--
 hw/arm/pxa2xx_gpio.c|   2 +-
 hw/arm/pxa2xx_pic.c |   2 +-
 hw/arm/smmuv3.c |   8 +-
 hw/arm/spitz.c  |   8 +-
 hw/arm/stellaris.c  |   6 +-
 hw/arm/strongarm.c  |  12 +--
 hw/arm/versatilepb.c|   2 +-
 hw/arm/virt-acpi-build.c|   2 +-
 hw/arm/z2.c |   4 +-
 hw/audio/ac97.c |   4 +-
 hw/audio/asc.c  |   4 +-
 hw/audio/cs4231.c   |   2 +-
 hw/audio/cs4231a.c  |   2 +-
 hw/audio/es1370.c   |   4 +-
 hw/audio/gus.c  |   2 +-
 hw/audio/hda-codec.c|   8 +-
 hw/audio/intel-hda.c|   4 +-
 hw/audio/lm4549.c   |   2 +-
 hw/audio/marvell_88w8618.c  |   2 +-
 hw/audio/pcspk.c|   2 +-
 

[PATCH v2 08/71] target/i386: Constify VMState in machine.c

2023-12-20 Thread Richard Henderson
Signed-off-by: Richard Henderson 
---
 target/i386/machine.c | 128 +-
 1 file changed, 64 insertions(+), 64 deletions(-)

diff --git a/target/i386/machine.c b/target/i386/machine.c
index a1041ef828..c3ae320814 100644
--- a/target/i386/machine.c
+++ b/target/i386/machine.c
@@ -18,7 +18,7 @@ static const VMStateDescription vmstate_segment = {
 .name = "segment",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(selector, SegmentCache),
 VMSTATE_UINTTL(base, SegmentCache),
 VMSTATE_UINT32(limit, SegmentCache),
@@ -43,7 +43,7 @@ static const VMStateDescription vmstate_xmm_reg = {
 .name = "xmm_reg",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(ZMM_Q(0), ZMMReg),
 VMSTATE_UINT64(ZMM_Q(1), ZMMReg),
 VMSTATE_END_OF_LIST()
@@ -59,7 +59,7 @@ static const VMStateDescription vmstate_ymmh_reg = {
 .name = "ymmh_reg",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(ZMM_Q(2), ZMMReg),
 VMSTATE_UINT64(ZMM_Q(3), ZMMReg),
 VMSTATE_END_OF_LIST()
@@ -74,7 +74,7 @@ static const VMStateDescription vmstate_zmmh_reg = {
 .name = "zmmh_reg",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(ZMM_Q(4), ZMMReg),
 VMSTATE_UINT64(ZMM_Q(5), ZMMReg),
 VMSTATE_UINT64(ZMM_Q(6), ZMMReg),
@@ -92,7 +92,7 @@ static const VMStateDescription vmstate_hi16_zmm_reg = {
 .name = "hi16_zmm_reg",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(ZMM_Q(0), ZMMReg),
 VMSTATE_UINT64(ZMM_Q(1), ZMMReg),
 VMSTATE_UINT64(ZMM_Q(2), ZMMReg),
@@ -114,7 +114,7 @@ static const VMStateDescription vmstate_bnd_regs = {
 .name = "bnd_regs",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(lb, BNDReg),
 VMSTATE_UINT64(ub, BNDReg),
 VMSTATE_END_OF_LIST()
@@ -128,7 +128,7 @@ static const VMStateDescription vmstate_mtrr_var = {
 .name = "mtrr_var",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(base, MTRRVar),
 VMSTATE_UINT64(mask, MTRRVar),
 VMSTATE_END_OF_LIST()
@@ -142,7 +142,7 @@ static const VMStateDescription vmstate_lbr_records_var = {
 .name = "lbr_records_var",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(from, LBREntry),
 VMSTATE_UINT64(to, LBREntry),
 VMSTATE_UINT64(info, LBREntry),
@@ -201,7 +201,7 @@ static const VMStateDescription vmstate_fpreg_tmp = {
 .name = "fpreg_tmp",
 .post_load = fpreg_post_load,
 .pre_save  = fpreg_pre_save,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(tmp_mant, x86_FPReg_tmp),
 VMSTATE_UINT16(tmp_exp, x86_FPReg_tmp),
 VMSTATE_END_OF_LIST()
@@ -210,7 +210,7 @@ static const VMStateDescription vmstate_fpreg_tmp = {
 
 static const VMStateDescription vmstate_fpreg = {
 .name = "fpreg",
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_WITH_TMP(FPReg, x86_FPReg_tmp, vmstate_fpreg_tmp),
 VMSTATE_END_OF_LIST()
 }
@@ -453,7 +453,7 @@ static const VMStateDescription vmstate_exception_info = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = exception_info_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(env.exception_pending, X86CPU),
 VMSTATE_UINT8(env.exception_injected, X86CPU),
 VMSTATE_UINT8(env.exception_has_payload, X86CPU),
@@ -475,7 +475,7 @@ static const VMStateDescription vmstate_steal_time_msr = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = steal_time_msr_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(env.steal_time_msr, X86CPU),
 VMSTATE_END_OF_LIST()
 }
@@ -486,7 +486,7 @@ static const VMStateDescription vmstate_async_pf_msr = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = async_pf_msr_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64(env.async_pf_en_msr, X86CPU),
 VMSTATE_END_OF_LIST()
 }
@@ -497,7 +497,7 @@ static const VMStateDescription vmstate_async_pf_int_msr = {
 .version_id = 1,
 .minimum_version_id = 1,

[PATCH v2 02/71] target/arm: Constify VMState in machine.c

2023-12-20 Thread Richard Henderson
Tested-by: Philippe Mathieu-Daudé 
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Richard Henderson 
---
 target/arm/machine.c | 54 ++--
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/target/arm/machine.c b/target/arm/machine.c
index 9e20b41189..542be14bec 100644
--- a/target/arm/machine.c
+++ b/target/arm/machine.c
@@ -49,7 +49,7 @@ static const VMStateDescription vmstate_vfp = {
 .version_id = 3,
 .minimum_version_id = 3,
 .needed = vfp_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 /* For compatibility, store Qn out of Zn here.  */
 VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[0].d, ARMCPU, 0, 2),
 VMSTATE_UINT64_SUB_ARRAY(env.vfp.zregs[1].d, ARMCPU, 0, 2),
@@ -115,7 +115,7 @@ static const VMStateDescription vmstate_iwmmxt = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = iwmmxt_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64_ARRAY(env.iwmmxt.regs, ARMCPU, 16),
 VMSTATE_UINT32_ARRAY(env.iwmmxt.cregs, ARMCPU, 16),
 VMSTATE_END_OF_LIST()
@@ -140,7 +140,7 @@ static const VMStateDescription vmstate_zreg_hi_reg = {
 .name = "cpu/sve/zreg_hi",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64_SUB_ARRAY(d, ARMVectorReg, 2, ARM_MAX_VQ - 2),
 VMSTATE_END_OF_LIST()
 }
@@ -150,7 +150,7 @@ static const VMStateDescription vmstate_preg_reg = {
 .name = "cpu/sve/preg",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64_ARRAY(p, ARMPredicateReg, 2 * ARM_MAX_VQ / 8),
 VMSTATE_END_OF_LIST()
 }
@@ -161,7 +161,7 @@ static const VMStateDescription vmstate_sve = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = sve_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT_ARRAY(env.vfp.zregs, ARMCPU, 32, 0,
  vmstate_zreg_hi_reg, ARMVectorReg),
 VMSTATE_STRUCT_ARRAY(env.vfp.pregs, ARMCPU, 17, 0,
@@ -174,7 +174,7 @@ static const VMStateDescription vmstate_vreg = {
 .name = "vreg",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT64_ARRAY(d, ARMVectorReg, ARM_MAX_VQ * 2),
 VMSTATE_END_OF_LIST()
 }
@@ -196,7 +196,7 @@ static const VMStateDescription vmstate_za = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = za_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_STRUCT_ARRAY(env.zarray, ARMCPU, ARM_MAX_VQ * 16, 0,
  vmstate_vreg, ARMVectorReg),
 VMSTATE_END_OF_LIST()
@@ -217,7 +217,7 @@ static const VMStateDescription vmstate_serror = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = serror_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT8(env.serror.pending, ARMCPU),
 VMSTATE_UINT8(env.serror.has_esr, ARMCPU),
 VMSTATE_UINT64(env.serror.esr, ARMCPU),
@@ -235,7 +235,7 @@ static const VMStateDescription vmstate_irq_line_state = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = irq_line_state_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(env.irq_line_state, ARMCPU),
 VMSTATE_END_OF_LIST()
 }
@@ -254,7 +254,7 @@ static const VMStateDescription vmstate_m_faultmask_primask 
= {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = m_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(env.v7m.faultmask[M_REG_NS], ARMCPU),
 VMSTATE_UINT32(env.v7m.primask[M_REG_NS], ARMCPU),
 VMSTATE_END_OF_LIST()
@@ -289,7 +289,7 @@ static const VMStateDescription vmstate_m_csselr = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = m_csselr_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(env.v7m.csselr, ARMCPU, M_REG_NUM_BANKS),
 VMSTATE_VALIDATE("CSSELR is valid", csselr_vmstate_validate),
 VMSTATE_END_OF_LIST()
@@ -301,7 +301,7 @@ static const VMStateDescription vmstate_m_scr = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = m_needed,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(env.v7m.scr[M_REG_NS], ARMCPU),
 VMSTATE_END_OF_LIST()
 }
@@ -312,7 +312,7 @@ static const VMStateDescription vmstate_m_other_sp = {
 .version_id = 1,
 .minimum_version_id = 1,
 .needed = m_needed,
-.fields = (VMStateField[]) {
+.fields = (const 

[PATCH v2 06/71] target/cris: Constify VMState in machine.c

2023-12-20 Thread Richard Henderson
Reviewed-by: Philippe Mathieu-Daudé 
Signed-off-by: Richard Henderson 
---
 target/cris/machine.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/target/cris/machine.c b/target/cris/machine.c
index f370f33486..7b9bde872a 100644
--- a/target/cris/machine.c
+++ b/target/cris/machine.c
@@ -26,7 +26,7 @@ static const VMStateDescription vmstate_tlbset = {
 .name = "cpu/tlbset",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32(lo, TLBSet),
 VMSTATE_UINT32(hi, TLBSet),
 VMSTATE_END_OF_LIST()
@@ -37,7 +37,7 @@ static const VMStateDescription vmstate_cris_env = {
 .name = "env",
 .version_id = 2,
 .minimum_version_id = 2,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_UINT32_ARRAY(regs, CPUCRISState, 16),
 VMSTATE_UINT32_ARRAY(pregs, CPUCRISState, 16),
 VMSTATE_UINT32(pc, CPUCRISState),
@@ -85,7 +85,7 @@ const VMStateDescription vmstate_cris_cpu = {
 .name = "cpu",
 .version_id = 1,
 .minimum_version_id = 1,
-.fields = (VMStateField[]) {
+.fields = (const VMStateField[]) {
 VMSTATE_CPU(),
 VMSTATE_STRUCT(env, CRISCPU, 1, vmstate_cris_env, CPUCRISState),
 VMSTATE_END_OF_LIST()
-- 
2.34.1




  1   2   3   >