From patchwork Thu Jun 6 13:36:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13688520 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 6792AC27C65 for ; Thu, 6 Jun 2024 13:37:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7fSCl/CWUFvKQMe4D2SHVq1Zw1Ex7gTT7RNFgB4ItKc=; b=X4JXOiNvHhdR/n 3cdogv+2QR8J8o3mcVTefhb1CDIMmdHD14Rynr02/ZqBAVnSt7Cxx8ZHM8jKaOLfuiI0fPPCOOxvz 6malmG8wMPLBEMjyd7MdSvFf4kCEeRReFtQtXefMExdx2kldUuPCiYAV8RB7wkr2kt46tvuLP02hK jZ4hcNLhgZdSe1tqf8HqxOffYNfunpVl6m4rrLEYouhHUgSDFVMKc7hoFzAvAQWk2NZ+uBY3C0RwG 6LY/RJQW6+kJFnM5sPYiY2bLrUyMz2jpnGOkouPgPgpSJ0LdXvXmqrIGxOF8g74A6T7km0VRQEQwg rr8rQW/Pf2ul+BfiTf6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sFDIS-00000009vZe-0sO7; Thu, 06 Jun 2024 13:36:52 +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 1sFDIL-00000009vVR-1J23 for linux-arm-kernel@lists.infradead.org; Thu, 06 Jun 2024 13:36:47 +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 A723D1596; Thu, 6 Jun 2024 06:37:07 -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 D71963F792; Thu, 6 Jun 2024 06:36:42 -0700 (PDT) From: Luca Fancellu To: linux-arm-kernel@lists.infradead.org Cc: diego.sueiro@arm.com Subject: [boot-wrapper 6/7] aarch64: Support PSCI for Armv8-R AArch64 Date: Thu, 6 Jun 2024 14:36:27 +0100 Message-Id: <20240606133628.3330423-7-luca.fancellu@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240606133628.3330423-1-luca.fancellu@arm.com> References: <20240606133628.3330423-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-20240606_063645_483766_2922243F X-CRM114-Status: GOOD ( 12.46 ) 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 --- 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],