Skip to contentSkip to conversation

efi_loader: Use sysreset instead of reset command

PATCH Superseded Masami Hiramatsu 3 participants 5 messages Mar 16, 2022 – Mar 21, 2022

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 efi_loader: Use sysreset instead of reset command

Use sysreset_walk_halt() directly from reset-after-capsule-on-disk feature to reboot (cold reset) machine instead of using reset command interface, since this is not a command.
Note that this will make CONFIG_EFI_CAPSULE_ON_DISK depending on the CONFIG_SYSRESET.

---
Changes in v2:
- Add CONFIG_SYSRESET dependency.
- Fix to add #include <sysreset.h>

---
 lib/efi_loader/Kconfig       |    1 +
 lib/efi_loader/efi_capsule.c |    5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)
lib/efi_loader/Kconfig +1 -0
index e5e35fe51f..33138237cc 100644
@@ -130,6 +130,7 @@ config EFI_RUNTIME_UPDATE_CAPSULE
 
 config EFI_CAPSULE_ON_DISK
 	bool "Enable capsule-on-disk support"
+	depends on SYSRESET
 	select EFI_HAVE_CAPSULE_SUPPORT
 	help
 	  Select this option if you want to use capsule-on-disk feature,
lib/efi_loader/efi_capsule.c +3 -2
index 613b531b82..a3d1d7e95a 100644
@@ -18,6 +18,7 @@
 #include <malloc.h>
 #include <mapmem.h>
 #include <sort.h>
+#include <sysreset.h>
 #include <asm/global_data.h>
 
 #include <crypto/pkcs7.h>
@@ -1150,9 +1151,9 @@ efi_status_t efi_launch_capsules(void)
 	 * UEFI spec requires to reset system after complete processing capsule
 	 * update on the storage.
 	 */
-	log_info("Reboot after firmware update");
+	log_info("Reboot after firmware update.\n");
 	/* Cold reset is required for loading the new firmware. */
-	do_reset(NULL, 0, 0, NULL);
+	sysreset_walk_halt(SYSRESET_COLD);
 	hang();
 	/* not reach here */
 
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Masami Hiramatsu

Use sysreset_walk_halt() directly from reset-after-capsule-on-disk feature to reboot (cold reset) machine instead of using reset command interface, since this is not a command.
Note that this will make CONFIG_EFI_CAPSULE_ON_DISK depending on the CONFIG_SYSRESET.

Quoted 46 lines

---
Changes in v2:
- Add CONFIG_SYSRESET dependency.
- Fix to add #include <sysreset.h>

---
  lib/efi_loader/Kconfig       |    1 +
  lib/efi_loader/efi_capsule.c |    5 +++--
  2 files changed, 4 insertions(+), 2 deletions(-)
lib/efi_loader/Kconfig +1 -0
index e5e35fe51f..33138237cc 100644
@@ -130,6 +130,7 @@ config EFI_RUNTIME_UPDATE_CAPSULE
 
  config EFI_CAPSULE_ON_DISK
  	bool "Enable capsule-on-disk support"
+	depends on SYSRESET
  	select EFI_HAVE_CAPSULE_SUPPORT
  	help
  	  Select this option if you want to use capsule-on-disk feature,
lib/efi_loader/efi_capsule.c +3 -2
index 613b531b82..a3d1d7e95a 100644
@@ -18,6 +18,7 @@
  #include <malloc.h>
  #include <mapmem.h>
  #include <sort.h>
+#include <sysreset.h>
  #include <asm/global_data.h>
 
  #include <crypto/pkcs7.h>
@@ -1150,9 +1151,9 @@ efi_status_t efi_launch_capsules(void)
  	 * UEFI spec requires to reset system after complete processing capsule
  	 * update on the storage.
  	 */
-	log_info("Reboot after firmware update");
+	log_info("Reboot after firmware update.\n");
  	/* Cold reset is required for loading the new firmware. */
-	do_reset(NULL, 0, 0, NULL);
+	sysreset_walk_halt(SYSRESET_COLD);
  	hang();
  	/* not reach here */
 
Reviewed-by
#2 lore raw
Quoted 8 lines · Heinrich Schuchardt
Quoted 6 lines · Masami Hiramatsu

Use sysreset_walk_halt() directly from reset-after-capsule-on-disk feature to reboot (cold reset) machine instead of using reset command interface, since this is not a command.
Note that this will make CONFIG_EFI_CAPSULE_ON_DISK depending on the CONFIG_SYSRESET.

Quoted 12 lines
Quoted 1 line
Quoted 8 lines

---
Changes in v2:
- Add CONFIG_SYSRESET dependency.
- Fix to add #include <sysreset.h>

---
  lib/efi_loader/Kconfig       |    1 +
  lib/efi_loader/efi_capsule.c |    5 +++--
  2 files changed, 4 insertions(+), 2 deletions(-)
Quoted 39 lines
Quoted 38 lines
lib/efi_loader/Kconfig +1 -0
index e5e35fe51f..33138237cc 100644
@@ -130,6 +130,7 @@ config EFI_RUNTIME_UPDATE_CAPSULE
 
  config EFI_CAPSULE_ON_DISK
      bool "Enable capsule-on-disk support"
+     depends on SYSRESET
      select EFI_HAVE_CAPSULE_SUPPORT
      help
        Select this option if you want to use capsule-on-disk feature,
lib/efi_loader/efi_capsule.c +3 -2
index 613b531b82..a3d1d7e95a 100644
@@ -18,6 +18,7 @@
  #include <malloc.h>
  #include <mapmem.h>
  #include <sort.h>
+#include <sysreset.h>
  #include <asm/global_data.h>
 
  #include <crypto/pkcs7.h>
@@ -1150,9 +1151,9 @@ efi_status_t efi_launch_capsules(void)
       * UEFI spec requires to reset system after complete processing capsule
       * update on the storage.
       */
-     log_info("Reboot after firmware update");
+     log_info("Reboot after firmware update.\n");
      /* Cold reset is required for loading the new firmware. */
-     do_reset(NULL, 0, 0, NULL);
+     sysreset_walk_halt(SYSRESET_COLD);
      hang();
      /* not reach here */
 
#3 lore raw
Quoted 32 lines · Simon Glass
Quoted 8 lines · Heinrich Schuchardt
Quoted 6 lines · Masami Hiramatsu

Use sysreset_walk_halt() directly from reset-after-capsule-on-disk feature to reboot (cold reset) machine instead of using reset command interface, since this is not a command.
Note that this will make CONFIG_EFI_CAPSULE_ON_DISK depending on the CONFIG_SYSRESET.

Quoted 12 lines
Quoted 1 line
Quoted 8 lines

---
Changes in v2:
- Add CONFIG_SYSRESET dependency.
- Fix to add #include <sysreset.h>

---
   lib/efi_loader/Kconfig       |    1 +
   lib/efi_loader/efi_capsule.c |    5 +++--
   2 files changed, 4 insertions(+), 2 deletions(-)
Quoted 7 lines
Quoted 7 lines
lib/efi_loader/Kconfig +0 -0
index e5e35fe51f..33138237cc 100644
@@ -130,6 +130,7 @@ config EFI_RUNTIME_UPDATE_CAPSULE
 
Quoted 3 lines
Quoted 3 lines

lib/efi_loader/Kconfig config EFI_RUNTIME_UPDATE_CAPSULE · line 133

Quoted 3 lines
lib/efi_loader/Kconfig +1 -0
   config EFI_CAPSULE_ON_DISK
       bool "Enable capsule-on-disk support"
+     depends on SYSRESET

With this change xilinx_zynq_virt_defconfig fails to build:

arm-linux-gnueabi-ld.bfd: cmd/efidebug.o: in function `do_efi_capsule_on_disk_update':
/home/zfsdt/workspace/u-boot-build/denx/cmd/efidebug.c:92: undefined reference to `efi_launch_capsules'

Command 'efi capsule disk-update' should only be enabled if CONFIG_EFI_CAPSULE_ON_DISK=y.

arm-linux-gnueabi-ld.bfd: lib/efi_loader/efi_setup.o: in function `efi_init_obj_list':
/home/zfsdt/workspace/u-boot-build/denx/lib/efi_loader/efi_setup.c:272:
undefined reference to `efi_load_capsule_drivers'
make: *** [Makefile:1801: u-boot] Error 1

efi_load_capsule_drivers() must be available even if EFI_CAPSULE_ON_DISK is not enabled to make CapsuleUpdate() work.

Please, add the missing changes.

Best regards

Heinrich

Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
lib/efi_loader/Kconfig +0 -0
       select EFI_HAVE_CAPSULE_SUPPORT
       help
         Select this option if you want to use capsule-on-disk feature,
lib/efi_loader/efi_capsule.c +3 -2
index 613b531b82..a3d1d7e95a 100644
@@ -18,6 +18,7 @@
   #include <malloc.h>
   #include <mapmem.h>
   #include <sort.h>
+#include <sysreset.h>
   #include <asm/global_data.h>
 
   #include <crypto/pkcs7.h>
@@ -1150,9 +1151,9 @@ efi_status_t efi_launch_capsules(void)
        * UEFI spec requires to reset system after complete processing capsule
        * update on the storage.
        */
-     log_info("Reboot after firmware update");
+     log_info("Reboot after firmware update.\n");
       /* Cold reset is required for loading the new firmware. */
-     do_reset(NULL, 0, 0, NULL);
+     sysreset_walk_halt(SYSRESET_COLD);
       hang();
       /* not reach here */
 
#4 lore raw

Hi Heinrich,

Thanks for finding the issues.

2022年3月19日(土) 18:02 Heinrich Schuchardt <[email protected]>:

Quoted 40 lines · Simon Glass
Quoted 32 lines · Heinrich Schuchardt
Quoted 8 lines · Masami Hiramatsu
Quoted 6 lines

Use sysreset_walk_halt() directly from reset-after-capsule-on-disk feature to reboot (cold reset) machine instead of using reset command interface, since this is not a command.
Note that this will make CONFIG_EFI_CAPSULE_ON_DISK depending on the CONFIG_SYSRESET.

Quoted 12 lines
Quoted 1 line
Quoted 8 lines

---
Changes in v2:
- Add CONFIG_SYSRESET dependency.
- Fix to add #include <sysreset.h>

---
   lib/efi_loader/Kconfig       |    1 +
   lib/efi_loader/efi_capsule.c |    5 +++--
   2 files changed, 4 insertions(+), 2 deletions(-)
Quoted 7 lines
Quoted 7 lines
lib/efi_loader/Kconfig +0 -0
index e5e35fe51f..33138237cc 100644
@@ -130,6 +130,7 @@ config EFI_RUNTIME_UPDATE_CAPSULE
 
Quoted 3 lines
Quoted 3 lines

lib/efi_loader/Kconfig config EFI_RUNTIME_UPDATE_CAPSULE · line 133

Quoted 3 lines
lib/efi_loader/Kconfig +1 -0
   config EFI_CAPSULE_ON_DISK
       bool "Enable capsule-on-disk support"
+     depends on SYSRESET

With this change xilinx_zynq_virt_defconfig fails to build:

Quoted 7 lines

arm-linux-gnueabi-ld.bfd: cmd/efidebug.o: in function `do_efi_capsule_on_disk_update':
/home/zfsdt/workspace/u-boot-build/denx/cmd/efidebug.c:92: undefined reference to `efi_launch_capsules'

Command 'efi capsule disk-update' should only be enabled if CONFIG_EFI_CAPSULE_ON_DISK=y.

OK.

Quoted 8 lines

arm-linux-gnueabi-ld.bfd: lib/efi_loader/efi_setup.o: in function `efi_init_obj_list':
/home/zfsdt/workspace/u-boot-build/denx/lib/efi_loader/efi_setup.c:272:
undefined reference to `efi_load_capsule_drivers'
make: *** [Makefile:1801: u-boot] Error 1

efi_load_capsule_drivers() must be available even if EFI_CAPSULE_ON_DISK is not enabled to make CapsuleUpdate() work.

Yes, we have CONFIG_EFI_HAVE_CAPSULE_SUPPORT for such case.

Quoted 2 lines

Please, add the missing changes.

OK, let me update the series.

Thank you!

Quoted 35 lines

Best regards

Heinrich

Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
lib/efi_loader/Kconfig +0 -0
       select EFI_HAVE_CAPSULE_SUPPORT
       help
         Select this option if you want to use capsule-on-disk feature,
lib/efi_loader/efi_capsule.c +3 -2
index 613b531b82..a3d1d7e95a 100644
@@ -18,6 +18,7 @@
   #include <malloc.h>
   #include <mapmem.h>
   #include <sort.h>
+#include <sysreset.h>
   #include <asm/global_data.h>
 
   #include <crypto/pkcs7.h>
@@ -1150,9 +1151,9 @@ efi_status_t efi_launch_capsules(void)
        * UEFI spec requires to reset system after complete processing capsule
        * update on the storage.
        */
-     log_info("Reboot after firmware update");
+     log_info("Reboot after firmware update.\n");
       /* Cold reset is required for loading the new firmware. */
-     do_reset(NULL, 0, 0, NULL);
+     sysreset_walk_halt(SYSRESET_COLD);
       hang();
       /* not reach here */
 
Signature · 1 line
Masami Hiramatsu