From patchwork Wed Feb 3 08:53:37 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [v2,12/21] qemu-kvm: Use upstream kvm_vcpu_dirty Date: Tue, 02 Feb 2010 22:53:37 -0000 From: Jan Kiszka X-Patchwork-Id: 44369 Message-Id: <7590889135b816c090cbbf20b16bb2e81083e350.1265187223.git.jan.kiszka@siemens.com> To: Avi Kivity , Marcelo Tosatti Cc: Anthony Liguori , Glauber Costa , Alexander Graf , kvm@vger.kernel.org, qemu-devel@nongnu.org Drop regs_modified in favor of upstream's equivalent and clean up kvm_cpu_synchronize_state at this chance. Signed-off-by: Jan Kiszka --- cpu-defs.h | 1 - hw/pc.c | 2 +- qemu-kvm.c | 18 +++++++++--------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/cpu-defs.h b/cpu-defs.h index 49a9e8d..c57d8df 100644 --- a/cpu-defs.h +++ b/cpu-defs.h @@ -142,7 +142,6 @@ struct KVMCPUState { pthread_t thread; int signalled; struct qemu_work_item *queued_work_first, *queued_work_last; - int regs_modified; }; #define CPU_TEMP_BUF_NLONGS 128 diff --git a/hw/pc.c b/hw/pc.c index 7a7dfa7..af6ea8b 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -744,7 +744,7 @@ CPUState *pc_new_cpu(const char *cpu_model) fprintf(stderr, "Unable to find x86 CPU definition\n"); exit(1); } - env->kvm_cpu_state.regs_modified = 1; + env->kvm_vcpu_dirty = 1; if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) { env->cpuid_apic_id = env->cpu_index; /* APIC reset callback resets cpu */ diff --git a/qemu-kvm.c b/qemu-kvm.c index 0094db9..6a72b89 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -861,9 +861,9 @@ int pre_kvm_run(kvm_context_t kvm, CPUState *env) { kvm_arch_pre_run(env, env->kvm_run); - if (env->kvm_cpu_state.regs_modified) { + if (env->kvm_vcpu_dirty) { kvm_arch_load_regs(env); - env->kvm_cpu_state.regs_modified = 0; + env->kvm_vcpu_dirty = 0; } pthread_mutex_unlock(&qemu_mutex); @@ -1530,16 +1530,16 @@ static void on_vcpu(CPUState *env, void (*func)(void *data), void *data) static void do_kvm_cpu_synchronize_state(void *_env) { CPUState *env = _env; - if (!env->kvm_cpu_state.regs_modified) { - kvm_arch_save_regs(env); - env->kvm_cpu_state.regs_modified = 1; - } + + kvm_arch_save_regs(env); } void kvm_cpu_synchronize_state(CPUState *env) { - if (!env->kvm_cpu_state.regs_modified) + if (!env->kvm_vcpu_dirty) { on_vcpu(env, do_kvm_cpu_synchronize_state, env); + env->kvm_vcpu_dirty = 1; + } } static void inject_interrupt(void *data) @@ -2329,9 +2329,9 @@ static void kvm_invoke_set_guest_debug(void *data) { struct kvm_set_guest_debug_data *dbg_data = data; - if (cpu_single_env->kvm_cpu_state.regs_modified) { + if (cpu_single_env->kvm_vcpu_dirty) { kvm_arch_save_regs(cpu_single_env); - cpu_single_env->kvm_cpu_state.regs_modified = 0; + cpu_single_env->kvm_vcpu_dirty = 0; } dbg_data->err = kvm_set_guest_debug(cpu_single_env,