Commit 599275c0 authored by Paolo Bonzini's avatar Paolo Bonzini
Browse files

KVM: mips, x86: do not rely on KVM_REQ_UNHALT



KVM_REQ_UNHALT is a weird request that simply reports the value of
kvm_arch_vcpu_runnable() on exit from kvm_vcpu_halt().  Only
MIPS and x86 are looking at it, the others just clear it.  Check
the state of the vCPU directly so that the request is handled
as a nop on all architectures.

No functional change intended, except for corner cases where an
event arrive immediately after a signal become pending or after
another similar host-side event.

Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20220921003201.1441511-12-seanjc@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 26844fee
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -955,14 +955,13 @@ enum emulation_result kvm_mips_emul_wait(struct kvm_vcpu *vcpu)
		kvm_vcpu_halt(vcpu);

		/*
		 * We we are runnable, then definitely go off to user space to
		 * We are runnable, then definitely go off to user space to
		 * check if any I/O interrupts are pending.
		 */
		if (kvm_check_request(KVM_REQ_UNHALT, vcpu)) {
		kvm_clear_request(KVM_REQ_UNHALT, vcpu);
		if (kvm_arch_vcpu_runnable(vcpu))
			vcpu->run->exit_reason = KVM_EXIT_IRQ_WINDOW_OPEN;
	}
	}

	return EMULATE_DONE;
}
+8 −1
Original line number Diff line number Diff line
@@ -10813,7 +10813,14 @@ static inline int vcpu_block(struct kvm_vcpu *vcpu)
		if (hv_timer)
			kvm_lapic_switch_to_hv_timer(vcpu);

		if (!kvm_check_request(KVM_REQ_UNHALT, vcpu))
		kvm_clear_request(KVM_REQ_UNHALT, vcpu);

		/*
		 * If the vCPU is not runnable, a signal or another host event
		 * of some kind is pending; service it without changing the
		 * vCPU's activity state.
		 */
		if (!kvm_arch_vcpu_runnable(vcpu))
			return 1;
	}