[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kvm-commits
Subject:    [COMMIT master] Fix mpstate reloads
From:       Avi Kivity <avi () redhat ! com>
Date:       2009-08-31 11:10:11
Message-ID: 20090831111011.4CBC525004D () cleopatra ! tlv ! redhat ! com
[Download RAW message or body]

From: Avi Kivity <avi@redhat.com>

Signed-off-by: Avi Kivity <avi@redhat.com>

diff --git a/hw/apic.c b/hw/apic.c
index 18db3be..68e5de3 100644
--- a/hw/apic.c
+++ b/hw/apic.c
@@ -488,6 +488,7 @@ void apic_init_reset(CPUState *env)
     if (!s)
         return;
 
+    cpu_synchronize_state(env);
     s->tpr = 0;
     s->spurious_vec = 0xff;
     s->log_dest = 0;
@@ -507,6 +508,10 @@ void apic_init_reset(CPUState *env)
     s->wait_for_sipi = 1;
 
     env->halted = !(s->apicbase & MSR_IA32_APICBASE_BSP);
+#ifdef KVM_CAP_MP_STATE
+    env->mp_state
+        = env->halted ? KVM_MP_STATE_INIT_RECEIVED : KVM_MP_STATE_RUNNABLE;
+#endif
 }
 
 static void apic_startup(APICState *s, int vector_num)
diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index 64398fb..f80d82b 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -1035,6 +1035,8 @@ void kvm_arch_save_mpstate(CPUState *env)
         env->mp_state = -1;
     else
         env->mp_state = mp_state.mp_state;
+#else
+    env->mp_state = -1;
 #endif
 }
 
diff --git a/qemu-kvm.c b/qemu-kvm.c
index 2d3ca71..d554749 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -878,7 +878,6 @@ 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;
     }
 }
@@ -966,8 +965,8 @@ int kvm_run(kvm_vcpu_context_t vcpu, void *env)
 #endif
 
     if (_env->kvm_cpu_state.regs_modified) {
+        printf("%s: cpu %d mp_state %d\n", __func__, _env->cpu_index, _env->mp_state);
         kvm_arch_put_registers(_env);
-        kvm_arch_load_mpstate(_env);
         _env->kvm_cpu_state.regs_modified = 0;
     }
 
@@ -1609,7 +1608,6 @@ static void kvm_do_save_mpstate(void *_env)
     CPUState *env = _env;
 
     kvm_arch_save_mpstate(env);
-    env->halted = (env->mp_state == KVM_MP_STATE_HALTED);
 }
 
 void kvm_save_mpstate(CPUState *env)
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index cfa5b80..1566eac 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -689,10 +689,6 @@ int kvm_arch_put_registers(CPUState *env)
     if (ret < 0)
         return ret;
 
-    ret = kvm_get_mp_state(env);
-    if (ret < 0)
-        return ret;
-
     return 0;
 }
 
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic