blob: d3ccb2ebe9cd55a7e3c9dca943d5695de845cc50 [file] [log] [blame]
Andrew Geissler9347dd42023-03-03 12:38:41 -06001From 521c121eccb386aca7c75d92528e495546adccec Mon Sep 17 00:00:00 2001
Brad Bishopbec4ebc2022-08-03 09:55:16 -04002From: Jaxson Han <jaxson.han@arm.com>
3Date: Mon, 25 Oct 2021 17:09:13 +0800
4Subject: [PATCH] aarch64: Disable CNTPCT_EL0 trap for v8-R64
5
6To allow EL1 to access CNTPCT_EL0 without traping into EL2, we need to
7set CNTHCTL_EL2.EL1PCTEN to 1.
8
9For v8-R64, the CNTHCTL_EL2 register follows the v8-A architecture.
10However, as described in the v8-A architecture profile, the
11CNTHCTL_EL2's bit assignments are different according to whether the
12FEAT_VHE is implemented.
13
14Since v8-R64 does not support FEAT_VHE, we do not need to detect
15FEAT_VHE. We can simply set CNTHCTL_EL2.EL1PCTEN to 1.
16
17Issue-ID: SCM-3508
18Upstream-Status: Inappropriate [other]
19 Implementation pending further discussion
20Signed-off-by: Jaxson Han <jaxson.han@arm.com>
21Change-Id: I4147e66341c8153312021e6f2ab67d0037246da1
22---
23 arch/aarch64/boot.S | 12 ++++++++++++
24 1 file changed, 12 insertions(+)
25
26diff --git a/arch/aarch64/boot.S b/arch/aarch64/boot.S
Andrew Geissler9347dd42023-03-03 12:38:41 -060027index a219ea7..27b1139 100644
Brad Bishopbec4ebc2022-08-03 09:55:16 -040028--- a/arch/aarch64/boot.S
29+++ b/arch/aarch64/boot.S
Andrew Geissler9347dd42023-03-03 12:38:41 -060030@@ -240,6 +240,18 @@ el2_init:
Brad Bishopbec4ebc2022-08-03 09:55:16 -040031 orr x0, x0, #(1 << 41) // HCR_EL2.API
32
33 1: msr hcr_el2, x0
34+
35+ /*
36+ * To disable trap when accessing CNTPCT_EL0, we need to set
37+ * CNTHCTL_EL2.EL1PCTEN to 1. However, the CNTHCTL_EL2 bit assignments
38+ * are different according to whether the FEAT_VHE is implemented.
39+ *
40+ * For Armv8-R AArch64, FEAT_VHE is not supported, so we do not need to
41+ * detect FEAT_VHE(ID_AA64MMFR1_EL1.VH) and simply set
42+ * CNTHCTL_EL2.EL1PCTEN to 1.
43+ */
44+ mov x0, #1 // CNTHCTL_EL2.EL1PCTEN
45+ msr cnthctl_el2, x0
46 isb
47
48 mov w0, #SPSR_KERNEL_EL1