qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 12/12] target/riscv: Support virtual time context synchron


From: Richard Henderson
Subject: Re: [PATCH v2 12/12] target/riscv: Support virtual time context synchronization
Date: Mon, 13 Dec 2021 07:21:48 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0

On 12/10/21 2:07 AM, Yifei Jiang via wrote:
+static bool kvmtimer_needed(void *opaque)
+{
+    return kvm_enabled();
+}
+
+
+static const VMStateDescription vmstate_kvmtimer = {
+    .name = "cpu/kvmtimer",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = kvmtimer_needed,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT64(env.kvm_timer_time, RISCVCPU),
+        VMSTATE_UINT64(env.kvm_timer_compare, RISCVCPU),
+        VMSTATE_UINT64(env.kvm_timer_state, RISCVCPU),
+
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+static int cpu_post_load(void *opaque, int version_id)
+{
+    RISCVCPU *cpu = opaque;
+    CPURISCVState *env = &cpu->env;
+
+    if (kvm_enabled()) {
+        env->kvm_timer_dirty = true;
+    }
+    return 0;
+}

This post-load belongs on the vmstate_kvmtimer struct, so that you need not re-check kvm_enabled().

  const VMStateDescription vmstate_riscv_cpu = {
      .name = "cpu",
-    .version_id = 3,
-    .minimum_version_id = 3,
+    .version_id = 4,
+    .minimum_version_id = 4,
+    .post_load = cpu_post_load,

No need for version change.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]