From patchwork Tue Jul 23 11:06:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 13739916 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 0A3F0C3DA49 for ; Tue, 23 Jul 2024 11:07:21 +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=GFUv5eV1fSxwNGi+jelOJiUsc1L8nwaZRy2O03bkVV8=; b=hGhTkEKl5mQ8dj6T47SNj7/7u1 1SFkiON20jomv0DFh5RHAHEKKNVj7TdcQJgU7BbG/DN39maS9OuM/1sSwV6yikwUVmwostddCqP+0 qbOS1XEaDbhYJWpLgjKnh6xuG7cFtDBwzEUae84hWGjUOSUUt83qfWE/aOSJLTRrWM33uD9k0Zieo pG+65hdn3YqwYqlHokGo1aD2hpd6ZF/V1EXoH6/hYeFG17VIAn7VBYNhr+A0X/4pCGBf5dgbyG4ii 2FHw4dwDzo1epMC+/qxy/9mgvQkZNJ6YwWaJegRSdWM/K8ic4AdHkXXdv3DALSu39jBws9uQ86suk SbvOoopw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sWDMJ-0000000CECt-06fO; Tue, 23 Jul 2024 11:07:07 +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 1sWDLu-0000000CE9C-3Hpv for linux-arm-kernel@lists.infradead.org; Tue, 23 Jul 2024 11:06:44 +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 D16EF1476; Tue, 23 Jul 2024 04:07:07 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.54.37]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D5C613F73F; Tue, 23 Jul 2024 04:06:40 -0700 (PDT) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org Cc: mark.rutland@arm.com, Anshuman Khandual Subject: [boot-wrapper 1/3] aarch64: Enable access into 128 bit system registers from EL2 and below Date: Tue, 23 Jul 2024 16:36:28 +0530 Message-Id: <20240723110630.483871-2-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240723110630.483871-1-anshuman.khandual@arm.com> References: <20240723110630.483871-1-anshuman.khandual@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240723_040642_882291_1665ACBF X-CRM114-Status: UNSURE ( 8.61 ) X-CRM114-Notice: Please train this message. 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 FEAT_D128 adds 128 bit system registers like PAR_EL1, TTBR0_EL1, TTBR1_EL1, TTBR0_EL2, TTBR1_EL2, TTBR0_EL12, TTBR1_EL12 , VTTBR_EL2, RCWMASK_EL1, and RCWSMASK_EL1. But access into these register from EL2 and below trap to EL3 unless SCR_EL3.D128En is set. Enable access to 128 bit registers when they are implemented. Signed-off-by: Anshuman Khandual --- arch/aarch64/include/asm/cpu.h | 2 ++ arch/aarch64/init.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/arch/aarch64/include/asm/cpu.h b/arch/aarch64/include/asm/cpu.h index 124ef91..0b8b463 100644 --- a/arch/aarch64/include/asm/cpu.h +++ b/arch/aarch64/include/asm/cpu.h @@ -57,6 +57,7 @@ #define SCR_EL3_EnTP2 BIT(41) #define SCR_EL3_TCR2EN BIT(43) #define SCR_EL3_PIEN BIT(45) +#define SCR_EL3_D128En BIT(47) #define HCR_EL2_RES1 BIT(1) @@ -85,6 +86,7 @@ #define ID_AA64MMFR3_EL1_S2PIE BITS(15, 12) #define ID_AA64MMFR3_EL1_S1POE BITS(19, 16) #define ID_AA64MMFR3_EL1_S2POE BITS(23, 20) +#define ID_AA64MMFR3_EL1_D128 BITS(35, 32) #define ID_AA64PFR1_EL1_MTE BITS(11, 8) #define ID_AA64PFR1_EL1_SME BITS(27, 24) diff --git a/arch/aarch64/init.c b/arch/aarch64/init.c index 37cb45f..7d9d0d9 100644 --- a/arch/aarch64/init.c +++ b/arch/aarch64/init.c @@ -89,6 +89,9 @@ void cpu_init_el3(void) if (!kernel_is_32bit()) scr |= SCR_EL3_RW; + if (mrs_field(ID_AA64MMFR3_EL1, D128)) + scr |= SCR_EL3_D128En; + msr(SCR_EL3, scr); msr(CPTR_EL3, cptr); From patchwork Tue Jul 23 11:06:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 13739925 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 16B66C3DA49 for ; Tue, 23 Jul 2024 11:07:56 +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=mFCoRn/ZDdOEP1lxJZpqCVzxK6yGkcneRZbDjTa/F0o=; b=x/Mj+/XSn6u/EbYMcF2e/03WBB X3UaKcpu3PCM56ZhvqLjYuJoENoGa9jFJcqbq0BHTKbaFIREHZYAV68Wioj2uKYxKLTVueiACveh1 ta7RFRDAuY3L+19ujz7sY1Tw69DRBk76Qv/mSe7hgMuGjvmjTJi5OdkRrX/n9rBij0KLlm3u9rSWo z/pebsJkc2Fh8zpOTk4c/GC9865nlqMLNoDzRu3mqlvcJ4/5tiMnksPgQPT9FP6dzPYkKd1r0CMz6 wH343+NncOnmcRAEmhXQCEZgpCiT9klPB1kLcVCH6aUilKOXveoMC6RH37oREdi0Ir1ta8IkE0eI9 wGLaqtUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sWDMx-0000000CEK2-0Mq7; Tue, 23 Jul 2024 11:07:47 +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 1sWDLy-0000000CEA2-2DDX for linux-arm-kernel@lists.infradead.org; Tue, 23 Jul 2024 11:06: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 6B77A139F; Tue, 23 Jul 2024 04:07:11 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.54.37]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1F3483F73F; Tue, 23 Jul 2024 04:06:42 -0700 (PDT) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org Cc: mark.rutland@arm.com, Anshuman Khandual Subject: [boot-wrapper 2/3] aarch64: Enable access into SCTLR2_ELx registers from EL2 and below Date: Tue, 23 Jul 2024 16:36:29 +0530 Message-Id: <20240723110630.483871-3-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240723110630.483871-1-anshuman.khandual@arm.com> References: <20240723110630.483871-1-anshuman.khandual@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240723_040646_640852_29A36127 X-CRM114-Status: UNSURE ( 9.89 ) X-CRM114-Notice: Please train this message. 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 FEAT_SCTLR2 adds SCTLR2_EL1 and SCTLR2_EL2 system registers But access into these register from EL2 and below trap to EL3 unless SCR_EL3.D128En is set. Enable access to SCTLR2_ELx registers when they are implemented. Signed-off-by: Anshuman Khandual --- arch/aarch64/include/asm/cpu.h | 4 +++- arch/aarch64/init.c | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/aarch64/include/asm/cpu.h b/arch/aarch64/include/asm/cpu.h index 0b8b463..57d66e4 100644 --- a/arch/aarch64/include/asm/cpu.h +++ b/arch/aarch64/include/asm/cpu.h @@ -56,6 +56,7 @@ #define SCR_EL3_HXEn BIT(38) #define SCR_EL3_EnTP2 BIT(41) #define SCR_EL3_TCR2EN BIT(43) +#define SCR_EL3_SCTLR2En BIT(44) #define SCR_EL3_PIEN BIT(45) #define SCR_EL3_D128En BIT(47) @@ -81,7 +82,8 @@ #define ID_AA64MMFR1_EL1_HCX BITS(43, 40) -#define ID_AA64MMFR3_EL1_TCRX BITS(4, 0) +#define ID_AA64MMFR3_EL1_TCRX BITS(3, 0) +#define ID_AA64MMFR3_EL1_SCTLRX BITS(7, 4) #define ID_AA64MMFR3_EL1_S1PIE BITS(11, 8) #define ID_AA64MMFR3_EL1_S2PIE BITS(15, 12) #define ID_AA64MMFR3_EL1_S1POE BITS(19, 16) diff --git a/arch/aarch64/init.c b/arch/aarch64/init.c index 7d9d0d9..5b21cb8 100644 --- a/arch/aarch64/init.c +++ b/arch/aarch64/init.c @@ -92,6 +92,9 @@ void cpu_init_el3(void) if (mrs_field(ID_AA64MMFR3_EL1, D128)) scr |= SCR_EL3_D128En; + if (mrs_field(ID_AA64MMFR3_EL1, SCTLRX)) + scr |= SCR_EL3_SCTLR2En; + msr(SCR_EL3, scr); msr(CPTR_EL3, cptr); From patchwork Tue Jul 23 11:06:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 13739926 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 959ECC3DA63 for ; Tue, 23 Jul 2024 11:08:24 +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=izQ9cHso8iX56RSNQb1IgGoY76pqb8P4AfbgHONbl3o=; b=024t5C1X/WdDSPzLR+z68CZbsR YF8KEkHd65swPC43dYqnih9GiGkVJQPVdOzal1VYCZ4BCqArDjLIlxXZinCpyzSvVgL0prB/AX11S 8ZPnX6yIPMGv6OZwBB3ipQDC972105OlRLJ7RXERtx4jGBUc4CEoC1yrR9vHJUetrQbuJcsvsuJnG ahbNhRkGq2ip8EfWAhthQrHp0DKrbQa2egUTc2WmwQKDdZV54zsbQZQOp/jh7ghsiKts9rm2S9+Qf A2drjfcrUoYB09TOd47Elm2AOVnME8n6gTFrWMFFJPfjFOBr83UwreY60tnq7uMXcorZpqoINCzak G3EtryFA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sWDNI-0000000CEPW-1XJH; Tue, 23 Jul 2024 11:08:08 +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 1sWDM0-0000000CEAi-368S for linux-arm-kernel@lists.infradead.org; Tue, 23 Jul 2024 11:06:49 +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 B43EB139F; Tue, 23 Jul 2024 04:07:13 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.54.37]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 94B763F73F; Tue, 23 Jul 2024 04:06:46 -0700 (PDT) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org Cc: mark.rutland@arm.com, Anshuman Khandual Subject: [boot-wrapper 3/3] aarch64: Enable access into RCW[S]MASK_EL1 registers from EL2 and below Date: Tue, 23 Jul 2024 16:36:30 +0530 Message-Id: <20240723110630.483871-4-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240723110630.483871-1-anshuman.khandual@arm.com> References: <20240723110630.483871-1-anshuman.khandual@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240723_040648_836185_6D69381F X-CRM114-Status: UNSURE ( 8.39 ) X-CRM114-Notice: Please train this message. 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 FEAT_THE adds RCW[S]MASK_EL1 system registers. But access into these system registers from EL2 and below trap to EL3 unless SCR_EL3.RCWMASKEn is set. Enable access to RCW[S]MASK_EL1 registers when they are implemented. Signed-off-by: Anshuman Khandual --- arch/aarch64/include/asm/cpu.h | 2 ++ arch/aarch64/init.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/arch/aarch64/include/asm/cpu.h b/arch/aarch64/include/asm/cpu.h index 57d66e4..8404152 100644 --- a/arch/aarch64/include/asm/cpu.h +++ b/arch/aarch64/include/asm/cpu.h @@ -55,6 +55,7 @@ #define SCR_EL3_TME BIT(34) #define SCR_EL3_HXEn BIT(38) #define SCR_EL3_EnTP2 BIT(41) +#define SCR_EL3_RCWMASKEn BIT(42) #define SCR_EL3_TCR2EN BIT(43) #define SCR_EL3_SCTLR2En BIT(44) #define SCR_EL3_PIEN BIT(45) @@ -92,6 +93,7 @@ #define ID_AA64PFR1_EL1_MTE BITS(11, 8) #define ID_AA64PFR1_EL1_SME BITS(27, 24) +#define ID_AA64PFR1_EL1_THE BITS(51, 48) #define ID_AA64PFR0_EL1_SVE BITS(35, 32) #define ID_AA64SMFR0_EL1 s3_0_c0_c4_5 diff --git a/arch/aarch64/init.c b/arch/aarch64/init.c index 5b21cb8..13a2339 100644 --- a/arch/aarch64/init.c +++ b/arch/aarch64/init.c @@ -95,6 +95,9 @@ void cpu_init_el3(void) if (mrs_field(ID_AA64MMFR3_EL1, SCTLRX)) scr |= SCR_EL3_SCTLR2En; + if (mrs_field(ID_AA64PFR1_EL1, THE)) + scr |= SCR_EL3_RCWMASKEn; + msr(SCR_EL3, scr); msr(CPTR_EL3, cptr);