Re: [PATCH v6 4/4] x86/sev: register tpm-svsm platform device

Stefano Garzarella
2025-04-09T10:43:15Z

On Wed, 9 Apr 2025 at 12:21, Borislav Petkov <bp@alien8.de> wrote:
>
> On Tue, Apr 08, 2025 at 01:54:07PM +0200, Stefano Garzarella wrote:
> > I see, so IIUC I can just apply the following change to this patch and avoid
> > to export snp_svsm_vtpm_probe() at all, right?
> >
> > diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c
> > index acbd9bc526b1..fa83e6c7f990 100644
> > --- a/arch/x86/coco/sev/core.c
> > +++ b/arch/x86/coco/sev/core.c
> > @@ -2702,8 +2702,10 @@ 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;
> > + if (snp_svsm_vtpm_probe()) {
> > + if (platform_device_register(&tpm_svsm_device))
> > + return -ENODEV;
> > + }
> > pr_info("SNP guest platform device initialized.\n");
> > return 0;
>
> No, this should go in tpm_svsm_probe().

Sorry, maybe I missed something.

tpm_svsm.c registers the driver with module_platform_driver_probe().

Someone (the platform I guess) has to register the device by calling
platform_device_register(), as we already do for example for
sev_guest.

If we move platform_device_register() to tpm_svsm_probe() how will the
probe be invoked?

Thanks,
Stefano