Patchwork [3/7] KVM regsync: Add register level parameter to do_kvm_cpu_synchronize_state

login
register
mail settings
Submitter Jason J. Herne
Date Dec. 21, 2012, 1:56 p.m.
Message ID <1356098161-4848-1-git-send-email-jjherne@us.ibm.com>
Download mbox | patch
Permalink /patch/207814/
State New
Headers show

Comments

Jason J. Herne - Dec. 21, 2012, 1:56 p.m.
From: "Jason J. Herne" <jjherne@us.ibm.com>

do_kvm_cpu_synchronize_state is called via run_on_cpu, so we can only pass
a single argument.  Create SyncStateArgs struct for this purpose and add
register level data member to it.

Signed-off-by: Jason J. Herne <jjherne@us.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 include/sysemu/kvm.h |    6 ++++++
 kvm-all.c            |   16 ++++++++++------
 2 files changed, 16 insertions(+), 6 deletions(-)

Patch

diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index c19b9d1..9a0e071 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -230,6 +230,12 @@  int kvm_check_extension(KVMState *s, unsigned int extension);
 
 uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function,
                                       uint32_t index, int reg);
+
+struct kvm_cpu_syncstate_args {
+    CPUArchState *env;
+    int register_level;
+};
+
 void kvm_cpu_synchronize_state(CPUArchState *env);
 void kvm_cpu_synchronize_post_reset(CPUArchState *env);
 void kvm_cpu_synchronize_post_init(CPUArchState *env);
diff --git a/kvm-all.c b/kvm-all.c
index fceda59..d227e8b 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1486,22 +1486,26 @@  void kvm_flush_coalesced_mmio_buffer(void)
     s->coalesced_flush_in_progress = false;
 }
 
-static void do_kvm_cpu_synchronize_state(void *_env)
+static void do_kvm_cpu_synchronize_state(void *_args)
 {
-    CPUArchState *env = _env;
+    struct kvm_cpu_syncstate_args *args = _args;
 
-    if (!env->kvm_vcpu_dirty) {
-        kvm_arch_get_registers(env, KVM_REGSYNC_FULL_STATE);
-        env->kvm_vcpu_dirty = 1;
+    if (!args->env->kvm_vcpu_dirty) {
+        kvm_arch_get_registers(args->env, args->register_level);
+        args->env->kvm_vcpu_dirty = 1;
     }
 }
 
 void kvm_cpu_synchronize_state(CPUArchState *env)
 {
     CPUState *cpu = ENV_GET_CPU(env);
+    struct kvm_cpu_syncstate_args args;
+
+    args.env = env;
+    args.register_level = KVM_REGSYNC_FULL_STATE;
 
     if (!env->kvm_vcpu_dirty) {
-        run_on_cpu(cpu, do_kvm_cpu_synchronize_state, env);
+        run_on_cpu(cpu, do_kvm_cpu_synchronize_state, &args);
     }
 }