From: Mark Rutland <mark.rutland@arm.com>
To: Luca Fancellu <luca.fancellu@arm.com>
Cc: andre.przywara@arm.com, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 5/6] aarch64: Support PSCI for Armv8-R AArch64
Date: Mon, 29 Jul 2024 17:09:34 +0100 [thread overview]
Message-ID: <Zqe-vjQm95Lk_4Ul@J2N7QTR9R3> (raw)
In-Reply-To: <20240716142906.1502802-6-luca.fancellu@arm.com>
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@arm.com>
> Reviewed-by: Andre Przywara <andre.przywara@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.
next prev parent reply other threads:[~2024-07-29 16:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-16 14:29 [PATCH v2 0/6] Add Armv8-R AArch64 support Luca Fancellu
2024-07-16 14:29 ` [PATCH v2 1/6] aarch64: Rename labels and prepare for lower EL booting Luca Fancellu
2024-07-16 14:29 ` [PATCH v2 2/6] aarch64: Prepare " Luca Fancellu
2024-07-16 14:29 ` [PATCH v2 3/6] aarch64: Remove TSCXT bit set from SCTLR_EL2_RESET Luca Fancellu
2024-07-19 10:05 ` Mark Rutland
2024-07-16 14:29 ` [PATCH v2 4/6] aarch64: Introduce EL2 boot code for Armv8-R AArch64 Luca Fancellu
2024-07-29 15:01 ` Mark Rutland
2024-07-29 15:27 ` Luca Fancellu
2024-07-29 16:14 ` Mark Rutland
2024-07-16 14:29 ` [PATCH v2 5/6] aarch64: Support PSCI " Luca Fancellu
2024-07-29 16:09 ` Mark Rutland [this message]
2024-07-30 11:31 ` Luca Fancellu
2024-07-30 12:55 ` Mark Rutland
2024-07-16 14:29 ` [PATCH v2 6/6] aarch64: Start Xen on Armv8-R at EL2 Luca Fancellu
2024-07-23 12:27 ` Mark Rutland
2024-07-23 12:35 ` Luca Fancellu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zqe-vjQm95Lk_4Ul@J2N7QTR9R3 \
--to=mark.rutland@arm.com \
--cc=andre.przywara@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=luca.fancellu@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox