From 4c0960c0c483fffc5f8e1dab169d946ac295bf44 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Mon, 17 Aug 2009 23:19:53 +0300 Subject: kvm: Simplify cpu_synchronize_state() cpu_synchronize_state() is a little unreadable since the 'modified' argument isn't self-explanatory. Simplify it by making it always synchronize the kernel state into qemu, and automatically flush the registers back to the kernel if they've been synchronized on this exit. Signed-off-by: Avi Kivity Signed-off-by: Anthony Liguori --- kvm-all.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'kvm-all.c') diff --git a/kvm-all.c b/kvm-all.c index f669c3ac0f..15c30d41be 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -57,6 +57,7 @@ struct KVMState KVMSlot slots[32]; int fd; int vmfd; + int regs_modified; int coalesced_mmio; int broken_set_mem_region; int migration_log; @@ -576,6 +577,14 @@ static void kvm_run_coalesced_mmio(CPUState *env, struct kvm_run *run) #endif } +void kvm_cpu_synchronize_state(CPUState *env) +{ + if (!env->kvm_state->regs_modified) { + kvm_arch_get_registers(env); + env->kvm_state->regs_modified = 1; + } +} + int kvm_cpu_exec(CPUState *env) { struct kvm_run *run = env->kvm_run; @@ -590,6 +599,11 @@ int kvm_cpu_exec(CPUState *env) break; } + if (env->kvm_state->regs_modified) { + kvm_arch_put_registers(env); + env->kvm_state->regs_modified = 0; + } + kvm_arch_pre_run(env, run); ret = kvm_vcpu_ioctl(env, KVM_RUN, 0); kvm_arch_post_run(env, run); -- cgit v1.2.3