[PATCH v4 4/4] x86/sev: register tpm-svsm platform device
From: Stefano Garzarella
Date: Mon Mar 24 2025 - 06:49:45 EST
From: Stefano Garzarella <sgarzare@xxxxxxxxxx>
SNP platform can provide a vTPM device emulated by SVSM.
The "tpm-svsm" device can be handled by the platform driver added
by the previous commit in drivers/char/tpm/tpm_svsm.c
Register the device unconditionally. The support check (e.g. SVSM, cmd)
is in snp_svsm_vtpm_probe(), keeping all logic in one place.
This function is called during the driver's probe along with other
setup tasks like memory allocation.
Signed-off-by: Stefano Garzarella <sgarzare@xxxxxxxxxx>
---
v4:
- explained better why we register it anyway in the commit message
---
arch/x86/coco/sev/core.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c
index 034aab7e76d2..0abcac87af89 100644
--- a/arch/x86/coco/sev/core.c
+++ b/arch/x86/coco/sev/core.c
@@ -2692,6 +2692,11 @@ static struct platform_device sev_guest_device = {
.id = -1,
};
+static struct platform_device tpm_svsm_device = {
+ .name = "tpm-svsm",
+ .id = -1,
+};
+
static int __init snp_init_platform_device(void)
{
if (!cc_platform_has(CC_ATTR_GUEST_SEV_SNP))
@@ -2700,6 +2705,9 @@ static int __init snp_init_platform_device(void)
if (platform_device_register(&sev_guest_device))
return -ENODEV;
+ if (platform_device_register(&tpm_svsm_device))
+ return -ENODEV;
+
pr_info("SNP guest platform device initialized.\n");
return 0;
}
--
2.49.0