public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 6.1.y] KVM: x86: fire timer when it is migrated and expired, and in oneshot mode
@ 2024-08-20  5:32 David Hunter
  2024-08-20  6:18 ` 答复: [外部邮件] " Li,Rongqing
  0 siblings, 1 reply; 8+ messages in thread
From: David Hunter @ 2024-08-20  5:32 UTC (permalink / raw)
  To: stable
  Cc: seanjc, pbonzini, dave.hansen, x86, hpa, kvm, linux-kernel,
	javier.carrasco.cruz, shuah, David Hunter, Peter Shier,
	Jim Mattson, Wanpeng Li, Li RongQing

From: Li RongQing <lirongqing@baidu.com>

[ Upstream Commit 8e6ed96cdd5001c55fccc80a17f651741c1ca7d2]

when the vCPU was migrated, if its timer is expired, KVM _should_ fire
the timer ASAP, zeroing the deadline here will cause the timer to
immediately fire on the destination

Cc: Sean Christopherson <seanjc@google.com>
Cc: Peter Shier <pshier@google.com>
Cc: Jim Mattson <jmattson@google.com>
Cc: Wanpeng Li <wanpengli@tencent.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Link: https://lore.kernel.org/r/20230106040625.8404-1-lirongqing@baidu.com
Signed-off-by: Sean Christopherson <seanjc@google.com>

(cherry picked from commit 8e6ed96cdd5001c55fccc80a17f651741c1ca7d2)
The code was able to compile without errors or warnings. 
Signed-off-by: David Hunter <david.hunter.linux@gmail.com>
---
 arch/x86/kvm/lapic.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index c90fef0258c5..3cd590ace95a 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -1843,8 +1843,12 @@ static bool set_target_expiration(struct kvm_lapic *apic, u32 count_reg)
 		if (unlikely(count_reg != APIC_TMICT)) {
 			deadline = tmict_to_ns(apic,
 				     kvm_lapic_get_reg(apic, count_reg));
-			if (unlikely(deadline <= 0))
-				deadline = apic->lapic_timer.period;
+			if (unlikely(deadline <= 0)) {
+				if (apic_lvtt_period(apic))
+					deadline = apic->lapic_timer.period;
+				else
+					deadline = 0;
+			}
 			else if (unlikely(deadline > apic->lapic_timer.period)) {
 				pr_info_ratelimited(
 				    "kvm: vcpu %i: requested lapic timer restore with "
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-08-27 18:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-20  5:32 [PATCH 6.1.y] KVM: x86: fire timer when it is migrated and expired, and in oneshot mode David Hunter
2024-08-20  6:18 ` 答复: [外部邮件] " Li,Rongqing
2024-08-20 14:07   ` Sean Christopherson
2024-08-26 22:13     ` [PATCH 6.1.y 0/2 V2] KVM: x86: fire timer when it is migrated David Hunter
2024-08-26 22:13       ` [PATCH 6.1.y 1/2 V2] KVM: x86: fire timer when it is migrated and expired, and in oneshot mode David Hunter
2024-08-26 22:13       ` [PATCH 6.1.y 2/2 V2] KVM: x86: Fix lapic timer interrupt lost after loading a snapshot David Hunter
2024-08-27 13:10         ` Greg KH
2024-08-27 18:52           ` Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox