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

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Heinrich Schuchardt
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 <[hidden email]>
---
 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

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 1/1] efi_loader: PSCI reset and shutdown for EL1

Sumit Garg-2
On Thu, 11 Oct 2018 at 08:56, Heinrich Schuchardt <[hidden email]> wrote:

>
> 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 <[hidden email]>
> ---
>  arch/arm/cpu/armv8/fwcall.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
>

I too was facing this crash and got it fixed before I saw this patch today.

Tested-by: Sumit Garg <[hidden email]>

> 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
>
> _______________________________________________
> U-Boot mailing list
> [hidden email]
> https://lists.denx.de/listinfo/u-boot
_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 1/1] efi_loader: PSCI reset and shutdown for EL1

Sumit Garg-2
On Thu, 11 Oct 2018 at 17:50, Sumit Garg <[hidden email]> wrote:

>
> On Thu, 11 Oct 2018 at 08:56, Heinrich Schuchardt <[hidden email]> wrote:
> >
> > 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 <[hidden email]>
> > ---
> >  arch/arm/cpu/armv8/fwcall.c | 14 +++++++++-----
> >  1 file changed, 9 insertions(+), 5 deletions(-)
> >
>
> I too was facing this crash and got it fixed before I saw this patch today.
>
> Tested-by: Sumit Garg <[hidden email]>
>
> > 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);

It doesn't seems to be a generic solution as u-boot could be loaded at
EL1 with PSCI calls still implemented in EL3 (smc for PSCI) in cases
like EL2 (virt. extension) isn't implemented on platform etc. So I
would probably suggest to use device tree parsing for PSCI method to
configure this variable here.

-Sumit

> > +       return EFI_SUCCESS;
> > +}
> > +
> >  void __efi_runtime EFIAPI efi_reset_system(
> >                         enum efi_reset_type reset_type,
> >                         efi_status_t reset_status,
> > --
> > 2.19.1
> >
> > _______________________________________________
> > U-Boot mailing list
> > [hidden email]
> > https://lists.denx.de/listinfo/u-boot
_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot