From patchwork Tue Jul 16 14:29:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13734557 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 C28D0C3DA59 for ; Tue, 16 Jul 2024 14:31:05 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Z/YmSeRsbZZ3S0JdTjbn9+yW0aKXbZSx/UOia/RiGoM=; b=OmVIBXm/ZjS3zqEDPiout6zPI2 +x78WaQE6gOPeYD4RG3QGmPMnvDCL0L3DVZzgsiDlV+44xGlFNLsAJhRbFx/SC+0GcxBVP9cS/zfq IRkIKypPhzNC1Vrsac3JRyw8e0XOMT5ObF8BbKAN7Jsvmq9Esn+vEAM7OLezPCdOlkD+z8FcXdrIQ JAE+hl8AWhPQ9BrhrEqV830+AMjmlYmbDI3Cclv/UrwzN8OgTFll0qYtG35tTFz+N5BRQiqrJub5s 38bMyeRSQ/h27AsB852u68rMZrsu/6/iOW+lSIbIkDQWp+/5oC93cFBjuaLvCyaO9tf4ErxvGyG21 d/EqeqmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTjCf-0000000Aj6G-0Ei7; Tue, 16 Jul 2024 14:30:53 +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 1sTjBH-0000000AiIS-2N7c for linux-arm-kernel@lists.infradead.org; Tue, 16 Jul 2024 14:29:29 +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 66652139F; Tue, 16 Jul 2024 07:29:52 -0700 (PDT) Received: from e125770.cambridge.arm.com (e125770.arm.com [10.1.199.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 717743F762; Tue, 16 Jul 2024 07:29:26 -0700 (PDT) From: Luca Fancellu To: andre.przywara@arm.com, mark.rutland@arm.com Cc: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 5/6] aarch64: Support PSCI for Armv8-R AArch64 Date: Tue, 16 Jul 2024 15:29:05 +0100 Message-Id: <20240716142906.1502802-6-luca.fancellu@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240716142906.1502802-1-luca.fancellu@arm.com> References: <20240716142906.1502802-1-luca.fancellu@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240716_072928_331363_33D56226 X-CRM114-Status: GOOD ( 12.67 ) 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 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]) # Allow a user to pass --with-initrd AC_ARG_WITH([initrd],