On Mon, 28 Feb 2022 at 14:07, Dov Murik <dovmurik@xxxxxxxxxxxxx> wrote: > > > > On 28/02/2022 14:49, Ard Biesheuvel wrote: > > On Mon, 28 Feb 2022 at 12:43, Dov Murik <dovmurik@xxxxxxxxxxxxx> wrote: > >> > >> If the efi_secret module is built, register a late_initcall in the EFI > >> driver which checks whether the EFI secret area is available and > >> populated, and then requests to load the efi_secret module. > >> > >> This will cause the <securityfs>/secrets/coco directory to appear in > >> guests into which secrets were injected; in other cases, the module is > >> not loaded. > >> > >> Signed-off-by: Dov Murik <dovmurik@xxxxxxxxxxxxx> > >> Reviewed-by: Gerd Hoffmann <kraxel@xxxxxxxxxx> > > > > It would be better to simply expose a platform device and associated > > driver, instead of hooking into the module machinery directly. > > > > We already do something similar for the EFI rtc and the efivars > > subsystem, using platform_device_register_simple() > > > > Thanks Ard, I'll look into this. > > I hope the mechanism you suggest allows me to perform complex check to > see if the device is really there (in this case: check for an efi > variable, map memory as encrypted, verify it starts with a specific GUID > -- everything before request_module() in the code below). > There is the device part and the driver part. Some of this belongs in the core code that registers the platform device, and some of it belongs in the driver. At this point, it probably does not matter that much which side does what, as the platform driver simply probes and can perform whatever check it needs, as long as it can back out gracefully (although I understand that, in this particular case, there are reasons why the driver may decide to wipe the secret)