Re: [RFC PATCH v2 5/6] tpm: add SNP SVSM vTPM driver

Stefano Garzarella
2025-03-03T16:19:15Z

On Fri, Feb 28, 2025 at 08:28:19PM -0400, Jason Gunthorpe wrote:
>On Fri, Feb 28, 2025 at 06:07:19PM +0100, Stefano Garzarella wrote:
>> +/*
>> + * tpm_svsm_remove() lives in .exit.text. For drivers registered via
>> + * module_platform_driver_probe() this is ok because they cannot get unbound
>> + * at runtime. So mark the driver struct with __refdata to prevent modpost
>> + * triggering a section mismatch warning.
>> + */
>
>??? Is that really true? I didn't know that

I initially followed drivers/virt/coco/sev-guest/sev-guest.c to figure
out how to clean a driver registered with
module_platform_driver_probe(), then I saw that pattern with the same
comment is used in several other drivers.

>
>I thought you could unbind anything using /sys/../unbind?

I can't see `unbind` for this driver:

$ ls /sys/bus/platform/drivers/tpm-svsm/
module tpm-svsm uevent

While I can see it for example for others like fw_cfg:

$ ls /sys/bus/platform/drivers/fw_cfg
bind module QEMU0002:00 uevent unbind

BTW I can unload the `tpm-svsm` module. Loading it again will cause
issues if I don't have a remove function that calls
tpm_chip_unregister().

Thanks,
Stefano