From: "Jörg Rödel" <joro@8bytes.org>
To: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org
Cc: hpa@zytor.com, Tom Lendacky <thomas.lendacky@amd.com>,
joro@8bytes.org, linux-kernel@vger.kernel.org,
linux-coco@lists.linux.dev, Joerg Roedel <joerg.roedel@amd.com>
Subject: [PATCH 2/3] x86/sev: Create /sys/devices/system/cpu/sev/ for all SEV guests
Date: Mon, 3 Aug 2026 14:58:26 +0200 [thread overview]
Message-ID: <20260803125827.718024-3-joro@8bytes.org> (raw)
In-Reply-To: <20260803125827.718024-1-joro@8bytes.org>
From: Joerg Roedel <joerg.roedel@amd.com>
The SYSFS directory for SEV is only created for SEV-SNP guests right
now. Change it to create it for SEV and SEV-ES guests as well so
attributes available on all versions of SEV have a place.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
.../ABI/testing/sysfs-devices-system-cpu | 5 ++--
arch/x86/coco/sev/core.c | 29 ++++++++++++-------
2 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/Documentation/ABI/testing/sysfs-devices-system-cpu b/Documentation/ABI/testing/sysfs-devices-system-cpu
index 82d10d556cc8..63586e299aa8 100644
--- a/Documentation/ABI/testing/sysfs-devices-system-cpu
+++ b/Documentation/ABI/testing/sysfs-devices-system-cpu
@@ -694,10 +694,11 @@ Date: May 2024
Contact: Linux kernel mailing list <linux-kernel@vger.kernel.org>
Description: Secure Encrypted Virtualization (SEV) information
- This directory is only present when running as an SEV-SNP guest.
+ This directory is only present when running as an SEV guest.
vmpl: Reports the Virtual Machine Privilege Level (VMPL) at which
- the SEV-SNP guest is running.
+ the SEV-SNP guest is running. This file is only present
+ when running as an SEV-SNP guest.
What: /sys/devices/system/cpu/svm
diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c
index ecd77d3217f3..5770b99feb9b 100644
--- a/arch/x86/coco/sev/core.c
+++ b/arch/x86/coco/sev/core.c
@@ -1433,14 +1433,7 @@ static ssize_t vmpl_show(struct kobject *kobj,
static struct kobj_attribute vmpl_attr = __ATTR_RO(vmpl);
-static struct attribute *vmpl_attrs[] = {
- &vmpl_attr.attr,
- NULL
-};
-
-static struct attribute_group sev_attr_group = {
- .attrs = vmpl_attrs,
-};
+static struct attribute_group sev_attr_group = {};
static int __init sev_sysfs_init(void)
{
@@ -1448,7 +1441,7 @@ static int __init sev_sysfs_init(void)
struct device *dev_root;
int ret;
- if (!cc_platform_has(CC_ATTR_GUEST_SEV_SNP))
+ if (!cc_platform_has(CC_ATTR_GUEST_SEV))
return -ENODEV;
dev_root = bus_get_dev_root(&cpu_subsys);
@@ -1463,9 +1456,25 @@ static int __init sev_sysfs_init(void)
ret = sysfs_create_group(sev_kobj, &sev_attr_group);
if (ret)
- kobject_put(sev_kobj);
+ goto drop_kobj;
+
+ /* Add SEV-SNP specific attributes */
+ if (cc_platform_has(CC_ATTR_GUEST_SEV_SNP)) {
+ /* VMPL */
+ ret = sysfs_add_file_to_group(sev_kobj, &vmpl_attr.attr, NULL);
+ if (ret)
+ goto drop_sysfs;
+ }
+
+ return 0;
+
+drop_sysfs:
+ sysfs_remove_group(sev_kobj, &sev_attr_group);
+drop_kobj:
+ kobject_put(sev_kobj);
return ret;
+
}
arch_initcall(sev_sysfs_init);
#endif // CONFIG_SYSFS
--
2.53.0
next prev parent reply other threads:[~2026-08-03 12:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 12:58 [PATCH 0/3 v2] x86/sev: Report MSR_AMD64_SEV in SYSFS Jörg Rödel
2026-08-03 12:58 ` [PATCH 1/3] x86/coco: Add CC_ATTR_GUEST_SEV Jörg Rödel
2026-08-03 12:58 ` Jörg Rödel [this message]
2026-08-03 12:58 ` [PATCH 3/3] x86/coco/sev: Make SEV_STATUS available via SYSFS Jörg Rödel
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=20260803125827.718024-3-joro@8bytes.org \
--to=joro@8bytes.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=joerg.roedel@amd.com \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@kernel.org \
--cc=thomas.lendacky@amd.com \
--cc=x86@kernel.org \
/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