bootstd: Make efi_mgr bootmeth work for non-sandbox setups
PATCH 1/1 bootstd: Make efi_mgr bootmeth work for non-sandbox setups
Enable the bootflow based on this bootmeth if the BootOrder EFI variable is set.
--- boot/bootmeth_efi_mgr.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
boot/bootmeth_efi_mgr.c +11 -1
@@ -14,6 +14,8 @@#include <bootmeth.h> #include <command.h> #include <dm.h> +#include <efi_loader.h> +#include <efi_variable.h> /** * struct efi_mgr_priv - private info for the efi-mgr driver
@@ -46,13 +48,21 @@ static int efi_mgr_check(struct udevice *dev, struct bootflow_iter *iter)static int efi_mgr_read_bootflow (struct udevice *dev,struct bootflow *bflow) {struct efi_mgr_priv *priv =dev_get_priv (dev); +efi_uintn_t size; +u16 *bootorder;if (priv->fake_dev) { bflow->state =BOOTFLOWST_READY ;return 0 ; } -/* To be implemented */ +/* Enable this method if the "BootOrder" UEFI exists. */ + bootorder =efi_get_var (u"BootOrder" , &efi_global_variable_guid, + &size); +if (bootorder) { + bflow->state =BOOTFLOWST_READY ; +return 0 ; + }return -EINVAL ; }
Signature · 1 line
2.41.0
Am 14. Juli 2023 21:56:02 MESZ schrieb Mark Kettenis <[email protected]>:
Quoted 27 lines
Enable the bootflow based on this bootmeth if the BootOrder EFI variable is set.
Signed-off-by Mark Kettenis <[email protected]>---
boot/bootmeth_efi_mgr.c| 12 +++++++++++-1 file changed, 11 insertions(+), 1 deletion(-)boot/bootmeth_efi_mgr.c +4
-0@@ -14,6 +14,8 @@#include <bootmeth.h> #include <command.h> #include <dm.h> +#include <efi_loader.h> +#include <efi_variable.h> /** * struct efi_mgr_priv - private info for the efi-mgr driver @@ -46,13 +48,21 @@ static int efi_mgr_check(struct udevice *dev, struct bootflow_iter *iter)static int efi_mgr_read_bootflow (struct udevice *dev,struct bootflow *bflow) {struct efi_mgr_priv *priv =dev_get_priv (dev); +efi_uintn_t size; +u16 *bootorder;
boot/bootmeth_efi_mgr.c static int efi_mgr_check(struct udevice *dev, struct bootflow_iter *iter) · line 61
Quoted 10 lines
boot/bootmeth_efi_mgr.c +3
-1if (priv->fake_dev) { bflow->state =BOOTFLOWST_READY ;return 0 ; } -/* To be implemented */ +/* Enable this method if the "BootOrder" UEFI exists. */ + bootorder =efi_get_var (u"BootOrder" , &efi_global_variable_guid, + &size);
Are EFI variables already loaded when you hit this code?
Even if the variable Boot Order is not set we must boot EFI/BOOT/BOOT????.EFI.
Best regards
Heinrich
Quoted 7 lines
boot/bootmeth_efi_mgr.c +4
-0+if (bootorder) { + bflow->state =BOOTFLOWST_READY ; +return 0 ; + }return -EINVAL ; }
Quoted 2 lines
Date: Fri, 14 Jul 2023 22:21:04 +0200
From: Heinrich Schuchardt <[email protected]>
Hi Heinrich,
Quoted 34 lines
Am 14. Juli 2023 21:56:02 MESZ schrieb Mark Kettenis <[email protected]>:
Quoted 33 lines
Enable the bootflow based on this bootmeth if the BootOrder EFI variable is set.
Signed-off-by Mark Kettenis <[email protected]>---
boot/bootmeth_efi_mgr.c| 12 +++++++++++-1 file changed, 11 insertions(+), 1 deletion(-)boot/bootmeth_efi_mgr.c +4
-0@@ -14,6 +14,8 @@#include <bootmeth.h> #include <command.h> #include <dm.h> +#include <efi_loader.h> +#include <efi_variable.h> /** * struct efi_mgr_priv - private info for the efi-mgr driver @@ -46,13 +48,21 @@ static int efi_mgr_check(struct udevice *dev, struct bootflow_iter *iter)static int efi_mgr_read_bootflow (struct udevice *dev,struct bootflow *bflow) {struct efi_mgr_priv *priv =dev_get_priv (dev); +efi_uintn_t size; +u16 *bootorder;if (priv->fake_dev) { bflow->state =BOOTFLOWST_READY ;return 0 ; }
Quoted 6 lines
boot/bootmeth_efi_mgr.c static int efi_mgr_check(struct udevice *dev, struct bootflow_iter *iter) · line 61
Quoted 4 lines
boot/bootmeth_efi_mgr.c +3
-1-/* To be implemented */ +/* Enable this method if the "BootOrder" UEFI exists. */ + bootorder =efi_get_var (u"BootOrder" , &efi_global_variable_guid, + &size);Are EFI variables already loaded when you hit this code?
They are in my case since I have some board code initializes the EFI subsystem early. But in general it would not. So I guess this would need a call to efi_init_obj_list().
Quoted 2 lines
Even if the variable Boot Order is not set we must boot EFI/BOOT/BOOT????.EFI.
That will still happen. If the efi_mgr method fails, standard boot will iterate over devices and use the efi method to boot from the default path.
Quoted 8 lines
Quoted 7 lines
boot/bootmeth_efi_mgr.c +4
-0+if (bootorder) { + bflow->state =BOOTFLOWST_READY ; +return 0 ; + }return -EINVAL ; }
Quoted 34 lines · Mark Kettenis
Enable the bootflow based on this bootmeth if the BootOrder EFI variable is set.
Signed-off-by Mark Kettenis <[email protected]>--- boot/bootmeth_efi_mgr.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)boot/bootmeth_efi_mgr.c +4
-1@@ -14,6 +14,8 @@#include <bootmeth.h> #include <command.h> #include <dm.h> +#include <efi_loader.h> +#include <efi_variable.h> /** * struct efi_mgr_priv - private info for the efi-mgr driver @@ -46,13 +48,21 @@ static int efi_mgr_check(struct udevice *dev, struct bootflow_iter *iter)static int efi_mgr_read_bootflow (struct udevice *dev,struct bootflow *bflow) {struct efi_mgr_priv *priv =dev_get_priv (dev); +efi_uintn_t size; +u16 *bootorder;if (priv->fake_dev) { bflow->state =BOOTFLOWST_READY ;return 0 ; } -/* To be implemented */
boot/bootmeth_efi_mgr.c static int efi_mgr_check(struct udevice *dev, struct bootflow_iter *iter) · line 68
Quoted 10 lines
boot/bootmeth_efi_mgr.c +7
-0+/* Enable this method if the "BootOrder" UEFI exists. */ + bootorder =efi_get_var (u"BootOrder" , &efi_global_variable_guid, + &size); +if (bootorder) { + bflow->state =BOOTFLOWST_READY ; +return 0 ; + }return -EINVAL ; }
There is no device-tree with compatible "u-boot,efi-bootmgr". So this looks like dead code up to now. Please, provide a unit test.
@Simon
Where is the documentation that describes the "u-boot,distro-efi" and "u-boot,efi-bootmgr" boot methods? Current doc/device-tree-bindings/bootmeth.txt is not sufficient and not included in the generated online documentation.
doc/device-tree-bindings/bootmeth.txt should be converted to yaml format so that it can be used for validation of device-trees.
Best regards
Heinrich