[PATCH 1/3] x86/coco: Add CC_ATTR_GUEST_SEV
From: Jörg Rödel
Date: Mon Aug 03 2026 - 09:14:59 EST
From: Joerg Roedel <joerg.roedel@xxxxxxx>
Add a new attribute to the CC platform code to check whether the
kernel runs in an environment using SEV memory encryption. This will
be used to establish the an sev/ directory in SYSFS (which is
currently SEV-SNP-only).
Signed-off-by: Joerg Roedel <joerg.roedel@xxxxxxx>
---
arch/x86/coco/core.c | 3 +++
include/linux/cc_platform.h | 9 +++++++++
2 files changed, 12 insertions(+)
diff --git a/arch/x86/coco/core.c b/arch/x86/coco/core.c
index 989ca9f72ba3..63c06c2ac409 100644
--- a/arch/x86/coco/core.c
+++ b/arch/x86/coco/core.c
@@ -95,6 +95,9 @@ static bool noinstr amd_cc_platform_has(enum cc_attr attr)
return (sev_status & MSR_AMD64_SEV_ENABLED) &&
!(sev_status & MSR_AMD64_SEV_ES_ENABLED);
+ case CC_ATTR_GUEST_SEV:
+ return sev_status & MSR_AMD64_SEV_ENABLED;
+
case CC_ATTR_GUEST_SEV_SNP:
return sev_status & MSR_AMD64_SEV_SNP_ENABLED;
diff --git a/include/linux/cc_platform.h b/include/linux/cc_platform.h
index 559353ad64ac..f87ee0652b04 100644
--- a/include/linux/cc_platform.h
+++ b/include/linux/cc_platform.h
@@ -73,6 +73,15 @@ enum cc_attr {
*/
CC_ATTR_GUEST_UNROLL_STRING_IO,
+ /**
+ * @CC_ATTR_GUEST_SEV: Guest SEV is active.
+ *
+ * The platform/OS is running as a virtual machine guest and actively
+ * using AMD SEV memory encryption. This is true for SEV, SEV-ES, and
+ * SEV-SNP guests.
+ */
+ CC_ATTR_GUEST_SEV,
+
/**
* @CC_ATTR_GUEST_SEV_SNP: Guest SNP is active.
*
--
2.53.0