[PATCH v2 5/6] aarch64: Support PSCI for Armv8-R AArch64
Mark Rutland
mark.rutland at arm.com
Mon Jul 29 09:09:34 PDT 2024
On Tue, Jul 16, 2024 at 03:29:05PM +0100, Luca Fancellu wrote:
> Add support for PSCI when booting Linux on Armv8-R AArch64,
> allow the autoconf parameter --enable-psci to take an argument
> which is the conduit to be used, it can be empty or 'smc' to
> select the smc conduit, it can be 'hvc' for the hvc conduit.
>
> Depending on the selected conduit, the vector table will be
> installed on the VBAR_EL3 or VBAR_EL2 register.
>
> Signed-off-by: Luca Fancellu <luca.fancellu at arm.com>
> Reviewed-by: Andre Przywara <andre.przywara at arm.com>
> ---
> v2 changes:
> - Add Andre R-by
> ---
> Makefile.am | 5 ++++-
> arch/aarch64/init.c | 15 ++++++++++++---
> configure.ac | 16 +++++++++++-----
> 3 files changed, 27 insertions(+), 9 deletions(-)
>
> diff --git a/Makefile.am b/Makefile.am
> index 6ebece25b230..34fbfb1f4ff8 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -49,11 +49,14 @@ endif
>
> if PSCI
> DEFINES += -DPSCI
> +if PSCI_HVC
> +DEFINES += -DPSCI_HVC
> +endif
> ARCH_OBJ += psci.o
> COMMON_OBJ += psci.o
> PSCI_NODE := psci { \
> compatible = \"arm,psci\"; \
> - method = \"smc\"; \
> + method = \"$(PSCI_METHOD)\"; \
> cpu_on = <$(PSCI_CPU_ON)>; \
> cpu_off = <$(PSCI_CPU_OFF)>; \
> };
> diff --git a/arch/aarch64/init.c b/arch/aarch64/init.c
> index 9402a01b9dca..9b8bd8723dba 100644
> --- a/arch/aarch64/init.c
> +++ b/arch/aarch64/init.c
> @@ -179,10 +179,19 @@ extern char psci_vectors[];
>
> bool cpu_init_psci_arch(void)
> {
> - if (mrs(CurrentEL) != CURRENTEL_EL3)
> + switch (mrs(CurrentEL)) {
> +#if !defined(PSCI_HVC)
> + case CURRENTEL_EL3:
> + msr(VBAR_EL3, (unsigned long)psci_vectors);
> + break;
> +#else
> + case CURRENTEL_EL2:
> + msr(VBAR_EL2, (unsigned long)psci_vectors);
> + break;
> +#endif
> + default:
> return false;
> -
> - msr(VBAR_EL3, (unsigned long)psci_vectors);
> + }
> isb();
>
> return true;
> diff --git a/configure.ac b/configure.ac
> index 9e3b7226cd69..44459a4c849e 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -83,13 +83,19 @@ AS_IF([test "x$X_IMAGE" != "x"],
> # Allow a user to pass --enable-psci
> AC_ARG_ENABLE([psci],
> AS_HELP_STRING([--disable-psci], [disable the psci boot method]),
> - [USE_PSCI=$enableval], [USE_PSCI="yes"])
> -AM_CONDITIONAL([PSCI], [test "x$USE_PSCI" = "xyes"])
> -AS_IF([test "x$USE_PSCI" = "xyes"], [], [USE_PSCI=no])
> -
> -AS_IF([test "x$USE_PSCI" != "xyes" -a "x$KERNEL_ES" = "x32"],
> + [case "${enableval}" in
> + yes|smc) USE_PSCI=smc ;;
> + hvc) USE_PSCI=hvc ;;
> + no) ;;
> + *) AC_MSG_ERROR([Bad value "${enableval}" for --enable-psci. Use "smc" or "hvc"]) ;;
> + esac])
> +AM_CONDITIONAL([PSCI], [test "x$USE_PSCI" = "xyes" -o "x$USE_PSCI" = "xsmc" -o "x$USE_PSCI" = "xhvc"])
> +AM_CONDITIONAL([PSCI_HVC], [test "x$USE_PSCI" = "xhvc"])
> +
> +AS_IF([test "x$USE_PSCI" = "xno" -a "x$KERNEL_ES" = "x32"],
> [AC_MSG_ERROR([With an AArch32 kernel, boot method must be PSCI.])]
> )
> +AC_SUBST([PSCI_METHOD], [$USE_PSCI])
As of this patch, if I build with --enable-psci=hvc, and boot on
ARMv8-A, it'll fail at boot time, since the boot-wrapper won't fix up
the SPSR (and will enter the kernel at EL2), and HVC will go to that
kernel.
I think that we either need to add support for dropping to EL1 in
ARMv8-A, or we should have an option to build for ARMv8-R specifically,
where we can automatically fix up the PSCI conduit.
Mark.
More information about the linux-arm-kernel
mailing list