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 EB2AEC433EF for ; Tue, 1 Feb 2022 17:24:16 +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=m7DBTPuKZBUZIoKYG0A1+0djF1XPgiUpCoiujf3IcTY=; b=Q7WkY8045yK89X qbgmNZuFhPvHC2qIvKhBslHY86+TDagPP9DHm60pe1lMTCliSx3GQhpHuZvY7in8A0W2g/vVZMO/3 qgf6W3J1egFLVCwJ5BITKjHP/EslSIfzMbRuog5lyx37ddqg+DL8YccMgGq7rspts9s1pT48iIVsg BePid5Dme1QENb6FtU2290R+rQ2Bq9KqRjrl7MpGli9ZTMqs+DwFX7qCSr93gxYjh3nPUaPrYK/cw 3QAWu97VSs30eDiqnGTFUadr4YDRFDsB3bEHuZJ/5Hq2862S2LY4kzPCzSctZJGvePaDP1NiUBrLH LGSiy9REYA8ga3U1dJyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nEwrQ-00D9T6-UC; Tue, 01 Feb 2022 17:22:33 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nEwqo-00D9Fy-TW for linux-arm-kernel@lists.infradead.org; Tue, 01 Feb 2022 17:21:57 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9596AB82F25; Tue, 1 Feb 2022 17:21:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E55CC340F0; Tue, 1 Feb 2022 17:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643736112; bh=OKu4AwZQGPfw53t+d4fkrFMmsWf7k4jKrFqbxmjgxrE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eyvrAb92pxSwfJqpv7i1KRQeTKAEn3qkedIv8VbjKiLmtSIMg5hTAhbFXGfEgvpNA vFDkrCL4iw6Wxeg8uDyAaJrM0/R1D85+TKKYabJRuWAa/XrKwtDmd0NvUP3oBe6E3p GDLVgKWkbz0XgrCx57KylyHW4LrdWYDAwSFgq56wT84DCawpAJGS3VArQQnApw5EII dfSadueaMfk374RODHGjl/hIevlSmBbBGszHfZfbsygYj9k6fJAe0M03b5xmVda5jq ksJnHH6Yibbqz8YaWiuulqDDvQ9LpWCF4UxxEbwXQaTp5D0r55xipRaPZcvSayPVVA +WAicUvDhZw6w== From: broonie@kernel.org To: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org, Mark Brown Subject: [boot-wrapper PATCH 2/2] aarch64: Enable use of SME by EL2 and below Date: Tue, 1 Feb 2022 17:21:32 +0000 Message-Id: <20220201172132.2399026-2-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220201172132.2399026-1-broonie@kernel.org> References: <20220201172132.2399026-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2791; h=from:subject; bh=haJMJwE2SBPmNPcH8i8pa/VzhJHYZyu9iv1PJ2PsXa8=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBh+WvT6yr0C1hnIVzjuotEWZdYzZpb22/YtmoGUDLV Alape9iJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYflr0wAKCRAk1otyXVSH0EoRB/ 9H3ryqvfu7x35RneGtxiJNjlhS+YiMU6OFnh53VUoFOasgeNAEtVQHP5upKgto/aq5FsidQivmbWxv cp/7OVvh1pdHCOQmzCFdBmyGLqBpPSEkckSMXzvuNCfHzx2iE6RCUGluv0RARa9R9PmApazei7rlC2 Qm0+an3GSs9zaU423nQ43dNuuPtsyc4w8KvEAI7V48ZXEpc/qRfu59byaaWOWStmcRJMq1ZeUussl4 iZUWPxX/SmFTogjC520IjsSV0JWCkd3ttQO/Rhj1KjjMUWnWkpk9gcQOKAdvrZ034gfJc4kGMUBQJ9 gN/a1MoElvXrybVdSp2wRUofwta4zO X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220201_092155_301131_3D8E6E61 X-CRM114-Status: GOOD ( 16.07 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Mark Brown Allow lower ELs to use SME when booted on a system that support it. This requires us to set two new bits, one in each of SCR_EL3 and CPTR_EL3, set the maximum vector length in a similar fashion to SVE and if the optional FA64 feature is present then set another feature bit in the new SMCR register. Signed-off-by: Mark Brown --- arch/aarch64/include/asm/cpu.h | 10 ++++++++++ arch/aarch64/init.c | 22 ++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/arch/aarch64/include/asm/cpu.h b/arch/aarch64/include/asm/cpu.h index ce80b6e..49f5a71 100644 --- a/arch/aarch64/include/asm/cpu.h +++ b/arch/aarch64/include/asm/cpu.h @@ -49,6 +49,7 @@ #define SCR_EL3_FGTEN BIT(27) #define SCR_EL3_ECVEN BIT(28) #define SCR_EL3_TME BIT(34) +#define SCR_EL3_EnTP2 BIT(41) #define HCR_EL2_RES1 BIT(1) @@ -69,9 +70,13 @@ #define ID_AA64MMFR0_EL1_FGT BITS(59, 56) #define ID_AA64MMFR0_EL1_ECV BITS(63, 60) +#define ID_AA64PFR1_EL1_SME BITS(27, 24) #define ID_AA64PFR1_EL1_MTE BITS(11, 8) #define ID_AA64PFR0_EL1_SVE BITS(35, 32) +#define ID_AA64SMFR0_EL1 s3_0_c0_c4_5 +#define ID_AA64SMFR0_EL1_FA64 (1UL << 63) + /* * Initial register values required for the boot-wrapper to run out-of-reset. */ @@ -96,6 +101,7 @@ #define SPSR_EL2H (9 << 0) /* EL2 Handler mode */ #define SPSR_HYP (0x1a << 0) /* M[3:0] = hyp, M[4] = AArch32 */ +#define CPTR_EL3_ESM (1 << 12) #define CPTR_EL3_EZ (1 << 8) #define ICC_SRE_EL2 S3_4_C12_C9_5 @@ -107,6 +113,10 @@ #define ZCR_EL3 s3_6_c1_c2_0 #define ZCR_EL3_LEN_MAX 0xf +#define SMCR_EL3 s3_6_c1_c2_6 +#define SMCR_EL3_FA64 (1 << 31) +#define SMCR_EL3_LEN_MAX 0xf + #define ID_AA64ISAR2_EL1 s3_0_c0_c6_2 #define SCTLR_EL1_CP15BEN (1 << 5) diff --git a/arch/aarch64/init.c b/arch/aarch64/init.c index 8bb0524..db73b58 100644 --- a/arch/aarch64/init.c +++ b/arch/aarch64/init.c @@ -47,6 +47,7 @@ void cpu_init_el3(void) unsigned long scr = SCR_EL3_RES1 | SCR_EL3_NS | SCR_EL3_HCE; unsigned long mdcr = 0; unsigned long cptr = 0; + unsigned long smcr = 0; if (cpu_has_pauth()) scr |= SCR_EL3_APK | SCR_EL3_API; @@ -95,6 +96,27 @@ void cpu_init_el3(void) msr(ZCR_EL3, ZCR_EL3_LEN_MAX); } + if (mrs_field(ID_AA64PFR1_EL1, SME)) { + cptr |= CPTR_EL3_ESM; + msr(CPTR_EL3, cptr); + isb(); + + scr |= SCR_EL3_EnTP2; + msr(SCR_EL3, scr); + isb(); + + /* + * Write the maximum possible vector length, hardware + * will constrain to the actual limit. + */ + smcr = SMCR_EL3_LEN_MAX; + + if (mrs_field(ID_AA64SMFR0_EL1, FA64)) + smcr |= SMCR_EL3_FA64; + + msr(SMCR_EL3, smcr); + } + msr(CNTFRQ_EL0, COUNTER_FREQ); } -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel