[PATCH 3/4] qemu-kvm: Process async MCE events in main loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This aligns qemu-kvm with upstream commit ab443475c9. Namely, we were
missing a call to an equivalent of kvm_arch_process_async_events from
the main loop. This adds a stripped down version of upstream's
process_async_events until we switch over.

Signed-off-by: Jan Kiszka <jan.kiszka@xxxxxxxxxxx>
---
 kvm.h          |    2 --
 qemu-kvm-x86.c |   27 +++++++++++++++++++++++++++
 qemu-kvm.c     |    9 ++++++---
 3 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/kvm.h b/kvm.h
index 90c4e48..bda6ad7 100644
--- a/kvm.h
+++ b/kvm.h
@@ -110,9 +110,7 @@ void kvm_arch_post_run(CPUState *env, struct kvm_run *run);
 
 int kvm_arch_handle_exit(CPUState *env, struct kvm_run *run);
 
-#ifdef OBSOLETE_KVM_IMPL
 int kvm_arch_process_async_events(CPUState *env);
-#endif
 
 int kvm_arch_get_registers(CPUState *env);
 
diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index 20093fc..96d2fa6 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -811,3 +811,30 @@ void kvm_arch_process_irqchip_events(CPUState *env)
         do_cpu_sipi(env);
     }
 }
+
+int kvm_arch_process_async_events(CPUState *env)
+{
+    if (env->interrupt_request & CPU_INTERRUPT_MCE) {
+        /* We must not raise CPU_INTERRUPT_MCE if it's not supported. */
+        assert(env->mcg_cap);
+
+        env->interrupt_request &= ~CPU_INTERRUPT_MCE;
+
+        kvm_cpu_synchronize_state(env);
+
+        if (env->exception_injected == EXCP08_DBLE) {
+            /* this means triple fault */
+            qemu_system_reset_request();
+            env->exit_request = 1;
+            return 0;
+        }
+        env->exception_injected = EXCP12_MCHK;
+        env->has_error_code = 0;
+
+        env->halted = 0;
+        if (kvm_irqchip_in_kernel() && env->mp_state == KVM_MP_STATE_HALTED) {
+            env->mp_state = KVM_MP_STATE_RUNNABLE;
+        }
+    }
+    return 0;
+}
diff --git a/qemu-kvm.c b/qemu-kvm.c
index 8781cde..d7d50f5 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -1414,9 +1414,12 @@ static int kvm_main_loop_cpu(CPUState *env)
 {
     while (1) {
         int run_cpu = !kvm_cpu_is_stopped(env);
-        if (run_cpu && !kvm_irqchip_in_kernel()) {
-            process_irqchip_events(env);
-            run_cpu = !env->halted;
+        if (run_cpu) {
+            kvm_arch_process_async_events(env);
+            if (!kvm_irqchip_in_kernel()) {
+                process_irqchip_events(env);
+                run_cpu = !env->halted;
+            }
         }
         if (run_cpu) {
             kvm_cpu_exec(env);
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux