[SRU][N:linux-gcp][PATCH v2 23/24] x86/sev: Register tpm-svsm platform device

Ian Whitfield ian.whitfield at canonical.com
Mon Jun 23 20:48:21 UTC 2025


From: Stefano Garzarella <sgarzare at redhat.com>

BugLink: https://bugs.launchpad.net/bugs/2111956

SNP platform can provide a vTPM device emulated by SVSM.

The "tpm-svsm" device can be handled by the platform driver registered by the
x86/sev core code.

Register the platform device only when SVSM is available and it supports vTPM
commands as checked by snp_svsm_vtpm_probe().

  [ bp: Massage commit message. ]

Signed-off-by: Stefano Garzarella <sgarzare at redhat.com>
Signed-off-by: Borislav Petkov (AMD) <bp at alien8.de>
Reviewed-by: Tom Lendacky <thomas.lendacky at amd.com>
Reviewed-by: Jarkko Sakkinen <jarkko at kernel.org>
Link: https://lore.kernel.org/r/20250410135118.133240-5-sgarzare@redhat.com
(cherry picked from commit e396dd85172c6098e3b70b17e91424edc7bb2d8f)
Signed-off-by: Ian Whitfield <ian.whitfield at canonical.com>
---
 arch/x86/coco/sev/core.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c
index 093c55293268..fa11788b2b5d 100644
--- a/arch/x86/coco/sev/core.c
+++ b/arch/x86/coco/sev/core.c
@@ -2549,6 +2549,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)
 {
 	struct sev_guest_platform_data data;
@@ -2568,7 +2573,11 @@ static int __init snp_init_platform_device(void)
 	if (platform_device_register(&sev_guest_device))
 		return -ENODEV;
 
-	pr_info("SNP guest platform device initialized.\n");
+	if (snp_svsm_vtpm_probe() &&
+	    platform_device_register(&tpm_svsm_device))
+		return -ENODEV;
+
+	pr_info("SNP guest platform devices initialized.\n");
 	return 0;
 }
 device_initcall(snp_init_platform_device);
-- 
2.43.0




More information about the kernel-team mailing list