From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9CEEEC3DA61 for ; Mon, 29 Jul 2024 16:10:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=o+lwSdHMUperjFXqJT0CNtaYZHbhVKDjY+vkxKHZhO0=; b=u4kNtEZkrBEsybMpi5Aw95aOSB zHPkF+QRQLdRs1AB3Rhhk9CWwBzDgezgv/guDoXpgoqW9X5zKSCUsrKtiJruNZac+h+c7+ByIEGv3 d68AYoTXQ6E5OwdZkyQ1kOsjtLoSgyoPS1lUgRlW2iXiFm94ep2l5Rat1m68ncclIpi+x15dqaVH2 s5FrWqYLXlJ+A/BriWngIflCsGfKkagsPgGxrOC14zoFiEHT/A3M12IogUFb+JSmh60XHGp6rCfLo DYzIO2wLFGpys6fuEtreBdpDy+eI++7V7jZpx5UkwwiejkaLT/fuxsgheVfRfgajZNVBzdAdGvLr7 ouirBqCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYSwn-0000000BxGh-45wf; Mon, 29 Jul 2024 16:10:05 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYSwN-0000000BxD8-1WLm for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2024 16:09:40 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2DBAF1007; Mon, 29 Jul 2024 09:10:03 -0700 (PDT) Received: from J2N7QTR9R3 (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CB1633F766; Mon, 29 Jul 2024 09:09:36 -0700 (PDT) Date: Mon, 29 Jul 2024 17:09:34 +0100 From: Mark Rutland To: Luca Fancellu Cc: andre.przywara@arm.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 5/6] aarch64: Support PSCI for Armv8-R AArch64 Message-ID: References: <20240716142906.1502802-1-luca.fancellu@arm.com> <20240716142906.1502802-6-luca.fancellu@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240716142906.1502802-6-luca.fancellu@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_090939_506352_CAB5A149 X-CRM114-Status: GOOD ( 25.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 > Reviewed-by: Andre Przywara > --- > 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.