diff mbox series

[v2,2/5] migration: Add 64bit variable array data type

Message ID 20220426230855.336292-3-atishp@rivosinc.com
State New
Headers show
Series Implement Sstc extension | expand

Commit Message

Atish Patra April 26, 2022, 11:08 p.m. UTC
unsigned 64bit variable array data type support is missing.
Add the required code to support it.

Signed-off-by: Atish Patra <atishp@rivosinc.com>
---
 include/migration/vmstate.h | 11 +++++++++++
 migration/vmstate.c         |  2 ++
 2 files changed, 13 insertions(+)

Comments

Richard Henderson April 27, 2022, 12:50 a.m. UTC | #1
On 4/26/22 16:08, Atish Patra wrote:
> +    .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
...
>       } else if (field->flags & VMS_VARRAY_UINT32) {
>           n_elems = *(uint32_t *)(opaque + field->num_offset);
> +    } else if (field->flags & VMS_VARRAY_UINT64) {
> +        n_elems = *(uint64_t *)(opaque + field->num_offset);

Offset type mismatch.  Since num_harts is uint32_t, I don't believe you need this patch at 
all.


r~
Atish Patra April 27, 2022, 2:36 a.m. UTC | #2
On Tue, Apr 26, 2022 at 5:50 PM Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> On 4/26/22 16:08, Atish Patra wrote:
> > +    .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
> ...
> >       } else if (field->flags & VMS_VARRAY_UINT32) {
> >           n_elems = *(uint32_t *)(opaque + field->num_offset);
> > +    } else if (field->flags & VMS_VARRAY_UINT64) {
> > +        n_elems = *(uint64_t *)(opaque + field->num_offset);
>
> Offset type mismatch.  Since num_harts is uint32_t, I don't believe you need this patch at
> all.
>

Ahh yes. You are right. I read the function description wrong and
assumed that VMSTATE_VARRAY_UINT32
creates an variable array of uint32_t elements only. Thanks for the
clarification.

>
> r~
diff mbox series

Patch

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index ad24aa193451..d289caea0143 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -147,6 +147,7 @@  enum VMStateFlags {
      * VMStateField.struct_version_id to tell which version of the
      * structure we are referencing to use. */
     VMS_VSTRUCT           = 0x8000,
+    VMS_VARRAY_UINT64     = 0x10000,
 };
 
 typedef enum {
@@ -428,6 +429,16 @@  extern const VMStateInfo vmstate_info_qlist;
     .offset     = vmstate_offset_pointer(_state, _field, _type),     \
 }
 
+#define VMSTATE_VARRAY_UINT64(_field, _state, _field_num, _version, _info, _type) {\
+    .name       = (stringify(_field)),                               \
+    .version_id = (_version),                                        \
+    .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
+    .info       = &(_info),                                          \
+    .size       = sizeof(_type),                                     \
+    .flags      = VMS_VARRAY_UINT64 | VMS_POINTER,                   \
+    .offset     = vmstate_offset_pointer(_state, _field, _type),     \
+}
+
 #define VMSTATE_VARRAY_UINT16_ALLOC(_field, _state, _field_num, _version, _info, _type) {\
     .name       = (stringify(_field)),                               \
     .version_id = (_version),                                        \
diff --git a/migration/vmstate.c b/migration/vmstate.c
index 36ae8b9e1918..3cd5e37ebe2d 100644
--- a/migration/vmstate.c
+++ b/migration/vmstate.c
@@ -35,6 +35,8 @@  static int vmstate_n_elems(void *opaque, const VMStateField *field)
         n_elems = *(int32_t *)(opaque + field->num_offset);
     } else if (field->flags & VMS_VARRAY_UINT32) {
         n_elems = *(uint32_t *)(opaque + field->num_offset);
+    } else if (field->flags & VMS_VARRAY_UINT64) {
+        n_elems = *(uint64_t *)(opaque + field->num_offset);
     } else if (field->flags & VMS_VARRAY_UINT16) {
         n_elems = *(uint16_t *)(opaque + field->num_offset);
     } else if (field->flags & VMS_VARRAY_UINT8) {