[PATCH v7 0/2] KVM: VMX: Workaround VMX preemption timer erratum

Sean Christopherson posted 2 patches 2 months ago
arch/x86/kvm/vmx/vmx.c | 158 ++++++++++++++++++++++++++---------------
1 file changed, 102 insertions(+), 56 deletions(-)
[PATCH v7 0/2] KVM: VMX: Workaround VMX preemption timer erratum
Posted by Sean Christopherson 2 months ago
Due to a widespread Intel erratum (e.g. EMR158), programming the VMX
preemption timer with certain large values may cause the timer to expire
earlier than expected. The recommended workaround is to cap the timer value
to strictly less than 2^25 * CPUID.15H:EBX[31:0] / CPUID.15H:EAX[31:0].

v7:
 - Ensure the timer doesn't exceed the architectural max. [Sashiko]

v6:
 - https://lore.kernel.org/all/20260729134203.1377606-2-seanjc@google.com
 - Collect reviews. [Chao, Binbin]
 - Massage the wording in patch 1's changelog. [Binbin]
 - Use an inclusive "max" instead of an exclusive "limit".
 - Define a local ARCHITECTURAL_MAX_VALUE instead of open coding it in multiple
   locations.
 - Don't apply the workaround when running as a guest.
 - WARN if the CPUID.0x15 information would result in max value of 0.

v5:
 - https://lore.kernel.org/all/20260724234914.987987-1-jmattson@google.com
 - Include Sean's preparatory patch burying VMX preemption timer code under
   CONFIG_X86_64=y [Sean]
 - Replace div_u64() with direct division (/)

v4: https://lore.kernel.org/all/20260722143024.3938899-1-jmattson@google.com
v3: https://lore.kernel.org/all/20260722040311.3369898-1-jmattson@google.com
v2: https://lore.kernel.org/all/20260720231639.1592848-1-jmattson@google.com
v1: https://lore.kernel.org/all/20260720205230.1457146-1-jmattson@google.com

Jim Mattson (1):
  KVM: VMX: Cap VMX preemption timer to work around Intel erratum

Sean Christopherson (1):
  KVM: VMX: Bury all of the VMX preemption timer code under
    CONFIG_X86_64=y

 arch/x86/kvm/vmx/vmx.c | 158 ++++++++++++++++++++++++++---------------
 1 file changed, 102 insertions(+), 56 deletions(-)


base-commit: 3c7d7f908d574277a845423ec32250a8d8df44c8
-- 
2.55.0.508.g3f0d502094-goog
Re: [PATCH v7 0/2] KVM: VMX: Workaround VMX preemption timer erratum
Posted by Sean Christopherson 1 month, 3 weeks ago
On Fri, 31 Jul 2026 10:19:24 -0700, Sean Christopherson wrote:
> Due to a widespread Intel erratum (e.g. EMR158), programming the VMX
> preemption timer with certain large values may cause the timer to expire
> earlier than expected. The recommended workaround is to cap the timer value
> to strictly less than 2^25 * CPUID.15H:EBX[31:0] / CPUID.15H:EAX[31:0].
> 
> v7:
>  - Ensure the timer doesn't exceed the architectural max. [Sashiko]
> 
> [...]

Applied to kvm-x86 vmx, thanks!

[1/2] KVM: VMX: Bury all of the VMX preemption timer code under CONFIG_X86_64=y
      https://github.com/kvm-x86/linux/commit/d0dea3ed847c
[2/2] KVM: VMX: Cap VMX preemption timer to work around Intel erratum
      https://github.com/kvm-x86/linux/commit/0aaedada606a

--
https://github.com/kvm-x86/linux/tree/next