Skip to content

Commit 599275c

Browse files
committed
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: Paolo Bonzini <[email protected]> Signed-off-by: Sean Christopherson <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 26844fe commit 599275c

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

arch/mips/kvm/emulate.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -955,13 +955,12 @@ enum emulation_result kvm_mips_emul_wait(struct kvm_vcpu *vcpu)
955955
kvm_vcpu_halt(vcpu);
956956

957957
/*
958-
* We we are runnable, then definitely go off to user space to
958+
* We are runnable, then definitely go off to user space to
959959
* check if any I/O interrupts are pending.
960960
*/
961-
if (kvm_check_request(KVM_REQ_UNHALT, vcpu)) {
962-
kvm_clear_request(KVM_REQ_UNHALT, vcpu);
961+
kvm_clear_request(KVM_REQ_UNHALT, vcpu);
962+
if (kvm_arch_vcpu_runnable(vcpu))
963963
vcpu->run->exit_reason = KVM_EXIT_IRQ_WINDOW_OPEN;
964-
}
965964
}
966965

967966
return EMULATE_DONE;

arch/x86/kvm/x86.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10813,7 +10813,14 @@ static inline int vcpu_block(struct kvm_vcpu *vcpu)
1081310813
if (hv_timer)
1081410814
kvm_lapic_switch_to_hv_timer(vcpu);
1081510815

10816-
if (!kvm_check_request(KVM_REQ_UNHALT, vcpu))
10816+
kvm_clear_request(KVM_REQ_UNHALT, vcpu);
10817+
10818+
/*
10819+
* If the vCPU is not runnable, a signal or another host event
10820+
* of some kind is pending; service it without changing the
10821+
* vCPU's activity state.
10822+
*/
10823+
if (!kvm_arch_vcpu_runnable(vcpu))
1081710824
return 1;
1081810825
}
1081910826

0 commit comments

Comments
 (0)