[boot-wrapper 6/7] aarch64: Support PSCI for Armv8-R AArch64
Andre Przywara
andre.przywara at arm.com
Fri Jun 21 04:01:17 PDT 2024
On Thu, 6 Jun 2024 14:36:27 +0100
Luca Fancellu <luca.fancellu at arm.com> wrote:
Hi,
> 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.
I am not super happy about this *build time* option, but I think the
alternatives are worse, and it keeps the code much simpler and cleaner:
> 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>
Cheers,
Andre
> ---
> 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 8006f2705193..3305e69270a4 100644
> --- a/arch/aarch64/init.c
> +++ b/arch/aarch64/init.c
> @@ -174,10 +174,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])
>
> # Allow a user to pass --with-initrd
> AC_ARG_WITH([initrd],
More information about the linux-arm-kernel
mailing list