Skip to content

Commit 0ea9494

Browse files
committed
KVM: x86: WARN if hrtimer callback for periodic APIC timer fires with period=0
WARN and don't restart the hrtimer if KVM's callback runs with the guest's APIC timer in periodic mode but with a period of '0', as not advancing the hrtimer's deadline would put the CPU into an infinite loop of hrtimer events. Observing a period of '0' should be impossible, even when the hrtimer is running on a different CPU than the vCPU, as KVM is supposed to cancel the hrtimer before changing (or zeroing) the period, e.g. when switching from periodic to one-shot. Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20251113205114.1647493-2-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent b3e5b67 commit 0ea9494

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/kvm/lapic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2970,7 +2970,7 @@ static enum hrtimer_restart apic_timer_fn(struct hrtimer *data)
29702970

29712971
apic_timer_expired(apic, true);
29722972

2973-
if (lapic_is_periodic(apic)) {
2973+
if (lapic_is_periodic(apic) && !WARN_ON_ONCE(!apic->lapic_timer.period)) {
29742974
advance_periodic_target_expiration(apic);
29752975
hrtimer_add_expires_ns(&ktimer->timer, ktimer->period);
29762976
return HRTIMER_RESTART;

0 commit comments

Comments
 (0)