[RFC PATCH kernel 13/17] x86/sev: Pass HV features to sev-guest device via platform data
From: Alexey Kardashevskiy
Date: Wed Sep 16 2026 - 08:21:58 EST
The SEV HV advertises supported options via GHCB, the guest stores
bitmask in the SEV core.
The sev-guest device is a user visible platform device (/dev/sev-guest)
which provides the interface to communicate with the HV via GHCB.
It may choose to limit the functionality depending on what is available.
The first user is going to be SEV-TIO which is going to trigger creation
of "tsm" folders in the PCI sysfs but only if GHCB advertised such
support.
This should cause no behavioural change.
Signed-off-by: Alexey Kardashevskiy <aik@xxxxxxx>
---
arch/x86/coco/sev/core.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c
index cc292d7c6fd1..5b912f42f493 100644
--- a/arch/x86/coco/sev/core.c
+++ b/arch/x86/coco/sev/core.c
@@ -1381,11 +1381,6 @@ static int snp_issue_guest_request(struct snp_guest_req *req)
return ret;
}
-static struct platform_device sev_guest_device = {
- .name = "sev-guest",
- .id = -1,
-};
-
static struct platform_device tpm_svsm_device = {
.name = "tpm-svsm",
.id = -1,
@@ -1393,10 +1388,17 @@ static struct platform_device tpm_svsm_device = {
static int __init snp_init_platform_device(void)
{
+ struct platform_device *dev;
+
if (!cc_platform_has(CC_ATTR_GUEST_SEV_SNP))
return -ENODEV;
- if (platform_device_register(&sev_guest_device))
+ dev = platform_device_register_data(NULL, "sev-guest", -1,
+ &sev_hv_features,
+ sizeof(sev_hv_features));
+ if (IS_ERR(dev))
+ return PTR_ERR(dev);
+ if (!dev)
return -ENODEV;
if (snp_svsm_vtpm_probe() &&
--
2.55.0