From: Gokul K <gokul02k@gmail.com>
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: "H. Peter Anvin" <hpa@zytor.com>,
Stefano Garzarella <sgarzare@redhat.com>,
Tom Lendacky <thomas.lendacky@amd.com>,
Jarkko Sakkinen <jarkko@kernel.org>,
linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH] x86/sev: Do not fail SNP platform init if the vTPM cannot be registered
Date: Fri, 21 Aug 2026 11:04:11 +0530 [thread overview]
Message-ID: <20260821053411.1215497-1-gokul02k@gmail.com> (raw)
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
next reply other threads:[~2026-08-21 5:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 5:34 Gokul K [this message]
2026-09-10 8:24 ` Stefano Garzarella
2026-09-12 18:24 ` Gokul K
2026-09-14 7:48 ` Stefano Garzarella
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=20260821053411.1215497-1-gokul02k@gmail.com \
--to=gokul02k@gmail.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jarkko@kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=sgarzare@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
all inboxes | Powered by JetHome®