diff mbox series

[resend] KVM: x86: fire timer when it is migrated and expired, and in oneshot mode

Message ID 20230106040625.8404-1-lirongqing@baidu.com (mailing list archive)
State New, archived
Headers show
Series [resend] KVM: x86: fire timer when it is migrated and expired, and in oneshot mode | expand

Commit Message

Li RongQing Jan. 6, 2023, 4:06 a.m. UTC
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>
---
 arch/x86/kvm/lapic.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Sean Christopherson Jan. 20, 2023, 12:19 a.m. UTC | #1
On Fri, 06 Jan 2023 12:06:25 +0800, Li RongQing wrote:
> 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
> 
> 

Applied to kvm-x86 apic, thanks!

[1/1] KVM: x86: fire timer when it is migrated and expired, and in oneshot mode
      https://github.com/kvm-x86/linux/commit/e9de8741ecfb

--
https://github.com/kvm-x86/linux/tree/next
https://github.com/kvm-x86/linux/tree/fixes
diff mbox series

Patch

diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 4efdb4a4..13f8ab3 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -1841,8 +1841,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 "