xref: /rk3399_ARM-atf/include/arch/aarch64/arch_features.h (revision 33e6aaacf1e8f327b33fe2db1f5e964b0adb41c7)
1 /*
2  * Copyright (c) 2019-2024, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef ARCH_FEATURES_H
8 #define ARCH_FEATURES_H
9 
10 #include <stdbool.h>
11 
12 #include <arch_helpers.h>
13 #include <common/feat_detect.h>
14 
15 #define ISOLATE_FIELD(reg, feat, mask)						\
16 	((unsigned int)(((reg) >> (feat)) & mask))
17 
18 #define CREATE_FEATURE_SUPPORTED(name, read_func, guard)			\
19 static inline bool is_ ## name ## _supported(void)				\
20 {										\
21 	if ((guard) == FEAT_STATE_DISABLED) {					\
22 		return false;							\
23 	}									\
24 	if ((guard) == FEAT_STATE_ALWAYS) {					\
25 		return true;							\
26 	}									\
27 	return read_func();							\
28 }
29 
30 #define CREATE_FEATURE_PRESENT(name, idreg, idfield, mask, idval)		\
31 static inline bool is_ ## name ## _present(void)				\
32 {										\
33 	return (ISOLATE_FIELD(read_ ## idreg(), idfield, mask) >= idval) 	\
34 		? true : false; 						\
35 }
36 
37 #define CREATE_FEATURE_FUNCS(name, idreg, idfield, mask, idval, guard)		\
38 CREATE_FEATURE_PRESENT(name, idreg, idfield, mask, idval)			\
39 CREATE_FEATURE_SUPPORTED(name, is_ ## name ## _present, guard)
40 
41 
42 /* +----------------------------+
43  * |	Features supported	|
44  * +----------------------------+
45  * |	GENTIMER		|
46  * +----------------------------+
47  * |	FEAT_PAN		|
48  * +----------------------------+
49  * |	FEAT_VHE		|
50  * +----------------------------+
51  * |	FEAT_TTCNP		|
52  * +----------------------------+
53  * |	FEAT_UAO		|
54  * +----------------------------+
55  * |	FEAT_PACQARMA3		|
56  * +----------------------------+
57  * |	FEAT_PAUTH		|
58  * +----------------------------+
59  * |	FEAT_TTST		|
60  * +----------------------------+
61  * |	FEAT_BTI		|
62  * +----------------------------+
63  * |	FEAT_MTE2		|
64  * +----------------------------+
65  * |	FEAT_SSBS		|
66  * +----------------------------+
67  * |	FEAT_NMI		|
68  * +----------------------------+
69  * |	FEAT_GCS		|
70  * +----------------------------+
71  * |	FEAT_EBEP		|
72  * +----------------------------+
73  * |	FEAT_SEBEP		|
74  * +----------------------------+
75  * |	FEAT_SEL2		|
76  * +----------------------------+
77  * |	FEAT_TWED		|
78  * +----------------------------+
79  * |	FEAT_FGT		|
80  * +----------------------------+
81  * |	FEAT_EC/ECV2		|
82  * +----------------------------+
83  * |	FEAT_RNG		|
84  * +----------------------------+
85  * |	FEAT_TCR2		|
86  * +----------------------------+
87  * |	FEAT_S2POE		|
88  * +----------------------------+
89  * |	FEAT_S1POE		|
90  * +----------------------------+
91  * |	FEAT_S2PIE		|
92  * +----------------------------+
93  * |	FEAT_S1PIE		|
94  * +----------------------------+
95  * |	FEAT_AMU/AMUV1P1	|
96  * +----------------------------+
97  * |	FEAT_MPAM		|
98  * +----------------------------+
99  * |	FEAT_HCX		|
100  * +----------------------------+
101  * |	FEAT_RNG_TRAP		|
102  * +----------------------------+
103  * |	FEAT_RME		|
104  * +----------------------------+
105  * |	FEAT_SB			|
106  * +----------------------------+
107  * |	FEAT_CSV2/CSV3		|
108  * +----------------------------+
109  * |	FEAT_SPE		|
110  * +----------------------------+
111  * |	FEAT_SVE		|
112  * +----------------------------+
113  * |	FEAT_RAS		|
114  * +----------------------------+
115  * |	FEAT_DIT		|
116  * +----------------------------+
117  * |	FEAT_SYS_REG_TRACE	|
118  * +----------------------------+
119  * |	FEAT_TRF		|
120  * +----------------------------+
121  * |	FEAT_NV/NV2		|
122  * +----------------------------+
123  * |	FEAT_BRBE		|
124  * +----------------------------+
125  * |	FEAT_TRBE		|
126  * +----------------------------+
127  * |	FEAT_SME/SME2		|
128  * +----------------------------+
129  * |	FEAT_PMUV3		|
130  * +----------------------------+
131  * |	FEAT_MTPMU		|
132  * +----------------------------+
133  * |	FEAT_FGT2		|
134  * +----------------------------+
135  */
136 
137 static inline bool is_armv7_gentimer_present(void)
138 {
139 	/* The Generic Timer is always present in an ARMv8-A implementation */
140 	return true;
141 }
142 
143 /* FEAT_PAN: Privileged access never */
144 CREATE_FEATURE_FUNCS(feat_pan, id_aa64mmfr1_el1, ID_AA64MMFR1_EL1_PAN_SHIFT,
145 		     ID_AA64MMFR1_EL1_PAN_MASK, 1U, ENABLE_FEAT_PAN)
146 
147 /* FEAT_VHE: Virtualization Host Extensions */
148 CREATE_FEATURE_FUNCS(feat_vhe, id_aa64mmfr1_el1, ID_AA64MMFR1_EL1_VHE_SHIFT,
149 		     ID_AA64MMFR1_EL1_VHE_MASK, 1U, ENABLE_FEAT_VHE)
150 
151 /* FEAT_TTCNP: Translation table common not private */
152 CREATE_FEATURE_PRESENT(feat_ttcnp, id_aa64mmfr2_el1, ID_AA64MMFR2_EL1_CNP_SHIFT,
153 			ID_AA64MMFR2_EL1_CNP_MASK, 1U)
154 
155 /* FEAT_UAO: User access override */
156 CREATE_FEATURE_PRESENT(feat_uao, id_aa64mmfr2_el1, ID_AA64MMFR2_EL1_UAO_SHIFT,
157 			ID_AA64MMFR2_EL1_UAO_MASK, 1U)
158 
159 /* If any of the fields is not zero, QARMA3 algorithm is present */
160 CREATE_FEATURE_PRESENT(feat_pacqarma3, id_aa64isar2_el1, 0,
161 			((ID_AA64ISAR2_GPA3_MASK << ID_AA64ISAR2_GPA3_SHIFT) |
162 			(ID_AA64ISAR2_APA3_MASK << ID_AA64ISAR2_APA3_SHIFT)), 1U)
163 
164 /* PAUTH */
165 static inline bool is_armv8_3_pauth_present(void)
166 {
167 	uint64_t mask_id_aa64isar1 =
168 		(ID_AA64ISAR1_GPI_MASK << ID_AA64ISAR1_GPI_SHIFT) |
169 		(ID_AA64ISAR1_GPA_MASK << ID_AA64ISAR1_GPA_SHIFT) |
170 		(ID_AA64ISAR1_API_MASK << ID_AA64ISAR1_API_SHIFT) |
171 		(ID_AA64ISAR1_APA_MASK << ID_AA64ISAR1_APA_SHIFT);
172 
173 	/*
174 	 * If any of the fields is not zero or QARMA3 is present,
175 	 * PAuth is present
176 	 */
177 	return ((read_id_aa64isar1_el1() & mask_id_aa64isar1) != 0U ||
178 		is_feat_pacqarma3_present());
179 }
180 
181 /* FEAT_TTST: Small translation tables */
182 CREATE_FEATURE_PRESENT(feat_ttst, id_aa64mmfr2_el1, ID_AA64MMFR2_EL1_ST_SHIFT,
183 			ID_AA64MMFR2_EL1_ST_MASK, 1U)
184 
185 /* FEAT_BTI: Branch target identification */
186 CREATE_FEATURE_PRESENT(feat_bti, id_aa64pfr1_el1, ID_AA64PFR1_EL1_BT_SHIFT,
187 			ID_AA64PFR1_EL1_BT_MASK, BTI_IMPLEMENTED)
188 
189 /* FEAT_MTE2: Memory tagging extension */
190 CREATE_FEATURE_FUNCS(feat_mte2, id_aa64pfr1_el1, ID_AA64PFR1_EL1_MTE_SHIFT,
191 		     ID_AA64PFR1_EL1_MTE_MASK, MTE_IMPLEMENTED_ELX, ENABLE_FEAT_MTE2)
192 
193 /* FEAT_SSBS: Speculative store bypass safe */
194 CREATE_FEATURE_PRESENT(feat_ssbs, id_aa64pfr1_el1, ID_AA64PFR1_EL1_SSBS_SHIFT,
195 			ID_AA64PFR1_EL1_SSBS_MASK, 1U)
196 
197 /* FEAT_NMI: Non-maskable interrupts */
198 CREATE_FEATURE_PRESENT(feat_nmi, id_aa64pfr1_el1, ID_AA64PFR1_EL1_NMI_SHIFT,
199 			ID_AA64PFR1_EL1_NMI_MASK, NMI_IMPLEMENTED)
200 
201 /* FEAT_EBEP */
202 CREATE_FEATURE_PRESENT(feat_ebep, id_aa64dfr1_el1, ID_AA64DFR1_EBEP_SHIFT,
203 			ID_AA64DFR1_EBEP_MASK, EBEP_IMPLEMENTED)
204 
205 /* FEAT_SEBEP */
206 CREATE_FEATURE_PRESENT(feat_sebep, id_aa64dfr0_el1, ID_AA64DFR0_SEBEP_SHIFT,
207 			ID_AA64DFR0_SEBEP_MASK, SEBEP_IMPLEMENTED)
208 
209 /* FEAT_SEL2: Secure EL2 */
210 CREATE_FEATURE_FUNCS(feat_sel2, id_aa64pfr0_el1, ID_AA64PFR0_SEL2_SHIFT,
211 		     ID_AA64PFR0_SEL2_MASK, 1U, ENABLE_FEAT_SEL2)
212 
213 /* FEAT_TWED: Delayed trapping of WFE */
214 CREATE_FEATURE_FUNCS(feat_twed, id_aa64mmfr1_el1, ID_AA64MMFR1_EL1_TWED_SHIFT,
215 		     ID_AA64MMFR1_EL1_TWED_MASK, 1U, ENABLE_FEAT_TWED)
216 
217 /* FEAT_FGT: Fine-grained traps */
218 CREATE_FEATURE_FUNCS(feat_fgt, id_aa64mmfr0_el1, ID_AA64MMFR0_EL1_FGT_SHIFT,
219 		     ID_AA64MMFR0_EL1_FGT_MASK, 1U, ENABLE_FEAT_FGT)
220 
221 /* FEAT_FGT2: Fine-grained traps extended */
222 CREATE_FEATURE_FUNCS(feat_fgt2, id_aa64mmfr0_el1, ID_AA64MMFR0_EL1_FGT_SHIFT,
223 		     ID_AA64MMFR0_EL1_FGT_MASK, FGT2_IMPLEMENTED, ENABLE_FEAT_FGT2)
224 
225 /* FEAT_ECV: Enhanced Counter Virtualization */
226 CREATE_FEATURE_FUNCS(feat_ecv, id_aa64mmfr0_el1, ID_AA64MMFR0_EL1_ECV_SHIFT,
227 		     ID_AA64MMFR0_EL1_ECV_MASK, 1U, ENABLE_FEAT_ECV)
228 CREATE_FEATURE_FUNCS(feat_ecv_v2, id_aa64mmfr0_el1, ID_AA64MMFR0_EL1_ECV_SHIFT,
229 		     ID_AA64MMFR0_EL1_ECV_MASK, ID_AA64MMFR0_EL1_ECV_SELF_SYNCH, ENABLE_FEAT_ECV)
230 
231 /* FEAT_RNG: Random number generator */
232 CREATE_FEATURE_FUNCS(feat_rng, id_aa64isar0_el1, ID_AA64ISAR0_RNDR_SHIFT,
233 		     ID_AA64ISAR0_RNDR_MASK, 1U, ENABLE_FEAT_RNG)
234 
235 /* FEAT_TCR2: Support TCR2_ELx regs */
236 CREATE_FEATURE_FUNCS(feat_tcr2, id_aa64mmfr3_el1, ID_AA64MMFR3_EL1_TCRX_SHIFT,
237 		     ID_AA64MMFR3_EL1_TCRX_MASK, 1U, ENABLE_FEAT_TCR2)
238 
239 /* FEAT_S2POE */
240 CREATE_FEATURE_FUNCS(feat_s2poe, id_aa64mmfr3_el1, ID_AA64MMFR3_EL1_S2POE_SHIFT,
241 		     ID_AA64MMFR3_EL1_S2POE_MASK, 1U, ENABLE_FEAT_S2POE)
242 
243 /* FEAT_S1POE */
244 CREATE_FEATURE_FUNCS(feat_s1poe, id_aa64mmfr3_el1, ID_AA64MMFR3_EL1_S1POE_SHIFT,
245 		     ID_AA64MMFR3_EL1_S1POE_MASK, 1U, ENABLE_FEAT_S1POE)
246 
247 static inline bool is_feat_sxpoe_supported(void)
248 {
249 	return is_feat_s1poe_supported() || is_feat_s2poe_supported();
250 }
251 
252 /* FEAT_S2PIE */
253 CREATE_FEATURE_FUNCS(feat_s2pie, id_aa64mmfr3_el1, ID_AA64MMFR3_EL1_S2PIE_SHIFT,
254 		     ID_AA64MMFR3_EL1_S2PIE_MASK, 1U, ENABLE_FEAT_S2PIE)
255 
256 /* FEAT_S1PIE */
257 CREATE_FEATURE_FUNCS(feat_s1pie, id_aa64mmfr3_el1, ID_AA64MMFR3_EL1_S1PIE_SHIFT,
258 		     ID_AA64MMFR3_EL1_S1PIE_MASK, 1U, ENABLE_FEAT_S1PIE)
259 
260 static inline bool is_feat_sxpie_supported(void)
261 {
262 	return is_feat_s1pie_supported() || is_feat_s2pie_supported();
263 }
264 
265 /* FEAT_GCS: Guarded Control Stack */
266 CREATE_FEATURE_FUNCS(feat_gcs, id_aa64pfr1_el1, ID_AA64PFR1_EL1_GCS_SHIFT,
267 		     ID_AA64PFR1_EL1_GCS_MASK, 1U, ENABLE_FEAT_GCS)
268 
269 /* FEAT_AMU: Activity Monitors Extension */
270 CREATE_FEATURE_FUNCS(feat_amu, id_aa64pfr0_el1, ID_AA64PFR0_AMU_SHIFT,
271 		     ID_AA64PFR0_AMU_MASK, 1U, ENABLE_FEAT_AMU)
272 
273 /* FEAT_AMUV1P1: AMU Extension v1.1 */
274 CREATE_FEATURE_FUNCS(feat_amuv1p1, id_aa64pfr0_el1, ID_AA64PFR0_AMU_SHIFT,
275 		     ID_AA64PFR0_AMU_MASK, ID_AA64PFR0_AMU_V1P1, ENABLE_FEAT_AMUv1p1)
276 
277 /*
278  * Return MPAM version:
279  *
280  * 0x00: None Armv8.0 or later
281  * 0x01: v0.1 Armv8.4 or later
282  * 0x10: v1.0 Armv8.2 or later
283  * 0x11: v1.1 Armv8.4 or later
284  *
285  */
286 static inline bool is_feat_mpam_present(void)
287 {
288 	unsigned int ret = (unsigned int)((((read_id_aa64pfr0_el1() >>
289 		ID_AA64PFR0_MPAM_SHIFT) & ID_AA64PFR0_MPAM_MASK) << 4) |
290 		((read_id_aa64pfr1_el1() >> ID_AA64PFR1_MPAM_FRAC_SHIFT)
291 			& ID_AA64PFR1_MPAM_FRAC_MASK));
292 	return ret;
293 }
294 
295 CREATE_FEATURE_SUPPORTED(feat_mpam, is_feat_mpam_present, ENABLE_FEAT_MPAM)
296 
297 /*
298  * FEAT_DebugV8P9: Debug extension. This function checks the field 3:0 of
299  * ID_AA64DFR0 Aarch64 Debug Feature Register 0 for the version of
300  * Feat_Debug supported. The value of the field determines feature presence
301  *
302  * 0b0110 - Arm v8.0 debug
303  * 0b0111 - Arm v8.0 debug architecture with Virtualization host extensions
304  * 0x1000 - FEAT_Debugv8p2 is supported
305  * 0x1001 - FEAT_Debugv8p4 is supported
306  * 0x1010 - FEAT_Debugv8p8 is supported
307  * 0x1011 - FEAT_Debugv8p9 is supported
308  *
309  */
310 CREATE_FEATURE_FUNCS(feat_debugv8p9, id_aa64dfr0_el1, ID_AA64DFR0_DEBUGVER_SHIFT,
311 		ID_AA64DFR0_DEBUGVER_MASK, DEBUGVER_V8P9_IMPLEMENTED,
312 		ENABLE_FEAT_DEBUGV8P9)
313 
314 /* FEAT_HCX: Extended Hypervisor Configuration Register */
315 CREATE_FEATURE_FUNCS(feat_hcx, id_aa64mmfr1_el1, ID_AA64MMFR1_EL1_HCX_SHIFT,
316 		     ID_AA64MMFR1_EL1_HCX_MASK, 1U, ENABLE_FEAT_HCX)
317 
318 /* FEAT_RNG_TRAP: Trapping support */
319 CREATE_FEATURE_PRESENT(feat_rng_trap, id_aa64pfr1_el1, ID_AA64PFR1_EL1_RNDR_TRAP_SHIFT,
320 		      ID_AA64PFR1_EL1_RNDR_TRAP_MASK, RNG_TRAP_IMPLEMENTED)
321 
322 /* Return the RME version, zero if not supported. */
323 CREATE_FEATURE_FUNCS(feat_rme, id_aa64pfr0_el1, ID_AA64PFR0_FEAT_RME_SHIFT,
324 		    ID_AA64PFR0_FEAT_RME_MASK, 1U, ENABLE_RME)
325 
326 /* FEAT_SB: Speculation barrier instruction */
327 CREATE_FEATURE_PRESENT(feat_sb, id_aa64isar1_el1, ID_AA64ISAR1_SB_SHIFT,
328 		       ID_AA64ISAR1_SB_MASK, 1U)
329 
330 /*
331  * FEAT_CSV2: Cache Speculation Variant 2. This checks bit fields[56-59]
332  * of id_aa64pfr0_el1 register and can be used to check for below features:
333  * FEAT_CSV2_2: Cache Speculation Variant CSV2_2.
334  * FEAT_CSV2_3: Cache Speculation Variant CSV2_3.
335  * 0b0000 - Feature FEAT_CSV2 is not implemented.
336  * 0b0001 - Feature FEAT_CSV2 is implemented, but FEAT_CSV2_2 and FEAT_CSV2_3
337  *          are not implemented.
338  * 0b0010 - Feature FEAT_CSV2_2 is implemented but FEAT_CSV2_3 is not
339  *          implemented.
340  * 0b0011 - Feature FEAT_CSV2_3 is implemented.
341  */
342 
343 CREATE_FEATURE_FUNCS(feat_csv2_2, id_aa64pfr0_el1, ID_AA64PFR0_CSV2_SHIFT,
344 		     ID_AA64PFR0_CSV2_MASK, CSV2_2_IMPLEMENTED, ENABLE_FEAT_CSV2_2)
345 CREATE_FEATURE_FUNCS(feat_csv2_3, id_aa64pfr0_el1, ID_AA64PFR0_CSV2_SHIFT,
346 		     ID_AA64PFR0_CSV2_MASK, CSV2_3_IMPLEMENTED, ENABLE_FEAT_CSV2_3)
347 
348 /* FEAT_SPE: Statistical Profiling Extension */
349 CREATE_FEATURE_FUNCS(feat_spe, id_aa64dfr0_el1, ID_AA64DFR0_PMS_SHIFT,
350 		     ID_AA64DFR0_PMS_MASK, 1U, ENABLE_SPE_FOR_NS)
351 
352 /* FEAT_SVE: Scalable Vector Extension */
353 CREATE_FEATURE_FUNCS(feat_sve, id_aa64pfr0_el1, ID_AA64PFR0_SVE_SHIFT,
354 		     ID_AA64PFR0_SVE_MASK, 1U, ENABLE_SVE_FOR_NS)
355 
356 /* FEAT_RAS: Reliability, Accessibility, Serviceability */
357 CREATE_FEATURE_FUNCS(feat_ras, id_aa64pfr0_el1, ID_AA64PFR0_RAS_SHIFT,
358 		     ID_AA64PFR0_RAS_MASK, 1U, ENABLE_FEAT_RAS)
359 
360 /* FEAT_DIT: Data Independent Timing instructions */
361 CREATE_FEATURE_FUNCS(feat_dit, id_aa64pfr0_el1, ID_AA64PFR0_DIT_SHIFT,
362 		     ID_AA64PFR0_DIT_MASK, 1U, ENABLE_FEAT_DIT)
363 
364 /* FEAT_SYS_REG_TRACE */
365 CREATE_FEATURE_FUNCS(feat_sys_reg_trace, id_aa64dfr0_el1, ID_AA64DFR0_TRACEVER_SHIFT,
366 		    ID_AA64DFR0_TRACEVER_MASK, 1U, ENABLE_SYS_REG_TRACE_FOR_NS)
367 
368 /* FEAT_TRF: TraceFilter */
369 CREATE_FEATURE_FUNCS(feat_trf, id_aa64dfr0_el1, ID_AA64DFR0_TRACEFILT_SHIFT,
370 		     ID_AA64DFR0_TRACEFILT_MASK, 1U, ENABLE_TRF_FOR_NS)
371 
372 /* FEAT_NV2: Enhanced Nested Virtualization */
373 CREATE_FEATURE_FUNCS(feat_nv, id_aa64mmfr2_el1, ID_AA64MMFR2_EL1_NV_SHIFT,
374 		     ID_AA64MMFR2_EL1_NV_MASK, 1U, 0U)
375 CREATE_FEATURE_FUNCS(feat_nv2, id_aa64mmfr2_el1, ID_AA64MMFR2_EL1_NV_SHIFT,
376 		     ID_AA64MMFR2_EL1_NV_MASK, NV2_IMPLEMENTED, CTX_INCLUDE_NEVE_REGS)
377 
378 /* FEAT_BRBE: Branch Record Buffer Extension */
379 CREATE_FEATURE_FUNCS(feat_brbe, id_aa64dfr0_el1, ID_AA64DFR0_BRBE_SHIFT,
380 		     ID_AA64DFR0_BRBE_MASK, 1U, ENABLE_BRBE_FOR_NS)
381 
382 /* FEAT_TRBE: Trace Buffer Extension */
383 CREATE_FEATURE_FUNCS(feat_trbe, id_aa64dfr0_el1, ID_AA64DFR0_TRACEBUFFER_SHIFT,
384 		     ID_AA64DFR0_TRACEBUFFER_MASK, 1U, ENABLE_TRBE_FOR_NS)
385 
386 /* FEAT_SME_FA64: Full A64 Instruction support in streaming SVE mode */
387 CREATE_FEATURE_PRESENT(feat_sme_fa64, id_aa64smfr0_el1, ID_AA64SMFR0_EL1_SME_FA64_SHIFT,
388 		    ID_AA64SMFR0_EL1_SME_FA64_MASK, 1U)
389 
390 /* FEAT_SMEx: Scalar Matrix Extension */
391 CREATE_FEATURE_FUNCS(feat_sme, id_aa64pfr1_el1, ID_AA64PFR1_EL1_SME_SHIFT,
392 		     ID_AA64PFR1_EL1_SME_MASK, 1U, ENABLE_SME_FOR_NS)
393 
394 CREATE_FEATURE_FUNCS(feat_sme2, id_aa64pfr1_el1, ID_AA64PFR1_EL1_SME_SHIFT,
395 		     ID_AA64PFR1_EL1_SME_MASK, SME2_IMPLEMENTED, ENABLE_SME2_FOR_NS)
396 
397 /*******************************************************************************
398  * Function to get hardware granularity support
399  ******************************************************************************/
400 
401 static inline bool is_feat_tgran4K_present(void)
402 {
403 	unsigned int tgranx = ISOLATE_FIELD(read_id_aa64mmfr0_el1(),
404 			     ID_AA64MMFR0_EL1_TGRAN4_SHIFT, ID_REG_FIELD_MASK);
405 	return (tgranx < 8U);
406 }
407 
408 CREATE_FEATURE_PRESENT(feat_tgran16K, id_aa64mmfr0_el1, ID_AA64MMFR0_EL1_TGRAN16_SHIFT,
409 		       ID_AA64MMFR0_EL1_TGRAN16_MASK, TGRAN16_IMPLEMENTED)
410 
411 static inline bool is_feat_tgran64K_present(void)
412 {
413 	unsigned int tgranx = ISOLATE_FIELD(read_id_aa64mmfr0_el1(),
414 			     ID_AA64MMFR0_EL1_TGRAN64_SHIFT, ID_REG_FIELD_MASK);
415 	return (tgranx < 8U);
416 }
417 
418 /* FEAT_PMUV3 */
419 CREATE_FEATURE_PRESENT(feat_pmuv3, id_aa64dfr0_el1, ID_AA64DFR0_PMUVER_SHIFT,
420 		      ID_AA64DFR0_PMUVER_MASK, 1U)
421 
422 /* FEAT_MTPMU */
423 static inline bool is_feat_mtpmu_present(void)
424 {
425 	unsigned int mtpmu = ISOLATE_FIELD(read_id_aa64dfr0_el1(), ID_AA64DFR0_MTPMU_SHIFT,
426 					   ID_AA64DFR0_MTPMU_MASK);
427 	return (mtpmu != 0U) && (mtpmu != MTPMU_NOT_IMPLEMENTED);
428 }
429 
430 CREATE_FEATURE_SUPPORTED(feat_mtpmu, is_feat_mtpmu_present, DISABLE_MTPMU)
431 
432 #endif /* ARCH_FEATURES_H */
433