Skip to contentSkip to conversation

x86/coco/sev: Make SEV_STATUS available via SYSFS

PATCH In review Jörg Rödel 2 participants 2 messages Jun 23 – Jul 12 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/coco/sev: Make SEV_STATUS available via SYSFS

From: Joerg Roedel <[email protected]>

Current user-space tooling which needs access to the SEV_STATUS MSR is using the MSR module. The use of this module poses a security risk in any trusted execution environment and is generally discouraged.

Instead, provide an file in SYSFS in the /sys/devices/system/cpu/sev/ directory to provide the value of the SEV_STATUS MSR to user-space.

---
 Documentation/ABI/testing/sysfs-devices-system-cpu | 4 ++++
 arch/x86/coco/sev/core.c                           | 8 ++++++++
 2 files changed, 12 insertions(+)
Documentation/ABI/testing/sysfs-devices-system-cpu +4 -0
index 82d10d556cc8..f7908ade4be8 100644
@@ -690,6 +690,7 @@ Description:	Umwait control
 
 What:		/sys/devices/system/cpu/sev
 		/sys/devices/system/cpu/sev/vmpl
+		/sys/devices/system/cpu/sev/sev_status
 Date:		May 2024
 Contact:	Linux kernel mailing list <[email protected]>
 Description:	Secure Encrypted Virtualization (SEV) information
@@ -699,6 +700,9 @@ Description:	Secure Encrypted Virtualization (SEV) information
 		vmpl: Reports the Virtual Machine Privilege Level (VMPL) at which
 		      the SEV-SNP guest is running.
 
+		sev_status: Reports the value of the SEV_STATUS MSR which
+			    enumerates the enabled features of an SEV-SNP
+			    environment.
 
 What:		/sys/devices/system/cpu/svm
 Date:		August 2019
arch/x86/coco/sev/core.c +8 -0
index 7ed3da998489..557c1f230cb9 100644
@@ -1435,10 +1435,18 @@ static ssize_t vmpl_show(struct kobject *kobj,
 	return sysfs_emit(buf, "%d\n", snp_vmpl);
 }
 
+static ssize_t sev_status_show(struct kobject *kobj,
+			       struct kobj_attribute *attr, char *buf)
+{
+	return sysfs_emit(buf, "0x%llx\n", sev_status);
+}
+
 static struct kobj_attribute vmpl_attr = __ATTR_RO(vmpl);
+static struct kobj_attribute sev_status_attr = __ATTR_RO(sev_status);
 
 static struct attribute *vmpl_attrs[] = {
 	&vmpl_attr.attr,
+	&sev_status_attr.attr,
 	NULL
 };
 
Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 6 lines · Jörg Rödel

From: Joerg Roedel <[email protected]>

Current user-space tooling which needs access to the SEV_STATUS MSR is using the MSR module. The use of this module poses a security risk in any trusted execution environment and is generally discouraged.

Quoted 8 lines

Instead, provide an file in SYSFS in the /sys/devices/system/cpu/sev/ directory to provide the value of the SEV_STATUS MSR to user-space.

---
 Documentation/ABI/testing/sysfs-devices-system-cpu | 4 ++++
 arch/x86/coco/sev/core.c                           | 8 ++++++++
 2 files changed, 12 insertions(+)

Sashiko does have a point...

https://sashiko.dev/#/patchset/20260623073820.1479769-1-joro%408bytes.org

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette