]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
KVM: Move kvm_guest_exit() after local_irq_enable()
authorLaurent Vivier <Laurent.Vivier@bull.net>
Thu, 18 Oct 2007 13:19:01 +0000 (15:19 +0200)
committerAvi Kivity <avi@qumranet.com>
Mon, 22 Oct 2007 10:03:29 +0000 (12:03 +0200)
We need to make sure that the timer interrupt happens before we clear
PF_VCPU, so the accounting code actually sees guest mode.

http://lkml.org/lkml/2007/10/15/114

Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
Signed-off-by: Avi Kivity <avi@qumranet.com>
drivers/kvm/kvm_main.c

index af2d288c881d32500a5f753cb6453432ce3b6c15..8c458f26287253c3958c6101e21bfbca1f90894b 100644 (file)
@@ -2054,12 +2054,21 @@ again:
 
        kvm_x86_ops->run(vcpu, kvm_run);
 
-       kvm_guest_exit();
        vcpu->guest_mode = 0;
        local_irq_enable();
 
        ++vcpu->stat.exits;
 
+       /*
+        * We must have an instruction between local_irq_enable() and
+        * kvm_guest_exit(), so the timer interrupt isn't delayed by
+        * the interrupt shadow.  The stat.exits increment will do nicely.
+        * But we need to prevent reordering, hence this barrier():
+        */
+       barrier();
+
+       kvm_guest_exit();
+
        preempt_enable();
 
        /*