Skip to contentSkip to conversation

distro_bootcmd: call EFI bootmgr even without having /EFI/boot

PATCH New Michael Walle 2 participants 3 messages Sep 23, 2020 – Sep 25, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 distro_bootcmd: call EFI bootmgr even without having /EFI/boot

Currently, the EFI bootmgr is only called if there is a EFI binary inside the path for removable media is found, i.e. /EFI/boot/. This doesn't make sense. It is the duty of the bootmgr to find out the path and name of the EFI binary to boot. It should be called even if there is no /EFI/boot directory.

Thus, call the bootmgr before we try to boot the EFI binary inside the removable media path.

---
 include/config_distro_bootcmd.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
include/config_distro_bootcmd.h +5 -2
index fc0935fa21..c745f115f8 100644
@@ -123,12 +123,14 @@
 
 
 #define BOOTENV_SHARED_EFI                                                \
-	"boot_efi_binary="                                                \
+	"boot_efi_bootmgr="                                               \
 		"if fdt addr ${fdt_addr_r}; then "                        \
 			"bootefi bootmgr ${fdt_addr_r};"                  \
 		"else "                                                   \
 			"bootefi bootmgr ${fdtcontroladdr};"              \
-		"fi;"                                                     \
+		"fi\0"                                                    \
+	\
+	"boot_efi_binary="                                                \
 		"load ${devtype} ${devnum}:${distro_bootpart} "           \
 			"${kernel_addr_r} efi/boot/"BOOTEFI_NAME"; "      \
 		"if fdt addr ${fdt_addr_r}; then "                        \
@@ -152,6 +154,7 @@
 				"run load_efi_dtb; "                      \
 			"fi;"                                             \
 		"done;"                                                   \
+		"run boot_efi_bootmgr;"                                   \
 		"if test -e ${devtype} ${devnum}:${distro_bootpart} "     \
 					"efi/boot/"BOOTEFI_NAME"; then "  \
 				"echo Found EFI removable media binary "  \
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 distro_bootcmd: call EFI bootmgr even without having /EFI/boot

Am 23. September 2020 23:15:50 MESZ schrieb Michael Walle <[email protected]>:

Quoted 5 lines

Currently, the EFI bootmgr is only called if there is a EFI binary inside the path for removable media is found, i.e. /EFI/boot/. This doesn't make sense. It is the duty of the bootmgr to find out the path and name of the EFI binary to boot. It should be called even if there is no /EFI/boot directory.

Yes, UEFI variables indicating the boot binary take precedence. \EFI\boot\ is the fallback.

Quoted 15 lines

Thus, call the bootmgr before we try to boot the EFI binary inside the removable media path.

---
include/config_distro_bootcmd.h | 7 +++++--

1 file changed, 5 insertions(+), 2 deletions(-)
include/config_distro_bootcmd.h +0 -0
index fc0935fa21..c745f115f8 100644

include/config_distro_bootcmd.h line 128

Quoted 7 lines
include/config_distro_bootcmd.h +1 -1
@@ -123,12 +123,14 @@
 
 
 #define BOOTENV_SHARED_EFI                                             
 \
-	"boot_efi_binary="                                                \
+	"boot_efi_bootmgr="                                               \
 		"if fdt addr ${fdt_addr_r}; then "                        \

The problem here is that we don't have a clue which device tree we should load to $fdt_addr_r to make this true.

include/config_distro_bootcmd.h

Quoted 3 lines
include/config_distro_bootcmd.h +0 -0
 			"bootefi bootmgr ${fdt_addr_r};"                  \
 		"else "                                                   \
 			"bootefi bootmgr ${fdtcontroladdr};"  

Don't pass an fdt address in the else path. Some boards use ACPI. If ACPI is not used we have a fallback logic in cmd/bootefi.c.

Best regards

Heinrich

            \
Quoted 15 lines
include/config_distro_bootcmd.h +3 -1
-		"fi;"                                                     \
+		"fi\0"                                                    \
+	\
+	"boot_efi_binary="                                                \
 		"load ${devtype} ${devnum}:${distro_bootpart} "           \
 			"${kernel_addr_r} efi/boot/"BOOTEFI_NAME"; "      \
		"if fdt addr ${fdt_addr_r}; then "                        \
include/config_distro_bootcmd.h +1 -0
@@ -152,6 +154,7 @@
 				"run load_efi_dtb; "                      \
 			"fi;"                                             \
 		"done;"                                                   \
+		"run boot_efi_bootmgr;"                                   \
 		"if test -e ${devtype} ${devnum}:${distro_bootpart} "     \
 					"efi/boot/"BOOTEFI_NAME"; then "  \
 				"echo Found EFI removable media binary "  \
#2 lore raw

PATCH 1/1 distro_bootcmd: call EFI bootmgr even without having /EFI/boot

Am 2020-09-24 00:17, schrieb Heinrich Schuchardt:

Quoted 28 lines

Am 23. September 2020 23:15:50 MESZ schrieb Michael Walle <[email protected]>:

Quoted 5 lines

Currently, the EFI bootmgr is only called if there is a EFI binary inside the path for removable media is found, i.e. /EFI/boot/. This doesn't make sense. It is the duty of the bootmgr to find out the path and name of the EFI binary to boot. It should be called even if there is no /EFI/boot directory.

Yes, UEFI variables indicating the boot binary take precedence. \EFI\boot\ is the fallback.

Quoted 17 lines

Thus, call the bootmgr before we try to boot the EFI binary inside the removable media path.

---
include/config_distro_bootcmd.h | 7 +++++--

1 file changed, 5 insertions(+), 2 deletions(-)
include/config_distro_bootcmd.h +0 -0
index fc0935fa21..c745f115f8 100644
@@ -123,12 +123,14 @@
 
 
Quoted 8 lines

include/config_distro_bootcmd.h line 127

Quoted 5 lines
include/config_distro_bootcmd.h +1 -1
 #define BOOTENV_SHARED_EFI
 \
-	"boot_efi_binary="                                                \
+	"boot_efi_bootmgr="                                               \
 		"if fdt addr ${fdt_addr_r}; then "                        \

The problem here is that we don't have a clue which device tree we should load to $fdt_addr_r to make this true.

The one specified in $fdtfile is loaded in the previous step if it exists, just like in the removable media case. So I'm not sure I what you mean.

But that raises the question how does the device tree end up in the ESP. And I guess there can be only one set of device trees. For example if you have two different kernel versions installed you'd have two sets of device trees available, but only one can be put in //ESP/dtb or //ESP/dtb/current).

Quoted 6 lines

include/config_distro_bootcmd.h

Quoted 3 lines
include/config_distro_bootcmd.h +0 -0
 			"bootefi bootmgr ${fdt_addr_r};"                  \
 		"else "                                                   \
 			"bootefi bootmgr ${fdtcontroladdr};"

Don't pass an fdt address in the else path. Some boards use ACPI. If ACPI is not used we have a fallback logic in cmd/bootefi.c.

Ok.

-michael