Skip to contentSkip to conversation

KVM: VMX: fix halt emulation while emulating invalid guest sate

PATCH In review Gleb Natapov 2 participants 2 messages May 8, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: VMX: fix halt emulation while emulating invalid guest sate

The invalid guest state emulation loop does not check halt_request which causes 100% cpu loop while guest is in halt and in invalid state, but more serious issue is that this leaves halt_request set, so random instruction emulated by vm86 #GP exit can be interpreted as halt which causes guest hang. Fix both problems by handling halt_request in emulation loop.

arch/x86/kvm/vmx.c +6 -0
index 5a87a58..a9fa4bc 100644
@@ -5312,6 +5312,12 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu)
 			return 0;
 		}
 
+		if (vcpu->arch.halt_request) {
+			vcpu->arch.halt_request = 0;
+			ret = kvm_emulate_halt(vcpu);
+			goto out;
+		}
+
 		if (signal_pending(current))
 			goto out;
 		if (need_resched())

--
Gleb.

maintainer Reviewed-by on v1 1/1
#1 lore raw

----- Messaggio originale -----

Quoted 34 lines

Da: "Gleb Natapov" <[email protected]>
A: [email protected]
Cc: [email protected], [email protected]
Inviato: Mercoledì, 8 maggio 2013 17:38:44
Oggetto: [PATCH] KVM: VMX: fix halt emulation while emulating invalid guest sate

The invalid guest state emulation loop does not check halt_request which causes 100% cpu loop while guest is in halt and in invalid state, but more serious issue is that this leaves halt_request set, so random instruction emulated by vm86 #GP exit can be interpreted as halt which causes guest hang. Fix both problems by handling halt_request in emulation loop.

arch/x86/kvm/vmx.c +6 -0
index 5a87a58..a9fa4bc 100644
@@ -5312,6 +5312,12 @@ static int handle_invalid_guest_state(struct kvm_vcpu
 *vcpu)
 			return 0;
 		}
 
+		if (vcpu->arch.halt_request) {
+			vcpu->arch.halt_request = 0;
+			ret = kvm_emulate_halt(vcpu);
+			goto out;
+		}
+
 		if (signal_pending(current))
 			goto out;
Quoted 4 lines

if (need_resched())
--
Gleb.