[U-Boot] [PATCH 1/1] efi_loader: PSCI reset and shutdown for EL1

Heinrich Schuchardt xypron.glpk at gmx.de
Thu Oct 11 03:26:31 UTC 2018


When starting an aarch64 system under QEMU it runs in EL1/EL0. So we have
to use HVC for PSCI calls.

Without the patch resetting Linux started with bootefi under
qemu-system-aarch64 results in a crash.

Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
 arch/arm/cpu/armv8/fwcall.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/arch/arm/cpu/armv8/fwcall.c b/arch/arm/cpu/armv8/fwcall.c
index 0ba3dad8cc..f1b6e60bae 100644
--- a/arch/arm/cpu/armv8/fwcall.c
+++ b/arch/arm/cpu/armv8/fwcall.c
@@ -78,12 +78,10 @@ void __efi_runtime smc_call(struct pt_regs *args)
 }
 
 /*
- * For now, all systems we support run at least in EL2 and thus
- * trigger PSCI calls to EL3 using SMC. If anyone ever wants to
- * use PSCI on U-Boot running below a hypervisor, please detect
- * this and set the flag accordingly.
+ * This flag controls if SMC or HVC is used to call PSCI services. If U-Boot has
+ * been called by a hypervisor (e.g. QEMU), it has to be set to false.
  */
-static const __efi_runtime_data bool use_smc_for_psci = true;
+static __efi_runtime_data bool use_smc_for_psci = true;
 
 void __noreturn __efi_runtime psci_system_reset(void)
 {
@@ -138,6 +136,12 @@ void reset_misc(void)
 }
 
 #ifdef CONFIG_EFI_LOADER
+efi_status_t efi_reset_system_init(void)
+{
+	use_smc_for_psci = (current_el() >= 2);
+	return EFI_SUCCESS;
+}
+
 void __efi_runtime EFIAPI efi_reset_system(
 			enum efi_reset_type reset_type,
 			efi_status_t reset_status,
-- 
2.19.1



More information about the U-Boot mailing list