aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2009-08-30 15:52:09 +0300
committerAvi Kivity <avi@redhat.com>2009-08-30 15:52:09 +0300
commit9c1257ac640c0e0ddd39d578666f36cac6f04e69 (patch)
treec7196c1f339563687d762182b5d9b82ddae383b7 /qemu-kvm.c
parentMerge commit '09aaa1602f9381c0e0fb539390b1793e51bdfc7b' into upstream-merge (diff)
parentkvm: Simplify cpu_synchronize_state() (diff)
downloadqemu-kvm-9c1257ac640c0e0ddd39d578666f36cac6f04e69.tar.gz
qemu-kvm-9c1257ac640c0e0ddd39d578666f36cac6f04e69.tar.bz2
qemu-kvm-9c1257ac640c0e0ddd39d578666f36cac6f04e69.zip
Merge commit '4c0960c0c483fffc5f8e1dab169d946ac295bf44' into upstream-merge
* commit '4c0960c0c483fffc5f8e1dab169d946ac295bf44': kvm: Simplify cpu_synchronize_state() Conflicts: hw/apic.c target-i386/machine.c Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'qemu-kvm.c')
-rw-r--r--qemu-kvm.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/qemu-kvm.c b/qemu-kvm.c
index b59e40370..2d3ca7166 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -874,6 +874,15 @@ int kvm_set_mpstate(kvm_vcpu_context_t vcpu, struct kvm_mp_state *mp_state)
}
#endif
+void kvm_cpu_synchronize_state(CPUState *env)
+{
+ if (!env->kvm_cpu_state.regs_modified) {
+ kvm_arch_get_registers(env);
+ kvm_arch_save_mpstate(env);
+ env->kvm_cpu_state.regs_modified = 1;
+ }
+}
+
static int handle_mmio(kvm_vcpu_context_t vcpu)
{
unsigned long addr = vcpu->run->mmio.phys_addr;
@@ -947,6 +956,7 @@ int kvm_run(kvm_vcpu_context_t vcpu, void *env)
int fd = vcpu->fd;
struct kvm_run *run = vcpu->run;
kvm_context_t kvm = vcpu->kvm;
+ CPUState *_env = env;
again:
push_nmi(kvm);
@@ -954,6 +964,13 @@ int kvm_run(kvm_vcpu_context_t vcpu, void *env)
if (!kvm->irqchip_in_kernel)
run->request_interrupt_window = kvm_arch_try_push_interrupts(env);
#endif
+
+ if (_env->kvm_cpu_state.regs_modified) {
+ kvm_arch_put_registers(_env);
+ kvm_arch_load_mpstate(_env);
+ _env->kvm_cpu_state.regs_modified = 0;
+ }
+
r = pre_kvm_run(kvm, env);
if (r)
return r;