All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Hunter <david.hunter.linux@gmail.com>
To: seanjc@google.com
Cc: dave.hansen@linux.intel.com, david.hunter.linux@gmail.com,
	hpa@zytor.com, javier.carrasco.cruz@gmail.com,
	jmattson@google.com, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org, lirongqing@baidu.com,
	pbonzini@redhat.com, pshier@google.com, shuah@kernel.org,
	stable@vger.kernel.org, x86@kernel.org,
	Wanpeng Li <wanpengli@tencent.com>
Subject: [PATCH 6.1.y 1/2 V2] KVM: x86: fire timer when it is migrated and expired, and in oneshot mode
Date: Mon, 26 Aug 2024 18:13:35 -0400	[thread overview]
Message-ID: <20240826221336.14023-2-david.hunter.linux@gmail.com> (raw)
In-Reply-To: <20240826221336.14023-1-david.hunter.linux@gmail.com>

[Upstream Commit 8e6ed96cdd5001c55fccc80a17f651741c1ca7d2
From: Li RongQing <lirongqing@baidu.com>

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]
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


  reply	other threads:[~2024-08-26 22:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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       ` David Hunter [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240826221336.14023-2-david.hunter.linux@gmail.com \
    --to=david.hunter.linux@gmail.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lirongqing@baidu.com \
    --cc=pbonzini@redhat.com \
    --cc=pshier@google.com \
    --cc=seanjc@google.com \
    --cc=shuah@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=wanpengli@tencent.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.