arm64/efi: use UEFI ResetSystem() Runtime Service for system reset
PATCH 1/1 arm64/efi: use UEFI ResetSystem() Runtime Service for system reset
If UEFI Runtime Services are available, the ResetSystem() service should be preferred over direct PSCI calls or other methods to reset the system. The reason is that the UpdateCapsule() UEFI Runtime Service, which is used to perform firmware updates, relies on this.
---
I sent roughly the same patch ~6 months ago, but at the time, we were still waiting for the restart notifier call chain patches to land. Since that code got rejected, I am proposing this again. Note that efi_enabled(x) always evaluates to 'false' on !CONFIG_EFI.
This fixes reboot on my Seattle [although it doesn't make it any faster :-)]
arch/arm64/kernel/process.c | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm64/kernel/process.c +9 -0
@@ -21,6 +21,7 @@#include <stdarg.h> #include <linux/compat.h> +#include <linux/efi.h> #include <linux/export.h> #include <linux/sched.h> #include <linux/kernel.h>
@@ -150,6 +151,14 @@ void machine_restart(char *cmd)local_irq_disable ();smp_send_stop (); +/* +* Prefer reboot via EFI if available, so that capsule updates [which +* rely on UEFI's ResetSystem() being called with the return value of +* UpdateCapsule()] have a chance of working as expected. +*/ +if (efi_enabled (EFI_RUNTIME_SERVICES )) +efi_reboot (reboot_mode,NULL ); +/* Now call the architecture specific reboot code. */ if (arm_pm_restart)arm_pm_restart (reboot_mode, cmd);
Signature · 1 line
1.8.3.2
Mark Rutland
reviewerPATCH 1/1 arm64/efi: use UEFI ResetSystem() Runtime Service for system reset
Hi Ard,
Quoted 11 lines · Ard Biesheuvel
If UEFI Runtime Services are available, the
ResetSystem()service should be preferred over direct PSCI calls or other methods to reset the system. The reason is that theUpdateCapsule()UEFI Runtime Service, which is used to perform firmware updates, relies on this.Signed-off-by Ard Biesheuvel <[email protected]>---
I sent roughly the same patch ~6 months ago, but at the time, we were still waiting for the restart notifier call chain patches to land. Since that code got rejected, I am proposing this again. Note thatefi_enabled(x)always evaluates to 'false' on !CONFIG_EFI.
Also, efi_reboot is a static inline for !CONFIG_EFI, so I can't see any possibility of a build failure.
Quoted 18 lines
This fixes reboot on my Seattle [although it doesn't make it any faster :-)]
arch/arm64/kernel/process.c | 9 +++++++++ 1 file changed, 9 insertions(+)arch/arm64/kernel/process.c +1
-0@@ -21,6 +21,7 @@#include <stdarg.h> #include <linux/compat.h> +#include <linux/efi.h> #include <linux/export.h> #include <linux/sched.h> #include <linux/kernel.h>
arch/arm64/kernel/process.c void machine_restart(char *cmd) · line 160
Quoted 10 lines
arch/arm64/kernel/process.c +7
-0@@ -150,6 +151,14 @@ void machine_restart(char *cmd)local_irq_disable ();smp_send_stop (); +/* +* Prefer reboot via EFI if available, so that capsule updates [which +* rely on UEFI's ResetSystem() being called with the return value of +* UpdateCapsule()] have a chance of working as expected. +*/ +if (efi_enabled (EFI_RUNTIME_SERVICES )) +efi_reboot (reboot_mode,NULL );
I expect that the particulars of the UpdateCapsule() will be handled within efi_reboot and won't require any additions here. So the comment could just be trimmed to say that UpdateCapsule() depends on the system being reset with ResetSystem().
Also, we need to make sure we call efi_poweroff to make UpdateCapsule() work when shutting the machine down (behind the scenes efi_poweroff calls ResetSystem(EfiResetShutdown, ...)).
For that I think adding the following to arch/arm64/kernel/efi.c is sufficient:
/*
* UpdateCapsule() depends on the system being shutdown via
* ResetSystem().
*/
bool efi_poweroff_required(void)
{
return efi_enabled(EFI_RUNTIME_SERVICES);
}I've given the patch a spin (with and without that addition) on Juno and Seattle. So with that folded in:
Thanks,
Mark.
PATCH 1/1 arm64/efi: use UEFI ResetSystem() Runtime Service for system reset
Quoted 39 lines · Mark Rutland
Hi Ard,
Quoted 11 lines · Ard Biesheuvel
If UEFI Runtime Services are available, the
ResetSystem()service should be preferred over direct PSCI calls or other methods to reset the system. The reason is that theUpdateCapsule()UEFI Runtime Service, which is used to perform firmware updates, relies on this.Signed-off-by Ard Biesheuvel <[email protected]>---
I sent roughly the same patch ~6 months ago, but at the time, we were still waiting for the restart notifier call chain patches to land. Since that code got rejected, I am proposing this again. Note thatefi_enabled(x)always evaluates to 'false' on !CONFIG_EFI.Also,
efi_rebootis a static inline for !CONFIG_EFI, so I can't see any possibility of a build failure.Quoted 21 lines
This fixes reboot on my Seattle [although it doesn't make it any faster :-)]
arch/arm64/kernel/process.c | 9 +++++++++ 1 file changed, 9 insertions(+)arch/arm64/kernel/process.c +1
-0@@ -21,6 +21,7 @@#include <stdarg.h> #include <linux/compat.h> +#include <linux/efi.h> #include <linux/export.h> #include <linux/sched.h> #include <linux/kernel.h> @@ -150,6 +151,14 @@ void machine_restart(char *cmd)local_irq_disable ();smp_send_stop ();
Quoted 13 lines
arch/arm64/kernel/process.c void machine_restart(char *cmd) · line 160
Quoted 7 lines
arch/arm64/kernel/process.c +7
-0+/* +* Prefer reboot via EFI if available, so that capsule updates [which +* rely on UEFI's ResetSystem() being called with the return value of +* UpdateCapsule()] have a chance of working as expected. +*/ +if (efi_enabled (EFI_RUNTIME_SERVICES )) +efi_reboot (reboot_mode,NULL );I expect that the particulars of the
UpdateCapsule()will be handled withinefi_rebootand won't require any additions here. So the comment could just be trimmed to say thatUpdateCapsule()depends on the system being reset withResetSystem().
OK.
Quoted 7 lines
Also, we need to make sure we call
efi_poweroffto makeUpdateCapsule()work when shutting the machine down (behind the scenesefi_poweroffcallsResetSystem(EfiResetShutdown, ...)).For that I think adding the following to
arch/arm64/kernel/efi.cis sufficient:
Quoted 9 lines
/*
*UpdateCapsule()depends on the system being shutdown via
*ResetSystem().
*/
boolefi_poweroff_required(void){ return efi_enabled(EFI_RUNTIME_SERVICES); }
Yes. I used to have this as a separate patch as well ~6 months ago, but I did not realise at the time that UpdateCapsule() depends on ResetSystem() for poweroff as well.
Quoted 6 lines
I've given the patch a spin (with and without that addition) on Juno and Seattle. So with that folded in:
Tested-by Mark Rutland <[email protected]>Reviewed-by Mark Rutland <[email protected]>
Thanks. I will fold it in and resend.
Signature · 1 line
Ard.