summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorfuqiang wang <fuqiang.wng@gmail.com>2025-11-13 12:51:12 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-01-02 12:57:20 +0100
commita16ccbffb144f2b91084375bd77a1b1aab01d28e (patch)
tree9fe1f75dba921ac784ebdc92d9ad5e36b5c111db /arch
parent16fa73b11a9472444f855b386e478d6ebfb2348a (diff)
downloadlinux-a16ccbffb144f2b91084375bd77a1b1aab01d28e.tar.gz
linux-a16ccbffb144f2b91084375bd77a1b1aab01d28e.tar.bz2
linux-a16ccbffb144f2b91084375bd77a1b1aab01d28e.zip
KVM: x86: Explicitly set new periodic hrtimer expiration in apic_timer_fn()
commit 9633f180ce994ab293ce4924a9b7aaf4673aa114 upstream. 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: fuqiang 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: Sean Christopherson <seanjc@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kvm/lapic.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 78b74ba17592..a5c927e7bae6 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -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;