On Wed, 2025-04-09 at 13:31 +0200, Borislav Petkov wrote: > On Wed, Apr 09, 2025 at 12:43:01PM +0200, Stefano Garzarella wrote: > > 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. > > Maybe that platform device thing is the wrong approach. Why does the > core code need to register some dummy platform device in the first > place? Why can't drivers/char/tpm/tpm_svsm.c probe and init without > it?
Because of the way driver and device matching works in Linux. We have to have a struct device because that sits at the he heart of the TPM driver binding. If we have a struct device, it has to sit on a bus (because that's the Linux design) and if we don't have a bus then we have to use a platform device (or, now, we could use a struct device on the faux bus). Busses can be either physical (PCI, GSC, ...) and abstract (virtio, xen, scsi, ...), so it's not impossible, if the SVSM has more than one device, that it should have it's own SVSM bus which we could then act a bit like the virtio bus and the SVSM vTPM struct device could sit on this (the TPM subsystem, like most driver subsystems, doesn't care about busses, it only cares that the abstract bus device id matching works). Regards, James