* [PATCH] x86/sev: Do not fail SNP platform init if the vTPM cannot be registered
@ 2026-08-21 5:34 Gokul K
0 siblings, 0 replies; only message in thread
From: Gokul K @ 2026-08-21 5:34 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86
Cc: H. Peter Anvin, Stefano Garzarella, Tom Lendacky, Jarkko Sakkinen,
linux-coco, linux-kernel
The SVSM vTPM is optional: snp_svsm_vtpm_probe() returns false when no
SVSM is present or when it does not implement TPM_SEND_COMMAND, and
snp_init_platform_device() happily returns success in that case.
When the vTPM *is* available but registering its platform device fails,
the same function instead returns -ENODEV, after sev_guest_device has
already been registered. That is worse than the absent-vTPM case in two
ways: the sev-guest device is left registered while the initcall reports
failure, and the error tells nobody anything, because the return value of
a device_initcall is only ever traced, never acted upon.
Log the failure and carry on, so an optional device that could not be
registered no longer determines the fate of an unrelated one. The vTPM
is simply absent, which is a state the guest already has to cope with.
Fixes: e396dd85172c ("x86/sev: Register tpm-svsm platform device")
Signed-off-by: Gokul K <gokul02k@gmail.com>
---
Compile-tested only. Reaching the failure path needs an SNP guest under an
SVSM whose vTPM platform device fails to register, which in practice means
-ENOMEM during initcalls; I have no way to reproduce that. Built at W=1 with
CONFIG_AMD_MEM_ENCRYPT=y, and confirmed the file is not built with it =n.
arch/x86/coco/sev/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c
index ecd77d3217f3..6501b6f7469a 100644
--- a/arch/x86/coco/sev/core.c
+++ b/arch/x86/coco/sev/core.c
@@ -1401,7 +1401,7 @@ static int __init snp_init_platform_device(void)
if (snp_svsm_vtpm_probe() &&
platform_device_register(&tpm_svsm_device))
- return -ENODEV;
+ pr_err("Failed to register the SVSM vTPM device\n");
pr_info("SNP guest platform devices initialized.\n");
return 0;
--
2.54.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-08-21 5:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-21 5:34 [PATCH] x86/sev: Do not fail SNP platform init if the vTPM cannot be registered Gokul K
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox