From mboxrd@z Thu Jan 1 00:00:00 1970 From: AKASHI Takahiro Date: Fri, 12 Mar 2021 13:44:56 +0900 Subject: [PATCH 5/6] efidebug: add multiple device path instances on Boot#### In-Reply-To: <20210305222303.2866284-5-ilias.apalodimas@linaro.org> References: <20210305222303.2866284-1-ilias.apalodimas@linaro.org> <20210305222303.2866284-5-ilias.apalodimas@linaro.org> Message-ID: <20210312044456.GC15112@laputa> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Ilias, Sorry, but I will have to repeat my question for better understandings. On Sat, Mar 06, 2021 at 12:23:01AM +0200, Ilias Apalodimas wrote: > The UEFI spec allow a packed array of UEFI device paths in the > FilePathList[] of an EFI_LOAD_OPTION. The first file path must > describe the loaded image but the rest are OS specific. > > Previous patches parse the device path and try to use the second > member of the array as an initrd. So let's modify efidebug slightly > and install the second file described in the command line as the > initrd device path. > > Signed-off-by: Ilias Apalodimas > --- > cmd/efidebug.c | 193 ++++++++++++++---- > doc/board/emulation/qemu_capsule_update.rst | 4 +- > doc/uefi/uefi.rst | 2 +- > .../test_efi_capsule/test_capsule_firmware.py | 6 +- > test/py/tests/test_efi_secboot/test_signed.py | 16 +- > .../test_efi_secboot/test_signed_intca.py | 8 +- > .../tests/test_efi_secboot/test_unsigned.py | 8 +- > 7 files changed, 179 insertions(+), 58 deletions(-) > > diff --git a/cmd/efidebug.c b/cmd/efidebug.c > index bbbcb0a54643..9a1c471a3eaa 100644 > --- a/cmd/efidebug.c > +++ b/cmd/efidebug.c > @@ -9,6 +9,8 @@ > #include > #include > #include > +#include > +#include > #include > #include > #include > @@ -19,6 +21,7 @@ > #include > #include > #include > +#include > > #define BS systab.boottime > #define RT systab.runtime > @@ -794,6 +797,65 @@ static int do_efi_show_tables(struct cmd_tbl *cmdtp, int flag, > return CMD_RET_SUCCESS; > } > > +/** > + * add_initrd_instance() - Append a device path to load_options pointing to an > + * inirtd > + * > + * @argc: Number of arguments > + * @argv: Argument array > + * @file_path Existing device path, the new instance will be appended > + * Return: Pointer to the device path or ERR_PTR > + * > + */ > +static > +struct efi_device_path *add_initrd_instance(const char *dev, const char *part, > + const char *file, > + const struct efi_device_path *fp, > + efi_uintn_t *fp_size) > +{ > + struct efi_device_path *tmp_dp = NULL, *tmp_fp = NULL; > + struct efi_device_path *final_fp = NULL, *initrd_dp = NULL; > + efi_status_t ret; > + const struct efi_initrd_dp id_dp = { > + .vendor = { > + { > + DEVICE_PATH_TYPE_MEDIA_DEVICE, > + DEVICE_PATH_SUB_TYPE_VENDOR_PATH, > + sizeof(id_dp.vendor), > + }, > + EFI_INITRD_MEDIA_GUID, > + }, > + .end = { > + DEVICE_PATH_TYPE_END, > + DEVICE_PATH_SUB_TYPE_END, > + sizeof(id_dp.end), > + } > + }; > + > + ret = efi_dp_from_name(dev, part, file, &tmp_dp, &tmp_fp); > + if (ret != EFI_SUCCESS) { > + printf("Cannot create device path for \"%s %s\"\n", part, file); > + goto out; > + } > + > + initrd_dp = > + efi_dp_append_instance((const struct efi_device_path *)&id_dp, > + tmp_fp); > + if (!initrd_dp) { > + printf("Cannot append media vendor device path path\n"); > + goto out; > + } > + final_fp = efi_dp_concat(fp, initrd_dp); > + *fp_size = efi_dp_size(fp) + efi_dp_size(initrd_dp) + > + (2 * sizeof(struct efi_device_path)); > + > +out: > + efi_free_pool(initrd_dp); > + efi_free_pool(tmp_dp); > + efi_free_pool(tmp_fp); > + return final_fp ? final_fp : ERR_PTR(-EINVAL); > +} > + > /** > * do_efi_boot_add() - set UEFI load option > * > @@ -806,7 +868,9 @@ static int do_efi_show_tables(struct cmd_tbl *cmdtp, int flag, > * > * Implement efidebug "boot add" sub-command. Create or change UEFI load option. > * > - * efidebug boot add