From: Sohil Mehta <sohil.mehta@intel.com>
To: kvm@vger.kernel.org, x86@kernel.org
Cc: Sean Christopherson <seanjc@google.com>,
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>, Shuah Khan <shuah@kernel.org>,
Binbin Wu <binbin.wu@linux.intel.com>,
Peter Zijlstra <peterz@infradead.org>,
"Chang S . Bae" <chang.seok.bae@intel.com>,
Kai Huang <kai.huang@intel.com>,
Fuad Tabba <fuad.tabba@linux.dev>, Chao Gao <chao.gao@intel.com>,
Yosry Ahmed <yosry@kernel.org>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
David Matlack <dmatlack@google.com>,
Bala-Vignesh-Reddy <reddybalavignesh9979@gmail.com>,
Kishen Maloor <kishen.maloor@intel.com>,
Rick Edgecombe <rick.p.edgecombe@intel.com>,
Sohil Mehta <sohil.mehta@intel.com>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: [PATCH v4 5/7] KVM: x86: Virtualize LASS and advertise support to userspace
Date: Wed, 5 Aug 2026 18:15:34 -0700 [thread overview]
Message-ID: <20260806011536.4172258-6-sohil.mehta@intel.com> (raw)
In-Reply-To: <20260806011536.4172258-1-sohil.mehta@intel.com>
From: Zeng Guang <guang.zeng@intel.com>
Virtualize Linear Address Space Separation (LASS) by letting the guest
enable CR4.LASS[bit 27]. Allow the guest to set CR4.LASS only if LASS is
enumerated in the guest's CPUID. Set CR4.LASS in the emulated
IA32_VMX_CR4_FIXED1 MSR so that LASS can be enabled in nested VMX
operation as well.
Keep CR4.LASS KVM-owned instead of making it guest-owned. LASS is
expected to be enabled once per vCPU at boot and rarely toggled at
runtime.
LASS is enumerated by CPUID.(EAX=07H,ECX=1):EAX.LASS[bit 6] and only
works in IA-32e mode. Advertise LASS to userspace on 64-bit kernels and
only when it is supported by the host. Notably, it will not be exposed
to userspace if the deprecated vsyscall=emulate mode is set on the
kernel command line.
Signed-off-by: Zeng Guang <guang.zeng@intel.com>
Signed-off-by: Binbin Wu <binbin.wu@linux.intel.com>
Signed-off-by: Sohil Mehta <sohil.mehta@intel.com>
---
v4:
- Split patch diffs and reworded the commit message
- Use X86_64_F() instead of F()
---
arch/x86/kvm/cpuid.c | 1 +
arch/x86/kvm/regs.h | 4 +++-
arch/x86/kvm/vmx/vmx.c | 1 +
3 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 9e9cf6538a96..c4dbd00f5e4e 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -1029,6 +1029,7 @@ void kvm_initialize_cpu_caps(void)
F(SM4),
F(AVX_VNNI),
F(AVX512_BF16),
+ X86_64_F(LASS),
F(CMPCCXADD),
F(FZRM),
F(FSRS),
diff --git a/arch/x86/kvm/regs.h b/arch/x86/kvm/regs.h
index 447f0ec3e63e..be8621695c41 100644
--- a/arch/x86/kvm/regs.h
+++ b/arch/x86/kvm/regs.h
@@ -28,7 +28,7 @@ static_assert(!(KVM_POSSIBLE_CR0_GUEST_BITS & X86_CR0_PDPTR_BITS));
| X86_CR4_OSXSAVE | X86_CR4_SMEP | X86_CR4_FSGSBASE \
| X86_CR4_OSXMMEXCPT | X86_CR4_LA57 | X86_CR4_VMXE \
| X86_CR4_SMAP | X86_CR4_PKE | X86_CR4_UMIP \
- | X86_CR4_LAM_SUP | X86_CR4_CET))
+ | X86_CR4_LAM_SUP | X86_CR4_CET | X86_CR4_LASS))
#define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR)
@@ -405,6 +405,8 @@ static inline bool __kvm_is_valid_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
__reserved_bits |= X86_CR4_PCIDE; \
if (!__cpu_has(__c, X86_FEATURE_LAM)) \
__reserved_bits |= X86_CR4_LAM_SUP; \
+ if (!__cpu_has(__c, X86_FEATURE_LASS)) \
+ __reserved_bits |= X86_CR4_LASS; \
if (!__cpu_has(__c, X86_FEATURE_SHSTK) && \
!__cpu_has(__c, X86_FEATURE_IBT)) \
__reserved_bits |= X86_CR4_CET; \
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index ecd105f35c78..3082195906da 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -7885,6 +7885,7 @@ static void nested_vmx_cr_fixed1_bits_update(struct kvm_vcpu *vcpu)
entry = kvm_find_cpuid_entry_index(vcpu, 0x7, 1);
cr4_fixed1_update(X86_CR4_LAM_SUP, eax, feature_bit(LAM));
+ cr4_fixed1_update(X86_CR4_LASS, eax, feature_bit(LASS));
#undef cr4_fixed1_update
}
--
2.43.0
next prev parent reply other threads:[~2026-08-06 1:18 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 1:15 [PATCH v4 0/7] KVM: x86: Add LASS virtualization support Sohil Mehta
2026-08-06 1:15 ` [PATCH v4 1/7] KVM: x86: Add an emulator flag to differentiate branch targets from fetches Sohil Mehta
2026-08-06 1:15 ` [PATCH v4 2/7] KVM: x86: Use linear_read_system() to read the TSS I/O bitmap Sohil Mehta
2026-08-19 3:19 ` Binbin Wu
2026-08-19 5:03 ` Sohil Mehta
2026-08-19 5:21 ` H. Peter Anvin
2026-08-19 5:26 ` Binbin Wu
2026-08-06 1:15 ` [PATCH v4 3/7] KVM: x86: Add LASS violation checks during instruction emulation Sohil Mehta
2026-08-19 5:58 ` Binbin Wu
2026-08-06 1:15 ` [PATCH v4 4/7] KVM: VMX: Implement LASS violation check Sohil Mehta
2026-08-19 8:49 ` Binbin Wu
2026-09-14 17:43 ` Chang S. Bae
2026-09-15 5:10 ` Sohil Mehta
2026-09-15 14:04 ` Sean Christopherson
2026-09-16 0:12 ` Sohil Mehta
2026-09-16 18:38 ` Sean Christopherson
2026-09-16 21:49 ` Sohil Mehta
2026-08-06 1:15 ` Sohil Mehta [this message]
2026-08-19 9:01 ` [PATCH v4 5/7] KVM: x86: Virtualize LASS and advertise support to userspace Binbin Wu
2026-08-06 1:15 ` [PATCH v4 6/7] KVM: selftests: Add coverage for LASS CPUID and CR4 handling Sohil Mehta
2026-08-20 6:01 ` Binbin Wu
2026-08-06 1:15 ` [PATCH v4 7/7] selftests/x86: Add a userspace test for LASS enforcement Sohil Mehta
2026-08-20 6:36 ` Binbin Wu
2026-09-15 3:22 ` Sohil Mehta
2026-09-14 18:21 ` Chang S. Bae
2026-09-15 3:16 ` Sohil Mehta
2026-08-26 3:50 ` [PATCH v4 0/7] KVM: x86: Add LASS virtualization support Kishen Maloor
2026-08-27 3:18 ` Chen, Farrah
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=20260806011536.4172258-6-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=dmatlack@google.com \
--cc=fuad.tabba@linux.dev \
--cc=hpa@zytor.com \
--cc=imbrenda@linux.ibm.com \
--cc=kai.huang@intel.com \
--cc=kishen.maloor@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=reddybalavignesh9979@gmail.com \
--cc=rick.p.edgecombe@intel.com \
--cc=seanjc@google.com \
--cc=shuah@kernel.org \
--cc=tglx@kernel.org \
--cc=x86@kernel.org \
--cc=yosry@kernel.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 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®