[tip: x86/sev] x86/sev: Add guest support for Enhanced SMT Protection

From: tip-bot2 for Pratik R. Sampat

Date: Thu Dec 03 2026 - 13:06:35 EST


The following commit has been merged into the x86/sev branch of tip:

Commit-ID: 0d4aa2a4f846391aad4ba8c14f42096a42b41635
Gitweb: https://git.kernel.org/tip/0d4aa2a4f846391aad4ba8c14f42096a42b41635
Author: Pratik R. Sampat <prsampat@xxxxxxx>
AuthorDate: Tue, 17 Nov 2026 17:56:59
Committer: Borislav Petkov (AMD) <bp@xxxxxxxxx>
CommitterDate: Thu, 03 Dec 2026 09:42:20 -08:00

x86/sev: Add guest support for Enhanced SMT Protection

Enhanced SMT Protection requires every VMSA to carry the vCPU's identity and
the mask of SMT siblings it may co-run with. The guest builds the VMSA itself
when bringing up an AP, so populate both fields there, before the page is
turned into a VMSA and while it is still writable.

[ bp: Massage, move the threads trusting each-other to a comment in
the code. ]

Signed-off-by: Pratik R. Sampat <prsampat@xxxxxxx>
Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
Reviewed-by: Tom Lendacky <thomas.lendacky@xxxxxxx>
Link: https://patch.msgid.link/4dd1bdbceacf5ebbde07899f8b20e052435ee2eb.1794935627.git.prsampat@xxxxxxx
---
arch/x86/boot/compressed/sev.c | 6 ++++--
arch/x86/coco/sev/core.c | 9 +++++++++
arch/x86/include/asm/msr-index.h | 4 +++-
3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/arch/x86/boot/compressed/sev.c b/arch/x86/boot/compressed/sev.c
index c6512f2..4e0fa5a 100644
--- a/arch/x86/boot/compressed/sev.c
+++ b/arch/x86/boot/compressed/sev.c
@@ -188,7 +188,8 @@ bool sev_es_check_ghcb_fault(unsigned long address)
MSR_AMD64_SNP_RESERVED_BIT13 | \
MSR_AMD64_SNP_RESERVED_BIT15 | \
MSR_AMD64_SNP_SECURE_AVIC | \
- MSR_AMD64_SNP_RESERVED_BITS19_22 | \
+ MSR_AMD64_SNP_ESMT_PROT | \
+ MSR_AMD64_SNP_RESERVED_BITS20_22 | \
MSR_AMD64_SNP_RESERVED_MASK)

#ifdef CONFIG_AMD_SECURE_AVIC
@@ -204,7 +205,8 @@ bool sev_es_check_ghcb_fault(unsigned long address)
*/
#define SNP_FEATURES_IMPL (MSR_AMD64_SNP_DEBUG_SWAP | \
MSR_AMD64_SNP_SECURE_TSC | \
- SNP_FEATURE_SECURE_AVIC)
+ SNP_FEATURE_SECURE_AVIC | \
+ MSR_AMD64_SNP_ESMT_PROT)

u64 snp_get_unsupported_features(u64 status)
{
diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c
index eb2e853..9631f83 100644
--- a/arch/x86/coco/sev/core.c
+++ b/arch/x86/coco/sev/core.c
@@ -89,6 +89,7 @@ static const char * const sev_status_feat_names[] = {
[MSR_AMD64_SNP_VMSA_REG_PROT_BIT] = "VMSARegProt",
[MSR_AMD64_SNP_SMT_PROT_BIT] = "SMTProt",
[MSR_AMD64_SNP_SECURE_AVIC_BIT] = "SecureAVIC",
+ [MSR_AMD64_SNP_ESMT_PROT_BIT] = "ESMTProt",
[MSR_AMD64_SNP_IBPB_ON_ENTRY_BIT] = "IBPBOnEntry",
};

@@ -849,6 +850,14 @@ static int wakeup_cpu_via_vmgexit(u32 apic_id, unsigned long start_ip, unsigned
vmsa->vmpl = snp_vmpl;
vmsa->sev_features = sev_status >> 2;

+ if (sev_status & MSR_AMD64_SEV_SNP_ENABLED &&
+ (sev_status & MSR_AMD64_SNP_ESMT_PROT)) {
+ vmsa->vcpu_id = apic_id;
+
+ /* all threads trust each other by default */
+ vmsa->vcpu_sibling_mask = U32_MAX;
+ }
+
/* Populate AP's TSC scale/offset to get accurate TSC values. */
if (cc_platform_has(CC_ATTR_GUEST_SNP_SECURE_TSC)) {
vmsa->tsc_scale = snp_tsc_scale;
diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index c091482..83517f5 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -754,7 +754,9 @@
#define MSR_AMD64_SNP_SMT_PROT BIT_ULL(MSR_AMD64_SNP_SMT_PROT_BIT)
#define MSR_AMD64_SNP_SECURE_AVIC_BIT 18
#define MSR_AMD64_SNP_SECURE_AVIC BIT_ULL(MSR_AMD64_SNP_SECURE_AVIC_BIT)
-#define MSR_AMD64_SNP_RESERVED_BITS19_22 GENMASK_ULL(22, 19)
+#define MSR_AMD64_SNP_ESMT_PROT_BIT 19
+#define MSR_AMD64_SNP_ESMT_PROT BIT_ULL(MSR_AMD64_SNP_ESMT_PROT_BIT)
+#define MSR_AMD64_SNP_RESERVED_BITS20_22 GENMASK_ULL(22, 20)
#define MSR_AMD64_SNP_IBPB_ON_ENTRY_BIT 23
#define MSR_AMD64_SNP_IBPB_ON_ENTRY BIT_ULL(MSR_AMD64_SNP_IBPB_ON_ENTRY_BIT)
#define MSR_AMD64_SNP_RESV_BIT 24