Commit 9633f180 authored by fuqiang wang's avatar fuqiang wang Committed by Sean Christopherson
Browse files

KVM: x86: Explicitly set new periodic hrtimer expiration in apic_timer_fn()



When restarting an hrtimer to emulate a the guest's APIC timer in periodic
mode, explicitly set the expiration using the target expiration computed
by advance_periodic_target_expiration() instead of adding the period to
the existing timer.  This will allow making adjustments to the expiration,
e.g. to deal with expirations far in the past, without having to implement
the same logic in both advance_periodic_target_expiration() and
apic_timer_fn().

Cc: stable@vger.kernel.org
Signed-off-by: default avatarfuqiang wang <fuqiang.wng@gmail.com>
[sean: split to separate patch, write changelog]
Link: https://patch.msgid.link/20251113205114.1647493-3-seanjc@google.com


Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
parent 0ea9494b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2972,7 +2972,7 @@ static enum hrtimer_restart apic_timer_fn(struct hrtimer *data)

	if (lapic_is_periodic(apic) && !WARN_ON_ONCE(!apic->lapic_timer.period)) {
		advance_periodic_target_expiration(apic);
		hrtimer_add_expires_ns(&ktimer->timer, ktimer->period);
		hrtimer_set_expires(&ktimer->timer, ktimer->target_expiration);
		return HRTIMER_RESTART;
	} else
		return HRTIMER_NORESTART;