From: Kishen Maloor <kishen.maloor@intel.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, zhao1.liu@intel.com, kvm@vger.kernel.org,
sohil.mehta@intel.com, xiaoyao.li@intel.com,
binbin.wu@linux.intel.com, farrah.chen@intel.com,
kishen.maloor@intel.com
Subject: [PATCH 2/5] target/i386: Add LASS support in CR4
Date: Tue, 25 Aug 2026 20:57:31 -0700 [thread overview]
Message-ID: <20260826035734.114685-3-kishen.maloor@intel.com> (raw)
In-Reply-To: <20260826035734.114685-1-kishen.maloor@intel.com>
From: Isaku Yamahata <isaku.yamahata@intel.com>
CR4.LASS[bit 27] enables Linear Address Space Separation, and may be set
only when CPUID.(EAX=7,ECX=1):EAX[6] enumerates LASS.
Recognize CR4.LASS as a valid bit by adding CR4_LASS_MASK to the known
bits, i.e. clearing it from CR4_RESERVED_MASK. Mark it reserved in
cr4_reserved_bits() and clear it in cpu_x86_update_cr4() when the guest
CPUID does not enumerate LASS. This keeps CR4 handling consistent on
paths that reach cpu_x86_update_cr4(), such as gdbstub register writes.
LASS is not emulated by TCG, so it is not added to TCG_7_1_EAX_FEATURES
and cannot be set under TCG (helper_write_crN() and helper_vmrun() both
reject reserved bits via cr4_reserved_bits()).
Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
[kishen: rewrote commit message, rebased, fixed formatting]
Signed-off-by: Kishen Maloor <kishen.maloor@intel.com>
---
target/i386/cpu.h | 7 ++++++-
target/i386/helper.c | 4 ++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index e6a197602d..98c406db32 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -277,6 +277,7 @@ typedef enum X86Seg {
#define CR4_PKE_MASK (1U << 22)
#define CR4_CET_MASK (1U << 23)
#define CR4_PKS_MASK (1U << 24)
+#define CR4_LASS_MASK (1U << 27)
#define CR4_LAM_SUP_MASK (1U << 28)
#ifdef TARGET_X86_64
@@ -293,7 +294,8 @@ typedef enum X86Seg {
| CR4_LA57_MASK \
| CR4_FSGSBASE_MASK | CR4_PCIDE_MASK | CR4_OSXSAVE_MASK \
| CR4_SMEP_MASK | CR4_SMAP_MASK | CR4_PKE_MASK | CR4_CET_MASK \
- | CR4_PKS_MASK | CR4_LAM_SUP_MASK | CR4_FRED_MASK))
+ | CR4_PKS_MASK | CR4_LASS_MASK | CR4_LAM_SUP_MASK \
+ | CR4_FRED_MASK))
#define DR6_BD (1 << 13)
#define DR6_BS (1 << 14)
@@ -3064,6 +3066,9 @@ static inline uint64_t cr4_reserved_bits(CPUX86State *env)
if (!(env->features[FEAT_7_0_ECX] & CPUID_7_0_ECX_PKS)) {
reserved_bits |= CR4_PKS_MASK;
}
+ if (!(env->features[FEAT_7_1_EAX] & CPUID_7_1_EAX_LASS)) {
+ reserved_bits |= CR4_LASS_MASK;
+ }
if (!(env->features[FEAT_7_1_EAX] & CPUID_7_1_EAX_LAM)) {
reserved_bits |= CR4_LAM_SUP_MASK;
}
diff --git a/target/i386/helper.c b/target/i386/helper.c
index 6836214162..43cfcfdafe 100644
--- a/target/i386/helper.c
+++ b/target/i386/helper.c
@@ -229,6 +229,10 @@ void cpu_x86_update_cr4(CPUX86State *env, uint32_t new_cr4)
new_cr4 &= ~CR4_PKS_MASK;
}
+ if (!(env->features[FEAT_7_1_EAX] & CPUID_7_1_EAX_LASS)) {
+ new_cr4 &= ~CR4_LASS_MASK;
+ }
+
if (!(env->features[FEAT_7_1_EAX] & CPUID_7_1_EAX_LAM)) {
new_cr4 &= ~CR4_LAM_SUP_MASK;
}
--
2.47.1
next prev parent reply other threads:[~2026-08-26 3:35 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 3:57 [PATCH 0/5] target/i386: Add support for LASS Kishen Maloor
2026-08-26 3:57 ` [PATCH 1/5] target/i386: Add support for LASS in CPUID enumeration Kishen Maloor
2026-09-02 10:14 ` Zhao Liu
2026-08-26 3:57 ` Kishen Maloor [this message]
2026-09-02 10:16 ` [PATCH 2/5] target/i386: Add LASS support in CR4 Zhao Liu
2026-08-26 3:57 ` [PATCH 3/5] target/i386: Introduce DiamondRapids-v3 to enable LASS Kishen Maloor
2026-09-02 10:16 ` Zhao Liu
2026-08-26 3:57 ` [PATCH 4/5] target/i386: Introduce SierraForest-v7 " Kishen Maloor
2026-09-02 10:17 ` Zhao Liu
2026-08-26 3:57 ` [PATCH 5/5] target/i386: Introduce ClearwaterForest-v5 " Kishen Maloor
2026-09-02 10:17 ` Zhao Liu
2026-08-27 3:07 ` [PATCH 0/5] target/i386: Add support for LASS Chen, Farrah
2026-09-01 16:08 ` Sohil Mehta
2026-09-02 2:40 ` Binbin Wu
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=20260826035734.114685-3-kishen.maloor@intel.com \
--to=kishen.maloor@intel.com \
--cc=binbin.wu@linux.intel.com \
--cc=farrah.chen@intel.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=sohil.mehta@intel.com \
--cc=xiaoyao.li@intel.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