[RFC 08/14] efi_loader: capsule: support firmware update

Sughosh Ganu sughosh.ganu at linaro.org
Wed Mar 18 15:09:58 CET 2020


On Tue, 17 Mar 2020 at 07:42, AKASHI Takahiro <takahiro.akashi at linaro.org>
wrote:

> A capsule tagged with the guid, EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID,
> is handled as a firmware update object.
> What efi_update_capsule() basically does is to load any firmware management
> protocol (or fmp) drivers contained in a capsule, find out an appropriate
> fmp driver and then invoke its set_image() interface against each binary
> in a capsule.
> In this commit, however, installing drivers is not supported yet.
>
> The result of applying a capsule is set to be stored in "CapsuleXXXX"
> variable, but its implementation is deferred to a fmp driver.
>
> Signed-off-by: AKASHI Takahiro <takahiro.akashi at linaro.org>
> ---
>  include/efi_api.h            | 127 +++++++++++++++++++++++++++
>  lib/efi_loader/Kconfig       |  12 +++
>  lib/efi_loader/efi_capsule.c | 165 +++++++++++++++++++++++++++++++++++
>  lib/efi_loader/efi_setup.c   |   4 +
>  4 files changed, 308 insertions(+)
>

<snip>


> diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
> index f3e2a555a6b9..f3526beed681 100644
> --- a/lib/efi_loader/efi_capsule.c
> +++ b/lib/efi_loader/efi_capsule.c
> @@ -14,10 +14,164 @@
>  #include <sort.h>
>

<snip>


>  /*
>   * Launch a capsule
>   */
> @@ -54,6 +208,17 @@ efi_status_t EFIAPI efi_update_capsule(
>         ret = EFI_SUCCESS;
>         for (i = 0, capsule = *capsule_header_array; i < capsule_count;
>              i++, capsule = *(++capsule_header_array)) {
> +               EFI_PRINT("EFI Capsule (guid:%pUl)\n",
> &capsule->capsule_guid);
> +               if (!guidcmp(&capsule->capsule_guid,
> +                            &efi_guid_firmware_management_capsule_id))
> +                       ret  = efi_capsule_update_firmware(
> +                                       (struct
> efi_firmware_management_capsule_header *)
> +                                       ((void *)capsule +
> sizeof(*capsule)));
>

Instead of sizeof(*capsule), please use header_size member of
efi_capsule_header. The spec mentions that the size of the capsule header
might be larger than the capsule header structure. Moreover, when testing
with a capsule built from the edk2 capsule generation script, i do see that
the header_size is greater than sizeof(efi_capsule_header).

-sughosh


More information about the U-Boot mailing list