Skip to content

Commit 7b0151c

Browse files
committed
KVM: x86: Remove WARN sanity check on hypervisor timer vs. UNINITIALIZED vCPU
Drop the WARN in KVM_RUN that asserts that KVM isn't using the hypervisor timer, a.k.a. the VMX preemption timer, for a vCPU that is in the UNINITIALIZIED activity state. The intent of the WARN is to sanity check that KVM won't drop a timer interrupt due to an unexpected transition to UNINITIALIZED, but unfortunately userspace can use various ioctl()s to force the unexpected state. Drop the sanity check instead of switching from the hypervisor timer to a software based timer, as the only reason to switch to a software timer when a vCPU is blocking is to ensure the timer interrupt wakes the vCPU, but said interrupt isn't a valid wake event for vCPUs in UNINITIALIZED state *and* the interrupt will be dropped in the end. Reported-by: Yikebaer Aizezi <[email protected]> Closes: https://lore.kernel.org/all/CALcu4rbFrU4go8sBHk3FreP+qjgtZCGcYNpSiEXOLm==qFv7iQ@mail.gmail.com Reviewed-by: Paolo Bonzini <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 765da7f commit 7b0151c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

arch/x86/kvm/x86.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11084,12 +11084,17 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
1108411084
r = -EINTR;
1108511085
goto out;
1108611086
}
11087+
1108711088
/*
11088-
* It should be impossible for the hypervisor timer to be in
11089-
* use before KVM has ever run the vCPU.
11089+
* Don't bother switching APIC timer emulation from the
11090+
* hypervisor timer to the software timer, the only way for the
11091+
* APIC timer to be active is if userspace stuffed vCPU state,
11092+
* i.e. put the vCPU into a nonsensical state. Only an INIT
11093+
* will transition the vCPU out of UNINITIALIZED (without more
11094+
* state stuffing from userspace), which will reset the local
11095+
* APIC and thus cancel the timer or drop the IRQ (if the timer
11096+
* already expired).
1109011097
*/
11091-
WARN_ON_ONCE(kvm_lapic_hv_timer_in_use(vcpu));
11092-
1109311098
kvm_vcpu_srcu_read_unlock(vcpu);
1109411099
kvm_vcpu_block(vcpu);
1109511100
kvm_vcpu_srcu_read_lock(vcpu);

0 commit comments

Comments
 (0)