Skip to contentSkip to conversation

target/i386: Add support for LASS

PATCH In review Kishen Maloor 5 participants 14 messages Aug 26 – Sep 2 KVM

lore
Share & tools
lore
#0 lore raw

cover target/i386: Add support for LASS

This series adds QEMU support for Linear Address Space Separation (LASS) [1], an Intel security feature that prevents a class of side-channel attacks relying on speculative accesses across the user/kernel boundary. Paging, along with SMEP and SMAP, already provides mode-based access protection, but enforcing it requires a page walk whose timing can leak the layout of kernel memory. LASS applies the equivalent protections during linear-address pre-processing: given the usual partitioning of the linear address space into a user half (bit 63 clear) and a supervisor half (bit 63 set), an access targeting the opposite half is rejected on the basis of bit 63 alone, before any page walk.

This series enumerates the LASS CPUID bit, recognizes CR4.LASS, and exposes LASS on the relevant Intel CPU models via new versioned models. LASS is not emulated by TCG.

Exposing LASS to a guest also requires KVM support: KVM must validate the CPUID bit and CR4.LASS, and enforce LASS violations in its instruction emulator. That enabling is currently under review [2].

Tested with a Linux guest on LASS-capable hardware: LASS is enumerated and CR4.LASS is set under KVM, and not enumerated under TCG.

[1] Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3A, Section 4.3, "Linear-Address-Space Separation (LASS)".
[2] https://lore.kernel.org/kvm/[email protected]/

Isaku Yamahata (2):
target/i386: Add support for LASS in CPUID enumeration target/i386: Add LASS support in CR4

Kishen Maloor (3):
target/i386: Introduce DiamondRapids-v3 to enable LASS target/i386: Introduce SierraForest-v7 to enable LASS target/i386: Introduce ClearwaterForest-v5 to enable LASS

 target/i386/cpu.c    | 26 +++++++++++++++++++++++++-
 target/i386/cpu.h    |  7 ++++++-
 target/i386/helper.c |  4 ++++
 3 files changed, 35 insertions(+), 2 deletions(-)
Signature · 1 line
2.47.1
#1 lore raw

PATCH 1/5 target/i386: Add support for LASS in CPUID enumeration

From: Isaku Yamahata <[email protected]>

Linear Address Space Separation (LASS) is a security feature that prevents a class of side-channel attacks relying on speculative accesses across the user/kernel boundary. Paging, along with SMEP and SMAP, already provides mode-based access protection, but enforcing it requires a page walk whose timing can leak the layout of kernel memory.

LASS applies the equivalent protections during linear-address pre-processing, before any page walk. Given the usual partitioning of the linear address space into a user half (bit 63 clear) and a supervisor half (bit 63 set), an access targeting the opposite half is rejected on the basis of bit 63 alone, raising a #GP. LASS is enabled via CR4.LASS[bit 27] and applies only in IA-32e mode.

Feature bit:
CPUID.(EAX=7,ECX=1):EAX[6]

A CPUID_7_1_EAX_LASS macro was previously added in commit 31df29c532a9 ("i386/tdx: Add supported CPUID bits related to TD Attributes"), but the bit was left unnamed in feature_word_info[FEAT_7_1_EAX]. Add the "lass" feature name to expose it via -cpu host, -cpu max, or an explicit +lass.

Exposing LASS to a guest also requires KVM support: KVM must validate the CPUID bit and CR4.LASS, and enforce LASS violations in its instruction emulator.

LASS is not implemented in TCG, so the bit is not added to TCG_7_1_EAX_FEATURES.

More details can be found in the Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3A, Section 4.3, "Linear-Address-Space Separation (LASS)".

[kishen: rewrote commit message, rebased]

---
KVM support for LASS is currently under review:
https://lore.kernel.org/kvm/[email protected]/

 target/i386/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/cpu.c +1 -1
index 5805d33ab9..5496e9475b 100644
@@ -1243,7 +1243,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
         .type = CPUID_FEATURE_WORD,
         .feat_names = {
             "sha512", "sm3", "sm4", NULL,
-            "avx-vnni", "avx512-bf16", NULL, "cmpccxadd",
+            "avx-vnni", "avx512-bf16", "lass", "cmpccxadd",
             NULL, NULL, "fzrm", "fsrs",
             "fsrc", NULL, NULL, NULL,
             NULL, "fred", "lkgs", "wrmsrns",
Signature · 1 line
2.47.1
Reviewed-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] target/i386: Add support for LASS in CPUID enumeration

Quoted 43 lines · Kishen Maloor

Date: Tue, 25 Aug 2026 20:57:30 -0700
From: Kishen Maloor <[email protected]>
Subject: [PATCH 1/5] target/i386: Add support for LASS in CPUID enumeration
X-Mailer: git-send-email 2.47.1

From: Isaku Yamahata <[email protected]>

Linear Address Space Separation (LASS) is a security feature that prevents a class of side-channel attacks relying on speculative accesses across the user/kernel boundary. Paging, along with SMEP and SMAP, already provides mode-based access protection, but enforcing it requires a page walk whose timing can leak the layout of kernel memory.

LASS applies the equivalent protections during linear-address pre-processing, before any page walk. Given the usual partitioning of the linear address space into a user half (bit 63 clear) and a supervisor half (bit 63 set), an access targeting the opposite half is rejected on the basis of bit 63 alone, raising a #GP. LASS is enabled via CR4.LASS[bit 27] and applies only in IA-32e mode.

Feature bit:
CPUID.(EAX=7,ECX=1):EAX[6]

A CPUID_7_1_EAX_LASS macro was previously added in commit 31df29c532a9 ("i386/tdx: Add supported CPUID bits related to TD Attributes"), but the bit was left unnamed in feature_word_info[FEAT_7_1_EAX]. Add the "lass" feature name to expose it via -cpu host, -cpu max, or an explicit +lass.

Exposing LASS to a guest also requires KVM support: KVM must validate the CPUID bit and CR4.LASS, and enforce LASS violations in its instruction emulator.

LASS is not implemented in TCG, so the bit is not added to TCG_7_1_EAX_FEATURES.

More details can be found in the Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3A, Section 4.3, "Linear-Address-Space Separation (LASS)".

[kishen: rewrote commit message, rebased]
Quoted 6 lines

---
KVM support for LASS is currently under review:
https://lore.kernel.org/kvm/[email protected]/

 target/i386/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#3 lore raw

PATCH 2/5 target/i386: Add LASS support in CR4

In reply to Kishen Maloor

From: Isaku Yamahata <[email protected]>

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()).

[kishen: rewrote commit message, rebased, fixed formatting]
---
 target/i386/cpu.h    | 7 ++++++-
 target/i386/helper.c | 4 ++++
 2 files changed, 10 insertions(+), 1 deletion(-)
target/i386/cpu.h +6 -1
index e6a197602d..98c406db32 100644
@@ -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;
     }
target/i386/helper.c +4 -0
index 6836214162..43cfcfdafe 100644
@@ -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;
     }
Signature · 1 line
2.47.1
Reviewed-by on v1 2/5
#4 lore raw

Re: [PATCH 2/5] target/i386: Add LASS support in CR4

Quoted 20 lines · Kishen Maloor

Date: Tue, 25 Aug 2026 20:57:31 -0700
From: Kishen Maloor <[email protected]>
Subject: [PATCH 2/5] target/i386: Add LASS support in CR4
X-Mailer: git-send-email 2.47.1

From: Isaku Yamahata <[email protected]>

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()).

Quoted 7 lines
[kishen: rewrote commit message, rebased, fixed formatting]
---
 target/i386/cpu.h    | 7 ++++++-
 target/i386/helper.c | 4 ++++
 2 files changed, 10 insertions(+), 1 deletion(-)
#5 lore raw

PATCH 3/5 target/i386: Introduce DiamondRapids-v3 to enable LASS

In reply to Kishen Maloor

Add DiamondRapids-v3 to expose Linear Address Space Separation (LASS) on the DiamondRapids CPU model.

---
 target/i386/cpu.c | 8 ++++++++
 1 file changed, 8 insertions(+)
target/i386/cpu.c +8 -0
index 5496e9475b..fa6b76be27 100644
@@ -5829,6 +5829,14 @@ static const X86CPUDefinition builtin_x86_defs[] = {
                     { /* end of list */ },
                 }
             },
+            {
+                .version = 3,
+                .note = "with LASS",
+                .props = (PropValue[]) {
+                    { "lass", "on" },
+                    { /* end of list */ },
+                }
+            },
             { /* end of list */ },
         },
     },
Signature · 1 line
2.47.1
Reviewed-by on v1 3/5
#6 lore raw

Re: [PATCH 3/5] target/i386: Introduce DiamondRapids-v3 to enable LASS

Quoted 5 lines · Kishen Maloor

Date: Tue, 25 Aug 2026 20:57:32 -0700
From: Kishen Maloor <[email protected]>
Subject: [PATCH 3/5] target/i386: Introduce DiamondRapids-v3 to enable LASS
X-Mailer: git-send-email 2.47.1

Quoted 7 lines

Add DiamondRapids-v3 to expose Linear Address Space Separation (LASS) on the DiamondRapids CPU model.

---
 target/i386/cpu.c | 8 ++++++++
 1 file changed, 8 insertions(+)
#7 lore raw

PATCH 4/5 target/i386: Introduce SierraForest-v7 to enable LASS

In reply to Kishen Maloor

Add SierraForest-v7 to expose Linear Address Space Separation (LASS) on the SierraForest CPU model.

---
 target/i386/cpu.c | 8 ++++++++
 1 file changed, 8 insertions(+)
target/i386/cpu.c +8 -0
index fa6b76be27..167df0e6cb 100644
@@ -6018,6 +6018,14 @@ static const X86CPUDefinition builtin_x86_defs[] = {
                     { /* end of list */ },
                 }
             },
+            {
+                .version = 7,
+                .note = "with LASS",
+                .props = (PropValue[]) {
+                    { "lass", "on" },
+                    { /* end of list */ },
+                }
+            },
             { /* end of list */ },
         },
     },
Signature · 1 line
2.47.1
Reviewed-by on v1 4/5
#8 lore raw

Re: [PATCH 4/5] target/i386: Introduce SierraForest-v7 to enable LASS

Quoted 5 lines · Kishen Maloor

Date: Tue, 25 Aug 2026 20:57:33 -0700
From: Kishen Maloor <[email protected]>
Subject: [PATCH 4/5] target/i386: Introduce SierraForest-v7 to enable LASS
X-Mailer: git-send-email 2.47.1

Quoted 7 lines

Add SierraForest-v7 to expose Linear Address Space Separation (LASS) on the SierraForest CPU model.

---
 target/i386/cpu.c | 8 ++++++++
 1 file changed, 8 insertions(+)
#9 lore raw

PATCH 5/5 target/i386: Introduce ClearwaterForest-v5 to enable LASS

In reply to Kishen Maloor

Add ClearwaterForest-v5 to expose Linear Address Space Separation (LASS) on the ClearwaterForest CPU model.

---
 target/i386/cpu.c | 8 ++++++++
 1 file changed, 8 insertions(+)
target/i386/cpu.c +8 -0
index 167df0e6cb..1c333c2780 100644
@@ -6190,6 +6190,14 @@ static const X86CPUDefinition builtin_x86_defs[] = {
                     { /* end of list */ },
                 }
             },
+            {
+                .version = 5,
+                .note = "with LASS",
+                .props = (PropValue[]) {
+                    { "lass", "on" },
+                    { /* end of list */ },
+                }
+            },
             { /* end of list */ },
         },
     },
Signature · 1 line
2.47.1
Reviewed-by on v1 5/5
#10 lore raw

Re: [PATCH 5/5] target/i386: Introduce ClearwaterForest-v5 to enable LASS

Quoted 6 lines · Kishen Maloor

Date: Tue, 25 Aug 2026 20:57:34 -0700
From: Kishen Maloor <[email protected]>
Subject: [PATCH 5/5] target/i386: Introduce ClearwaterForest-v5 to enable
LASS
X-Mailer: git-send-email 2.47.1

Quoted 7 lines

Add ClearwaterForest-v5 to expose Linear Address Space Separation (LASS) on the ClearwaterForest CPU model.

---
 target/i386/cpu.c | 8 ++++++++
 1 file changed, 8 insertions(+)
Tested-by on the v1 series
#11 lore raw
In reply to Kishen Maloor
Quoted 11 lines · Kishen Maloor

This series adds QEMU support for Linear Address Space Separation (LASS) [1], an Intel security feature that prevents a class of side-channel attacks relying on speculative accesses across the user/kernel boundary. Paging, along with SMEP and SMAP, already provides mode-based access protection, but enforcing it requires a page walk whose timing can leak the layout of kernel memory. LASS applies the equivalent protections during linear-address pre-processing: given the usual partitioning of the linear address space into a user half (bit 63 clear) and a supervisor half (bit 63 set), an access targeting the opposite half is rejected on the basis of bit 63 alone, before any page walk.

Quoted 8 lines

This series enumerates the LASS CPUID bit, recognizes CR4.LASS, and exposes LASS on the relevant Intel CPU models via new versioned models. LASS is not emulated by TCG.

Exposing LASS to a guest also requires KVM support: KVM must validate the CPUID bit and CR4.LASS, and enforce LASS violations in its instruction emulator. That enabling is currently under review [2].

I tested this series on Clearwater Forest (CWF), running a KVM guest with -cpu host. On the host I applied the KVM LASS enabling series referenced as [2] in the cover letter:

https://lore.kernel.org/kvm/[email protected]/

With both series applied, LASS is correctly enumerated in the guest, and the LASS functional tests pass with vsyscall=none/xonly/emulate.

Acked-by on the v1 series
#12 lore raw
In reply to Kishen Maloor
Quoted 9 lines · Kishen Maloor

Isaku Yamahata (2):
target/i386: Add support for LASS in CPUID enumeration target/i386: Add LASS support in CR4

Kishen Maloor (3):
target/i386: Introduce DiamondRapids-v3 to enable LASS target/i386: Introduce SierraForest-v7 to enable LASS target/i386: Introduce ClearwaterForest-v5 to enable LASS

Quoted 5 lines
 target/i386/cpu.c    | 26 +++++++++++++++++++++++++-
 target/i386/cpu.h    |  7 ++++++-
 target/i386/helper.c |  4 ++++
 3 files changed, 35 insertions(+), 2 deletions(-)
Reviewed-by on the v1 series
#13 lore raw
In reply to Kishen Maloor
Quoted 26 lines · Kishen Maloor

This series adds QEMU support for Linear Address Space Separation (LASS) [1], an Intel security feature that prevents a class of side-channel attacks relying on speculative accesses across the user/kernel boundary. Paging, along with SMEP and SMAP, already provides mode-based access protection, but enforcing it requires a page walk whose timing can leak the layout of kernel memory. LASS applies the equivalent protections during linear-address pre-processing: given the usual partitioning of the linear address space into a user half (bit 63 clear) and a supervisor half (bit 63 set), an access targeting the opposite half is rejected on the basis of bit 63 alone, before any page walk.

This series enumerates the LASS CPUID bit, recognizes CR4.LASS, and exposes LASS on the relevant Intel CPU models via new versioned models. LASS is not emulated by TCG.

Exposing LASS to a guest also requires KVM support: KVM must validate the CPUID bit and CR4.LASS, and enforce LASS violations in its instruction emulator. That enabling is currently under review [2].

Tested with a Linux guest on LASS-capable hardware: LASS is enumerated and CR4.LASS is set under KVM, and not enumerated under TCG.

[1] Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3A, Section 4.3, "Linear-Address-Space Separation (LASS)".
[2] https://lore.kernel.org/kvm/[email protected]/

Quoted 8 lines

Isaku Yamahata (2):
target/i386: Add support for LASS in CPUID enumeration target/i386: Add LASS support in CR4

Kishen Maloor (3):
target/i386: Introduce DiamondRapids-v3 to enable LASS target/i386: Introduce SierraForest-v7 to enable LASS target/i386: Introduce ClearwaterForest-v5 to enable LASS

Quoted 6 lines
 target/i386/cpu.c    | 26 +++++++++++++++++++++++++-
 target/i386/cpu.h    |  7 ++++++-
 target/i386/helper.c |  4 ++++
 3 files changed, 35 insertions(+), 2 deletions(-)