From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
To: Raymond Mao <raymond.mao@linaro.org>
Cc: u-boot@lists.denx.de, Heinrich Schuchardt <xypron.glpk@gmx.de>,
Masahisa Kojima <masahisa.kojima@linaro.org>,
Simon Glass <sjg@chromium.org>
Subject: Re: [PATCH 1/2] Boot var automatic management for removable medias
Date: Mon, 3 Apr 2023 13:34:07 +0300 [thread overview]
Message-ID: <ZCqrn4tfVoSyYGIb@hera> (raw)
In-Reply-To: <20230328164806.475324-1-raymond.mao@linaro.org>
Hi Raymond,
[...]
> + }
> + }
> + }
> +
> +out:
> + if (opt) {
> + for (i = 0; i < count; i++) {
> + if (opt[i].lo)
> + free(opt[i].lo);
> + }
> + free(opt);
> + }
> + efi_free_pool(volume_handles);
> +
> + return ret;
> +}
> diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
> index d2256713a8..1309e28134 100644
> --- a/lib/efi_loader/efi_disk.c
> +++ b/lib/efi_loader/efi_disk.c
> @@ -687,6 +687,13 @@ int efi_disk_probe(void *ctx, struct event *event)
> return -1;
> }
>
> + /* only do the boot option management when UEFI sub-system is initialized */
> + if (efi_obj_list_initialized == EFI_SUCCESS) {
> + ret = efi_bootmgr_update_media_device_boot_option();
I am not sure if this is the problem, but with these patches applied and no
media attached QEMU fails to initialize the EFI sub-system. IOW running
qemu-system-aarch64 -bios u-boot.bin -machine virt,secure=off -cpu cortex-a53 -m 2G -nographic -no-acpi
=> efidebug boot dump
No EFI system partition
Error: Cannot initialize UEFI sub-system, r = 14
We should always start EFI, even if scanning for boot options fails.
> + if (ret)
> + return -1;
> + }
> +
> return 0;
> }
>
> diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c
> index 1f4ab2b419..cdfd16ea77 100644
> --- a/lib/efi_loader/efi_helper.c
> +++ b/lib/efi_loader/efi_helper.c
> @@ -257,3 +257,28 @@ efi_status_t efi_next_variable_name(efi_uintn_t *size, u16 **buf, efi_guid_t *gu
>
> return ret;
> }
> +
> +/**
> + * efi_search_bootorder() - search the boot option index in BootOrder
> + *
> + * @bootorder: pointer to the BootOrder variable
> + * @num: number of BootOrder entry
> + * @target: target boot option index to search
> + * @index: pointer to store the index of BootOrder variable
> + * Return: true if exists, false otherwise
> + */
> +bool efi_search_bootorder(u16 *bootorder, efi_uintn_t num, u32 target, u32 *index)
> +{
> + u32 i;
> +
> + for (i = 0; i < num; i++) {
> + if (target == bootorder[i]) {
> + if (index)
> + *index = i;
> +
> + return true;
> + }
> + }
> +
> + return false;
> +}
> diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c
> index be95ed44e6..2f251553e1 100644
> --- a/lib/efi_loader/efi_variable.c
> +++ b/lib/efi_loader/efi_variable.c
> @@ -476,6 +476,10 @@ efi_status_t efi_init_variables(void)
> log_err("Invalid EFI variable seed\n");
> }
>
> + ret = efi_init_secure_state();
> + if (ret != EFI_SUCCESS)
> + return ret;
>
> - return efi_init_secure_state();
> + /* update boot option management after variable service initialized */
> + return efi_bootmgr_update_media_device_boot_option();
> }
> diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c
> index dfef18435d..a48d313ef0 100644
> --- a/lib/efi_loader/efi_variable_tee.c
> +++ b/lib/efi_loader/efi_variable_tee.c
> @@ -748,5 +748,6 @@ efi_status_t efi_init_variables(void)
> if (ret != EFI_SUCCESS)
> return ret;
>
> - return EFI_SUCCESS;
> + /* update boot option management after variable service initialized */
> + return efi_bootmgr_update_media_device_boot_option();
> }
> --
> 2.25.1
>
Regards
/Ilias
next prev parent reply other threads:[~2023-04-03 10:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-28 16:48 [PATCH 1/2] Boot var automatic management for removable medias Raymond Mao
2023-03-28 16:48 ` [PATCH 2/2] Load option with short device path for boot vars Raymond Mao
2023-04-03 10:34 ` Ilias Apalodimas [this message]
2023-04-05 0:14 ` [PATCH 1/2] Boot var automatic management for removable medias Raymond Mao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZCqrn4tfVoSyYGIb@hera \
--to=ilias.apalodimas@linaro.org \
--cc=masahisa.kojima@linaro.org \
--cc=raymond.mao@linaro.org \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox