From: Chao Gao <chao.gao@intel.com>
To: Venkatesh Srinivas <venkateshs@chromium.org>
Cc: <kvm@vger.kernel.org>, <stable@vger.kernel.org>,
David Matlack <dmatlack@google.com>,
Sean Christopherson <seanjc@google.com>,
Jim Mattson <jmattson@google.com>,
James Houghton <jthoughton@google.com>
Subject: Re: [PATCH] KVM: x86: Only reset TSC Deadline Timer in apic_timer_expired on KVM_RUN
Date: Mon, 20 Jul 2026 16:37:08 +0800 [thread overview]
Message-ID: <al3eNJFTJur4FI8T@intel.com> (raw)
In-Reply-To: <20260715234234.15382-2-venkateshs@chromium.org>
On Wed, Jul 15, 2026 at 11:42:35PM +0000, Venkatesh Srinivas wrote:
>Fixes a lost timer interrupt issue if:
>1) We are on an Intel platform w/ a VMX preemption timer && APICv
>2) A VMM calls KVM_GET_LAPIC before KVM_GET_MSRS to save vCPU state
>3) The thread executing the two calls migrates CPUs between the two calls
>
>After migration across CPUs, KVM_GET_MSRS calls vcpu_load, posting the
>interrupt and clearing the MSR:
>vcpu_load() ->
> kvm_arch_vcpu_load() ->
> kvm_lapic_restart_hv_timer() ->
> start_hv_timer() ->
> apic_timer_expired() ->
> kvm_apic_inject_pending_timer_irqs()
> . post interrupt into the LAPIC state
> . clear IA32_TSCDEADLINE
>
>The saved LAPIC state will be missing the pending interrupt and the saved
>MSR will be zero. Oops.
>
>Fix by only posting an interrupt when we're attempting to enter the guest
>(vcpu->wants_to_run == true), not for vcpu_load from other paths.
>
>Assisted-by: gemini:gemini-3.1-pro-preview
>Debugged-by: David Matlack <dmatlack@google.com>
>Debugged-by: Sean Christopherson <seanjc@google.com>
>Debugged-by: Jim Mattson <jmattson@google.com>
>Debugged-by: James Houghton <jthoughton@google.com>
>Signed-off-by: Venkatesh Srinivas <venkateshs@chromium.org>
Reviewed-by: Chao Gao <chao.gao@intel.com>
prev parent reply other threads:[~2026-07-20 8:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 23:42 [PATCH] KVM: x86: Only reset TSC Deadline Timer in apic_timer_expired on KVM_RUN Venkatesh Srinivas
2026-07-16 1:14 ` James Houghton
2026-07-20 13:51 ` Paolo Bonzini
2026-07-20 8:37 ` Chao Gao [this message]
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=al3eNJFTJur4FI8T@intel.com \
--to=chao.gao@intel.com \
--cc=dmatlack@google.com \
--cc=jmattson@google.com \
--cc=jthoughton@google.com \
--cc=kvm@vger.kernel.org \
--cc=seanjc@google.com \
--cc=stable@vger.kernel.org \
--cc=venkateshs@chromium.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.