From: Stefano Garzarella <sgarzare@redhat.com>
To: Gokul K <gokul02k@gmail.com>
Cc: 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, "H. Peter Anvin" <hpa@zytor.com>,
Tom Lendacky <thomas.lendacky@amd.com>,
Jarkko Sakkinen <jarkko@kernel.org>,
linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/sev: Do not fail SNP platform init if the vTPM cannot be registered
Date: Thu, 10 Sep 2026 10:24:41 +0200 [thread overview]
Message-ID: <aqJoJBNEpyKpKKix@sgarzare-redhat> (raw)
In-Reply-To: <20260821053411.1215497-1-gokul02k@gmail.com>
On Fri, Aug 21, 2026 at 11:04:11AM +0530, Gokul K wrote:
>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");
IIUC platform_device_register() fails only if something is really bad,
no memory, device already registered, etc. so IMO this should never
happen.
I'm opposed convert to an error message, but honestly I don't understand
which problem we are fixing.
Stefano
>
> pr_info("SNP guest platform devices initialized.\n");
> return 0;
>--
>2.54.0
>
>
next prev parent reply other threads:[~2026-09-10 8:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 5:34 [PATCH] x86/sev: Do not fail SNP platform init if the vTPM cannot be registered Gokul K
2026-09-10 8:24 ` Stefano Garzarella [this message]
2026-09-12 18:24 ` Gokul K
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=aqJoJBNEpyKpKKix@sgarzare-redhat \
--to=sgarzare@redhat.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=gokul02k@gmail.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=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.