Skip to content

Commit

Permalink
KVM: VMX: Limit iterations with emulator_invalid_guest_state
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
avikivity committed Jul 9, 2012
1 parent f0495f9 commit b8405c1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion arch/x86/kvm/vmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b8405c1

Please sign in to comment.