Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * SPDX-License-Identifier: BSD-3-Clause |
| 3 | * SPDX-FileCopyrightText: Copyright TF-RMM Contributors. |
| 4 | */ |
| 5 | |
| 6 | #ifndef ARCH_H |
| 7 | #define ARCH_H |
| 8 | |
| 9 | #include <utils_def.h> |
| 10 | |
| 11 | /* Cache line size */ |
| 12 | #define CACHE_WRITEBACK_GRANULE UL(64) |
| 13 | |
| 14 | /* Timer interrupt IDs defined by the Server Base System Architecture */ |
| 15 | #define EL1_VIRT_TIMER_PPI UL(27) |
| 16 | #define EL1_PHYS_TIMER_PPI UL(30) |
| 17 | |
| 18 | /* Counter-timer Physical Offset register */ |
| 19 | #define CNTPOFF_EL2 S3_4_C14_C0_6 |
| 20 | |
| 21 | /* MPAM0 Register */ |
| 22 | #define MPAM0_EL1 S3_0_C10_C5_1 |
| 23 | |
| 24 | /* Interrupt Controller registers */ |
| 25 | #define ICC_HPPIR1_EL1 S3_0_C12_C12_2 |
| 26 | #define ICC_SRE_EL2 S3_4_C12_C9_5 |
| 27 | |
| 28 | /* Interrupt Controller Control Register */ |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 29 | #define ICC_CTLR_EL1 S3_0_C12_C12_4 |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 30 | |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 31 | #define ICC_CTLR_EL1_EXT_RANGE_BIT (UL(1) << 19) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 32 | |
| 33 | /* Virtual GIC registers */ |
| 34 | #define ICH_AP0R0_EL2 S3_4_C12_C8_0 |
| 35 | #define ICH_AP0R1_EL2 S3_4_C12_C8_1 |
| 36 | #define ICH_AP0R2_EL2 S3_4_C12_C8_2 |
| 37 | #define ICH_AP0R3_EL2 S3_4_C12_C8_3 |
| 38 | #define ICH_AP1R0_EL2 S3_4_C12_C9_0 |
| 39 | #define ICH_AP1R1_EL2 S3_4_C12_C9_1 |
| 40 | #define ICH_AP1R2_EL2 S3_4_C12_C9_2 |
| 41 | #define ICH_AP1R3_EL2 S3_4_C12_C9_3 |
| 42 | |
| 43 | #define ICH_LR0_EL2 S3_4_C12_C12_0 |
| 44 | #define ICH_LR1_EL2 S3_4_C12_C12_1 |
| 45 | #define ICH_LR2_EL2 S3_4_C12_C12_2 |
| 46 | #define ICH_LR3_EL2 S3_4_C12_C12_3 |
| 47 | #define ICH_LR4_EL2 S3_4_C12_C12_4 |
| 48 | #define ICH_LR5_EL2 S3_4_C12_C12_5 |
| 49 | #define ICH_LR6_EL2 S3_4_C12_C12_6 |
| 50 | #define ICH_LR7_EL2 S3_4_C12_C12_7 |
| 51 | #define ICH_LR8_EL2 S3_4_C12_C13_0 |
| 52 | #define ICH_LR9_EL2 S3_4_C12_C13_1 |
| 53 | #define ICH_LR10_EL2 S3_4_C12_C13_2 |
| 54 | #define ICH_LR11_EL2 S3_4_C12_C13_3 |
| 55 | #define ICH_LR12_EL2 S3_4_C12_C13_4 |
| 56 | #define ICH_LR13_EL2 S3_4_C12_C13_5 |
| 57 | #define ICH_LR14_EL2 S3_4_C12_C13_6 |
| 58 | #define ICH_LR15_EL2 S3_4_C12_C13_7 |
| 59 | |
| 60 | #define ICH_HCR_EL2 S3_4_C12_C11_0 |
| 61 | #define ICH_VTR_EL2 S3_4_C12_C11_1 |
| 62 | #define ICH_MISR_EL2 S3_4_C12_C11_2 |
| 63 | #define ICH_VMCR_EL2 S3_4_C12_C11_7 |
| 64 | |
| 65 | /* RNDR definition */ |
| 66 | #define RNDR S3_3_C2_C4_0 |
| 67 | |
Shruti Gupta | 5732bfe | 2024-01-17 13:21:06 +0000 | [diff] [blame] | 68 | /* Data Independent Timing Registers */ |
| 69 | #define DIT S3_3_C4_C2_5 |
| 70 | #define DIT_BIT (UL(1) << 24) |
| 71 | |
Javier Almansa Sobrino | cfd3254 | 2024-10-09 19:38:56 +0100 | [diff] [blame^] | 72 | /* SCTLR2_EL12 register */ |
| 73 | #define SCTLR2_EL12 S3_5_C1_C0_3 |
| 74 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 75 | /* CLIDR definitions */ |
| 76 | #define LOC_SHIFT U(24) |
| 77 | #define CTYPE_SHIFT(n) U(3 * ((n) - 1)) |
| 78 | #define CLIDR_FIELD_WIDTH U(3) |
| 79 | |
| 80 | /* CSSELR definitions */ |
| 81 | #define LEVEL_SHIFT U(1) |
| 82 | |
| 83 | /* Data cache set/way op type defines */ |
| 84 | #define DCISW U(0x0) |
| 85 | #define DCCISW U(0x1) |
| 86 | #define DCCSW U(0x2) |
| 87 | |
| 88 | #define TCR_EL2_T0SZ_SHIFT UL(0) |
| 89 | #define TCR_EL2_T0SZ_WIDTH UL(6) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 90 | |
| 91 | #define TCR_EL2_T1SZ_SHIFT UL(16) |
| 92 | #define TCR_EL2_T1SZ_WIDTH UL(6) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 93 | |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 94 | #define TCR_EL2_EPD0_BIT (UL(1) << 7) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 95 | |
| 96 | #define TCR_EL2_IRGN0_SHIFT UL(8) |
| 97 | #define TCR_EL2_IRGN0_WIDTH UL(2) |
| 98 | #define TCR_EL2_IRGN0_WBWA INPLACE(TCR_EL2_IRGN0, UL(1)) |
| 99 | |
| 100 | #define TCR_EL2_ORGN0_SHIFT UL(10) |
| 101 | #define TCR_EL2_ORGN0_WIDTH UL(2) |
| 102 | #define TCR_EL2_ORGN0_WBWA INPLACE(TCR_EL2_ORGN0, UL(1)) |
| 103 | |
| 104 | #define TCR_EL2_IRGN1_SHIFT UL(24) |
| 105 | #define TCR_EL2_IRGN1_WIDTH UL(2) |
| 106 | #define TCR_EL2_IRGN1_WBWA INPLACE(TCR_EL2_IRGN1, UL(1)) |
| 107 | |
| 108 | #define TCR_EL2_ORGN1_SHIFT UL(26) |
| 109 | #define TCR_EL2_ORGN1_WIDTH UL(2) |
| 110 | #define TCR_EL2_ORGN1_WBWA INPLACE(TCR_EL2_ORGN1, UL(1)) |
| 111 | |
| 112 | #define TCR_EL2_SH0_SHIFT UL(12) |
| 113 | #define TCR_EL2_SH0_WIDTH UL(2) |
| 114 | #define TCR_EL2_SH0_IS INPLACE(TCR_EL2_SH0, UL(3)) |
| 115 | |
| 116 | #define TCR_EL2_SH1_SHIFT UL(28) |
| 117 | #define TCR_EL2_SH1_WIDTH UL(2) |
| 118 | #define TCR_EL2_SH1_IS INPLACE(TCR_EL2_SH1, UL(3)) |
| 119 | |
| 120 | #define TCR_EL2_TG0_SHIFT UL(14) |
| 121 | #define TCR_EL2_TG0_WIDTH UL(2) |
| 122 | #define TCR_EL2_TG0_4K INPLACE(TCR_EL2_TG0, UL(0)) |
| 123 | |
| 124 | #define TCR_EL2_TG1_SHIFT UL(30) |
| 125 | #define TCR_EL2_TG1_WIDTH UL(2) |
Javier Almansa Sobrino | 7019490 | 2023-02-28 10:27:02 +0000 | [diff] [blame] | 126 | #define TCR_EL2_TG1_4K INPLACE(TCR_EL2_TG1, UL(2)) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 127 | |
| 128 | #define TCR_EL2_IPS_SHIFT UL(32) |
| 129 | #define TCR_EL2_IPS_WIDTH UL(3) |
| 130 | #define TCR_PS_BITS_4GB INPLACE(TCR_EL2_IPS, UL(0)) |
| 131 | #define TCR_PS_BITS_64GB INPLACE(TCR_EL2_IPS, UL(1)) |
| 132 | #define TCR_PS_BITS_1TB INPLACE(TCR_EL2_IPS, UL(2)) |
| 133 | #define TCR_PS_BITS_4TB INPLACE(TCR_EL2_IPS, UL(3)) |
| 134 | #define TCR_PS_BITS_16TB INPLACE(TCR_EL2_IPS, UL(4)) |
| 135 | #define TCR_PS_BITS_256TB INPLACE(TCR_EL2_IPS, UL(5)) |
Javier Almansa Sobrino | 765a316 | 2023-04-27 17:42:58 +0100 | [diff] [blame] | 136 | #define TCR_PS_BITS_4PB INPLACE(TCR_EL2_IPS, UL(6)) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 137 | |
Javier Almansa Sobrino | 765a316 | 2023-04-27 17:42:58 +0100 | [diff] [blame] | 138 | #define TCR_EL2_DS_SHIFT UL(59) |
| 139 | #define TCR_EL2_DS_WIDTH UL(1) |
| 140 | #define TCR_EL2_DS_LPA2_EN INPLACE(TCR_EL2_DS, UL(1)) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 141 | |
| 142 | #define TCR_EL2_AS (UL(1) << 36) |
| 143 | #define TCR_EL2_HPD0 (UL(1) << 41) |
| 144 | #define TCR_EL2_HPD1 (UL(1) << 42) |
| 145 | #define TCR_EL2_E0PD1 (UL(1) << 56) /* TODO: ARMv8.5-E0PD, otherwise RES0 */ |
| 146 | |
| 147 | #define TCR_TxSZ_MIN UL(16) |
Javier Almansa Sobrino | 765a316 | 2023-04-27 17:42:58 +0100 | [diff] [blame] | 148 | #define TCR_TxSZ_MIN_LPA2 UL(12) |
Javier Almansa Sobrino | ed93259 | 2023-01-24 12:50:41 +0000 | [diff] [blame] | 149 | #define TCR_TxSZ_MAX UL(48) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 150 | |
| 151 | /* HCR definitions */ |
| 152 | #define HCR_FWB (UL(1) << 46) |
| 153 | #define HCR_TEA (UL(1) << 37) |
| 154 | #define HCR_API (UL(1) << 41) |
| 155 | #define HCR_APK (UL(1) << 40) |
| 156 | #define HCR_TERR (UL(1) << 36) |
| 157 | #define HCR_TLOR (UL(1) << 35) |
| 158 | #define HCR_E2H (UL(1) << 34) |
| 159 | #define HCR_RW (UL(1) << 31) |
AlexeiFedorov | 862f96c | 2024-03-01 16:26:48 +0000 | [diff] [blame] | 160 | #define HCR_TDZ (UL(1) << 28) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 161 | #define HCR_TGE (UL(1) << 27) |
| 162 | #define HCR_TSW (UL(1) << 22) |
| 163 | #define HCR_TACR (UL(1) << 21) |
| 164 | #define HCR_TIDCP (UL(1) << 20) |
| 165 | #define HCR_TSC (UL(1) << 19) |
| 166 | #define HCR_TID3 (UL(1) << 18) |
| 167 | #define HCR_TWE (UL(1) << 14) |
| 168 | #define HCR_TWI (UL(1) << 13) |
| 169 | #define HCR_VSE (UL(1) << 8) |
| 170 | |
| 171 | #define HCR_BSU_SHIFT 10 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 172 | #define HCR_BSU_WIDTH U(2) |
| 173 | #define HCR_BSU_IS INPLACE(HCR_BSU, UL(1)) /* Barriers are promoted to IS */ |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 174 | |
| 175 | #define HCR_FB (UL(1) << 9) |
| 176 | #define HCR_VI (UL(1) << 7) |
| 177 | #define HCR_AMO (UL(1) << 5) |
| 178 | #define HCR_IMO (UL(1) << 4) |
| 179 | #define HCR_FMO (UL(1) << 3) |
| 180 | #define HCR_PTW (UL(1) << 2) |
| 181 | #define HCR_SWIO (UL(1) << 1) |
| 182 | #define HCR_VM (UL(1) << 0) |
| 183 | |
Arunachalam Ganapathy | 591354a | 2023-11-16 10:49:09 +0000 | [diff] [blame] | 184 | #define HCR_REALM_FLAGS (HCR_FWB | HCR_E2H | HCR_RW | HCR_TSC | \ |
Sona Mathew | c744b93 | 2024-07-16 11:29:25 -0500 | [diff] [blame] | 185 | HCR_AMO | HCR_BSU_IS | HCR_IMO | HCR_FMO | \ |
| 186 | HCR_PTW | HCR_SWIO | HCR_VM | HCR_TID3 | \ |
| 187 | HCR_TEA | HCR_API | HCR_APK) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 188 | |
| 189 | #define HCR_EL2_INIT (HCR_TGE | HCR_E2H | HCR_TEA) |
| 190 | |
Javier Almansa Sobrino | cfd3254 | 2024-10-09 19:38:56 +0100 | [diff] [blame^] | 191 | /* HCRX_EL2 Register */ |
| 192 | #define HCRX_EL2 S3_4_C1_C2_2 |
| 193 | |
| 194 | /* HCRX_EL2 definitions */ |
| 195 | #define HCRX_SCTLR2EN (UL(1) << 15) |
| 196 | |
| 197 | #define HCRX_INIT (UL(0)) |
| 198 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 199 | #define MAIR_ELx_ATTR0_SHIFT 0 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 200 | #define MAIR_ELx_ATTR0_WIDTH U(8) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 201 | |
| 202 | /******************************************************************************* |
| 203 | * Definitions of MAIR encodings for device and normal memory |
| 204 | ******************************************************************************/ |
| 205 | /* |
| 206 | * MAIR encodings for device memory attributes. |
| 207 | */ |
| 208 | #define MAIR_DEV_NGNRNE UL(0x0) /* Device nGnRnE */ |
| 209 | #define MAIR_DEV_NGNRNE_IDX 0x1 |
| 210 | |
| 211 | #define MAIR_DEV_NGNRE UL(0x4) |
| 212 | |
| 213 | #define MAIR_NIOWBNTRW 0xff |
| 214 | #define MAIR_NIOWBNTRW_IDX 0x0 |
| 215 | |
| 216 | /* |
| 217 | * MAIR encodings for normal memory attributes. |
| 218 | * |
| 219 | * Cache Policy |
| 220 | * WT: Write Through |
| 221 | * WB: Write Back |
| 222 | * NC: Non-Cacheable |
| 223 | * |
| 224 | * Transient Hint |
| 225 | * NTR: Non-Transient |
| 226 | * TR: Transient |
| 227 | * |
| 228 | * Allocation Policy |
| 229 | * RA: Read Allocate |
| 230 | * WA: Write Allocate |
| 231 | * RWA: Read and Write Allocate |
| 232 | * NA: No Allocation |
| 233 | */ |
| 234 | #define MAIR_NORM_WT_TR_WA UL(0x1) |
| 235 | #define MAIR_NORM_WT_TR_RA UL(0x2) |
| 236 | #define MAIR_NORM_WT_TR_RWA UL(0x3) |
| 237 | #define MAIR_NORM_NC UL(0x4) |
| 238 | #define MAIR_NORM_WB_TR_WA UL(0x5) |
| 239 | #define MAIR_NORM_WB_TR_RA UL(0x6) |
| 240 | #define MAIR_NORM_WB_TR_RWA UL(0x7) |
| 241 | #define MAIR_NORM_WT_NTR_NA UL(0x8) |
| 242 | #define MAIR_NORM_WT_NTR_WA UL(0x9) |
| 243 | #define MAIR_NORM_WT_NTR_RA UL(0xa) |
| 244 | #define MAIR_NORM_WT_NTR_RWA UL(0xb) |
| 245 | #define MAIR_NORM_WB_NTR_NA UL(0xc) |
| 246 | #define MAIR_NORM_WB_NTR_WA UL(0xd) |
| 247 | #define MAIR_NORM_WB_NTR_RA UL(0xe) |
| 248 | #define MAIR_NORM_WB_NTR_RWA UL(0xf) |
| 249 | |
| 250 | #define MAIR_NORM_OUTER_SHIFT U(4) |
| 251 | |
| 252 | #define MAKE_MAIR_NORMAL_MEMORY(inner, outer) \ |
| 253 | ((inner) | ((outer) << MAIR_NORM_OUTER_SHIFT)) |
| 254 | |
| 255 | #define MAKE_MAIR_NORMAL_MEMORY_IO(_mair) \ |
| 256 | MAKE_MAIR_NORMAL_MEMORY(_mair, _mair) |
| 257 | |
| 258 | /* |
| 259 | * TTBR Definitions |
| 260 | */ |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 261 | #define TTBR_CNP_BIT UL(1) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 262 | |
| 263 | #define TTBRx_EL2_CnP_SHIFT 0 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 264 | #define TTBRx_EL2_CnP_WIDTH U(1) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 265 | |
| 266 | #define TTBRx_EL2_BADDR_SHIFT 1 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 267 | #define TTBRx_EL2_BADDR_WIDTH U(47) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 268 | |
Javier Almansa Sobrino | f6fff69 | 2024-02-02 17:13:57 +0000 | [diff] [blame] | 269 | #define TTBRx_EL2_BADDR_MSB_LPA2_SHIFT 2 |
| 270 | #define TTBRx_EL2_BADDR_MSB_LPA2_WIDTH U(4) |
| 271 | #define EL2_BADDR_MSB_LPA2_SHIFT 48 |
| 272 | #define EL2_BADDR_MSB_LPA2_WIDTH TTBRx_EL2_BADDR_MSB_LPA2_WIDTH |
| 273 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 274 | #define TTBRx_EL2_ASID_SHIFT 48 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 275 | #define TTBRx_EL2_ASID_WIDTH U(16) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 276 | |
| 277 | /* |
| 278 | * VTTBR Definitions |
| 279 | */ |
| 280 | #define VTTBR_EL2_VMID_SHIFT 48 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 281 | #define VTTBR_EL2_VMID_WIDTH U(16) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 282 | |
| 283 | /* |
| 284 | * ESR Definitions |
| 285 | */ |
| 286 | #define ESR_EL2_EC_SHIFT 26 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 287 | #define ESR_EL2_EC_WIDTH U(6) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 288 | |
| 289 | #define ESR_EL2_IL_SHIFT 25 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 290 | #define ESR_EL2_IL_WIDTH U(1) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 291 | |
| 292 | #define ESR_EL2_ISS_SHIFT 0 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 293 | #define ESR_EL2_ISS_WIDTH U(25) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 294 | |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 295 | #define ESR_EL2_EC_UNKNOWN INPLACE(ESR_EL2_EC, UL(0)) |
| 296 | #define ESR_EL2_EC_WFX INPLACE(ESR_EL2_EC, UL(1)) |
| 297 | #define ESR_EL2_EC_FPU INPLACE(ESR_EL2_EC, UL(7)) |
| 298 | #define ESR_EL2_EC_SVC INPLACE(ESR_EL2_EC, UL(21)) |
| 299 | #define ESR_EL2_EC_HVC INPLACE(ESR_EL2_EC, UL(22)) |
| 300 | #define ESR_EL2_EC_SMC INPLACE(ESR_EL2_EC, UL(23)) |
| 301 | #define ESR_EL2_EC_SYSREG INPLACE(ESR_EL2_EC, UL(24)) |
| 302 | #define ESR_EL2_EC_SVE INPLACE(ESR_EL2_EC, UL(25)) |
Arunachalam Ganapathy | 83f46ca | 2023-08-15 18:13:27 +0100 | [diff] [blame] | 303 | #define ESR_EL2_EC_SME INPLACE(ESR_EL2_EC, UL(29)) |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 304 | #define ESR_EL2_EC_INST_ABORT INPLACE(ESR_EL2_EC, UL(32)) |
| 305 | #define ESR_EL2_EC_INST_ABORT_SEL INPLACE(ESR_EL2_EC, UL(33)) |
| 306 | #define ESR_EL2_EC_DATA_ABORT INPLACE(ESR_EL2_EC, UL(36)) |
| 307 | #define ESR_EL2_EC_DATA_ABORT_SEL INPLACE(ESR_EL2_EC, UL(37)) |
| 308 | #define ESR_EL2_EC_SERROR INPLACE(ESR_EL2_EC, UL(47)) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 309 | |
| 310 | /* Data/Instruction Abort ESR fields */ |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 311 | #define ESR_EL2_ABORT_ISV_BIT (UL(1) << 24) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 312 | |
| 313 | #define ESR_EL2_ABORT_SAS_SHIFT 22 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 314 | #define ESR_EL2_ABORT_SAS_WIDTH U(2) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 315 | |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 316 | #define ESR_EL2_ABORT_SAS_BYTE_VAL 0U |
| 317 | #define ESR_EL2_ABORT_SAS_HWORD_VAL 1U |
| 318 | #define ESR_EL2_ABORT_SAS_WORD_VAL 2U |
| 319 | #define ESR_EL2_ABORT_SAS_DWORD_VAL 3U |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 320 | |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 321 | #define ESR_EL2_ABORT_SSE_BIT (UL(1) << 21) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 322 | |
| 323 | #define ESR_EL2_ABORT_SRT_SHIFT 16 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 324 | #define ESR_EL2_ABORT_SRT_WIDTH U(5) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 325 | |
| 326 | #define ESR_EL2_ABORT_SET_SHIFT 11 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 327 | #define ESR_EL2_ABORT_SET_WIDTH U(2) |
| 328 | #define ESR_EL2_ABORT_SET_UER INPLACE(ESR_EL2_ABORT_SET, UL(0)) |
| 329 | #define ESR_EL2_ABORT_SET_UC INPLACE(ESR_EL2_ABORT_SET, UL(2)) |
| 330 | #define ESR_EL2_ABORT_SET_UEO INPLACE(ESR_EL2_ABORT_SET, UL(3)) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 331 | |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 332 | #define ESR_EL2_ABORT_SF_BIT (UL(1) << 15) |
| 333 | #define ESR_EL2_ABORT_FNV_BIT (UL(1) << 10) |
| 334 | #define ESR_EL2_ABORT_EA_BIT (UL(1) << 9) |
| 335 | #define ESR_EL2_ABORT_S1PTW_BIT (UL(1) << 7) |
| 336 | #define ESR_EL2_ABORT_WNR_BIT (UL(1) << 6) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 337 | #define ESR_EL2_ABORT_FSC_SHIFT 0 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 338 | #define ESR_EL2_ABORT_FSC_WIDTH U(6) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 339 | |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 340 | #define ESR_EL2_ABORT_FSC_TRANSLATION_FAULT UL(0x04) |
| 341 | #define ESR_EL2_ABORT_FSC_PERMISSION_FAULT UL(0x0c) |
| 342 | #define ESR_EL2_ABORT_FSC_TRANSLATION_FAULT_L0 UL(0x04) |
| 343 | #define ESR_EL2_ABORT_FSC_SEA UL(0x10) |
| 344 | #define ESR_EL2_ABORT_FSC_SEA_TTW_START UL(0x13) |
| 345 | #define ESR_EL2_ABORT_FSC_SEA_TTW_END UL(0x17) |
| 346 | #define ESR_EL2_ABORT_FSC_GPF UL(0x28) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 347 | #define ESR_EL2_ABORT_FSC_LEVEL_SHIFT 0 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 348 | #define ESR_EL2_ABORT_FSC_LEVEL_WIDTH U(2) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 349 | |
| 350 | /* The ESR fields that are reported to the host on Instr./Data Synchronous Abort */ |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 351 | #define ESR_NONEMULATED_ABORT_MASK ( \ |
| 352 | MASK(ESR_EL2_EC) | \ |
| 353 | MASK(ESR_EL2_ABORT_SET) | \ |
| 354 | ESR_EL2_ABORT_FNV_BIT | \ |
| 355 | ESR_EL2_ABORT_EA_BIT | \ |
| 356 | MASK(ESR_EL2_ABORT_FSC)) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 357 | |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 358 | #define ESR_EMULATED_ABORT_MASK ( \ |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 359 | ESR_NONEMULATED_ABORT_MASK | \ |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 360 | ESR_EL2_ABORT_ISV_BIT | \ |
| 361 | MASK(ESR_EL2_ABORT_SAS) | \ |
| 362 | ESR_EL2_ABORT_SF_BIT | \ |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 363 | ESR_EL2_ABORT_WNR_BIT) |
| 364 | |
| 365 | #define ESR_EL2_SERROR_DFSC_SHIFT 0 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 366 | #define ESR_EL2_SERROR_DFSC_WIDTH U(6) |
| 367 | #define ESR_EL2_SERROR_DFSC_UNCAT INPLACE(ESR_EL2_SERROR_DFSC, UL(0)) |
| 368 | #define ESR_EL2_SERROR_DFSC_ASYNC INPLACE(ESR_EL2_SERROR_DFSC, UL(1)) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 369 | |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 370 | #define ESR_EL2_SERROR_EA_BIT (UL(1) << 9) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 371 | |
| 372 | #define ESR_EL2_SERROR_AET_SHIFT 10 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 373 | #define ESR_EL2_SERROR_AET_WIDTH U(3) |
| 374 | #define ESR_EL2_SERROR_AET_UC INPLACE(ESR_EL2_SERROR_AET, UL(0)) |
| 375 | #define ESR_EL2_SERROR_AET_UEU INPLACE(ESR_EL2_SERROR_AET, UL(1)) |
| 376 | #define ESR_EL2_SERROR_AET_UEO INPLACE(ESR_EL2_SERROR_AET, UL(2)) |
| 377 | #define ESR_EL2_SERROR_AET_UER INPLACE(ESR_EL2_SERROR_AET, UL(3)) |
| 378 | #define ESR_EL2_SERROR_AET_CE INPLACE(ESR_EL2_SERROR_AET, UL(6)) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 379 | |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 380 | #define ESR_EL2_SERROR_IESB_BIT (UL(1) << 13) |
| 381 | #define ESR_EL2_SERROR_IDS_BIT (UL(1) << 24) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 382 | |
| 383 | /* The ESR fields that are reported to the host on SError */ |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 384 | #define ESR_SERROR_MASK ( \ |
| 385 | ESR_EL2_SERROR_IDS_BIT | \ |
| 386 | MASK(ESR_EL2_SERROR_AET) | \ |
| 387 | ESR_EL2_SERROR_EA_BIT | \ |
| 388 | MASK(ESR_EL2_SERROR_DFSC)) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 389 | |
| 390 | #define ESR_EL2_SYSREG_TRAP_OP0_SHIFT 20 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 391 | #define ESR_EL2_SYSREG_TRAP_OP0_WIDTH U(2) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 392 | |
| 393 | #define ESR_EL2_SYSREG_TRAP_OP2_SHIFT 17 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 394 | #define ESR_EL2_SYSREG_TRAP_OP2_WIDTH U(3) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 395 | |
| 396 | #define ESR_EL2_SYSREG_TRAP_OP1_SHIFT 14 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 397 | #define ESR_EL2_SYSREG_TRAP_OP1_WIDTH U(3) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 398 | |
| 399 | #define ESR_EL2_SYSREG_TRAP_CRN_SHIFT 10 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 400 | #define ESR_EL2_SYSREG_TRAP_CRN_WIDTH U(4) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 401 | |
| 402 | #define ESR_EL2_SYSREG_TRAP_RT_SHIFT 5 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 403 | #define ESR_EL2_SYSREG_TRAP_RT_WIDTH U(5) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 404 | |
| 405 | #define ESR_EL2_SYSREG_TRAP_CRM_SHIFT 1 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 406 | #define ESR_EL2_SYSREG_TRAP_CRM_WIDTH U(4) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 407 | |
| 408 | /* WFx ESR fields */ |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 409 | #define ESR_EL2_WFx_TI_BIT (UL(1) << 0) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 410 | |
| 411 | /* xVC ESR fields */ |
| 412 | #define ESR_EL2_xVC_IMM_SHIFT 0 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 413 | #define ESR_EL2_xVC_IMM_WIDTH U(16) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 414 | |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 415 | /* ID_AA64DFR0_EL1 definitions */ |
| 416 | #define ID_AA64DFR0_EL1_HPMN0_SHIFT UL(60) |
| 417 | #define ID_AA64DFR0_EL1_HPMN0_WIDTH UL(4) |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 418 | |
AlexeiFedorov | eaec0c4 | 2023-02-01 18:13:32 +0000 | [diff] [blame] | 419 | #define ID_AA64DFR0_EL1_ExtTrcBuff_SHIFT UL(56) |
| 420 | #define ID_AA64DFR0_EL1_ExtTrcBuff_WIDTH UL(4) |
| 421 | |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 422 | #define ID_AA64DFR0_EL1_BRBE_SHIFT UL(52) |
| 423 | #define ID_AA64DFR0_EL1_BRBE_WIDTH UL(4) |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 424 | |
| 425 | #define ID_AA64DFR0_EL1_MTPMU_SHIFT UL(48) |
| 426 | #define ID_AA64DFR0_EL1_MTPMU_WIDTH UL(4) |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 427 | |
| 428 | #define ID_AA64DFR0_EL1_TraceBuffer_SHIFT UL(44) |
| 429 | #define ID_AA64DFR0_EL1_TraceBuffer_WIDTH UL(4) |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 430 | |
| 431 | #define ID_AA64DFR0_EL1_TraceFilt_SHIFT UL(40) |
| 432 | #define ID_AA64DFR0_EL1_TraceFilt_WIDTH UL(4) |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 433 | |
| 434 | #define ID_AA64DFR0_EL1_DoubleLock_SHIFT UL(36) |
| 435 | #define ID_AA64DFR0_EL1_DoubleLock_WIDTH UL(4) |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 436 | |
| 437 | #define ID_AA64DFR0_EL1_PMSVer_SHIFT UL(32) |
| 438 | #define ID_AA64DFR0_EL1_PMSVer_WIDTH UL(4) |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 439 | |
| 440 | #define ID_AA64DFR0_EL1_CTX_CMPS_SHIFT UL(28) |
| 441 | #define ID_AA64DFR0_EL1_CTX_CMPS_WIDTH UL(4) |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 442 | |
AlexeiFedorov | eaec0c4 | 2023-02-01 18:13:32 +0000 | [diff] [blame] | 443 | #define ID_AA64DFR0_EL1_SEBEP_SHIFT UL(24) |
| 444 | #define ID_AA64DFR0_EL1_SEBEP_WIDTH UL(4) |
| 445 | |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 446 | #define ID_AA64DFR0_EL1_WRPs_SHIFT UL(20) |
| 447 | #define ID_AA64DFR0_EL1_WRPs_WIDTH UL(4) |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 448 | |
AlexeiFedorov | eaec0c4 | 2023-02-01 18:13:32 +0000 | [diff] [blame] | 449 | #define ID_AA64DFR0_EL1_PMSS_SHIFT UL(16) |
| 450 | #define ID_AA64DFR0_EL1_PMSS_WIDTH UL(4) |
| 451 | |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 452 | #define ID_AA64DFR0_EL1_BRPs_SHIFT UL(12) |
| 453 | #define ID_AA64DFR0_EL1_BRPs_WIDTH UL(4) |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 454 | |
| 455 | #define ID_AA64DFR0_EL1_PMUVer_SHIFT UL(8) |
| 456 | #define ID_AA64DFR0_EL1_PMUVer_WIDTH UL(4) |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 457 | |
AlexeiFedorov | eaec0c4 | 2023-02-01 18:13:32 +0000 | [diff] [blame] | 458 | /* Performance Monitors Extension version */ |
| 459 | #define ID_AA64DFR0_EL1_PMUv3p7 UL(7) |
| 460 | #define ID_AA64DFR0_EL1_PMUv3p8 UL(8) |
| 461 | #define ID_AA64DFR0_EL1_PMUv3p9 UL(9) |
| 462 | |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 463 | #define ID_AA64DFR0_EL1_TraceVer_SHIFT UL(4) |
| 464 | #define ID_AA64DFR0_EL1_TraceVer_WIDTH UL(4) |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 465 | |
| 466 | #define ID_AA64DFR0_EL1_DebugVer_SHIFT UL(0) |
| 467 | #define ID_AA64DFR0_EL1_DebugVer_WIDTH UL(4) |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 468 | |
| 469 | /* Debug architecture version */ |
AlexeiFedorov | eaec0c4 | 2023-02-01 18:13:32 +0000 | [diff] [blame] | 470 | #define ID_AA64DFR0_EL1_Debugv8 UL(6) |
AlexeiFedorov | a2ef91d | 2024-08-08 13:49:20 +0100 | [diff] [blame] | 471 | #define ID_AA64DFR0_EL1_Debugv8p1 UL(7) |
AlexeiFedorov | eaec0c4 | 2023-02-01 18:13:32 +0000 | [diff] [blame] | 472 | #define ID_AA64DFR0_EL1_Debugv8p2 UL(8) |
| 473 | #define ID_AA64DFR0_EL1_Debugv8p4 UL(9) |
| 474 | #define ID_AA64DFR0_EL1_Debugv8p8 UL(10) |
AlexeiFedorov | a2ef91d | 2024-08-08 13:49:20 +0100 | [diff] [blame] | 475 | #define ID_AA64DFR0_EL1_Debugv8p9 UL(11) |
AlexeiFedorov | eaec0c4 | 2023-02-01 18:13:32 +0000 | [diff] [blame] | 476 | |
| 477 | /* ID_AA64DFR1_EL1 definitions */ |
| 478 | #define ID_AA64DFR1_EL1_EBEP_SHIFT UL(48) |
| 479 | #define ID_AA64DFR1_EL1_EBEP_WIDTH UL(4) |
| 480 | |
| 481 | #define ID_AA64DFR1_EL1_ICNTR_SHIFT UL(36) |
| 482 | #define ID_AA64DFR1_EL1_ICNTR_WIDTH UL(4) |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 483 | |
AlexeiFedorov | a2ef91d | 2024-08-08 13:49:20 +0100 | [diff] [blame] | 484 | #define ID_AA64DFR1_EL1_WRPs_SHIFT UL(16) |
| 485 | #define ID_AA64DFR1_EL1_WRPs_WIDTH UL(8) |
| 486 | |
| 487 | #define ID_AA64DFR1_EL1_BRPs_SHIFT UL(8) |
| 488 | #define ID_AA64DFR1_EL1_BRPs_WIDTH UL(8) |
| 489 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 490 | /* ID_AA64PFR0_EL1 definitions */ |
| 491 | #define ID_AA64PFR0_EL1_SVE_SHIFT UL(32) |
| 492 | #define ID_AA64PFR0_EL1_SVE_WIDTH UL(4) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 493 | |
| 494 | #define ID_AA64PFR0_EL1_AMU_SHIFT UL(44) |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 495 | #define ID_AA64PFR0_EL1_AMU_WIDTH UL(4) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 496 | |
Arunachalam Ganapathy | a27de37 | 2023-03-06 11:13:49 +0000 | [diff] [blame] | 497 | /* ID_AA64PFR1_EL1 definitions */ |
| 498 | #define ID_AA64PFR1_EL1_MTE_SHIFT UL(8) |
| 499 | #define ID_AA64PFR1_EL1_MTE_WIDTH UL(4) |
| 500 | |
Arunachalam Ganapathy | 83f46ca | 2023-08-15 18:13:27 +0100 | [diff] [blame] | 501 | #define ID_AA64PFR1_EL1_SME_SHIFT UL(24) |
| 502 | #define ID_AA64PFR1_EL1_SME_WIDTH UL(4) |
| 503 | #define ID_AA64PFR1_EL1_SME_NOT_IMPLEMENTED UL(0) |
| 504 | #define ID_AA64PFR1_EL1_SME_IMPLEMENTED UL(1) |
| 505 | #define ID_AA64PFR1_EL1_SME2_IMPLEMENTED UL(2) |
| 506 | |
Javier Almansa Sobrino | cfd3254 | 2024-10-09 19:38:56 +0100 | [diff] [blame^] | 507 | #define ID_AA64PFR1_EL1_DF2_SHIFT UL(56) |
| 508 | #define ID_AA64PFR1_EL1_DF2_WIDTH UL(4) |
| 509 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 510 | /* ID_AA64MMFR0_EL1 definitions */ |
| 511 | #define ID_AA64MMFR0_EL1_PARANGE_SHIFT U(0) |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 512 | #define ID_AA64MMFR0_EL1_PARANGE_WIDTH UL(4) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 513 | |
| 514 | #define PARANGE_0000_WIDTH U(32) |
| 515 | #define PARANGE_0001_WIDTH U(36) |
| 516 | #define PARANGE_0010_WIDTH U(40) |
| 517 | #define PARANGE_0011_WIDTH U(42) |
| 518 | #define PARANGE_0100_WIDTH U(44) |
| 519 | #define PARANGE_0101_WIDTH U(48) |
| 520 | #define PARANGE_0110_WIDTH U(52) |
| 521 | |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 522 | #define ID_AA64MMFR0_EL1_ECV_SHIFT UL(60) |
| 523 | #define ID_AA64MMFR0_EL1_ECV_WIDTH UL(4) |
AlexeiFedorov | eaec0c4 | 2023-02-01 18:13:32 +0000 | [diff] [blame] | 524 | #define ID_AA64MMFR0_EL1_ECV_NOT_SUPPORTED UL(0x0) |
| 525 | #define ID_AA64MMFR0_EL1_ECV_SUPPORTED UL(0x1) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 526 | #define ID_AA64MMFR0_EL1_ECV_SELF_SYNCH ULL(0x2) |
| 527 | |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 528 | #define ID_AA64MMFR0_EL1_FGT_SHIFT UL(56) |
| 529 | #define ID_AA64MMFR0_EL1_FGT_WIDTH UL(4) |
AlexeiFedorov | eaec0c4 | 2023-02-01 18:13:32 +0000 | [diff] [blame] | 530 | #define ID_AA64MMFR0_EL1_FGT_NOT_SUPPORTED UL(0x0) |
| 531 | #define ID_AA64MMFR0_EL1_FGT_SUPPORTED UL(0x1) |
| 532 | #define ID_AA64MMFR0_EL1_FGT2_SUPPORTED UL(0x2) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 533 | |
| 534 | #define ID_AA64MMFR0_EL1_TGRAN4_2_SHIFT U(40) |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 535 | #define ID_AA64MMFR0_EL1_TGRAN4_2_WIDTH U(4) |
AlexeiFedorov | eaec0c4 | 2023-02-01 18:13:32 +0000 | [diff] [blame] | 536 | #define ID_AA64MMFR0_EL1_TGRAN4_2_TGRAN4 UL(0x0) |
| 537 | #define ID_AA64MMFR0_EL1_TGRAN4_2_NOT_SUPPORTED UL(0x1) |
| 538 | #define ID_AA64MMFR0_EL1_TGRAN4_2_SUPPORTED UL(0x2) |
| 539 | #define ID_AA64MMFR0_EL1_TGRAN4_2_LPA2 UL(0x3) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 540 | |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 541 | #define ID_AA64MMFR0_EL1_TGRAN16_2_SHIFT UL(32) |
| 542 | #define ID_AA64MMFR0_EL1_TGRAN16_2_WIDTH UL(4) |
AlexeiFedorov | eaec0c4 | 2023-02-01 18:13:32 +0000 | [diff] [blame] | 543 | #define ID_AA64MMFR0_EL1_TGRAN16_2_TGRAN16 UL(0x0) |
| 544 | #define ID_AA64MMFR0_EL1_TGRAN16_2_NOT_SUPPORTED UL(0x1) |
| 545 | #define ID_AA64MMFR0_EL1_TGRAN16_2_SUPPORTED UL(0x2) |
| 546 | #define ID_AA64MMFR0_EL1_TGRAN16_2_LPA2 UL(0x3) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 547 | |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 548 | #define ID_AA64MMFR0_EL1_TGRAN4_SHIFT UL(28) |
| 549 | #define ID_AA64MMFR0_EL1_TGRAN4_WIDTH UL(4) |
AlexeiFedorov | eaec0c4 | 2023-02-01 18:13:32 +0000 | [diff] [blame] | 550 | #define ID_AA64MMFR0_EL1_TGRAN4_SUPPORTED UL(0x0) |
| 551 | #define ID_AA64MMFR0_EL1_TGRAN4_LPA2 UL(0x1) |
| 552 | #define ID_AA64MMFR0_EL1_TGRAN4_NOT_SUPPORTED UL(0xf) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 553 | |
| 554 | #define ID_AA64MMFR0_EL1_TGRAN64_SHIFT UL(24) |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 555 | #define ID_AA64MMFR0_EL1_TGRAN64_WIDTH UL(4) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 556 | #define ID_AA64MMFR0_EL1_TGRAN64_SUPPORTED UL(0x0) |
| 557 | #define ID_AA64MMFR0_EL1_TGRAN64_NOT_SUPPORTED UL(0xf) |
| 558 | |
| 559 | #define ID_AA64MMFR0_EL1_TGRAN16_SHIFT UL(20) |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 560 | #define ID_AA64MMFR0_EL1_TGRAN16_WIDTH UL(4) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 561 | #define ID_AA64MMFR0_EL1_TGRAN16_NOT_SUPPORTED UL(0x0) |
| 562 | #define ID_AA64MMFR0_EL1_TGRAN16_SUPPORTED UL(0x1) |
| 563 | #define ID_AA64MMFR0_EL1_TGRAN16_LPA2 UL(0x2) |
| 564 | |
| 565 | /* RNDR definitions */ |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 566 | #define ID_AA64ISAR0_EL1_RNDR_SHIFT UL(60) |
| 567 | #define ID_AA64ISAR0_EL1_RNDR_WIDTH UL(4) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 568 | |
| 569 | /* ID_AA64MMFR1_EL1 definitions */ |
| 570 | #define ID_AA64MMFR1_EL1_VMIDBits_SHIFT UL(4) |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 571 | #define ID_AA64MMFR1_EL1_VMIDBits_WIDTH UL(4) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 572 | #define ID_AA64MMFR1_EL1_VMIDBits_8 UL(0) |
| 573 | #define ID_AA64MMFR1_EL1_VMIDBits_16 UL(2) |
| 574 | |
Arunachalam Ganapathy | f649121 | 2023-02-23 16:04:34 +0000 | [diff] [blame] | 575 | /* SVE Feature ID register 0 */ |
| 576 | #define ID_AA64ZFR0_EL1 S3_0_C0_C4_4 |
| 577 | |
Arunachalam Ganapathy | 83f46ca | 2023-08-15 18:13:27 +0100 | [diff] [blame] | 578 | /* SME Feature ID register 0 */ |
| 579 | #define ID_AA64SMFR0_EL1 S3_0_C0_C4_5 |
| 580 | |
AlexeiFedorov | be9209c | 2024-02-27 15:16:00 +0000 | [diff] [blame] | 581 | /* PAR_EL1 definitions */ |
| 582 | #define PAR_EL1_F_BIT (UL(1) << 0) |
| 583 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 584 | /* HPFAR_EL2 definitions */ |
| 585 | #define HPFAR_EL2_FIPA_SHIFT 4 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 586 | #define HPFAR_EL2_FIPA_WIDTH U(40) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 587 | #define HPFAR_EL2_FIPA_OFFSET 8 |
| 588 | |
| 589 | /* SPSR definitions */ |
| 590 | #define SPSR_EL2_MODE_SHIFT 0 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 591 | #define SPSR_EL2_MODE_WIDTH U(4) |
| 592 | #define SPSR_EL2_MODE_EL0t INPLACE(SPSR_EL2_MODE, UL(0)) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 593 | |
| 594 | #define SPSR_EL2_MODE_SHIFT 0 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 595 | #define SPSR_EL2_MODE_WIDTH U(4) |
| 596 | #define SPSR_EL2_MODE_EL1h INPLACE(SPSR_EL2_MODE, UL(5)) |
| 597 | #define SPSR_EL2_MODE_EL1t INPLACE(SPSR_EL2_MODE, UL(4)) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 598 | |
| 599 | /* FIXME: DAIF definitions are redundant here. Might need unification. */ |
| 600 | #define SPSR_EL2_nRW_SHIFT 4 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 601 | #define SPSR_EL2_nRW_WIDTH U(1) |
| 602 | #define SPSR_EL2_nRW_AARCH64 INPLACE(SPSR_EL2_nRW, UL(0)) |
| 603 | #define SPSR_EL2_nRW_AARCH32 INPLACE(SPSR_EL2_nRW, UL(1)) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 604 | |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 605 | #define SPSR_EL2_DAIF_SHIFT 6 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 606 | #define SPSR_EL2_AIF_SHIFT U(6) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 607 | |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 608 | #define DAIF_FIQ_BIT (UL(1) << 0) |
| 609 | #define DAIF_IRQ_BIT (UL(1) << 1) |
| 610 | #define DAIF_ABT_BIT (UL(1) << 2) |
| 611 | #define DAIF_DBG_BIT (UL(1) << 3) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 612 | |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 613 | #define SPSR_EL2_F_BIT (UL(1) << 6) |
| 614 | #define SPSR_EL2_I_BIT (UL(1) << 7) |
| 615 | #define SPSR_EL2_A_BIT (UL(1) << 8) |
| 616 | #define SPSR_EL2_D_BIT (UL(1) << 9) |
| 617 | #define SPSR_EL2_SSBS_BIT (UL(1) << 12) |
| 618 | #define SPSR_EL2_ALLINT_BIT (UL(1) << 13) |
| 619 | #define SPSR_EL2_IL_BIT (UL(1) << 20) |
| 620 | #define SPSR_EL2_SS_BIT (UL(1) << 21) |
| 621 | #define SPSR_EL2_PAN_BIT (UL(1) << 22) |
| 622 | #define SPSR_EL2_UAO_BIT (UL(1) << 23) |
| 623 | #define SPSR_EL2_DIT_BIT (UL(1) << 24) |
| 624 | #define SPSR_EL2_TCO_BIT (UL(1) << 25) |
| 625 | #define SPSR_EL2_V_BIT (UL(1) << 28) |
| 626 | #define SPSR_EL2_C_BIT (UL(1) << 29) |
| 627 | #define SPSR_EL2_Z_BIT (UL(1) << 30) |
| 628 | #define SPSR_EL2_N_BIT (UL(1) << 31) |
| 629 | #define SPSR_EL2_PM_BIT (UL(1) << 32) |
| 630 | #define SPSR_EL2_PPEND_BIT (UL(1) << 33) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 631 | |
Arunachalam Ganapathy | 4f601e7 | 2023-05-22 11:49:29 +0100 | [diff] [blame] | 632 | /* Floating point control and status register */ |
| 633 | #define FPCR S3_3_C4_C4_0 |
| 634 | #define FPSR S3_3_C4_C4_1 |
| 635 | |
Arunachalam Ganapathy | f649121 | 2023-02-23 16:04:34 +0000 | [diff] [blame] | 636 | /* SVE Control Register */ |
| 637 | #define ZCR_EL2 S3_4_C1_C2_0 |
Arunachalam Ganapathy | 2b45658 | 2023-05-19 11:56:44 +0100 | [diff] [blame] | 638 | #define ZCR_EL2_LEN_SHIFT UL(0) |
| 639 | #define ZCR_EL2_LEN_WIDTH UL(4) |
Arunachalam Ganapathy | f649121 | 2023-02-23 16:04:34 +0000 | [diff] [blame] | 640 | |
Arunachalam Ganapathy | 4f601e7 | 2023-05-22 11:49:29 +0100 | [diff] [blame] | 641 | #define ZCR_EL12 S3_5_C1_C2_0 |
| 642 | |
Arunachalam Ganapathy | 83f46ca | 2023-08-15 18:13:27 +0100 | [diff] [blame] | 643 | /* SME Control Register */ |
| 644 | #define SMCR_EL2 S3_4_C1_C2_6 |
| 645 | #define SMCR_EL2_LEN_SHIFT UL(0) |
| 646 | #define SMCR_EL2_LEN_WIDTH UL(4) |
| 647 | /* |
| 648 | * SMCR_EL2_RAZ_LEN is defined to find the architecturally permitted SVL. This |
| 649 | * is a combination of RAZ and LEN bit fields. |
| 650 | */ |
| 651 | #define SMCR_EL2_RAZ_LEN_SHIFT UL(0) |
| 652 | #define SMCR_EL2_RAZ_LEN_WIDTH UL(9) |
| 653 | #define SMCR_EL2_EZT0_BIT (UL(1) << 30) |
| 654 | #define SMCR_EL2_FA64_BIT (UL(1) << 31) |
| 655 | |
| 656 | /* Streaming Vector Control register */ |
| 657 | #define SVCR S3_3_C4_C2_2 |
| 658 | #define SVCR_SM_BIT (UL(1) << 0) |
| 659 | #define SVCR_ZA_BIT (UL(1) << 1) |
| 660 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 661 | /* VTCR definitions */ |
| 662 | #define VTCR_T0SZ_SHIFT 0 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 663 | #define VTCR_T0SZ_WIDTH U(6) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 664 | |
| 665 | #define VTCR_SL0_SHIFT 6 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 666 | #define VTCR_SL0_WIDTH U(2) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 667 | |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 668 | #define VTCR_SL0_4K_L2 INPLACE(VTCR_SL0, UL(0)) |
| 669 | #define VTCR_SL0_4K_L1 INPLACE(VTCR_SL0, UL(1)) |
| 670 | #define VTCR_SL0_4K_L0 INPLACE(VTCR_SL0, UL(2)) |
| 671 | #define VTCR_SL0_4K_L3 INPLACE(VTCR_SL0, UL(3)) |
Javier Almansa Sobrino | f6fff69 | 2024-02-02 17:13:57 +0000 | [diff] [blame] | 672 | #define VTCR_SL0_4K_LM1 VTCR_SL0_4K_L2 |
| 673 | |
| 674 | #define VTCR_SL2_SHIFT 33 |
| 675 | #define VTCR_SL2_WIDTH U(1) |
| 676 | #define VCTR_SL2_4K_LM1 INPLACE(VTCR_SL2, UL(1)) |
| 677 | |
| 678 | #define VTCR_DS_SHIFT 32 |
| 679 | #define VTCR_DS_WIDTH U(1) |
| 680 | #define VTCR_DS_52BIT INPLACE(VTCR_DS, UL(1)) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 681 | |
| 682 | #define VTCR_IRGN0_SHIFT 8 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 683 | #define VTCR_IRGN0_WIDTH U(2) |
| 684 | #define VTCR_IRGN0_WBRAWA INPLACE(VTCR_IRGN0, UL(1)) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 685 | |
| 686 | #define VTCR_ORGN0_SHIFT 10 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 687 | #define VTCR_ORGN0_WIDTH U(2) |
| 688 | #define VTCR_ORGN0_WBRAWA INPLACE(VTCR_ORGN0, UL(1)) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 689 | |
| 690 | #define VTCR_SH0_SHIFT 12 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 691 | #define VTCR_SH0_WIDTH U(2) |
| 692 | #define VTCR_SH0_IS INPLACE(VTCR_SH0, UL(3)) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 693 | |
| 694 | #define VTCR_TG0_SHIFT 14 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 695 | #define VTCR_TG0_WIDTH U(2) |
| 696 | #define VTCR_TG0_4K INPLACE(VTCR_TG0, UL(0)) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 697 | |
| 698 | #define VTCR_PS_SHIFT 16 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 699 | #define VTCR_PS_WIDTH U(3) |
Mathieu Poirier | 6752efa | 2024-09-24 11:53:59 -0600 | [diff] [blame] | 700 | #define VTCR_PS_32 INPLACE(VTCR_PS, UL(0)) |
| 701 | #define VTCR_PS_36 INPLACE(VTCR_PS, UL(1)) |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 702 | #define VTCR_PS_40 INPLACE(VTCR_PS, UL(2)) |
Mathieu Poirier | 6752efa | 2024-09-24 11:53:59 -0600 | [diff] [blame] | 703 | #define VTCR_PS_42 INPLACE(VTCR_PS, UL(3)) |
| 704 | #define VTCR_PS_44 INPLACE(VTCR_PS, UL(4)) |
| 705 | #define VTCR_PS_48 INPLACE(VTCR_PS, UL(5)) |
| 706 | #define VTCR_PS_52 INPLACE(VTCR_PS, UL(6)) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 707 | |
| 708 | #define VTCR_VS (UL(1) << 19) |
| 709 | #define VTCR_NSA (UL(1) << 30) |
| 710 | #define VTCR_RES1 (UL(1) << 31) |
| 711 | |
| 712 | #define VTCR_FLAGS ( \ |
| 713 | VTCR_IRGN0_WBRAWA | /* PTW inner cache attr. is WB RAWA*/ \ |
| 714 | VTCR_ORGN0_WBRAWA | /* PTW outer cache attr. is WB RAWA*/ \ |
| 715 | VTCR_SH0_IS | /* PTW shareability attr. is Outer Sharable*/\ |
| 716 | VTCR_TG0_4K | /* 4K granule size in non-secure PT*/ \ |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 717 | /* VS = 0 size(VMID) = 8 */ \ |
| 718 | /* NSW = 0 non-secure s2 is made of secure pages*/ \ |
| 719 | VTCR_NSA | /* non-secure IPA maps to non-secure PA */ \ |
| 720 | VTCR_RES1 \ |
| 721 | ) |
| 722 | |
| 723 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 724 | /* PMCR_EL0 Definitions */ |
AlexeiFedorov | eaec0c4 | 2023-02-01 18:13:32 +0000 | [diff] [blame] | 725 | #define PMCR_EL0_N_SHIFT 11 |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 726 | #define PMCR_EL0_N_WIDTH U(5) |
AlexeiFedorov | eaec0c4 | 2023-02-01 18:13:32 +0000 | [diff] [blame] | 727 | #define PMCR_EL0_LC_BIT (UL(1) << 6) |
| 728 | #define PMCR_EL0_DP_BIT (UL(1) << 5) |
| 729 | #define PMCR_EL0_C_BIT (UL(1) << 2) |
| 730 | #define PMCR_EL0_P_BIT (UL(1) << 1) |
| 731 | #define PMCR_EL0_E_BIT (UL(1) << 0) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 732 | |
AlexeiFedorov | eaec0c4 | 2023-02-01 18:13:32 +0000 | [diff] [blame] | 733 | #define PMCR_EL0_INIT (PMCR_EL0_LC_BIT | PMCR_EL0_DP_BIT) |
| 734 | #define PMCR_EL0_INIT_RESET (PMCR_EL0_INIT | PMCR_EL0_C_BIT | \ |
| 735 | PMCR_EL0_P_BIT) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 736 | |
AlexeiFedorov | 862f96c | 2024-03-01 16:26:48 +0000 | [diff] [blame] | 737 | /* DCZID_EL0 Definitions */ |
| 738 | #define DCZID_EL0_BS_SHIFT 0 |
| 739 | #define DCZID_EL0_BS_WIDTH U(4) |
| 740 | #define DCZID_EL0_DZP_BIT (UL(1) << 4) |
| 741 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 742 | /* MDSCR_EL1 Definitions */ |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 743 | #define MDSCR_EL1_TDCC_BIT (UL(1) << 12) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 744 | |
| 745 | /* SCTLR register definitions */ |
Arvind Ram Prakash | bd36a1b | 2022-12-15 12:16:36 -0600 | [diff] [blame] | 746 | #define SCTLR_ELx_RES1_BIT ((UL(1) << 22) /* TODO: ARMv8.5-CSEH, otherwise RES1 */ | \ |
| 747 | (UL(1) << 11) /* TODO: ARMv8.5-CSEH, otherwise RES1 */) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 748 | |
Arvind Ram Prakash | bd36a1b | 2022-12-15 12:16:36 -0600 | [diff] [blame] | 749 | #define SCTLR_ELx_M_BIT (UL(1) << 0) |
AlexeiFedorov | bb01b42 | 2023-10-24 17:00:50 +0100 | [diff] [blame] | 750 | #define SCTLR_ELx_A_BIT (UL(1) << 1) |
Arvind Ram Prakash | bd36a1b | 2022-12-15 12:16:36 -0600 | [diff] [blame] | 751 | #define SCTLR_ELx_C_BIT (UL(1) << 2) |
| 752 | #define SCTLR_ELx_SA_BIT (UL(1) << 3) |
| 753 | #define SCTLR_ELx_SA0_BIT (UL(1) << 4) |
| 754 | #define SCTLR_ELx_CP15BEN_BIT (UL(1) << 5) |
| 755 | #define SCTLR_ELx_nAA_BIT (UL(1) << 6) |
| 756 | #define SCTLR_ELx_SED_BIT (UL(1) << 8) |
| 757 | #define SCTLR_ELx_EOS_BIT (UL(1) << 11) |
| 758 | #define SCTLR_ELx_I_BIT (UL(1) << 12) |
| 759 | #define SCTLR_ELx_DZE_BIT (UL(1) << 14) |
| 760 | #define SCTLR_ELx_UCT_BIT (UL(1) << 15) |
| 761 | #define SCTLR_ELx_nTWI_BIT (UL(1) << 16) |
| 762 | #define SCTLR_ELx_nTWE_BIT (UL(1) << 18) |
| 763 | #define SCTLR_ELx_WXN_BIT (UL(1) << 19) |
| 764 | #define SCTLR_ELx_TSCXT_BIT (UL(1) << 20) |
| 765 | #define SCTLR_ELx_EIS_BIT (UL(1) << 22) |
| 766 | #define SCTLR_ELx_SPAN_BIT (UL(1) << 23) |
| 767 | #define SCTLR_ELx_EE_BIT (UL(1) << 25) |
| 768 | #define SCTLR_ELx_UCI_BIT (UL(1) << 26) |
| 769 | #define SCTLR_ELx_nTLSMD_BIT (UL(1) << 28) |
| 770 | #define SCTLR_ELx_LSMAOE_BIT (UL(1) << 29) |
| 771 | #define SCTLR_ELx_EnIA_BIT (UL(1) << 31) |
Shruti Gupta | a4cb2a2 | 2023-05-23 14:55:49 +0100 | [diff] [blame] | 772 | #define SCTLR_ELx_BT0_BIT (UL(1) << 35) |
| 773 | #define SCTLR_ELx_BT1_BIT (UL(1) << 36) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 774 | |
Arvind Ram Prakash | bd36a1b | 2022-12-15 12:16:36 -0600 | [diff] [blame] | 775 | #define SCTLR_EL1_FLAGS (SCTLR_ELx_SPAN_BIT | SCTLR_ELx_EIS_BIT | SCTLR_ELx_nTWE_BIT | \ |
| 776 | SCTLR_ELx_nTWI_BIT | SCTLR_ELx_EOS_BIT | SCTLR_ELx_nAA_BIT | \ |
| 777 | SCTLR_ELx_CP15BEN_BIT | SCTLR_ELx_SA0_BIT | SCTLR_ELx_SA_BIT) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 778 | |
AlexeiFedorov | bb01b42 | 2023-10-24 17:00:50 +0100 | [diff] [blame] | 779 | #define SCTLR_EL2_BITS (SCTLR_ELx_C_BIT /* Data accesses are cacheable |
Arvind Ram Prakash | bd36a1b | 2022-12-15 12:16:36 -0600 | [diff] [blame] | 780 | * as per translation tables */ | \ |
| 781 | /* SCTLR_EL2_M = 0 (MMU disabled) */ \ |
| 782 | /* SCTLR_EL2_A = 0 |
| 783 | * (No alignment checks) */ \ |
| 784 | SCTLR_ELx_SA_BIT /* SP aligned at EL2 */ | \ |
| 785 | SCTLR_ELx_SA0_BIT /* SP Alignment check enable for EL0 */ \ |
| 786 | /* SCTLR_EL2_CP15BEN = 0 (EL0 using AArch32: |
| 787 | * EL0 execution of the CP15DMB, CP15DSB, |
| 788 | * and CP15ISB instructions is |
| 789 | * UNDEFINED. */ \ |
| 790 | /* SCTLR_EL2_NAA = 0 (unaligned MA fault |
| 791 | * at EL2 and EL0) */ \ |
| 792 | /* SCTLR_EL2_ITD = 0 (A32 Only) */ | \ |
| 793 | SCTLR_ELx_SED_BIT /* A32 Only, RES1 for non-A32 systems */ \ |
| 794 | /* SCTLR_EL2_EOS TODO: ARMv8.5-CSEH, |
| 795 | * otherwise RES1 */ | \ |
| 796 | SCTLR_ELx_I_BIT /* I$ is ON for EL2 and EL0 */ | \ |
| 797 | SCTLR_ELx_DZE_BIT /* Do not trap DC ZVA */ | \ |
| 798 | SCTLR_ELx_UCT_BIT /* Allow EL0 access to CTR_EL0 */ | \ |
| 799 | SCTLR_ELx_nTWI_BIT /* Don't trap WFI from EL0 to EL2 */ | \ |
| 800 | SCTLR_ELx_nTWE_BIT /* Don't trap WFE from EL0 to EL2 */ | \ |
| 801 | SCTLR_ELx_WXN_BIT /* W implies XN */ | \ |
| 802 | SCTLR_ELx_TSCXT_BIT /* Trap EL0 accesss to SCXTNUM_EL0 */ | \ |
| 803 | /* SCTLR_EL2_EIS EL2 exception is context |
| 804 | * synchronizing |
| 805 | */ \ |
| 806 | SCTLR_ELx_RES1_BIT | \ |
| 807 | /* SCTLR_EL2_SPAN = 0 (Set PSTATE.PAN = 1 on |
| 808 | * exceptions to EL2)) */ \ |
| 809 | SCTLR_ELx_UCI_BIT /* Allow cache maintenance |
| 810 | * instructions at EL0 */ | \ |
| 811 | SCTLR_ELx_nTLSMD_BIT /* A32/T32 only */ | \ |
| 812 | SCTLR_ELx_LSMAOE_BIT /* A32/T32 only */) |
| 813 | |
AlexeiFedorov | bb01b42 | 2023-10-24 17:00:50 +0100 | [diff] [blame] | 814 | #ifdef RMM_FPU_USE_AT_REL2 |
| 815 | #define SCTLR_EL2_INIT SCTLR_EL2_BITS |
| 816 | #else |
| 817 | #define SCTLR_EL2_INIT (SCTLR_EL2_BITS | \ |
| 818 | SCTLR_ELx_A_BIT /* Alignment fault check enable */) |
| 819 | #endif |
| 820 | |
Arvind Ram Prakash | bd36a1b | 2022-12-15 12:16:36 -0600 | [diff] [blame] | 821 | #define SCTLR_EL2_RUNTIME (SCTLR_EL2_INIT | \ |
| 822 | SCTLR_ELx_M_BIT /* MMU enabled */) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 823 | |
Javier Almansa Sobrino | cfd3254 | 2024-10-09 19:38:56 +0100 | [diff] [blame^] | 824 | /* SCTLR2_ELx Register definitions */ |
| 825 | #define SCTLR2_ELx_NMEA_BIT (UL(1) << 2) |
| 826 | #define SCTLR2_ELx_EnADERR_BIT (UL(1) << 3) |
| 827 | #define SCTLR2_ELx_EnANERR_BIT (UL(1) << 4) |
| 828 | #define SCTLR2_ELx_EASE_BIT (UL(1) << 5) |
| 829 | #define SCTLR2_ELx_EnIDCP128_BIT (UL(1) << 6) |
| 830 | |
Arunachalam Ganapathy | 9ade18b | 2023-06-12 14:07:21 +0100 | [diff] [blame] | 831 | /* RMM sets HCR_EL2.E2H to 1. CPTR_EL2 definitions when HCR_EL2.E2H == 1 */ |
| 832 | #define CPTR_EL2_VHE_TTA (UL(1) << 28) |
| 833 | #define CPTR_EL2_VHE_TAM (UL(1) << 30) |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 834 | |
Arunachalam Ganapathy | 9ade18b | 2023-06-12 14:07:21 +0100 | [diff] [blame] | 835 | #define CPTR_EL2_VHE_FPEN_SHIFT UL(20) |
| 836 | #define CPTR_EL2_VHE_FPEN_WIDTH UL(2) |
| 837 | #define CPTR_EL2_VHE_FPEN_TRAP_ALL_00 UL(0) |
| 838 | #define CPTR_EL2_VHE_FPEN_TRAP_TGE_01 UL(1) |
| 839 | #define CPTR_EL2_VHE_FPEN_TRAP_ALL_10 UL(2) |
| 840 | #define CPTR_EL2_VHE_FPEN_NO_TRAP_11 UL(3) |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 841 | |
Arunachalam Ganapathy | 9ade18b | 2023-06-12 14:07:21 +0100 | [diff] [blame] | 842 | #define CPTR_EL2_VHE_ZEN_SHIFT UL(16) |
| 843 | #define CPTR_EL2_VHE_ZEN_WIDTH UL(2) |
| 844 | #define CPTR_EL2_VHE_ZEN_TRAP_ALL_00 UL(0x0) |
| 845 | #define CPTR_EL2_VHE_ZEN_NO_TRAP_11 UL(0x3) |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 846 | |
Arunachalam Ganapathy | 83f46ca | 2023-08-15 18:13:27 +0100 | [diff] [blame] | 847 | #define CPTR_EL2_VHE_SMEN_SHIFT UL(24) |
| 848 | #define CPTR_EL2_VHE_SMEN_WIDTH UL(2) |
| 849 | #define CPTR_EL2_VHE_SMEN_TRAP_ALL_00 UL(0x0) |
| 850 | #define CPTR_EL2_VHE_SMEN_NO_TRAP_11 UL(0x3) |
| 851 | |
Arunachalam Ganapathy | ddccbae | 2023-10-03 11:29:42 +0100 | [diff] [blame] | 852 | #define CPTR_EL2_VHE_SIMD_MASK (MASK(CPTR_EL2_VHE_FPEN) | \ |
| 853 | MASK(CPTR_EL2_VHE_ZEN) | \ |
| 854 | MASK(CPTR_EL2_VHE_SMEN)) |
| 855 | |
Arunachalam Ganapathy | 83f46ca | 2023-08-15 18:13:27 +0100 | [diff] [blame] | 856 | /* Trap all AMU, trace, FPU, SVE, SME accesses */ |
Arunachalam Ganapathy | 9ade18b | 2023-06-12 14:07:21 +0100 | [diff] [blame] | 857 | #define CPTR_EL2_VHE_INIT ((CPTR_EL2_VHE_ZEN_TRAP_ALL_00 << \ |
| 858 | CPTR_EL2_VHE_ZEN_SHIFT) | \ |
Arunachalam Ganapathy | 83f46ca | 2023-08-15 18:13:27 +0100 | [diff] [blame] | 859 | (CPTR_EL2_VHE_SMEN_TRAP_ALL_00 << \ |
| 860 | CPTR_EL2_VHE_SMEN_SHIFT) | \ |
Arunachalam Ganapathy | 9ade18b | 2023-06-12 14:07:21 +0100 | [diff] [blame] | 861 | (CPTR_EL2_VHE_FPEN_TRAP_ALL_00 << \ |
| 862 | CPTR_EL2_VHE_FPEN_SHIFT) | \ |
| 863 | CPTR_EL2_VHE_TTA | \ |
| 864 | CPTR_EL2_VHE_TAM) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 865 | |
| 866 | /* MDCR_EL2 definitions */ |
AlexeiFedorov | eaec0c4 | 2023-02-01 18:13:32 +0000 | [diff] [blame] | 867 | #define MDCR_EL2_HPMFZS (UL(1) << 36) |
| 868 | #define MDCR_EL2_HPMFZO (UL(1) << 29) |
| 869 | #define MDCR_EL2_MTPME (UL(1) << 28) |
| 870 | #define MDCR_EL2_TDCC (UL(1) << 27) |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 871 | #define MDCR_EL2_HLP (UL(1) << 26) |
| 872 | #define MDCR_EL2_HCCD (UL(1) << 23) |
| 873 | #define MDCR_EL2_TTRF (UL(1) << 19) |
| 874 | #define MDCR_EL2_HPMD (UL(1) << 17) |
| 875 | #define MDCR_EL2_TPMS (UL(1) << 14) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 876 | #define MDCR_EL2_E2PB(x) ((x) << 12) |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 877 | #define MDCR_EL2_E2PB_EL1 UL(3) |
| 878 | #define MDCR_EL2_TDRA_BIT (UL(1) << 11) |
| 879 | #define MDCR_EL2_TDOSA_BIT (UL(1) << 10) |
| 880 | #define MDCR_EL2_TDA_BIT (UL(1) << 9) |
| 881 | #define MDCR_EL2_TDE_BIT (UL(1) << 8) |
| 882 | #define MDCR_EL2_HPME_BIT (UL(1) << 7) |
| 883 | #define MDCR_EL2_TPM_BIT (UL(1) << 6) |
| 884 | #define MDCR_EL2_TPMCR_BIT (UL(1) << 5) |
AlexeiFedorov | eaec0c4 | 2023-02-01 18:13:32 +0000 | [diff] [blame] | 885 | |
| 886 | #define MDCR_EL2_HPMN_SHIFT UL(0) |
| 887 | #define MDCR_EL2_HPMN_WIDTH UL(5) |
| 888 | |
| 889 | #define MDCR_EL2_INIT (MDCR_EL2_MTPME | \ |
| 890 | MDCR_EL2_HCCD | \ |
| 891 | MDCR_EL2_HPMD | \ |
| 892 | MDCR_EL2_TDA_BIT | \ |
| 893 | MDCR_EL2_TPM_BIT | \ |
| 894 | MDCR_EL2_TPMCR_BIT) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 895 | |
Arvind Ram Prakash | bd36a1b | 2022-12-15 12:16:36 -0600 | [diff] [blame] | 896 | /* Armv8.3 Pointer Authentication Registers */ |
| 897 | #define APIAKeyLo_EL1 S3_0_C2_C1_0 |
| 898 | #define APIAKeyHi_EL1 S3_0_C2_C1_1 |
| 899 | #define APIBKeyLo_EL1 S3_0_C2_C1_2 |
| 900 | #define APIBKeyHi_EL1 S3_0_C2_C1_3 |
| 901 | #define APDAKeyLo_EL1 S3_0_C2_C2_0 |
| 902 | #define APDAKeyHi_EL1 S3_0_C2_C2_1 |
| 903 | #define APDBKeyLo_EL1 S3_0_C2_C2_2 |
| 904 | #define APDBKeyHi_EL1 S3_0_C2_C2_3 |
| 905 | #define APGAKeyLo_EL1 S3_0_C2_C3_0 |
| 906 | #define APGAKeyHi_EL1 S3_0_C2_C3_1 |
| 907 | |
AlexeiFedorov | 887a8aa | 2024-09-11 16:22:20 +0100 | [diff] [blame] | 908 | /* |
| 909 | * MPIDR_EL1 definitions |
| 910 | * 'MPIDR_EL1_AFF<n>_VAL_SHIFT' constants specify the right shift |
| 911 | * for affinity field <n> that gives the field's actual value. |
| 912 | */ |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 913 | |
AlexeiFedorov | 887a8aa | 2024-09-11 16:22:20 +0100 | [diff] [blame] | 914 | /* Aff0[3:0] - Affinity level 0 |
| 915 | * For compatibility with GICv3 only Aff0[3:0] field is used, |
| 916 | * and Aff0[7:4] of MPIDR_EL1 value is RES0 to match RmiRecMpidr. |
| 917 | */ |
| 918 | #define MPIDR_EL1_AFF0_SHIFT U(0) |
| 919 | #define MPIDR_EL1_AFF0_WIDTH U(4) |
| 920 | #define MPIDR_EL1_AFF0_VAL_SHIFT U(0) |
| 921 | |
| 922 | /* Aff1[15:8] - Affinity level 1 */ |
| 923 | #define MPIDR_EL1_AFF1_SHIFT U(8) |
| 924 | #define MPIDR_EL1_AFF1_WIDTH U(8) |
| 925 | #define MPIDR_EL1_AFF1_VAL_SHIFT U(4) |
| 926 | |
| 927 | /* Aff2[23:16] - Affinity level 2 */ |
| 928 | #define MPIDR_EL1_AFF2_SHIFT U(16) |
| 929 | #define MPIDR_EL1_AFF2_WIDTH U(8) |
| 930 | #define MPIDR_EL1_AFF2_VAL_SHIFT U(4) |
| 931 | |
| 932 | /* Aff3[39:32] - Affinity level 3 */ |
| 933 | #define MPIDR_EL1_AFF3_SHIFT U(32) |
| 934 | #define MPIDR_EL1_AFF3_WIDTH U(8) |
| 935 | #define MPIDR_EL1_AFF3_VAL_SHIFT U(12) |
| 936 | |
| 937 | /* |
| 938 | * Extract the value of MPIDR_EL1.Aff<n> register field shifted right |
| 939 | * so it can be evaluated directly. |
| 940 | */ |
| 941 | #define MPIDR_EL1_AFF(n, reg) \ |
| 942 | (((reg) & MASK(MPIDR_EL1_AFF##n)) >> MPIDR_EL1_AFF##n##_VAL_SHIFT) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 943 | |
| 944 | /* |
| 945 | * RmiRecMpidr type definitions. |
| 946 | * |
AlexeiFedorov | 887a8aa | 2024-09-11 16:22:20 +0100 | [diff] [blame] | 947 | * 'RMI_MPIDR_AFF<n>_VAL_SHIFT' constants specify the right shift |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 948 | * for affinity field <n> that gives the field's actual value. |
| 949 | * |
| 950 | * Aff0[3:0] - Affinity level 0 |
| 951 | * For compatibility with GICv3 only Aff0[3:0] field is used, |
| 952 | * and Aff0[7:4] of a REC MPIDR value is RES0. |
| 953 | */ |
AlexeiFedorov | 887a8aa | 2024-09-11 16:22:20 +0100 | [diff] [blame] | 954 | #define RMI_MPIDR_AFF0_SHIFT U(0) |
| 955 | #define RMI_MPIDR_AFF0_WIDTH U(4) |
| 956 | #define RMI_MPIDR_AFF0_VAL_SHIFT U(0) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 957 | |
| 958 | /* Aff1[15:8] - Affinity level 1 */ |
AlexeiFedorov | 887a8aa | 2024-09-11 16:22:20 +0100 | [diff] [blame] | 959 | #define RMI_MPIDR_AFF1_SHIFT U(8) |
| 960 | #define RMI_MPIDR_AFF1_WIDTH U(8) |
| 961 | #define RMI_MPIDR_AFF1_VAL_SHIFT U(4) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 962 | |
| 963 | /* Aff2[23:16] - Affinity level 2 */ |
AlexeiFedorov | 887a8aa | 2024-09-11 16:22:20 +0100 | [diff] [blame] | 964 | #define RMI_MPIDR_AFF2_SHIFT U(16) |
| 965 | #define RMI_MPIDR_AFF2_WIDTH U(8) |
| 966 | #define RMI_MPIDR_AFF2_VAL_SHIFT U(4) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 967 | |
AlexeiFedorov | 887a8aa | 2024-09-11 16:22:20 +0100 | [diff] [blame] | 968 | /* Aff3[31:24] - Affinity level 3 */ |
| 969 | #define RMI_MPIDR_AFF3_SHIFT U(24) |
| 970 | #define RMI_MPIDR_AFF3_WIDTH U(8) |
| 971 | #define RMI_MPIDR_AFF3_VAL_SHIFT U(4) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 972 | |
| 973 | /* |
AlexeiFedorov | 887a8aa | 2024-09-11 16:22:20 +0100 | [diff] [blame] | 974 | * Extract the value of RmiRecMpidr.Aff<n> field shifted right |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 975 | * so it can be evaluated directly. |
| 976 | */ |
AlexeiFedorov | 887a8aa | 2024-09-11 16:22:20 +0100 | [diff] [blame] | 977 | #define RMI_MPIDR_AFF(n, val) \ |
| 978 | (((val) & MASK(RMI_MPIDR_AFF##n)) >> RMI_MPIDR_AFF##n##_VAL_SHIFT) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 979 | |
AlexeiFedorov | 887a8aa | 2024-09-11 16:22:20 +0100 | [diff] [blame] | 980 | /* VMPIDR bit [31] = RES1 */ |
| 981 | #define VMPIDR_EL2_RES1 (UL(1) << 31) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 982 | |
| 983 | /* ICC_SRE_EL2 defintions */ |
| 984 | #define ICC_SRE_EL2_ENABLE (UL(1) << 3) /* Enable lower EL access to ICC_SRE_EL1 */ |
| 985 | #define ICC_SRE_EL2_DIB (UL(1) << 2) /* Disable IRQ bypass */ |
| 986 | #define ICC_SRE_EL2_DFB (UL(1) << 1) /* Disable FIQ bypass */ |
| 987 | #define ICC_SRE_EL2_SRE (UL(1) << 0) /* Enable sysreg access */ |
| 988 | |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 989 | #define ICC_SRE_EL2_INIT (ICC_SRE_EL2_ENABLE | ICC_SRE_EL2_DIB | \ |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 990 | ICC_SRE_EL2_DFB | ICC_SRE_EL2_SRE) |
| 991 | |
| 992 | /* MPAM definitions */ |
| 993 | #define MPAM2_EL2_INIT 0x0 |
| 994 | #define MPAMHCR_EL2_INIT 0x0 |
| 995 | |
| 996 | #define PMSCR_EL2_INIT 0x0 |
| 997 | |
| 998 | #define SYSREG_ESR(op0, op1, crn, crm, op2) \ |
AlexeiFedorov | 13b86dd | 2023-08-29 10:38:09 +0100 | [diff] [blame] | 999 | ((UL(op0) << ESR_EL2_SYSREG_TRAP_OP0_SHIFT) | \ |
| 1000 | (UL(op1) << ESR_EL2_SYSREG_TRAP_OP1_SHIFT) | \ |
| 1001 | (UL(crn) << ESR_EL2_SYSREG_TRAP_CRN_SHIFT) | \ |
| 1002 | (UL(crm) << ESR_EL2_SYSREG_TRAP_CRM_SHIFT) | \ |
| 1003 | (UL(op2) << ESR_EL2_SYSREG_TRAP_OP2_SHIFT)) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1004 | |
| 1005 | #define ESR_EL2_SYSREG_MASK SYSREG_ESR(3, 7, 15, 15, 7) |
| 1006 | |
| 1007 | #define ESR_EL2_SYSREG_ID_MASK SYSREG_ESR(3, 7, 15, 0, 0) |
| 1008 | #define ESR_EL2_SYSREG_ID SYSREG_ESR(3, 0, 0, 0, 0) |
| 1009 | |
| 1010 | #define ESR_EL2_SYSREG_ID_AA64PFR0_EL1 SYSREG_ESR(3, 0, 0, 4, 0) |
| 1011 | #define ESR_EL2_SYSREG_ID_AA64PFR1_EL1 SYSREG_ESR(3, 0, 0, 4, 1) |
| 1012 | #define ESR_EL2_SYSREG_ID_AA64ZFR0_EL1 SYSREG_ESR(3, 0, 0, 4, 4) |
Arunachalam Ganapathy | 83f46ca | 2023-08-15 18:13:27 +0100 | [diff] [blame] | 1013 | #define ESR_EL2_SYSREG_ID_AA64SMFR0_EL1 SYSREG_ESR(3, 0, 0, 4, 5) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1014 | |
| 1015 | #define ESR_EL2_SYSREG_ID_AA64DFR0_EL1 SYSREG_ESR(3, 0, 0, 5, 0) |
| 1016 | #define ESR_EL2_SYSREG_ID_AA64DFR1_EL1 SYSREG_ESR(3, 0, 0, 5, 1) |
| 1017 | |
| 1018 | #define ESR_EL2_SYSREG_ID_AA64AFR0_EL1 SYSREG_ESR(3, 0, 0, 5, 4) |
| 1019 | #define ESR_EL2_SYSREG_ID_AA64AFR1_EL1 SYSREG_ESR(3, 0, 0, 5, 5) |
| 1020 | |
| 1021 | #define ESR_EL2_SYSREG_ID_AA64ISAR0_EL1 SYSREG_ESR(3, 0, 0, 6, 0) |
| 1022 | #define ESR_EL2_SYSREG_ID_AA64ISAR1_EL1 SYSREG_ESR(3, 0, 0, 6, 1) |
| 1023 | |
| 1024 | #define ESR_EL2_SYSREG_ID_AA64MMFR0_EL1 SYSREG_ESR(3, 0, 0, 7, 0) |
| 1025 | #define ESR_EL2_SYSREG_ID_AA64MMFR1_EL1 SYSREG_ESR(3, 0, 0, 7, 1) |
| 1026 | #define ESR_EL2_SYSREG_ID_AA64MMFR2_EL1 SYSREG_ESR(3, 0, 0, 7, 2) |
| 1027 | |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 1028 | /* ID_AA64ISAR1_EL1 definitions */ |
| 1029 | #define ID_AA64ISAR1_EL1_GPI_SHIFT UL(28) |
| 1030 | #define ID_AA64ISAR1_EL1_GPI_WIDTH UL(4) |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 1031 | |
| 1032 | #define ID_AA64ISAR1_EL1_GPA_SHIFT UL(24) |
| 1033 | #define ID_AA64ISAR1_EL1_GPA_WIDTH UL(4) |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 1034 | |
| 1035 | #define ID_AA64ISAR1_EL1_API_SHIFT UL(8) |
| 1036 | #define ID_AA64ISAR1_EL1_API_WIDTH UL(4) |
AlexeiFedorov | 7bb7a70 | 2023-01-17 17:04:14 +0000 | [diff] [blame] | 1037 | |
| 1038 | #define ID_AA64ISAR1_EL1_APA_SHIFT UL(4) |
| 1039 | #define ID_AA64ISAR1_EL1_APA_WIDTH UL(4) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1040 | |
| 1041 | #define ESR_EL2_SYSREG_TIMERS_MASK SYSREG_ESR(3, 3, 15, 12, 0) |
| 1042 | #define ESR_EL2_SYSREG_TIMERS SYSREG_ESR(3, 3, 14, 0, 0) |
| 1043 | |
| 1044 | #define ESR_EL2_SYSREG_TIMER_CNTP_TVAL_EL0 SYSREG_ESR(3, 3, 14, 2, 0) |
| 1045 | #define ESR_EL2_SYSREG_TIMER_CNTP_CTL_EL0 SYSREG_ESR(3, 3, 14, 2, 1) |
| 1046 | #define ESR_EL2_SYSREG_TIMER_CNTP_CVAL_EL0 SYSREG_ESR(3, 3, 14, 2, 2) |
| 1047 | #define ESR_EL2_SYSREG_TIMER_CNTV_TVAL_EL0 SYSREG_ESR(3, 3, 14, 3, 0) |
| 1048 | #define ESR_EL2_SYSREG_TIMER_CNTV_CTL_EL0 SYSREG_ESR(3, 3, 14, 3, 1) |
| 1049 | #define ESR_EL2_SYSREG_TIMER_CNTV_CVAL_EL0 SYSREG_ESR(3, 3, 14, 3, 2) |
| 1050 | |
| 1051 | #define ESR_EL2_SYSREG_ICC_PMR_EL1 SYSREG_ESR(3, 0, 4, 6, 0) |
| 1052 | |
| 1053 | /* |
| 1054 | * GIC system registers encoding mask for registers from |
| 1055 | * ICC_IAR0_EL1(3, 0, 12, 8, 0) to ICC_IGRPEN1_EL1(3, 0, 12, 12, 7). |
| 1056 | */ |
| 1057 | #define ESR_EL2_SYSREG_ICC_EL1_MASK SYSREG_ESR(3, 3, 15, 8, 0) |
| 1058 | #define ESR_EL2_SYSREG_ICC_EL1 SYSREG_ESR(3, 0, 12, 8, 0) |
| 1059 | |
| 1060 | #define ESR_EL2_SYSREG_ICC_DIR SYSREG_ESR(3, 0, 12, 11, 1) |
| 1061 | #define ESR_EL2_SYSREG_ICC_SGI1R_EL1 SYSREG_ESR(3, 0, 12, 11, 5) |
| 1062 | #define ESR_EL2_SYSREG_ICC_SGI0R_EL1 SYSREG_ESR(3, 0, 12, 11, 7) |
| 1063 | |
| 1064 | #define ESR_EL2_SYSREG_DIRECTION (UL(1) << 0) |
AlexeiFedorov | 13b86dd | 2023-08-29 10:38:09 +0100 | [diff] [blame] | 1065 | #define ESR_EL2_SYSREG_IS_WRITE(esr) (((esr) & ESR_EL2_SYSREG_DIRECTION) == 0UL) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1066 | |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 1067 | #define ESR_IL(esr) ((esr) & MASK(ESR_EL2_IL)) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1068 | |
AlexeiFedorov | feaef16 | 2022-12-23 16:59:51 +0000 | [diff] [blame] | 1069 | #define ESR_EL2_SYSREG_ISS_RT(esr) EXTRACT(ESR_EL2_SYSREG_TRAP_RT, esr) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1070 | |
AlexeiFedorov | 93f5ec5 | 2023-08-31 14:26:53 +0100 | [diff] [blame] | 1071 | #define ICC_HPPIR1_EL1_INTID_SHIFT UL(0) |
| 1072 | #define ICC_HPPIR1_EL1_INTID_WIDTH UL(24) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1073 | |
| 1074 | #define CNTHCTL_EL2_EL0PCTEN (UL(1) << UL(0)) |
| 1075 | #define CNTHCTL_EL2_EL0VCTEN (UL(1) << UL(1)) |
| 1076 | #define CNTHCTL_EL2_EL1PCTEN (UL(1) << 10) |
| 1077 | #define CNTHCTL_EL2_EL1PTEN (UL(1) << 11) |
| 1078 | #define CNTHCTL_EL2_EL1TVT (UL(1) << 13) |
| 1079 | #define CNTHCTL_EL2_EL1TVCT (UL(1) << 14) |
| 1080 | #define CNTHCTL_EL2_CNTVMASK (UL(1) << 18) |
| 1081 | #define CNTHCTL_EL2_CNTPMASK (UL(1) << 19) |
| 1082 | |
| 1083 | #define CNTHCTL_EL2_INIT (CNTHCTL_EL2_EL0VCTEN | CNTHCTL_EL2_EL0PCTEN) |
| 1084 | |
| 1085 | #define CNTHCTL_EL2_NO_TRAPS (CNTHCTL_EL2_EL1PCTEN | \ |
| 1086 | CNTHCTL_EL2_EL1PTEN) |
| 1087 | |
| 1088 | #define CNTx_CTL_ENABLE (UL(1) << 0) |
| 1089 | #define CNTx_CTL_IMASK (UL(1) << 1) |
| 1090 | #define CNTx_CTL_ISTATUS (UL(1) << 2) |
| 1091 | |
| 1092 | /******************************************************************************* |
| 1093 | * Definitions of register offsets, fields and macros for CPU system |
| 1094 | * instructions. |
| 1095 | ******************************************************************************/ |
| 1096 | |
| 1097 | #define TLBI_ADDR_SHIFT U(12) |
AlexeiFedorov | 1ba649f | 2023-10-19 13:56:02 +0100 | [diff] [blame] | 1098 | #define TLBI_ADDR_MASK UL(0x0FFFFFFFFFFF) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1099 | #define TLBI_ADDR(x) (((x) >> TLBI_ADDR_SHIFT) & TLBI_ADDR_MASK) |
| 1100 | |
| 1101 | /* ID_AA64MMFR2_EL1 definitions */ |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 1102 | #define ID_AA64MMFR2_EL1_ST_SHIFT UL(28) |
| 1103 | #define ID_AA64MMFR2_EL1_ST_WIDTH UL(4) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1104 | |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 1105 | #define ID_AA64MMFR2_EL1_CNP_SHIFT UL(0) |
| 1106 | #define ID_AA64MMFR2_EL1_CNP_WIDTH UL(4) |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1107 | |
Javier Almansa Sobrino | cfd3254 | 2024-10-09 19:38:56 +0100 | [diff] [blame^] | 1108 | /* ID_AA64MMFR3_EL1_definitions */ |
| 1109 | #define ID_AA64MMFR3 S3_0_C0_C7_3 |
| 1110 | #define ID_AA64MMFR3_EL1_SCTLRX_SHIFT UL(4) |
| 1111 | #define ID_AA64MMFR3_EL1_SCTLRX_WIDTH UL(4) |
| 1112 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1113 | /* Custom defined values to indicate the vector offset to exception handlers */ |
| 1114 | #define ARM_EXCEPTION_SYNC_LEL 0 |
| 1115 | #define ARM_EXCEPTION_IRQ_LEL 1 |
| 1116 | #define ARM_EXCEPTION_FIQ_LEL 2 |
| 1117 | #define ARM_EXCEPTION_SERROR_LEL 3 |
| 1118 | |
AlexeiFedorov | 537bee0 | 2023-02-02 13:38:23 +0000 | [diff] [blame] | 1119 | #define VBAR_CEL_SP_EL0_OFFSET 0x0 |
| 1120 | #define VBAR_CEL_SP_ELx_OFFSET 0x200 |
| 1121 | #define VBAR_LEL_AA64_OFFSET 0x400 |
| 1122 | #define VBAR_LEL_AA32_OFFSET 0x600 |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1123 | |
Javier Almansa Sobrino | cfd3254 | 2024-10-09 19:38:56 +0100 | [diff] [blame^] | 1124 | /* SError vector offset from Sync exception vector */ |
| 1125 | #define VBAR_SERROR_OFFSET UL(0x180) |
| 1126 | |
AlexeiFedorov | 4c7d485 | 2024-01-25 14:37:34 +0000 | [diff] [blame] | 1127 | /* Stack Pointer selection */ |
| 1128 | #define MODE_SP_EL0 UL(0) |
| 1129 | #define MODE_SP_ELX UL(1) |
| 1130 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1131 | #endif /* ARCH_H */ |