Andrew Geissler | 9347dd4 | 2023-03-03 12:38:41 -0600 | [diff] [blame^] | 1 | From 521c121eccb386aca7c75d92528e495546adccec Mon Sep 17 00:00:00 2001 |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 2 | From: Jaxson Han <jaxson.han@arm.com> |
| 3 | Date: Mon, 25 Oct 2021 17:09:13 +0800 |
| 4 | Subject: [PATCH] aarch64: Disable CNTPCT_EL0 trap for v8-R64 |
| 5 | |
| 6 | To allow EL1 to access CNTPCT_EL0 without traping into EL2, we need to |
| 7 | set CNTHCTL_EL2.EL1PCTEN to 1. |
| 8 | |
| 9 | For v8-R64, the CNTHCTL_EL2 register follows the v8-A architecture. |
| 10 | However, as described in the v8-A architecture profile, the |
| 11 | CNTHCTL_EL2's bit assignments are different according to whether the |
| 12 | FEAT_VHE is implemented. |
| 13 | |
| 14 | Since v8-R64 does not support FEAT_VHE, we do not need to detect |
| 15 | FEAT_VHE. We can simply set CNTHCTL_EL2.EL1PCTEN to 1. |
| 16 | |
| 17 | Issue-ID: SCM-3508 |
| 18 | Upstream-Status: Inappropriate [other] |
| 19 | Implementation pending further discussion |
| 20 | Signed-off-by: Jaxson Han <jaxson.han@arm.com> |
| 21 | Change-Id: I4147e66341c8153312021e6f2ab67d0037246da1 |
| 22 | --- |
| 23 | arch/aarch64/boot.S | 12 ++++++++++++ |
| 24 | 1 file changed, 12 insertions(+) |
| 25 | |
| 26 | diff --git a/arch/aarch64/boot.S b/arch/aarch64/boot.S |
Andrew Geissler | 9347dd4 | 2023-03-03 12:38:41 -0600 | [diff] [blame^] | 27 | index a219ea7..27b1139 100644 |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 28 | --- a/arch/aarch64/boot.S |
| 29 | +++ b/arch/aarch64/boot.S |
Andrew Geissler | 9347dd4 | 2023-03-03 12:38:41 -0600 | [diff] [blame^] | 30 | @@ -240,6 +240,18 @@ el2_init: |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 31 | 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 |