From: Sohil Mehta <sohil.mehta@intel.com>
To: kvm@vger.kernel.org, Sean Christopherson <seanjc@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H . Peter Anvin" <hpa@zytor.com>, Xin Li <xin@zytor.com>,
Shivansh Dhiman <shivansh.dhiman@amd.com>,
David Woodhouse <dwmw@amazon.co.uk>,
Chao Gao <chao.gao@intel.com>,
Binbin Wu <binbin.wu@linux.intel.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Sohil Mehta <sohil.mehta@intel.com>,
"Chang S . Bae" <chang.seok.bae@intel.com>,
Zhao Liu <zhao1.liu@intel.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3 0/3] KVM: VMX: Support the secondary VM-exit controls
Date: Thu, 3 Dec 2026 22:46:31 -0800 [thread overview]
Message-ID: <20261204064634.1569133-1-sohil.mehta@intel.com> (raw)
This series puts the secondary VM-exit controls support in place (independent
of FRED). The patches are mature and ready for maintainer review. Preferably,
they can be merged into the KVM tree separately. Otherwise, I'll place the
patches at the beginning of the FRED series for a combined merge.
Changes in v3
-------------
- Rebase onto the latest kvm-x86/next (kvm-x86-next-2026.12.03)
- Clear the secondary exit controls when KVM is running on Hyper-V [patch 1]
- Give Sean's reason for the separate pair table [patch 1]
- Spell out how FRED uses both exit controls [patch 2]
- Pick up review tags from Chao and Binbin
v2: https://lore.kernel.org/lkml/20261203065149.2952509-1-sohil.mehta@intel.com/
Background
----------
Some of these patches started out as part of the FRED KVM series [1]. I am
working towards getting the core infrastructure pieces ready first then the
FRED guest support followed by the nested FRED support.
The secondary VM-exit controls are a 64-bit VMCS field, activated by bit 31 of
the primary VM-exit controls. The SDM defines four of them so far: "save
FRED", "load FRED", "load IA32_SPEC_CTRL" and "prematurely busy shadow stack".
With this series, KVM discovers the field and programs it in vmcs01 and
vmcs02, so that FRED or any other user of these controls only has to set its
own bits later on.
Patches
-------
Patch 1 adds the support for the secondary VM-exit controls.
Patch 2 fixes an issue reported by sashiko related to the entry/exit pair
checking [2] and patch 3 adds the new field to the VMCS dump. The last two
patches are optional, but they help complete the support.
vmcs02 issue
------------
KVM seeds vmcs02's VM-exit controls from vmcs01's, so vmcs02 inherits bit
31 but not the secondary controls themselves. vmcs02 then runs with the
secondary controls active but empty, which is harmless only while every
bit is clear.
Once FRED sets its controls in vmcs01, vmcs02 also inherits FRED's VM-entry
control. Entering any L2 loads FRED state, but the exit from L2 doesn't
restore the host's. Until the next VM entry the host runs with a zeroed FRED
configuration, and any event in that window hangs the CPU.
This isn't specific to FRED, any future secondary VM-exit control would
likewise be silently off whenever an L2 runs.
Testing
-------
This was tested on a FRED capable system with FRED enabled as well as
fred=off. The CPU enumerates all four secondary VM-exit controls
(IA32_VMX_EXIT_CTLS2 = 0xf), so KVM activates the field in vmcs01 and copies
it into vmcs02, with every bit clear.
A debug dump_vmcs() on first VM exit from vmcs01 and from vmcs02 shows the
same controls in both:
ExitControls=0x902befff SecondaryExitControls=0x0000000000000000
KVM selftests and kvm-unit-tests show no regressions.
Patch 2's new check was also tested with the upcoming FRED guest support,
whose pair has two exit controls. KVM keeps the pair when all three controls
are supported and rejects it when any one is forced off.
Links
-----
[1]: https://lore.kernel.org/lkml/20260911213659.2025974-2-sohil.mehta@intel.com/
[2]: https://lore.kernel.org/lkml/20260911220046.1A4A91F000FF@smtp.kernel.org/
Previous versions
-----------------
v2: https://lore.kernel.org/lkml/20261203065149.2952509-1-sohil.mehta@intel.com/
v1: https://lore.kernel.org/lkml/20261126022743.4082392-1-sohil.mehta@intel.com/
Sohil Mehta (1):
KVM: VMX: Treat partial support of an entry/exit pair as inconsistent
Xin Li (Intel) (2):
KVM: VMX: Support the secondary VM-exit controls
KVM: VMX: Dump the secondary VM-exit controls in dump_vmcs()
arch/x86/include/asm/msr-index.h | 1 +
arch/x86/include/asm/vmx.h | 3 ++
arch/x86/kvm/vmx/capabilities.h | 6 ++++
arch/x86/kvm/vmx/hyperv_evmcs.h | 2 ++
arch/x86/kvm/vmx/nested.c | 3 ++
arch/x86/kvm/vmx/vmcs.h | 1 +
arch/x86/kvm/vmx/vmx.c | 52 +++++++++++++++++++++++++++++---
arch/x86/kvm/vmx/vmx.h | 7 ++++-
arch/x86/kvm/vmx/vmx_onhyperv.c | 1 +
9 files changed, 71 insertions(+), 5 deletions(-)
base-commit: 4c9f462c7094c480144c98a942af7e935fa87a6a
--
2.43.0
next reply other threads:[~2026-12-04 6:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 6:46 Sohil Mehta [this message]
2026-12-04 6:46 ` [PATCH v3 1/3] " Sohil Mehta
2026-12-04 6:46 ` [PATCH v3 2/3] KVM: VMX: Treat partial support of an entry/exit pair as inconsistent Sohil Mehta
2026-12-04 6:46 ` [PATCH v3 3/3] KVM: VMX: Dump the secondary VM-exit controls in dump_vmcs() Sohil Mehta
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=20261204064634.1569133-1-sohil.mehta@intel.com \
--to=sohil.mehta@intel.com \
--cc=binbin.wu@linux.intel.com \
--cc=bp@alien8.de \
--cc=chang.seok.bae@intel.com \
--cc=chao.gao@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=dwmw@amazon.co.uk \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=shivansh.dhiman@amd.com \
--cc=tglx@kernel.org \
--cc=vkuznets@redhat.com \
--cc=x86@kernel.org \
--cc=xin@zytor.com \
--cc=zhao1.liu@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®