From: Chao Gao <chao.gao@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <seanjc@google.com>
Cc: <kvm@vger.kernel.org>, <isaku.yamahata@gmail.com>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 00/36] KVM: VMX APIC timer virtualization support
Date: Thu, 16 Jul 2026 16:30:26 +0800 [thread overview]
Message-ID: <aliWoldWX9/9tqNn@intel.com> (raw)
In-Reply-To: <cover.1772732517.git.isaku.yamahata@intel.com>
On Thu, Mar 05, 2026 at 09:43:40AM -0800, isaku.yamahata@intel.com wrote:
>From: Isaku Yamahata <isaku.yamahata@intel.com>
>
>This patch series is v2 of VMX APIC timer virtualization support.
Hi,
I'm picking up the APIC timer virtualization work that Isaku posted [1].
While reviewing the series, I noticed that APIC timer virtualization and
the VMX preemption timer share fundamental properties:
- Both run only in guest mode, requiring KVM to switch to a software
hrtimer when the vCPU blocks.
- Both are armed/disarmed by writing a VMCS field (a countdown for the
preemption timer, an absolute TSC deadline for APIC timer
virtualization).
These are exactly the properties the existing hv_timer infrastructure
was designed for. This v2 series treats APIC timer virtualization as
an entirely new mechanism, introducing a separate apic_virt_timer_in_use
flag with five dedicated hooks and helpers to arm/disarm and manage state
transitions in the common x86 flows (see [2]). I think we can avoid that.
The idea is to reuse set_hv_timer()/cancel_hv_timer() for APIC timer
virtualization, with two additions:
First, the pieces specific to APIC timer virtualization:
- Configure the timer interrupt vector in the VMCS.
- Disable MSR interception for TSC_DEADLINE when the guest is in
deadline mode (so writes go directly to hardware).
- Re-enable interception when the guest leaves deadline mode or masks
the timer.
These are naturally scoped to LVTT register writes, so a single
update_lvtt() vendor hook is sufficient.
Second, tracking the timer state. With the preemption timer, KVM
intercepts every MSR_IA32_TSC_DEADLINE write and knows precisely when a
timer is armed. With APIC timer virtualization, the MSR is not
intercepted and the guest arms and re-arms the timer without KVM's
knowledge. When the vCPU halts, KVM needs to know whether a timer is
armed and its deadline to set up the software wakeup timer.
The solution is straightforward: on VM-exit, read back the deadline from
the VMCS and update KVM's existing tracking (hv_timer_in_use and
ktimer->tscdeadline). This is one vmcs_read64() per VM-exit, negligible
compared to the exit cost itself. The existing vcpu_block() path then
works unchanged.
I prototyped this approach [3] for enabling APIC timer virtualization for
L1 guests (nested support isn't considered). The result is roughly a third
of the code (110 LoC vs. 300 LoC), with details of hypervisor timers
(preemption timer or APIC timer virtualization) fully contained in VMX. The
only change to common x86 code is a single kvm_x86_call in apic_update_lvtt().
I plan to post a series based on this approach and would appreciate
feedback on the direction before doing so.
Thanks,
Chao
[1] https://lore.kernel.org/kvm/cover.1772732517.git.isaku.yamahata@intel.com/
[2] https://lore.kernel.org/kvm/727502c8f79850fae6a8a476a624e5902861db39.1772732517.git.isaku.yamahata@intel.com/
[3] https://github.com/gaochaointel/linux-dev/commits/43056263022fe57cc9a10ebf2828f0f29611d6c
prev parent reply other threads:[~2026-07-16 8:30 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-05 17:43 [PATCH v2 00/36] KVM: VMX APIC timer virtualization support isaku.yamahata
2026-03-05 17:43 ` [PATCH v2 01/36] KVM: VMX: Detect APIC timer virtualization bit isaku.yamahata
2026-03-05 17:43 ` [PATCH v2 02/36] KVM: x86: Implement APIC virt timer helpers with callbacks isaku.yamahata
2026-03-05 17:43 ` [PATCH v2 03/36] KVM: x86/lapic: Start/stop sw/hv timer on vCPU un/block isaku.yamahata
2026-03-05 17:43 ` [PATCH v2 04/36] KVM: x86/lapic: Wire DEADLINE MSR update to guest virtual TSC deadline isaku.yamahata
2026-03-05 17:43 ` [PATCH v2 05/36] KVM: x86/lapic: Add a trace point for guest virtual timer isaku.yamahata
2026-03-05 17:43 ` [PATCH v2 06/36] KVM: VMX: Implement the hooks for VMX guest virtual deadline timer isaku.yamahata
2026-03-05 17:43 ` [PATCH v2 07/36] KVM: VMX: Update APIC timer virtualization on apicv changed isaku.yamahata
2026-03-05 17:43 ` [PATCH v2 08/36] KVM: nVMX: Disallow/allow guest APIC timer virtualization switch to/from L2 isaku.yamahata
2026-03-05 17:43 ` [PATCH v2 09/36] KVM: nVMX: Pass struct msr_data to VMX MSRs emulation isaku.yamahata
2026-03-05 17:43 ` [PATCH v2 10/36] KVM: nVMX: Supports VMX tertiary controls and GUEST_APIC_TIMER bit isaku.yamahata
2026-03-05 17:43 ` [PATCH v2 11/36] KVM: nVMX: Add alignment check for struct vmcs12 isaku.yamahata
2026-03-05 17:43 ` [PATCH v2 12/36] KVM: nVMX: Add tertiary VM-execution control VMCS support isaku.yamahata
2026-03-05 17:43 ` [PATCH v2 13/36] KVM: nVMX: Update intercept on TSC deadline MSR isaku.yamahata
2026-03-05 17:43 ` [PATCH v2 14/36] KVM: nVMX: Handle virtual timer vector VMCS field isaku.yamahata
2026-03-05 17:43 ` [PATCH v2 15/36] KVM: VMX: Make vmx_calc_deadline_l1_to_host() non-static isaku.yamahata
2026-03-05 17:43 ` [PATCH v2 16/36] KVM: nVMX: Enable guest deadline and its shadow VMCS field isaku.yamahata
2026-03-06 11:14 ` kernel test robot
2026-03-05 17:43 ` [PATCH v2 17/36] KVM: nVMX: Add VM entry checks related to APIC timer virtualization isaku.yamahata
2026-03-05 17:43 ` [PATCH v2 18/36] KVM: nVMX: Add check vmread/vmwrite on tertiary control isaku.yamahata
2026-03-05 17:43 ` [PATCH v2 19/36] KVM: nVMX: Add check VMCS index for guest timer virtualization isaku.yamahata
2026-03-05 17:44 ` [PATCH v2 20/36] KVM: VMX: Advertise tertiary controls to the user space isaku.yamahata
2026-03-05 17:44 ` [PATCH v2 21/36] KVM: VMX: dump_vmcs() support the guest virt timer isaku.yamahata
2026-03-05 17:44 ` [PATCH v2 22/36] KVM: VMX: Enable APIC timer virtualization isaku.yamahata
2026-03-05 17:44 ` [PATCH v2 23/36] KVM: VMX: Introduce module parameter for APIC virt timer support isaku.yamahata
2026-03-05 17:44 ` [PATCH v2 24/36] KVM: nVMX: Introduce module parameter for nested APIC timer virtualization isaku.yamahata
2026-03-05 17:44 ` [PATCH v2 25/36] KVM: selftests: Add a test to measure local timer latency isaku.yamahata
2026-03-05 17:44 ` [PATCH v2 26/36] KVM: selftests: Add nVMX support to timer_latency test case isaku.yamahata
2026-03-05 17:44 ` [PATCH v2 27/36] KVM: selftests: Add test for nVMX MSR_IA32_VMX_PROCBASED_CTLS3 isaku.yamahata
2026-03-05 17:44 ` [PATCH v2 28/36] KVM: selftests: Add test vmx_set_nested_state_test with EVMCS disabled isaku.yamahata
2026-03-05 17:44 ` [PATCH v2 29/36] KVM: selftests: Add tests nested state of APIC timer virtualization isaku.yamahata
2026-03-05 17:44 ` [PATCH v2 30/36] KVM: selftests: Add VMCS access test to " isaku.yamahata
2026-03-05 17:44 ` [PATCH v2 31/36] KVM: selftests: Add serialize() helper and X86_FEATURE_SERIALIZE isaku.yamahata
2026-03-05 17:44 ` [PATCH v2 32/36] KVM: selftests: Test cases for L1 APIC timer virtualization isaku.yamahata
2026-03-05 17:44 ` [PATCH v2 33/36] KVM: selftests: Add tests for nVMX to vmx_apic_timer_virt isaku.yamahata
2026-03-05 17:44 ` [PATCH v2 34/36] KVM: selftests: Add a global option to disable in-kernel irqchip isaku.yamahata
2026-03-05 17:44 ` [PATCH v2 35/36] KVM: selftests: Test VMX apic timer virt with inkernel apic disable isaku.yamahata
2026-03-05 17:44 ` [PATCH v2 36/36] Documentation: KVM: x86: Update documentation of struct vmcs12 isaku.yamahata
2026-07-16 8:30 ` 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=aliWoldWX9/9tqNn@intel.com \
--to=chao.gao@intel.com \
--cc=isaku.yamahata@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
/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.