Skip to contentSkip to conversation

KVM: Simplify vcpu_enter_guest() mmu reload logic slightly

PATCH Applied Avi Kivity 2 participants 2 messages Jun 23, 2010 – Jun 28, 2010

Subsystems (3)
lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

PATCH 1/1 KVM: Simplify vcpu_enter_guest() mmu reload logic slightly

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.

---
 arch/x86/kvm/x86.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)
arch/x86/kvm/x86.c +5 -7
index d0b9252..ae2e282 100644
@@ -4606,15 +4606,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))
@@ -4639,6 +4633,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);
Signature · 1 line
1.7.1
#1 lore raw
Quoted 9 lines · Avi Kivity

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.

---
 arch/x86/kvm/x86.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

Applied, thanks.