qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Jason J. Herne" <jjherne@us.ibm.com>
To: agraf@suse.de, borntraeger@de.ibm.com, aliguori@us.ibm.com,
	mtosatti@redhat.com, qemu-devel@nongnu.org, R65777@freescale.com,
	jan.kiszka@siemens.com
Cc: "Jason J. Herne" <jjherne@us.ibm.com>
Subject: [Qemu-devel] [PATCH 4/7 v2] KVM regsync: Add register bitmap parameter to do_kvm_cpu_synchronize_state
Date: Thu, 10 Jan 2013 10:29:04 -0500	[thread overview]
Message-ID: <1357831744-3950-1-git-send-email-jjherne@us.ibm.com> (raw)

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 bitmap 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            |   27 +++++++++++++++++----------
 2 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index e0738ba..193d1f4 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -223,6 +223,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 {
+    CPUState *cpu;
+    int regmap;
+};
+
 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 1aa61bb..77ab72a 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -231,7 +231,7 @@ int kvm_init_vcpu(CPUArchState *env)
 
     cpu->kvm_fd = ret;
     cpu->kvm_state = s;
-    cpu->kvm_vcpu_dirty = true;
+    cpu->kvm_vcpu_dirty = KVM_REGSYNC_FULL_STATE;
 
     mmap_size = kvm_ioctl(s, KVM_GET_VCPU_MMAP_SIZE, 0);
     if (mmap_size < 0) {
@@ -1491,20 +1491,27 @@ void kvm_flush_coalesced_mmio_buffer(void)
 
 static void do_kvm_cpu_synchronize_state(void *arg)
 {
-    CPUState *cpu = arg;
+    struct kvm_cpu_syncstate_args *args = arg;
 
-    if (!cpu->kvm_vcpu_dirty) {
-        kvm_arch_get_registers(cpu, KVM_REGSYNC_FULL_STATE);
-        cpu->kvm_vcpu_dirty = true;
+    /* Do not sync regs that are already dirty */
+    int regs_to_get = args->regmap & ~args->cpu->kvm_vcpu_dirty;
+
+    if (regs_to_get) {
+        kvm_arch_get_registers(args->cpu, regs_to_get);
+        args->cpu->kvm_vcpu_dirty |= regs_to_get;
     }
 }
 
 void kvm_cpu_synchronize_state(CPUArchState *env)
 {
     CPUState *cpu = ENV_GET_CPU(env);
+    struct kvm_cpu_syncstate_args args;
+
+    args.cpu = cpu;
+    args.regmap = KVM_REGSYNC_FULL_STATE;
 
-    if (!cpu->kvm_vcpu_dirty) {
-        run_on_cpu(cpu, do_kvm_cpu_synchronize_state, cpu);
+    if (args.regmap & ~cpu->kvm_vcpu_dirty) {
+        run_on_cpu(cpu, do_kvm_cpu_synchronize_state, &args);
     }
 }
 
@@ -1513,7 +1520,7 @@ void kvm_cpu_synchronize_post_reset(CPUArchState *env)
     CPUState *cpu = ENV_GET_CPU(env);
 
     kvm_arch_put_registers(cpu, KVM_REGSYNC_RESET_STATE);
-    cpu->kvm_vcpu_dirty = false;
+    cpu->kvm_vcpu_dirty &= ~KVM_REGSYNC_RESET_STATE;
 }
 
 void kvm_cpu_synchronize_post_init(CPUArchState *env)
@@ -1521,7 +1528,7 @@ void kvm_cpu_synchronize_post_init(CPUArchState *env)
     CPUState *cpu = ENV_GET_CPU(env);
 
     kvm_arch_put_registers(cpu, KVM_REGSYNC_FULL_STATE);
-    cpu->kvm_vcpu_dirty = false;
+    cpu->kvm_vcpu_dirty &= ~KVM_REGSYNC_FULL_STATE;
 }
 
 int kvm_cpu_exec(CPUArchState *env)
@@ -1540,7 +1547,7 @@ int kvm_cpu_exec(CPUArchState *env)
     do {
         if (cpu->kvm_vcpu_dirty) {
             kvm_arch_put_registers(cpu, KVM_REGSYNC_RUNTIME_STATE);
-            cpu->kvm_vcpu_dirty = false;
+            cpu->kvm_vcpu_dirty &= ~KVM_REGSYNC_RUNTIME_STATE;
         }
 
         kvm_arch_pre_run(cpu, run);
-- 
1.7.9.5

             reply	other threads:[~2013-01-10 15:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-10 15:29 Jason J. Herne [this message]
2013-01-12 11:08 ` [Qemu-devel] [PATCH 4/7 v2] KVM regsync: Add register bitmap parameter to do_kvm_cpu_synchronize_state Blue Swirl
2013-01-14 11:32 ` Bhushan Bharat-R65777
2013-01-16 16:05 ` Marcelo Tosatti
2013-01-16 16:12   ` Marcelo Tosatti
2013-01-16 17:00   ` Bhushan Bharat-R65777
2013-01-16 17:23     ` Marcelo Tosatti
2013-01-16 20:09     ` Marcelo Tosatti
2013-01-16 20:03   ` Christian Borntraeger
2013-01-16 20:21     ` Marcelo Tosatti
2013-01-16 20:41       ` Christian Borntraeger
2013-01-16 23:01         ` Marcelo Tosatti
     [not found]           ` <9F9185C2-DDA5-4242-9BF2-664F4E0329F9@suse.de>
2013-02-01 15:47             ` Jason J. Herne

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=1357831744-3950-1-git-send-email-jjherne@us.ibm.com \
    --to=jjherne@us.ibm.com \
    --cc=R65777@freescale.com \
    --cc=agraf@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=jan.kiszka@siemens.com \
    --cc=mtosatti@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).