On Wed, Dec 22, 2021 at 06:23:56PM +0100, Rafael J. Wysocki wrote: > On Wed, Dec 22, 2021 at 5:32 AM Chen Yu <yu.c.chen@xxxxxxxxx> wrote: > > > > Introduce the pfr_update driver which can be used for Platform Firmware > > Runtime code injection and driver update [1]. The user is expected to > > provide the EFI capsule, and pass it to the driver by writing the capsule > > to a device special file. The capsule is transferred by the driver to the > > platform firmware with the help of an ACPI _DSM method under the special > > ACPI Platform Firmware Runtime Update device (INTC1080), and the actual > > firmware update is carried out by the low-level Management Mode code in > > the platform firmware. > > > > This patch allows certain pieces of the platform firmware to be > > updated on the fly while the system is running (runtime) without the > > need to restart it, which is key in the cases when the system needs to > > be available 100% of the time and it cannot afford the downtime related > > to restarting it, or when the work carried out by the system is > > particularly important, so it cannot be interrupted, and it is not > > practical to wait until it is complete. > > > > Link: https://uefi.org/sites/default/files/resources/Intel_MM_OS_Interface_Spec_Rev100.pdf # [1] > > Cc: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> > > Cc: Ard Biesheuvel <ardb@xxxxxxxxxx> > > Cc: Ashok Raj <ashok.raj@xxxxxxxxx> > > Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> > > Cc: Len Brown <lenb@xxxxxxxxxx> > > Cc: Mike Rapoport <rppt@xxxxxxxxxx> > > Cc: "Rafael J. Wysocki" <rafael@xxxxxxxxxx> > > Tested-by: Hongyu Ning <hongyu.ning@xxxxxxxxx> > > Signed-off-by: Chen Yu <yu.c.chen@xxxxxxxxx> > > --- > > [cut history] > [...] > > +static bool applicable_image(const void *data, struct pfru_update_cap_info *cap, > > + struct pfru_device *pfru_dev) > > +{ > > + struct pfru_payload_hdr *payload_hdr; > > + const efi_capsule_header_t *cap_hdr = data; > > + const struct efi_manage_capsule_header *m_hdr; > > + const struct efi_manage_capsule_image_header *m_img_hdr; > > + const struct efi_image_auth *auth; > > + int type, size; > > + > > + /* > > + * If the code in the capsule is older than the current > > + * firmware code, the update will be rejected by the firmware, > > + * so check the version of it upfront without engaging the > > + * Management Mode update mechanism which may be costly. > > + */ > > Since we are worrying so much about engaging the Management Mode in > vain, it is somewhat inconsistent to only check the firmware version > information and avoid doing some general sanity checks on the capsule > image (for example, whether or not the image size value in the header > is consistent with the image size etc.). > > I'm not asking for another version of this patch, but something like a > follow-up change adding more sanity checks on top of this series. > Ok, I'll sync with specification team and then enhance the sanity check in a follow-up change. thanks, Chenyu