KVM: VMX: Limit iterations with emulator_invalid_guest_state
authorAvi Kivity <avi@redhat.com>
Thu, 7 Jun 2012 14:08:48 +0000 (17:08 +0300)
committerAvi Kivity <avi@redhat.com>
Mon, 9 Jul 2012 11:19:01 +0000 (14:19 +0300)
Otherwise, if the guest ends up looping, we never exit the srcu critical
section, which causes synchronize_srcu() to hang.

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

index 82ab1fb..debac49 100644 (file)
@@ -4977,11 +4977,12 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu)
        int ret = 1;
        u32 cpu_exec_ctrl;
        bool intr_window_requested;
+       unsigned count = 130;
 
        cpu_exec_ctrl = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL);
        intr_window_requested = cpu_exec_ctrl & CPU_BASED_VIRTUAL_INTR_PENDING;
 
-       while (!guest_state_valid(vcpu)) {
+       while (!guest_state_valid(vcpu) && count-- != 0) {
                if (intr_window_requested
                    && (kvm_get_rflags(&vmx->vcpu) & X86_EFLAGS_IF))
                        return handle_interrupt_window(&vmx->vcpu);