[PATCH 1/1] sandbox: add bootmethod EFI boot-manager

The EFI boot-manager is the default method to boot EFI binaries. We should be able to use it on the Sandbox.
* Enable EFI boot-manager bootmethod on the sandbox. * Adjust unit tests to reflect the additional boot method.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com --- arch/sandbox/dts/test.dts | 4 ++++ test/boot/bootmeth.c | 28 +++++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 8412506c17a..1248ed66089 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -119,6 +119,10 @@ compatible = "u-boot,distro-efi"; };
+ efimgr { + compatible = "u-boot,efi-bootmgr"; + }; + theme { font-size = <30>; menu-inset = <3>; diff --git a/test/boot/bootmeth.c b/test/boot/bootmeth.c index 518d99c4a27..fe175ccb755 100644 --- a/test/boot/bootmeth.c +++ b/test/boot/bootmeth.c @@ -21,11 +21,13 @@ static int bootmeth_cmd_list(struct unit_test_state *uts) ut_assert_nextlinen("---"); ut_assert_nextline(" 0 0 extlinux Extlinux boot from a block device"); ut_assert_nextline(" 1 1 efi EFI boot from an .efi file"); - if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL)) - ut_assert_nextline(" glob 2 firmware0 VBE simple"); + if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL)) { + ut_assert_nextline(" glob 2 efimgr EFI bootmgr flow"); + ut_assert_nextline(" glob 3 firmware0 VBE simple"); + } ut_assert_nextlinen("---"); ut_assert_nextline(IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) ? - "(3 bootmeths)" : "(2 bootmeths)"); + "(4 bootmeths)" : "(2 bootmeths)"); ut_assert_console_end();
return 0; @@ -56,11 +58,13 @@ static int bootmeth_cmd_order(struct unit_test_state *uts) ut_assert_nextlinen("---"); ut_assert_nextline(" 0 0 extlinux Extlinux boot from a block device"); ut_assert_nextline(" - 1 efi EFI boot from an .efi file"); - if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL)) - ut_assert_nextline(" glob 2 firmware0 VBE simple"); + if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL)) { + ut_assert_nextline(" glob 2 efimgr EFI bootmgr flow"); + ut_assert_nextline(" glob 3 firmware0 VBE simple"); + } ut_assert_nextlinen("---"); ut_assert_nextline(IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) ? - "(3 bootmeths)" : "(2 bootmeths)"); + "(4 bootmeths)" : "(2 bootmeths)"); ut_assert_console_end();
/* Check the -a flag with the reverse order */ @@ -71,11 +75,13 @@ static int bootmeth_cmd_order(struct unit_test_state *uts) ut_assert_nextlinen("---"); ut_assert_nextline(" 1 0 extlinux Extlinux boot from a block device"); ut_assert_nextline(" 0 1 efi EFI boot from an .efi file"); - if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL)) - ut_assert_nextline(" glob 2 firmware0 VBE simple"); + if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL)) { + ut_assert_nextline(" glob 2 efimgr EFI bootmgr flow"); + ut_assert_nextline(" glob 3 firmware0 VBE simple"); + } ut_assert_nextlinen("---"); ut_assert_nextline(IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) ? - "(3 bootmeths)" : "(2 bootmeths)"); + "(4 bootmeths)" : "(2 bootmeths)"); ut_assert_console_end();
/* Now reset the order to empty, which should show all of them again */ @@ -84,7 +90,7 @@ static int bootmeth_cmd_order(struct unit_test_state *uts) ut_assertnull(env_get("bootmeths")); ut_assertok(run_command("bootmeth list", 0)); ut_assert_skip_to_line(IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) ? - "(3 bootmeths)" : "(2 bootmeths)"); + "(4 bootmeths)" : "(2 bootmeths)");
/* Try reverse order */ ut_assertok(run_command("bootmeth order "efi extlinux"", 0)); @@ -116,7 +122,7 @@ static int bootmeth_cmd_order_glob(struct unit_test_state *uts) ut_assert_nextline("Order Seq Name Description"); ut_assert_nextlinen("---"); ut_assert_nextline(" 0 1 efi EFI boot from an .efi file"); - ut_assert_nextline(" glob 2 firmware0 VBE simple"); + ut_assert_nextline(" glob 3 firmware0 VBE simple"); ut_assert_nextlinen("---"); ut_assert_nextline("(2 bootmeths)"); ut_assertnonnull(env_get("bootmeths"));

On Tue, 8 Oct 2024 at 16:32, Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
The EFI boot-manager is the default method to boot EFI binaries. We should be able to use it on the Sandbox.
- Enable EFI boot-manager bootmethod on the sandbox.
- Adjust unit tests to reflect the additional boot method.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com
arch/sandbox/dts/test.dts | 4 ++++ test/boot/bootmeth.c | 28 +++++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

Hi Heinrich,
Thank you for the patch.
On mer., oct. 09, 2024 at 00:32, Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
The EFI boot-manager is the default method to boot EFI binaries. We should be able to use it on the Sandbox.
- Enable EFI boot-manager bootmethod on the sandbox.
- Adjust unit tests to reflect the additional boot method.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com
Reviewed-by: Mattijs Korpershoek mkorpershoek@baylibre.com
arch/sandbox/dts/test.dts | 4 ++++ test/boot/bootmeth.c | 28 +++++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 8412506c17a..1248ed66089 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -119,6 +119,10 @@ compatible = "u-boot,distro-efi"; };
efimgr {
compatible = "u-boot,efi-bootmgr";
};
- theme { font-size = <30>; menu-inset = <3>;
diff --git a/test/boot/bootmeth.c b/test/boot/bootmeth.c index 518d99c4a27..fe175ccb755 100644 --- a/test/boot/bootmeth.c +++ b/test/boot/bootmeth.c @@ -21,11 +21,13 @@ static int bootmeth_cmd_list(struct unit_test_state *uts) ut_assert_nextlinen("---"); ut_assert_nextline(" 0 0 extlinux Extlinux boot from a block device"); ut_assert_nextline(" 1 1 efi EFI boot from an .efi file");
- if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL))
ut_assert_nextline(" glob 2 firmware0 VBE simple");
- if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL)) {
ut_assert_nextline(" glob 2 efimgr EFI bootmgr flow");
ut_assert_nextline(" glob 3 firmware0 VBE simple");
- } ut_assert_nextlinen("---"); ut_assert_nextline(IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) ?
"(3 bootmeths)" : "(2 bootmeths)");
"(4 bootmeths)" : "(2 bootmeths)");
ut_assert_console_end();
return 0;
@@ -56,11 +58,13 @@ static int bootmeth_cmd_order(struct unit_test_state *uts) ut_assert_nextlinen("---"); ut_assert_nextline(" 0 0 extlinux Extlinux boot from a block device"); ut_assert_nextline(" - 1 efi EFI boot from an .efi file");
- if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL))
ut_assert_nextline(" glob 2 firmware0 VBE simple");
- if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL)) {
ut_assert_nextline(" glob 2 efimgr EFI bootmgr flow");
ut_assert_nextline(" glob 3 firmware0 VBE simple");
- } ut_assert_nextlinen("---"); ut_assert_nextline(IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) ?
"(3 bootmeths)" : "(2 bootmeths)");
"(4 bootmeths)" : "(2 bootmeths)");
ut_assert_console_end();
/* Check the -a flag with the reverse order */
@@ -71,11 +75,13 @@ static int bootmeth_cmd_order(struct unit_test_state *uts) ut_assert_nextlinen("---"); ut_assert_nextline(" 1 0 extlinux Extlinux boot from a block device"); ut_assert_nextline(" 0 1 efi EFI boot from an .efi file");
- if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL))
ut_assert_nextline(" glob 2 firmware0 VBE simple");
- if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL)) {
ut_assert_nextline(" glob 2 efimgr EFI bootmgr flow");
ut_assert_nextline(" glob 3 firmware0 VBE simple");
- } ut_assert_nextlinen("---"); ut_assert_nextline(IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) ?
"(3 bootmeths)" : "(2 bootmeths)");
"(4 bootmeths)" : "(2 bootmeths)");
ut_assert_console_end();
/* Now reset the order to empty, which should show all of them again */
@@ -84,7 +90,7 @@ static int bootmeth_cmd_order(struct unit_test_state *uts) ut_assertnull(env_get("bootmeths")); ut_assertok(run_command("bootmeth list", 0)); ut_assert_skip_to_line(IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) ?
"(3 bootmeths)" : "(2 bootmeths)");
"(4 bootmeths)" : "(2 bootmeths)");
/* Try reverse order */ ut_assertok(run_command("bootmeth order "efi extlinux"", 0));
@@ -116,7 +122,7 @@ static int bootmeth_cmd_order_glob(struct unit_test_state *uts) ut_assert_nextline("Order Seq Name Description"); ut_assert_nextlinen("---"); ut_assert_nextline(" 0 1 efi EFI boot from an .efi file");
- ut_assert_nextline(" glob 2 firmware0 VBE simple");
- ut_assert_nextline(" glob 3 firmware0 VBE simple"); ut_assert_nextlinen("---"); ut_assert_nextline("(2 bootmeths)"); ut_assertnonnull(env_get("bootmeths"));
-- 2.45.2

Hi Heinrich,
On Fri, 11 Oct 2024 at 08:27, Mattijs Korpershoek mkorpershoek@baylibre.com wrote:
Hi Heinrich,
Thank you for the patch.
On mer., oct. 09, 2024 at 00:32, Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
The EFI boot-manager is the default method to boot EFI binaries. We should be able to use it on the Sandbox.
- Enable EFI boot-manager bootmethod on the sandbox.
- Adjust unit tests to reflect the additional boot method.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com
Reviewed-by: Mattijs Korpershoek mkorpershoek@baylibre.com
arch/sandbox/dts/test.dts | 4 ++++ test/boot/bootmeth.c | 28 +++++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-)
This produces the following output on sandbox, for me:
=> bootfl scan efi_set_blk_dev_to_system_partition() No EFI system partition efi_set_blk_dev_to_system_partition() No EFI system partition efi_var_to_file() Failed to persist EFI variables efi_set_blk_dev_to_system_partition() No EFI system partition efi_var_to_file() Failed to persist EFI variables efi_set_blk_dev_to_system_partition() No EFI system partition efi_var_to_file() Failed to persist EFI variables efi_set_blk_dev_to_system_partition() No EFI system partition efi_var_to_file() Failed to persist EFI variables efi_set_blk_dev_to_system_partition() No EFI system partition efi_var_to_file() Failed to persist EFI variables efi_set_blk_dev_to_system_partition() No EFI system partition efi_var_to_file() Failed to persist EFI variables efi_set_blk_dev_to_system_partition() No EFI system partition efi_var_to_file() Failed to persist EFI variables
Perhaps we need to make this option, e.g. with a 'bootstd' command to enable it?
Regards, Simon

On 10/18/24 01:23, Simon Glass wrote:
Hi Heinrich,
On Fri, 11 Oct 2024 at 08:27, Mattijs Korpershoek mkorpershoek@baylibre.com wrote:
Hi Heinrich,
Thank you for the patch.
On mer., oct. 09, 2024 at 00:32, Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
The EFI boot-manager is the default method to boot EFI binaries. We should be able to use it on the Sandbox.
- Enable EFI boot-manager bootmethod on the sandbox.
- Adjust unit tests to reflect the additional boot method.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com
Reviewed-by: Mattijs Korpershoek mkorpershoek@baylibre.com
arch/sandbox/dts/test.dts | 4 ++++ test/boot/bootmeth.c | 28 +++++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-)
This produces the following output on sandbox, for me:
=> bootfl scan efi_set_blk_dev_to_system_partition() No EFI system partition efi_set_blk_dev_to_system_partition() No EFI system partition efi_var_to_file() Failed to persist EFI variables efi_set_blk_dev_to_system_partition() No EFI system partition efi_var_to_file() Failed to persist EFI variables efi_set_blk_dev_to_system_partition() No EFI system partition efi_var_to_file() Failed to persist EFI variables efi_set_blk_dev_to_system_partition() No EFI system partition efi_var_to_file() Failed to persist EFI variables efi_set_blk_dev_to_system_partition() No EFI system partition efi_var_to_file() Failed to persist EFI variables efi_set_blk_dev_to_system_partition() No EFI system partition efi_var_to_file() Failed to persist EFI variables efi_set_blk_dev_to_system_partition() No EFI system partition efi_var_to_file() Failed to persist EFI variables
Perhaps we need to make this option, e.g. with a 'bootstd' command to enable it?
These messages only appear if you have no ESP on a connected block device and store EFI variables on disk. For each block device a BOOT#### variable is created.
Instead of changing this patch we should reduce the noisiness.
For a user it should be sufficient to read once that EFI variables cannot be persisted due to a missing ESP.
Best regards
Heinrich
participants (3)
-
Heinrich Schuchardt
-
Mattijs Korpershoek
-
Simon Glass