From patchwork Thu Oct 17 09:55:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Fancellu X-Patchwork-Id: 13839808 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 73FC4D21274 for ; Thu, 17 Oct 2024 10:21:55 +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=9ZVoUsc3gCkSydV+NTS3AUww6pPp0B7Wid62TAZPJus=; b=kuHP30SYjxuAC/Ueldue6fepsy MsMHdL4JS9sgo/tYs+AhIeI1SWPnwePw1/FC/X5lCb0higWz/mt71kbPcCvdP2OEY9o39IQ8xOITg 1aPLQHWMntUjmOSrcAXBt+JZQoyXF0o1yPAVHGo0bbkAvZMiZ9kjcCEHNIzIAq8acgYhTY2mJTkwT BCGiYkTyWdBv+L79RMsptF1Z8B1heoOj8yDqGMTUkf7KXfwwVL1jd5Wd1MupN3zNHG2+qvZBiDLOb UEwo71ljpuL3Vm34OK/6pDoMjkefnYurheV2LeGMIG0hoHWKfKHpxmE86sqGnDMcuMvqlvs6s+irw E4mmiBxg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1NdY-0000000EVDe-16sb; Thu, 17 Oct 2024 10:21:44 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1NEB-0000000ER1c-1pzJ for linux-arm-kernel@lists.infradead.org; Thu, 17 Oct 2024 09:55:35 +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 A7EA91570; Thu, 17 Oct 2024 02:56:00 -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 66E4E3F71E; Thu, 17 Oct 2024 02:55:30 -0700 (PDT) From: Luca Fancellu To: mark.rutland@arm.com, andre.przywara@arm.com Cc: linux-arm-kernel@lists.infradead.org Subject: [boot-wrapper v4 3/4] aarch64: Implement PSCI for Armv8-R Date: Thu, 17 Oct 2024 10:55:19 +0100 Message-Id: <20241017095520.939464-4-luca.fancellu@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241017095520.939464-1-luca.fancellu@arm.com> References: <20241017095520.939464-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-20241017_025531_616530_AA4F5FCA X-CRM114-Status: GOOD ( 11.78 ) 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 Armv8-R doesn't have EL3, so the PSCI vector needs to be installed in VBAR_EL2 and the conduit needs to be 'hcv' instead of 'smc'. Implement the modifications needed when --with-bw-arch is 'aarch64-r'. Signed-off-by: Luca Fancellu --- v4 changes: - rework cpu_init_psci_arch code to don't have #ifdef --- Makefile.am | 2 +- arch/aarch64/init.c | 15 +++++++++++---- configure.ac | 3 +++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Makefile.am b/Makefile.am index 44ea3f7e0d7b..aecda694fd6c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -71,7 +71,7 @@ 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 9bbfce3aaf34..da036bb0b947 100644 --- a/arch/aarch64/init.c +++ b/arch/aarch64/init.c @@ -224,13 +224,20 @@ extern char psci_vectors[]; static void cpu_init_psci_arch(unsigned int cpu) { - if (mrs(CurrentEL) != CURRENTEL_EL3) { - print_cpu_warn(cpu, "PSCI could not be initialized (not booted at EL3).\r\n"); + if (!bootwrapper_is_r_class() && mrs(CurrentEL) == CURRENTEL_EL3) { + msr(VBAR_EL3, (unsigned long)psci_vectors); + isb(); return; } - msr(VBAR_EL3, (unsigned long)psci_vectors); - isb(); + if (bootwrapper_is_r_class() && mrs(CurrentEL) == CURRENTEL_EL2) { + msr(VBAR_EL2, (unsigned long)psci_vectors); + isb(); + return; + } + + print_cpu_warn(cpu, "PSCI could not be initialized (not booted at EL3).\r\n"); + } #else static void cpu_init_psci_arch(unsigned int cpu) { } diff --git a/configure.ac b/configure.ac index 95e2b7f05756..a433c89bd2ae 100644 --- a/configure.ac +++ b/configure.ac @@ -107,6 +107,9 @@ AC_ARG_ENABLE([psci], [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_ARCH" = "xaarch64-r"], + AC_SUBST([PSCI_METHOD], [hvc]), AC_SUBST([PSCI_METHOD], [smc]) +) AS_IF([test "x$USE_PSCI" != "xyes" -a "x$KERNEL_ES" = "x32"], [AC_MSG_ERROR([With an AArch32 kernel, boot method must be PSCI.])]