KVM: Simplify vcpu_enter_guest() mmu reload logic slightly
authorAvi Kivity <avi@redhat.com>
Wed, 23 Jun 2010 11:26:18 +0000 (14:26 +0300)
committerAvi Kivity <avi@redhat.com>
Sun, 1 Aug 2010 07:47:19 +0000 (10:47 +0300)
No need to reload the mmu in between two different vcpu->requests checks.

kvm_mmu_reload() may trigger KVM_REQ_TRIPLE_FAULT, but that will be caught
during atomic guest entry later.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/x86/kvm/x86.c

index d39d6b25d3e5e6db3f7f5d38fc835e149d851dc6..27322d3412325695ef80856d5414b62f328fc964 100644 (file)
@@ -4616,15 +4616,9 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
        bool req_int_win = !irqchip_in_kernel(vcpu->kvm) &&
                vcpu->run->request_interrupt_window;
 
-       if (vcpu->requests)
+       if (vcpu->requests) {
                if (kvm_check_request(KVM_REQ_MMU_RELOAD, vcpu))
                        kvm_mmu_unload(vcpu);
-
-       r = kvm_mmu_reload(vcpu);
-       if (unlikely(r))
-               goto out;
-
-       if (vcpu->requests) {
                if (kvm_check_request(KVM_REQ_MIGRATE_TIMER, vcpu))
                        __kvm_migrate_timers(vcpu);
                if (kvm_check_request(KVM_REQ_KVMCLOCK_UPDATE, vcpu))
@@ -4649,6 +4643,10 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
                }
        }
 
+       r = kvm_mmu_reload(vcpu);
+       if (unlikely(r))
+               goto out;
+
        preempt_disable();
 
        kvm_x86_ops->prepare_guest_switch(vcpu);