xref: /freebsd/sys/arm64/arm64/identcpu.c (revision e80cb2254414018d41b00004fe7c7ccf828e0fbc)
1 /*-
2  * Copyright (c) 2014 Andrew Turner
3  * Copyright (c) 2014 The FreeBSD Foundation
4  * All rights reserved.
5  *
6  * Portions of this software were developed by Semihalf
7  * under sponsorship of the FreeBSD Foundation.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  */
31 
32 #include <sys/param.h>
33 #include <sys/kernel.h>
34 #include <sys/malloc.h>
35 #include <sys/proc.h>
36 #include <sys/pcpu.h>
37 #include <sys/sbuf.h>
38 #include <sys/smp.h>
39 #include <sys/sysctl.h>
40 #include <sys/sysent.h>
41 #include <sys/systm.h>
42 
43 #include <machine/atomic.h>
44 #include <machine/cpu.h>
45 #include <machine/cpu_feat.h>
46 #include <machine/cpufunc.h>
47 #include <machine/elf.h>
48 #include <machine/md_var.h>
49 #include <machine/undefined.h>
50 
51 static MALLOC_DEFINE(M_IDENTCPU, "CPU ID", "arm64 CPU identification memory");
52 
53 struct cpu_desc;
54 #ifdef INVARIANTS
55 static bool hwcaps_set = false;
56 #endif
57 
58 static void print_cpu_midr(struct sbuf *sb, u_int cpu);
59 static void print_cpu_features(u_int cpu, struct cpu_desc *desc,
60     struct cpu_desc *prev_desc);
61 static void print_cpu_caches(struct sbuf *sb, struct cpu_desc *desc);
62 #ifdef COMPAT_FREEBSD32
63 static u_long parse_cpu_features_hwcap32(void);
64 #endif
65 
66 const char machine[] = "arm64";
67 
68 #ifdef SCTL_MASK32
69 extern int adaptive_machine_arch;
70 #endif
71 
72 static SYSCTL_NODE(_machdep, OID_AUTO, cache, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
73     "Cache management tuning");
74 
75 static int allow_dic = 1;
76 SYSCTL_INT(_machdep_cache, OID_AUTO, allow_dic, CTLFLAG_RDTUN, &allow_dic, 0,
77     "Allow optimizations based on the DIC cache bit");
78 
79 static int allow_idc = 1;
80 SYSCTL_INT(_machdep_cache, OID_AUTO, allow_idc, CTLFLAG_RDTUN, &allow_idc, 0,
81     "Allow optimizations based on the IDC cache bit");
82 
83 static bool emulate_ctr = false;
84 
85 static void check_cpu_regs(u_int cpu, struct cpu_desc *desc,
86     struct cpu_desc *prev_desc);
87 static uint64_t update_special_reg_field(uint64_t user_reg, u_int type,
88     uint64_t value, u_int width, u_int shift, bool sign);
89 
90 /*
91  * The default implementation of I-cache sync assumes we have an
92  * aliasing cache until we know otherwise.
93  */
94 void (*arm64_icache_sync_range)(void *, vm_size_t) =
95     &arm64_aliasing_icache_sync_range;
96 
97 static int
sysctl_hw_machine(SYSCTL_HANDLER_ARGS)98 sysctl_hw_machine(SYSCTL_HANDLER_ARGS)
99 {
100 #ifdef SCTL_MASK32
101 	static const char machine32[] = "arm";
102 #endif
103 	int error;
104 
105 #ifdef SCTL_MASK32
106 	if ((req->flags & SCTL_MASK32) != 0 && adaptive_machine_arch)
107 		error = SYSCTL_OUT(req, machine32, sizeof(machine32));
108 	else
109 #endif
110 		error = SYSCTL_OUT(req, machine, sizeof(machine));
111 	return (error);
112 }
113 
114 SYSCTL_PROC(_hw, HW_MACHINE, machine, CTLTYPE_STRING | CTLFLAG_RD |
115 	 CTLFLAG_CAPRD | CTLFLAG_MPSAFE, NULL, 0, sysctl_hw_machine, "A",
116 	 "Machine class");
117 
118 static char cpu_model[64];
119 SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD | CTLFLAG_CAPRD,
120 	cpu_model, sizeof(cpu_model), "Machine model");
121 
122 #define	MAX_CACHES	8	/* Maximum number of caches supported
123 				   architecturally. */
124 /*
125  * Per-CPU affinity as provided in MPIDR_EL1
126  * Indexed by CPU number in logical order selected by the system.
127  * Relevant fields can be extracted using CPU_AFFn macros,
128  * Aff3.Aff2.Aff1.Aff0 construct a unique CPU address in the system.
129  *
130  * Fields used by us:
131  * Aff1 - Cluster number
132  * Aff0 - CPU number in Aff1 cluster
133  */
134 uint64_t __cpu_affinity[MAXCPU];
135 static u_int cpu_aff_levels;
136 
137 struct cpu_desc {
138 	uint64_t	mpidr;
139 	uint64_t	id_aa64afr0;
140 	uint64_t	id_aa64afr1;
141 	uint64_t	id_aa64dfr0;
142 	uint64_t	id_aa64dfr1;
143 	uint64_t	id_aa64isar0;
144 	uint64_t	id_aa64isar1;
145 	uint64_t	id_aa64isar2;
146 	uint64_t	id_aa64mmfr0;
147 	uint64_t	id_aa64mmfr1;
148 	uint64_t	id_aa64mmfr2;
149 	uint64_t	id_aa64mmfr3;
150 	uint64_t	id_aa64mmfr4;
151 	uint64_t	id_aa64pfr0;
152 	uint64_t	id_aa64pfr1;
153 	uint64_t	id_aa64pfr2;
154 	uint64_t	id_aa64zfr0;
155 	uint64_t	ctr;
156 #ifdef COMPAT_FREEBSD32
157 	uint64_t	id_isar5;
158 	uint64_t	mvfr0;
159 	uint64_t	mvfr1;
160 #endif
161 	uint64_t	clidr;
162 	uint32_t	ccsidr[MAX_CACHES][2]; /* 2 possible types. */
163 	bool		have_sve;
164 };
165 
166 static struct cpu_desc cpu_desc0;
167 static struct cpu_desc *cpu_desc;
168 static struct cpu_desc kern_cpu_desc;
169 static struct cpu_desc user_cpu_desc;
170 static struct cpu_desc l_user_cpu_desc;
171 
172 static struct cpu_desc *
get_cpu_desc(u_int cpu)173 get_cpu_desc(u_int cpu)
174 {
175 	/* The cpu_desc for CPU 0 is used before the allocator is ready. */
176 	if (cpu == 0)
177 		return (&cpu_desc0);
178 
179 	MPASS(cpu_desc != NULL);
180 	return (&cpu_desc[cpu - 1]);
181 }
182 
183 struct cpu_parts {
184 	u_int		part_id;
185 	const char	*part_name;
186 };
187 #define	CPU_PART_NONE	{ 0, NULL }
188 
189 struct cpu_implementers {
190 	u_int			impl_id;
191 	const char		*impl_name;
192 	/*
193 	 * Part number is implementation defined
194 	 * so each vendor will have its own set of values and names.
195 	 */
196 	const struct cpu_parts	*cpu_parts;
197 };
198 #define	CPU_IMPLEMENTER_NONE	{ 0, NULL, NULL }
199 
200 /*
201  * Per-implementer table of (PartNum, CPU Name) pairs.
202  */
203 /* ARM Ltd. */
204 static const struct cpu_parts cpu_parts_arm[] = {
205 	{ CPU_PART_AEM_V8, "AEMv8" },
206 	{ CPU_PART_FOUNDATION, "Foundation-Model" },
207 	{ CPU_PART_CORTEX_A34, "Cortex-A34" },
208 	{ CPU_PART_CORTEX_A35, "Cortex-A35" },
209 	{ CPU_PART_CORTEX_A53, "Cortex-A53" },
210 	{ CPU_PART_CORTEX_A55, "Cortex-A55" },
211 	{ CPU_PART_CORTEX_A57, "Cortex-A57" },
212 	{ CPU_PART_CORTEX_A65, "Cortex-A65" },
213 	{ CPU_PART_CORTEX_A65AE, "Cortex-A65AE" },
214 	{ CPU_PART_CORTEX_A72, "Cortex-A72" },
215 	{ CPU_PART_CORTEX_A73, "Cortex-A73" },
216 	{ CPU_PART_CORTEX_A75, "Cortex-A75" },
217 	{ CPU_PART_CORTEX_A76, "Cortex-A76" },
218 	{ CPU_PART_CORTEX_A76AE, "Cortex-A76AE" },
219 	{ CPU_PART_CORTEX_A77, "Cortex-A77" },
220 	{ CPU_PART_CORTEX_A78, "Cortex-A78" },
221 	{ CPU_PART_CORTEX_A78AE, "Cortex-A78AE" },
222 	{ CPU_PART_CORTEX_A78C, "Cortex-A78C" },
223 	{ CPU_PART_CORTEX_A510, "Cortex-A510" },
224 	{ CPU_PART_CORTEX_A520, "Cortex-A520" },
225 	{ CPU_PART_CORTEX_A710, "Cortex-A710" },
226 	{ CPU_PART_CORTEX_A715, "Cortex-A715" },
227 	{ CPU_PART_CORTEX_A720, "Cortex-A720" },
228 	{ CPU_PART_CORTEX_A725, "Cortex-A725" },
229 	{ CPU_PART_CORTEX_X925, "Cortex-A925" },
230 	{ CPU_PART_CORTEX_X1, "Cortex-X1" },
231 	{ CPU_PART_CORTEX_X1C, "Cortex-X1C" },
232 	{ CPU_PART_CORTEX_X2, "Cortex-X2" },
233 	{ CPU_PART_CORTEX_X3, "Cortex-X3" },
234 	{ CPU_PART_CORTEX_X4, "Cortex-X4" },
235 	{ CPU_PART_NEOVERSE_E1, "Neoverse-E1" },
236 	{ CPU_PART_NEOVERSE_N1, "Neoverse-N1" },
237 	{ CPU_PART_NEOVERSE_N2, "Neoverse-N2" },
238 	{ CPU_PART_NEOVERSE_N3, "Neoverse-N3" },
239 	{ CPU_PART_NEOVERSE_V1, "Neoverse-V1" },
240 	{ CPU_PART_NEOVERSE_V2, "Neoverse-V2" },
241 	{ CPU_PART_NEOVERSE_V3, "Neoverse-V3" },
242 	{ CPU_PART_NEOVERSE_V3AE, "Neoverse-V3AE" },
243 	CPU_PART_NONE,
244 };
245 
246 /* Cavium */
247 static const struct cpu_parts cpu_parts_cavium[] = {
248 	{ CPU_PART_THUNDERX, "ThunderX" },
249 	{ CPU_PART_THUNDERX2, "ThunderX2" },
250 	CPU_PART_NONE,
251 };
252 
253 /* APM (now Ampere) */
254 static const struct cpu_parts cpu_parts_apm[] = {
255 	{ CPU_PART_EMAG8180, "eMAG 8180" },
256 	CPU_PART_NONE,
257 };
258 
259 /* Ampere */
260 static const struct cpu_parts cpu_parts_ampere[] = {
261 	{ CPU_PART_AMPERE1, "AmpereOne AC03" },
262 	{ CPU_PART_AMPERE1A, "AmpereOne AC04" },
263 	CPU_PART_NONE,
264 };
265 
266 /* Microsoft */
267 static const struct cpu_parts cpu_parts_microsoft[] = {
268 	{ CPU_PART_AZURE_COBALT_100, "Azure Cobalt 100" },
269 	CPU_PART_NONE,
270 };
271 
272 /* Qualcomm */
273 static const struct cpu_parts cpu_parts_qcom[] = {
274 	{ CPU_PART_KRYO400_GOLD, "Kryo 400 Gold" },
275 	{ CPU_PART_KRYO400_SILVER, "Kryo 400 Silver" },
276 	CPU_PART_NONE,
277 };
278 
279 /* Apple */
280 static const struct cpu_parts cpu_parts_apple[] = {
281 	{ CPU_PART_M1_ICESTORM, "M1 Icestorm" },
282 	{ CPU_PART_M1_FIRESTORM, "M1 Firestorm" },
283 	{ CPU_PART_M1_ICESTORM_PRO, "M1 Pro Icestorm" },
284 	{ CPU_PART_M1_FIRESTORM_PRO, "M1 Pro Firestorm" },
285 	{ CPU_PART_M1_ICESTORM_MAX, "M1 Max Icestorm" },
286 	{ CPU_PART_M1_FIRESTORM_MAX, "M1 Max Firestorm" },
287 	{ CPU_PART_M2_BLIZZARD, "M2 Blizzard" },
288 	{ CPU_PART_M2_AVALANCHE, "M2 Avalanche" },
289 	{ CPU_PART_M2_BLIZZARD_PRO, "M2 Pro Blizzard" },
290 	{ CPU_PART_M2_AVALANCHE_PRO, "M2 Pro Avalanche" },
291 	{ CPU_PART_M2_BLIZZARD_MAX, "M2 Max Blizzard" },
292 	{ CPU_PART_M2_AVALANCHE_MAX, "M2 Max Avalanche" },
293 	CPU_PART_NONE,
294 };
295 
296 /* Unknown */
297 static const struct cpu_parts cpu_parts_none[] = {
298 	CPU_PART_NONE,
299 };
300 
301 /*
302  * Implementers table.
303  */
304 const struct cpu_implementers cpu_implementers[] = {
305 	{ CPU_IMPL_AMPERE,	"Ampere",	cpu_parts_ampere },
306 	{ CPU_IMPL_APPLE,	"Apple",	cpu_parts_apple },
307 	{ CPU_IMPL_APM,		"APM",		cpu_parts_apm },
308 	{ CPU_IMPL_ARM,		"ARM",		cpu_parts_arm },
309 	{ CPU_IMPL_BROADCOM,	"Broadcom",	cpu_parts_none },
310 	{ CPU_IMPL_CAVIUM,	"Cavium",	cpu_parts_cavium },
311 	{ CPU_IMPL_DEC,		"DEC",		cpu_parts_none },
312 	{ CPU_IMPL_FREESCALE,	"Freescale",	cpu_parts_none },
313 	{ CPU_IMPL_FUJITSU,	"Fujitsu",	cpu_parts_none },
314 	{ CPU_IMPL_HISILICON,	"HiSilicon",	cpu_parts_none },
315 	{ CPU_IMPL_INFINEON,	"IFX",		cpu_parts_none },
316 	{ CPU_IMPL_INTEL,	"Intel",	cpu_parts_none },
317 	{ CPU_IMPL_MARVELL,	"Marvell",	cpu_parts_none },
318 	{ CPU_IMPL_MICROSOFT,	"Microsoft",	cpu_parts_microsoft },
319 	{ CPU_IMPL_NVIDIA,	"NVIDIA",	cpu_parts_none },
320 	{ CPU_IMPL_QUALCOMM,	"Qualcomm",	cpu_parts_qcom },
321 	CPU_IMPLEMENTER_NONE,
322 };
323 
324 #define	MRS_TYPE_MASK		0xf
325 #define	MRS_INVALID		0
326 #define	MRS_EXACT		1
327 #define	MRS_EXACT_IF_DIFFERENT	2
328 #define	MRS_LOWER		3
329 #define	MRS_HIGHER_OR_ZERO	4
330 #define	MRS_HIGHER		5
331 #define	MRS_SAFE_SHIFT		4
332 #define	MRS_SAFE_MASK		(0xfu << MRS_SAFE_SHIFT)
333 #define	MRS_SAFE(x)		(((x) << MRS_SAFE_SHIFT) & MRS_SAFE_MASK)
334 #define	MRS_SAFE_VAL(x)		(((x) & MRS_SAFE_MASK) >> MRS_SAFE_SHIFT)
335 #define	MRS_FREEBSD		(1u << 8)
336 #define	MRS_LINUX		(1u << 9)
337 #define	MRS_USERSPACE		(MRS_FREEBSD | MRS_LINUX)
338 
339 struct mrs_field_value {
340 	uint64_t	value;
341 	const char	*desc;
342 };
343 
344 #define	MRS_FIELD_VALUE(_value, _desc)					\
345 	{								\
346 		.value = (_value),					\
347 		.desc = (_desc),					\
348 	}
349 
350 #define	MRS_FIELD_VALUE_NONE_IMPL(_reg, _field, _none, _impl)		\
351 	MRS_FIELD_VALUE(_reg ## _ ## _field ## _ ## _none, ""),		\
352 	MRS_FIELD_VALUE(_reg ## _ ## _field ## _ ## _impl, #_field)
353 
354 #define	MRS_FIELD_VALUE_COUNT(_reg, _field, _desc)			\
355 	MRS_FIELD_VALUE(0ul << _reg ## _ ## _field ## _SHIFT, "1 " _desc), \
356 	MRS_FIELD_VALUE(1ul << _reg ## _ ## _field ## _SHIFT, "2 " _desc "s"), \
357 	MRS_FIELD_VALUE(2ul << _reg ## _ ## _field ## _SHIFT, "3 " _desc "s"), \
358 	MRS_FIELD_VALUE(3ul << _reg ## _ ## _field ## _SHIFT, "4 " _desc "s"), \
359 	MRS_FIELD_VALUE(4ul << _reg ## _ ## _field ## _SHIFT, "5 " _desc "s"), \
360 	MRS_FIELD_VALUE(5ul << _reg ## _ ## _field ## _SHIFT, "6 " _desc "s"), \
361 	MRS_FIELD_VALUE(6ul << _reg ## _ ## _field ## _SHIFT, "7 " _desc "s"), \
362 	MRS_FIELD_VALUE(7ul << _reg ## _ ## _field ## _SHIFT, "8 " _desc "s"), \
363 	MRS_FIELD_VALUE(8ul << _reg ## _ ## _field ## _SHIFT, "9 " _desc "s"), \
364 	MRS_FIELD_VALUE(9ul << _reg ## _ ## _field ## _SHIFT, "10 "_desc "s"), \
365 	MRS_FIELD_VALUE(10ul<< _reg ## _ ## _field ## _SHIFT, "11 "_desc "s"), \
366 	MRS_FIELD_VALUE(11ul<< _reg ## _ ## _field ## _SHIFT, "12 "_desc "s"), \
367 	MRS_FIELD_VALUE(12ul<< _reg ## _ ## _field ## _SHIFT, "13 "_desc "s"), \
368 	MRS_FIELD_VALUE(13ul<< _reg ## _ ## _field ## _SHIFT, "14 "_desc "s"), \
369 	MRS_FIELD_VALUE(14ul<< _reg ## _ ## _field ## _SHIFT, "15 "_desc "s"), \
370 	MRS_FIELD_VALUE(15ul<< _reg ## _ ## _field ## _SHIFT, "16 "_desc "s")
371 
372 /*
373  * Used for printing I/D cache line sizes & CWG/ERG, as 0 is a special case
374  * in some cases the decoded string needs to be passed in.
375  */
376 #define	MRS_FIELD_VALUE_CACHE(_reg, _field, _0desc, _desc)		\
377 	MRS_FIELD_VALUE(0ul << _reg ## _ ## _field ## _SHIFT, _0desc), \
378 	MRS_FIELD_VALUE(1ul << _reg ## _ ## _field ## _SHIFT, "8 "   _desc), \
379 	MRS_FIELD_VALUE(2ul << _reg ## _ ## _field ## _SHIFT, "16 "  _desc), \
380 	MRS_FIELD_VALUE(3ul << _reg ## _ ## _field ## _SHIFT, "32 "  _desc), \
381 	MRS_FIELD_VALUE(4ul << _reg ## _ ## _field ## _SHIFT, "64 "  _desc), \
382 	MRS_FIELD_VALUE(5ul << _reg ## _ ## _field ## _SHIFT, "128 " _desc), \
383 	MRS_FIELD_VALUE(6ul << _reg ## _ ## _field ## _SHIFT, "256 " _desc), \
384 	MRS_FIELD_VALUE(7ul << _reg ## _ ## _field ## _SHIFT, "512 " _desc), \
385 	MRS_FIELD_VALUE(8ul << _reg ## _ ## _field ## _SHIFT, "1k "  _desc), \
386 	MRS_FIELD_VALUE(9ul << _reg ## _ ## _field ## _SHIFT, "2k "  _desc), \
387 	MRS_FIELD_VALUE(10ul<< _reg ## _ ## _field ## _SHIFT, "4k "  _desc), \
388 	MRS_FIELD_VALUE(11ul<< _reg ## _ ## _field ## _SHIFT, "8k "  _desc), \
389 	MRS_FIELD_VALUE(12ul<< _reg ## _ ## _field ## _SHIFT, "16k " _desc), \
390 	MRS_FIELD_VALUE(13ul<< _reg ## _ ## _field ## _SHIFT, "32k " _desc), \
391 	MRS_FIELD_VALUE(14ul<< _reg ## _ ## _field ## _SHIFT, "64k " _desc), \
392 	MRS_FIELD_VALUE(15ul<< _reg ## _ ## _field ## _SHIFT, "128k "_desc)
393 
394 #define	MRS_FIELD_VALUE_END	{ .desc = NULL }
395 
396 struct mrs_field_hwcap {
397 	uint64_t	min;
398 	u_long		hwcap_val;
399 	u_int		hwcap_id;
400 };
401 
402 #define	MRS_HWCAP(_hwcap_id, _val, _min)			\
403 {								\
404 	.hwcap_id = (_hwcap_id),				\
405 	.hwcap_val = (_val),					\
406 	.min = (_min),						\
407 }
408 
409 #define	MRS_HWCAP_END		{ .hwcap_id = 0 }
410 
411 struct mrs_field {
412 	const char	*name;
413 	const struct mrs_field_value *values;
414 	const struct mrs_field_hwcap *hwcaps;
415 	uint64_t	mask;
416 	bool		sign;
417 	u_int		type;
418 	u_int		width;
419 	u_int		shift;
420 };
421 
422 #define	MRS_FIELD_RES1(_width, _shift)					\
423 	{								\
424 		.sign = false,						\
425 		.type =	MRS_EXACT | MRS_SAFE((1u << (_width)) - 1) |	\
426 		    MRS_USERSPACE,					\
427 		.width = (_width),					\
428 		.shift = (_shift),					\
429 	}
430 
431 #define	MRS_FIELD_HWCAP(_register, _name, _sign, _type, _visibility,	\
432     _values, _hwcap)							\
433 	{								\
434 		.name = #_name,						\
435 		.sign = (_sign),					\
436 		.type = ((_type) | (_visibility)),			\
437 		.width = _register ## _ ## _name ## _WIDTH,		\
438 		.shift = _register ## _ ## _name ## _SHIFT,		\
439 		.mask = _register ## _ ## _name ## _MASK,		\
440 		.values = (_values),					\
441 		.hwcaps = (_hwcap),					\
442 	}
443 
444 #define	MRS_FIELD(_register, _name, _sign, _type, _visibility, _values)	\
445 	MRS_FIELD_HWCAP(_register, _name, _sign, _type, _visibility,	\
446 	    _values, NULL)
447 
448 #define	MRS_FIELD_END	{ .type = MRS_INVALID, }
449 
450 /* CTR_EL0 */
451 static const struct mrs_field_value ctr_dic[] = {
452 	MRS_FIELD_VALUE_NONE_IMPL(CTR, DIC, NONE, IMPL),
453 	MRS_FIELD_VALUE_END,
454 };
455 
456 static const struct mrs_field_value ctr_idc[] = {
457 	MRS_FIELD_VALUE_NONE_IMPL(CTR, IDC, NONE, IMPL),
458 	MRS_FIELD_VALUE_END,
459 };
460 
461 static const struct mrs_field_value ctr_cwg[] = {
462 	MRS_FIELD_VALUE_CACHE(CTR, CWG, "Unknown CWG",
463 	    "byte CWG"),
464 	MRS_FIELD_VALUE_END,
465 };
466 
467 static const struct mrs_field_value ctr_erg[] = {
468 	MRS_FIELD_VALUE_CACHE(CTR, ERG, "Unknown ERG",
469 	    "byte ERG"),
470 	MRS_FIELD_VALUE_END,
471 };
472 
473 static const struct mrs_field_value ctr_dline[] = {
474 	MRS_FIELD_VALUE_CACHE(CTR, DLINE, "4 byte D-cacheline",
475 	    "byte D-cacheline"),
476 	MRS_FIELD_VALUE_END,
477 };
478 
479 static const struct mrs_field_value ctr_l1ip[] = {
480 	MRS_FIELD_VALUE(CTR_L1IP_VIPT, "VIPT I-cache"),
481 	MRS_FIELD_VALUE(CTR_L1IP_PIPT, "PIPT I-cache"),
482 	MRS_FIELD_VALUE_END,
483 };
484 
485 static const struct mrs_field_value ctr_iline[] = {
486 	MRS_FIELD_VALUE_CACHE(CTR, ILINE, "4 byte I-cacheline",
487 	    "byte I-cacheline"),
488 	MRS_FIELD_VALUE_END,
489 };
490 
491 static const struct mrs_field ctr_fields[] = {
492 	/* Bit 31 is RES1 */
493 	MRS_FIELD_RES1(1, 31),
494 	MRS_FIELD(CTR, DIC, false, MRS_LOWER, MRS_USERSPACE, ctr_dic),
495 	MRS_FIELD(CTR, IDC, false, MRS_LOWER, MRS_USERSPACE, ctr_idc),
496 	MRS_FIELD(CTR, CWG, false, MRS_HIGHER_OR_ZERO, MRS_USERSPACE, ctr_cwg),
497 	MRS_FIELD(CTR, ERG, false, MRS_HIGHER_OR_ZERO, MRS_USERSPACE, ctr_erg),
498 	MRS_FIELD(CTR, DLINE, false, MRS_LOWER, MRS_USERSPACE, ctr_dline),
499 	/* If the ICache types are different report the safe option */
500 	MRS_FIELD(CTR, L1IP, false, MRS_EXACT_IF_DIFFERENT |
501 	    MRS_SAFE(CTR_L1IP_VIPT >> CTR_L1IP_SHIFT), MRS_USERSPACE,
502 	    ctr_l1ip),
503 	MRS_FIELD(CTR, ILINE, false, MRS_LOWER, MRS_USERSPACE, ctr_iline),
504 	MRS_FIELD_END,
505 };
506 
507 /* ID_AA64AFR0_EL1 */
508 static const struct mrs_field id_aa64afr0_fields[] = {
509 	MRS_FIELD_END,
510 };
511 
512 
513 /* ID_AA64AFR1_EL1 */
514 static const struct mrs_field id_aa64afr1_fields[] = {
515 	MRS_FIELD_END,
516 };
517 
518 
519 /* ID_AA64DFR0_EL1 */
520 static const struct mrs_field_value id_aa64dfr0_hpmn0[] = {
521 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64DFR0, HPMN0, CONSTR, DEFINED),
522 	MRS_FIELD_VALUE_END,
523 };
524 
525 static const struct mrs_field_value id_aa64dfr0_brbe[] = {
526 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64DFR0, BRBE, NONE, IMPL),
527 	MRS_FIELD_VALUE(ID_AA64DFR0_BRBE_EL3, "BRBE EL3"),
528 	MRS_FIELD_VALUE_END,
529 };
530 
531 static const struct mrs_field_value id_aa64dfr0_mtpmu[] = {
532 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64DFR0, MTPMU, NONE, IMPL),
533 	MRS_FIELD_VALUE(ID_AA64DFR0_MTPMU_NONE_MT_RES0, "MTPMU res0"),
534 	MRS_FIELD_VALUE_END,
535 };
536 
537 static const struct mrs_field_value id_aa64dfr0_tracebuffer[] = {
538 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64DFR0, TraceBuffer, NONE, IMPL),
539 	MRS_FIELD_VALUE_END,
540 };
541 
542 static const struct mrs_field_value id_aa64dfr0_tracefilt[] = {
543 	MRS_FIELD_VALUE(ID_AA64DFR0_TraceFilt_NONE, ""),
544 	MRS_FIELD_VALUE(ID_AA64DFR0_TraceFilt_8_4, "Trace v8.4"),
545 	MRS_FIELD_VALUE_END,
546 };
547 
548 static const struct mrs_field_value id_aa64dfr0_doublelock[] = {
549 	MRS_FIELD_VALUE(ID_AA64DFR0_DoubleLock_IMPL, "DoubleLock"),
550 	MRS_FIELD_VALUE(ID_AA64DFR0_DoubleLock_NONE, ""),
551 	MRS_FIELD_VALUE_END,
552 };
553 
554 static const struct mrs_field_value id_aa64dfr0_pmsver[] = {
555 	MRS_FIELD_VALUE(ID_AA64DFR0_PMSVer_NONE, ""),
556 	MRS_FIELD_VALUE(ID_AA64DFR0_PMSVer_SPE, "SPE"),
557 	MRS_FIELD_VALUE(ID_AA64DFR0_PMSVer_SPE_1_1, "SPEv1p1"),
558 	MRS_FIELD_VALUE(ID_AA64DFR0_PMSVer_SPE_1_2, "SPEv1p2"),
559 	MRS_FIELD_VALUE(ID_AA64DFR0_PMSVer_SPE_1_3, "SPEv1p3"),
560 	MRS_FIELD_VALUE(ID_AA64DFR0_PMSVer_SPE_1_4, "SPEv1p4"),
561 	MRS_FIELD_VALUE_END,
562 };
563 
564 static const struct mrs_field_value id_aa64dfr0_ctx_cmps[] = {
565 	MRS_FIELD_VALUE_COUNT(ID_AA64DFR0, CTX_CMPs, "CTX BKPT"),
566 	MRS_FIELD_VALUE_END,
567 };
568 
569 static const struct mrs_field_value id_aa64dfr0_wrps[] = {
570 	MRS_FIELD_VALUE_COUNT(ID_AA64DFR0, WRPs, "Watchpoint"),
571 	MRS_FIELD_VALUE_END,
572 };
573 
574 static const struct mrs_field_value id_aa64dfr0_pmss[] = {
575 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64DFR0, PMSS, NONE, IMPL),
576 	MRS_FIELD_VALUE_END,
577 };
578 
579 static const struct mrs_field_value id_aa64dfr0_brps[] = {
580 	MRS_FIELD_VALUE_COUNT(ID_AA64DFR0, BRPs, "Breakpoint"),
581 	MRS_FIELD_VALUE_END,
582 };
583 
584 static const struct mrs_field_value id_aa64dfr0_pmuver[] = {
585 	MRS_FIELD_VALUE(ID_AA64DFR0_PMUVer_NONE, ""),
586 	MRS_FIELD_VALUE(ID_AA64DFR0_PMUVer_3, "PMUv3"),
587 	MRS_FIELD_VALUE(ID_AA64DFR0_PMUVer_3_1, "PMUv3p1"),
588 	MRS_FIELD_VALUE(ID_AA64DFR0_PMUVer_3_4, "PMUv3p4"),
589 	MRS_FIELD_VALUE(ID_AA64DFR0_PMUVer_3_5, "PMUv3p5"),
590 	MRS_FIELD_VALUE(ID_AA64DFR0_PMUVer_3_7, "PMUv3p7"),
591 	MRS_FIELD_VALUE(ID_AA64DFR0_PMUVer_3_8, "PMUv3p8"),
592 	MRS_FIELD_VALUE(ID_AA64DFR0_PMUVer_3_9, "PMUv3p9"),
593 	MRS_FIELD_VALUE(ID_AA64DFR0_PMUVer_IMPL, "IMPL PMU"),
594 	MRS_FIELD_VALUE_END,
595 };
596 
597 static const struct mrs_field_value id_aa64dfr0_tracever[] = {
598 	MRS_FIELD_VALUE(ID_AA64DFR0_TraceVer_NONE, ""),
599 	MRS_FIELD_VALUE(ID_AA64DFR0_TraceVer_IMPL, "Trace"),
600 	MRS_FIELD_VALUE_END,
601 };
602 
603 static const struct mrs_field_value id_aa64dfr0_debugver[] = {
604 	MRS_FIELD_VALUE(ID_AA64DFR0_DebugVer_8, "Debugv8"),
605 	MRS_FIELD_VALUE(ID_AA64DFR0_DebugVer_8_VHE, "Debugv8_VHE"),
606 	MRS_FIELD_VALUE(ID_AA64DFR0_DebugVer_8_2, "Debugv8p2"),
607 	MRS_FIELD_VALUE(ID_AA64DFR0_DebugVer_8_4, "Debugv8p4"),
608 	MRS_FIELD_VALUE(ID_AA64DFR0_DebugVer_8_8, "Debugv8p8"),
609 	MRS_FIELD_VALUE(ID_AA64DFR0_DebugVer_8_9, "Debugv8p9"),
610 	MRS_FIELD_VALUE_END,
611 };
612 
613 static const struct mrs_field id_aa64dfr0_fields[] = {
614 	MRS_FIELD(ID_AA64DFR0, HPMN0, false, MRS_LOWER, 0, id_aa64dfr0_hpmn0),
615 	MRS_FIELD(ID_AA64DFR0, BRBE, false, MRS_LOWER, 0, id_aa64dfr0_brbe),
616 	MRS_FIELD(ID_AA64DFR0, MTPMU, true, MRS_LOWER, 0, id_aa64dfr0_mtpmu),
617 	MRS_FIELD(ID_AA64DFR0, TraceBuffer, false, MRS_LOWER, 0,
618 	    id_aa64dfr0_tracebuffer),
619 	MRS_FIELD(ID_AA64DFR0, TraceFilt, false, MRS_LOWER, 0,
620 	    id_aa64dfr0_tracefilt),
621 	MRS_FIELD(ID_AA64DFR0, DoubleLock, false, MRS_LOWER, 0,
622 	    id_aa64dfr0_doublelock),
623 	MRS_FIELD(ID_AA64DFR0, PMSVer, false, MRS_LOWER, 0, id_aa64dfr0_pmsver),
624 	MRS_FIELD(ID_AA64DFR0, CTX_CMPs, false, MRS_LOWER, 0,
625 	    id_aa64dfr0_ctx_cmps),
626 	MRS_FIELD(ID_AA64DFR0, WRPs, false, MRS_LOWER, MRS_USERSPACE,
627 	    id_aa64dfr0_wrps),
628 	MRS_FIELD(ID_AA64DFR0, PMSS, false, MRS_LOWER, 0, id_aa64dfr0_pmss),
629 	MRS_FIELD(ID_AA64DFR0, BRPs, false, MRS_LOWER, MRS_USERSPACE,
630 	    id_aa64dfr0_brps),
631 	MRS_FIELD(ID_AA64DFR0, PMUVer, false, MRS_LOWER, 0, id_aa64dfr0_pmuver),
632 	MRS_FIELD(ID_AA64DFR0, TraceVer, false, MRS_LOWER, 0,
633 	    id_aa64dfr0_tracever),
634 	MRS_FIELD(ID_AA64DFR0, DebugVer, false, MRS_LOWER | MRS_SAFE(0x6), 0,
635 	    id_aa64dfr0_debugver),
636 	MRS_FIELD_END,
637 };
638 
639 
640 /* ID_AA64DFR1_EL1 */
641 static const struct mrs_field_value id_aa64dfr1_dpfzs[] = {
642 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64DFR1, DPFZS, NONE, IMPL),
643 	MRS_FIELD_VALUE_END,
644 };
645 
646 static const struct mrs_field_value id_aa64dfr1_pmicntr[] = {
647 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64DFR1, PMICNTR, NONE, IMPL),
648 	MRS_FIELD_VALUE_END,
649 };
650 
651 static const struct mrs_field_value id_aa64dfr1_spmu[] = {
652 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64DFR1, SPMU, NONE, IMPL),
653 	MRS_FIELD_VALUE_END,
654 };
655 
656 static const struct mrs_field id_aa64dfr1_fields[] = {
657 	MRS_FIELD(ID_AA64DFR1, DPFZS, false, MRS_LOWER, 0, id_aa64dfr1_dpfzs),
658 	MRS_FIELD(ID_AA64DFR1, PMICNTR, false, MRS_LOWER, 0, id_aa64dfr1_pmicntr),
659 	MRS_FIELD(ID_AA64DFR1, SPMU, false, MRS_LOWER, 0, id_aa64dfr1_spmu),
660 	MRS_FIELD_END,
661 };
662 
663 
664 /* ID_AA64ISAR0_EL1 */
665 static const struct mrs_field_value id_aa64isar0_rndr[] = {
666 	MRS_FIELD_VALUE(ID_AA64ISAR0_RNDR_NONE, ""),
667 	MRS_FIELD_VALUE(ID_AA64ISAR0_RNDR_IMPL, "RNG"),
668 	MRS_FIELD_VALUE_END,
669 };
670 
671 static const struct mrs_field_hwcap id_aa64isar0_rndr_caps[] = {
672 	MRS_HWCAP(2, HWCAP2_RNG, ID_AA64ISAR0_RNDR_IMPL),
673 	MRS_HWCAP_END
674 };
675 
676 static const struct mrs_field_value id_aa64isar0_tlb[] = {
677 	MRS_FIELD_VALUE(ID_AA64ISAR0_TLB_NONE, ""),
678 	MRS_FIELD_VALUE(ID_AA64ISAR0_TLB_TLBIOS, "TLBI-OS"),
679 	MRS_FIELD_VALUE(ID_AA64ISAR0_TLB_TLBIOSR, "TLBI-OSR"),
680 	MRS_FIELD_VALUE_END,
681 };
682 
683 static const struct mrs_field_value id_aa64isar0_ts[] = {
684 	MRS_FIELD_VALUE(ID_AA64ISAR0_TS_NONE, ""),
685 	MRS_FIELD_VALUE(ID_AA64ISAR0_TS_CondM_8_4, "CondM-8.4"),
686 	MRS_FIELD_VALUE(ID_AA64ISAR0_TS_CondM_8_5, "CondM-8.5"),
687 	MRS_FIELD_VALUE_END,
688 };
689 
690 static const struct mrs_field_hwcap id_aa64isar0_ts_caps[] = {
691 	MRS_HWCAP(1, HWCAP_FLAGM, ID_AA64ISAR0_TS_CondM_8_4),
692 	MRS_HWCAP(2, HWCAP2_FLAGM2, ID_AA64ISAR0_TS_CondM_8_5),
693 	MRS_HWCAP_END
694 };
695 
696 static const struct mrs_field_value id_aa64isar0_fhm[] = {
697 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR0, FHM, NONE, IMPL),
698 	MRS_FIELD_VALUE_END,
699 };
700 
701 static const struct mrs_field_hwcap id_aa64isar0_fhm_caps[] = {
702 	MRS_HWCAP(1, HWCAP_ASIMDFHM, ID_AA64ISAR0_FHM_IMPL),
703 	MRS_HWCAP_END
704 };
705 
706 static const struct mrs_field_value id_aa64isar0_dp[] = {
707 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR0, DP, NONE, IMPL),
708 	MRS_FIELD_VALUE_END,
709 };
710 
711 static const struct mrs_field_hwcap id_aa64isar0_dp_caps[] = {
712 	MRS_HWCAP(1, HWCAP_ASIMDDP, ID_AA64ISAR0_DP_IMPL),
713 	MRS_HWCAP_END
714 };
715 
716 static const struct mrs_field_value id_aa64isar0_sm4[] = {
717 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR0, SM4, NONE, IMPL),
718 	MRS_FIELD_VALUE_END,
719 };
720 
721 static const struct mrs_field_hwcap id_aa64isar0_sm4_caps[] = {
722 	MRS_HWCAP(1, HWCAP_SM4, ID_AA64ISAR0_SM4_IMPL),
723 	MRS_HWCAP_END
724 };
725 
726 static const struct mrs_field_value id_aa64isar0_sm3[] = {
727 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR0, SM3, NONE, IMPL),
728 	MRS_FIELD_VALUE_END,
729 };
730 
731 static const struct mrs_field_hwcap id_aa64isar0_sm3_caps[] = {
732 	MRS_HWCAP(1, HWCAP_SM3, ID_AA64ISAR0_SM3_IMPL),
733 	MRS_HWCAP_END
734 };
735 
736 static const struct mrs_field_value id_aa64isar0_sha3[] = {
737 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR0, SHA3, NONE, IMPL),
738 	MRS_FIELD_VALUE_END,
739 };
740 
741 static const struct mrs_field_hwcap id_aa64isar0_sha3_caps[] = {
742 	MRS_HWCAP(1, HWCAP_SHA3, ID_AA64ISAR0_SHA3_IMPL),
743 	MRS_HWCAP_END
744 };
745 
746 static const struct mrs_field_value id_aa64isar0_rdm[] = {
747 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR0, RDM, NONE, IMPL),
748 	MRS_FIELD_VALUE_END,
749 };
750 
751 static const struct mrs_field_hwcap id_aa64isar0_rdm_caps[] = {
752 	MRS_HWCAP(1, HWCAP_ASIMDRDM, ID_AA64ISAR0_RDM_IMPL),
753 	MRS_HWCAP_END
754 };
755 
756 static const struct mrs_field_value id_aa64isar0_tme[] = {
757 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR0, TME, NONE, IMPL),
758 	MRS_FIELD_VALUE_END,
759 };
760 
761 static const struct mrs_field_value id_aa64isar0_atomic[] = {
762 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR0, Atomic, NONE, IMPL),
763 	MRS_FIELD_VALUE_END,
764 };
765 
766 static const struct mrs_field_hwcap id_aa64isar0_atomic_caps[] = {
767 	MRS_HWCAP(1, HWCAP_ATOMICS, ID_AA64ISAR0_Atomic_IMPL),
768 	MRS_HWCAP_END
769 };
770 
771 static const struct mrs_field_value id_aa64isar0_crc32[] = {
772 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR0, CRC32, NONE, BASE),
773 	MRS_FIELD_VALUE_END,
774 };
775 
776 static const struct mrs_field_hwcap id_aa64isar0_crc32_caps[] = {
777 	MRS_HWCAP(1, HWCAP_CRC32, ID_AA64ISAR0_CRC32_BASE),
778 	MRS_HWCAP_END
779 };
780 
781 static const struct mrs_field_value id_aa64isar0_sha2[] = {
782 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR0, SHA2, NONE, BASE),
783 	MRS_FIELD_VALUE(ID_AA64ISAR0_SHA2_512, "SHA2+SHA512"),
784 	MRS_FIELD_VALUE_END,
785 };
786 
787 static const struct mrs_field_hwcap id_aa64isar0_sha2_caps[] = {
788 	MRS_HWCAP(1, HWCAP_SHA2, ID_AA64ISAR0_SHA2_BASE),
789 	MRS_HWCAP(1, HWCAP_SHA512, ID_AA64ISAR0_SHA2_512),
790 	MRS_HWCAP_END
791 };
792 
793 static const struct mrs_field_value id_aa64isar0_sha1[] = {
794 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR0, SHA1, NONE, BASE),
795 	MRS_FIELD_VALUE_END,
796 };
797 
798 static const struct mrs_field_hwcap id_aa64isar0_sha1_caps[] = {
799 	MRS_HWCAP(1, HWCAP_SHA1, ID_AA64ISAR0_SHA1_BASE),
800 	MRS_HWCAP_END
801 };
802 
803 static const struct mrs_field_value id_aa64isar0_aes[] = {
804 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR0, AES, NONE, BASE),
805 	MRS_FIELD_VALUE(ID_AA64ISAR0_AES_PMULL, "AES+PMULL"),
806 	MRS_FIELD_VALUE_END,
807 };
808 
809 static const struct mrs_field_hwcap id_aa64isar0_aes_caps[] = {
810 	MRS_HWCAP(1, HWCAP_AES, ID_AA64ISAR0_AES_BASE),
811 	MRS_HWCAP(1, HWCAP_PMULL, ID_AA64ISAR0_AES_PMULL),
812 	MRS_HWCAP_END
813 };
814 
815 static const struct mrs_field id_aa64isar0_fields[] = {
816 	MRS_FIELD_HWCAP(ID_AA64ISAR0, RNDR, false, MRS_LOWER, MRS_USERSPACE,
817 	    id_aa64isar0_rndr, id_aa64isar0_rndr_caps),
818 	MRS_FIELD(ID_AA64ISAR0, TLB, false, MRS_LOWER, 0, id_aa64isar0_tlb),
819 	MRS_FIELD_HWCAP(ID_AA64ISAR0, TS, false, MRS_LOWER, MRS_USERSPACE,
820 	    id_aa64isar0_ts, id_aa64isar0_ts_caps),
821 	MRS_FIELD_HWCAP(ID_AA64ISAR0, FHM, false, MRS_LOWER, MRS_USERSPACE,
822 	    id_aa64isar0_fhm, id_aa64isar0_fhm_caps),
823 	MRS_FIELD_HWCAP(ID_AA64ISAR0, DP, false, MRS_LOWER, MRS_USERSPACE,
824 	    id_aa64isar0_dp, id_aa64isar0_dp_caps),
825 	MRS_FIELD_HWCAP(ID_AA64ISAR0, SM4, false, MRS_LOWER, MRS_USERSPACE,
826 	    id_aa64isar0_sm4, id_aa64isar0_sm4_caps),
827 	MRS_FIELD_HWCAP(ID_AA64ISAR0, SM3, false, MRS_LOWER, MRS_USERSPACE,
828 	    id_aa64isar0_sm3, id_aa64isar0_sm3_caps),
829 	MRS_FIELD_HWCAP(ID_AA64ISAR0, SHA3, false, MRS_LOWER, MRS_USERSPACE,
830 	    id_aa64isar0_sha3, id_aa64isar0_sha3_caps),
831 	MRS_FIELD_HWCAP(ID_AA64ISAR0, RDM, false, MRS_LOWER, MRS_USERSPACE,
832 	    id_aa64isar0_rdm, id_aa64isar0_rdm_caps),
833 	MRS_FIELD(ID_AA64ISAR0, TME, false, MRS_LOWER, 0, id_aa64isar0_tme),
834 	MRS_FIELD_HWCAP(ID_AA64ISAR0, Atomic, false, MRS_LOWER, MRS_USERSPACE,
835 	    id_aa64isar0_atomic, id_aa64isar0_atomic_caps),
836 	MRS_FIELD_HWCAP(ID_AA64ISAR0, CRC32, false, MRS_LOWER, MRS_USERSPACE,
837 	    id_aa64isar0_crc32, id_aa64isar0_crc32_caps),
838 	MRS_FIELD_HWCAP(ID_AA64ISAR0, SHA2, false, MRS_LOWER, MRS_USERSPACE,
839 	    id_aa64isar0_sha2, id_aa64isar0_sha2_caps),
840 	MRS_FIELD_HWCAP(ID_AA64ISAR0, SHA1, false, MRS_LOWER, MRS_USERSPACE,
841 	    id_aa64isar0_sha1, id_aa64isar0_sha1_caps),
842 	MRS_FIELD_HWCAP(ID_AA64ISAR0, AES, false, MRS_LOWER, MRS_USERSPACE,
843 	    id_aa64isar0_aes, id_aa64isar0_aes_caps),
844 	MRS_FIELD_END,
845 };
846 
847 
848 /* ID_AA64ISAR1_EL1 */
849 static const struct mrs_field_value id_aa64isar1_ls64[] = {
850 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR1, LS64, NONE, IMPL),
851 	MRS_FIELD_VALUE(ID_AA64ISAR1_LS64_V, "LS64v"),
852 	MRS_FIELD_VALUE(ID_AA64ISAR1_LS64_ACCDATA, "LS64+ACCDATA"),
853 	MRS_FIELD_VALUE_END,
854 };
855 
856 static const struct mrs_field_value id_aa64isar1_xs[] = {
857 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR1, XS, NONE, IMPL),
858 	MRS_FIELD_VALUE_END,
859 };
860 
861 static const struct mrs_field_value id_aa64isar1_i8mm[] = {
862 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR1, I8MM, NONE, IMPL),
863 	MRS_FIELD_VALUE_END,
864 };
865 
866 static const struct mrs_field_hwcap id_aa64isar1_i8mm_caps[] = {
867 	MRS_HWCAP(2, HWCAP2_I8MM, ID_AA64ISAR1_I8MM_IMPL),
868 	MRS_HWCAP_END
869 };
870 
871 static const struct mrs_field_value id_aa64isar1_dgh[] = {
872 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR1, DGH, NONE, IMPL),
873 	MRS_FIELD_VALUE_END,
874 };
875 
876 static const struct mrs_field_hwcap id_aa64isar1_dgh_caps[] = {
877 	MRS_HWCAP(2, HWCAP2_DGH, ID_AA64ISAR1_DGH_IMPL),
878 	MRS_HWCAP_END
879 };
880 
881 static const struct mrs_field_value id_aa64isar1_bf16[] = {
882 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR1, BF16, NONE, IMPL),
883 	MRS_FIELD_VALUE(ID_AA64ISAR1_BF16_EBF, "EBF16"),
884 	MRS_FIELD_VALUE_END,
885 };
886 
887 static const struct mrs_field_hwcap id_aa64isar1_bf16_caps[] = {
888 	MRS_HWCAP(2, HWCAP2_BF16, ID_AA64ISAR1_BF16_IMPL),
889 	MRS_HWCAP_END
890 };
891 
892 static const struct mrs_field_value id_aa64isar1_specres[] = {
893 	MRS_FIELD_VALUE(ID_AA64ISAR1_SPECRES_NONE, ""),
894 	MRS_FIELD_VALUE(ID_AA64ISAR1_SPECRES_8_5, "PredInv v8.5"),
895 	MRS_FIELD_VALUE(ID_AA64ISAR1_SPECRES_8_9, "PredInv v8.9"),
896 	MRS_FIELD_VALUE_END,
897 };
898 
899 static const struct mrs_field_value id_aa64isar1_sb[] = {
900 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR1, SB, NONE, IMPL),
901 	MRS_FIELD_VALUE_END,
902 };
903 
904 static const struct mrs_field_hwcap id_aa64isar1_sb_caps[] = {
905 	MRS_HWCAP(1, HWCAP_SB, ID_AA64ISAR1_SB_IMPL),
906 	MRS_HWCAP_END
907 };
908 
909 static const struct mrs_field_value id_aa64isar1_frintts[] = {
910 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR1, FRINTTS, NONE, IMPL),
911 	MRS_FIELD_VALUE_END,
912 };
913 
914 static const struct mrs_field_hwcap id_aa64isar1_frintts_caps[] = {
915 	MRS_HWCAP(2, HWCAP2_FRINT, ID_AA64ISAR1_FRINTTS_IMPL),
916 	MRS_HWCAP_END
917 };
918 
919 static const struct mrs_field_value id_aa64isar1_gpi[] = {
920 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR1, GPI, NONE, IMPL),
921 	MRS_FIELD_VALUE_END,
922 };
923 
924 static const struct mrs_field_hwcap id_aa64isar1_gpi_caps[] = {
925 	MRS_HWCAP(1, HWCAP_PACG, ID_AA64ISAR1_GPI_IMPL),
926 	MRS_HWCAP_END
927 };
928 
929 static const struct mrs_field_value id_aa64isar1_gpa[] = {
930 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR1, GPA, NONE, IMPL),
931 	MRS_FIELD_VALUE_END,
932 };
933 
934 static const struct mrs_field_hwcap id_aa64isar1_gpa_caps[] = {
935 	MRS_HWCAP(1, HWCAP_PACG, ID_AA64ISAR1_GPA_IMPL),
936 	MRS_HWCAP_END
937 };
938 
939 static const struct mrs_field_value id_aa64isar1_lrcpc[] = {
940 	MRS_FIELD_VALUE(ID_AA64ISAR1_LRCPC_NONE, ""),
941 	MRS_FIELD_VALUE(ID_AA64ISAR1_LRCPC_RCPC_8_3, "RCPC-8.3"),
942 	MRS_FIELD_VALUE(ID_AA64ISAR1_LRCPC_RCPC_8_4, "RCPC-8.4"),
943 	MRS_FIELD_VALUE_END,
944 };
945 
946 static const struct mrs_field_hwcap id_aa64isar1_lrcpc_caps[] = {
947 	MRS_HWCAP(1, HWCAP_LRCPC, ID_AA64ISAR1_LRCPC_RCPC_8_3),
948 	MRS_HWCAP(1, HWCAP_ILRCPC, ID_AA64ISAR1_LRCPC_RCPC_8_4),
949 	MRS_HWCAP_END
950 };
951 
952 static const struct mrs_field_value id_aa64isar1_fcma[] = {
953 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR1, FCMA, NONE, IMPL),
954 	MRS_FIELD_VALUE_END,
955 };
956 
957 static const struct mrs_field_hwcap id_aa64isar1_fcma_caps[] = {
958 	MRS_HWCAP(1, HWCAP_FCMA, ID_AA64ISAR1_FCMA_IMPL),
959 	MRS_HWCAP_END
960 };
961 
962 static const struct mrs_field_value id_aa64isar1_jscvt[] = {
963 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR1, JSCVT, NONE, IMPL),
964 	MRS_FIELD_VALUE_END,
965 };
966 
967 static const struct mrs_field_hwcap id_aa64isar1_jscvt_caps[] = {
968 	MRS_HWCAP(1, HWCAP_JSCVT, ID_AA64ISAR1_JSCVT_IMPL),
969 	MRS_HWCAP_END
970 };
971 
972 static const struct mrs_field_value id_aa64isar1_api[] = {
973 	MRS_FIELD_VALUE(ID_AA64ISAR1_API_NONE, ""),
974 	MRS_FIELD_VALUE(ID_AA64ISAR1_API_PAC, "API PAC"),
975 	MRS_FIELD_VALUE(ID_AA64ISAR1_API_EPAC, "API EPAC"),
976 	MRS_FIELD_VALUE(ID_AA64ISAR1_API_EPAC2, "Impl PAuth+EPAC2"),
977 	MRS_FIELD_VALUE(ID_AA64ISAR1_API_FPAC, "Impl PAuth+FPAC"),
978 	MRS_FIELD_VALUE(ID_AA64ISAR1_API_FPAC_COMBINED,
979 	    "Impl PAuth+FPAC+Combined"),
980 	MRS_FIELD_VALUE_END,
981 };
982 
983 static const struct mrs_field_hwcap id_aa64isar1_api_caps[] = {
984 	MRS_HWCAP(1, HWCAP_PACA, ID_AA64ISAR1_API_PAC),
985 	MRS_HWCAP_END
986 };
987 
988 static const struct mrs_field_value id_aa64isar1_apa[] = {
989 	MRS_FIELD_VALUE(ID_AA64ISAR1_APA_NONE, ""),
990 	MRS_FIELD_VALUE(ID_AA64ISAR1_APA_PAC, "APA PAC"),
991 	MRS_FIELD_VALUE(ID_AA64ISAR1_APA_EPAC, "APA EPAC"),
992 	MRS_FIELD_VALUE(ID_AA64ISAR1_APA_EPAC2, "APA EPAC2"),
993 	MRS_FIELD_VALUE(ID_AA64ISAR1_APA_FPAC, "APA FPAC"),
994 	MRS_FIELD_VALUE(ID_AA64ISAR1_APA_FPAC_COMBINED,
995 	    "APA FPAC+Combined"),
996 	MRS_FIELD_VALUE_END,
997 };
998 
999 static const struct mrs_field_hwcap id_aa64isar1_apa_caps[] = {
1000 	MRS_HWCAP(1, HWCAP_PACA, ID_AA64ISAR1_APA_PAC),
1001 	MRS_HWCAP_END
1002 };
1003 
1004 static const struct mrs_field_value id_aa64isar1_dpb[] = {
1005 	MRS_FIELD_VALUE(ID_AA64ISAR1_DPB_NONE, ""),
1006 	MRS_FIELD_VALUE(ID_AA64ISAR1_DPB_DCCVAP, "DCPoP"),
1007 	MRS_FIELD_VALUE(ID_AA64ISAR1_DPB_DCCVADP, "DCCVADP"),
1008 	MRS_FIELD_VALUE_END,
1009 };
1010 
1011 static const struct mrs_field_hwcap id_aa64isar1_dpb_caps[] = {
1012 	MRS_HWCAP(1, HWCAP_DCPOP, ID_AA64ISAR1_DPB_DCCVAP),
1013 	MRS_HWCAP(2, HWCAP2_DCPODP, ID_AA64ISAR1_DPB_DCCVADP),
1014 	MRS_HWCAP_END
1015 };
1016 
1017 static const struct mrs_field id_aa64isar1_fields[] = {
1018 	MRS_FIELD(ID_AA64ISAR1, LS64, false, MRS_LOWER, 0, id_aa64isar1_ls64),
1019 	MRS_FIELD(ID_AA64ISAR1, XS, false, MRS_LOWER, 0, id_aa64isar1_xs),
1020 	MRS_FIELD_HWCAP(ID_AA64ISAR1, I8MM, false, MRS_LOWER, MRS_USERSPACE,
1021 	    id_aa64isar1_i8mm, id_aa64isar1_i8mm_caps),
1022 	MRS_FIELD_HWCAP(ID_AA64ISAR1, DGH, false, MRS_LOWER, MRS_USERSPACE,
1023 	    id_aa64isar1_dgh, id_aa64isar1_dgh_caps),
1024 	MRS_FIELD_HWCAP(ID_AA64ISAR1, BF16, false, MRS_LOWER, MRS_USERSPACE,
1025 	    id_aa64isar1_bf16, id_aa64isar1_bf16_caps),
1026 	MRS_FIELD(ID_AA64ISAR1, SPECRES, false, MRS_LOWER, 0,
1027 	    id_aa64isar1_specres),
1028 	MRS_FIELD_HWCAP(ID_AA64ISAR1, SB, false, MRS_LOWER, MRS_USERSPACE,
1029 	    id_aa64isar1_sb, id_aa64isar1_sb_caps),
1030 	MRS_FIELD_HWCAP(ID_AA64ISAR1, FRINTTS, false, MRS_LOWER, MRS_USERSPACE,
1031 	    id_aa64isar1_frintts, id_aa64isar1_frintts_caps),
1032 	MRS_FIELD_HWCAP(ID_AA64ISAR1, GPI, false, MRS_LOWER, MRS_USERSPACE,
1033 	    id_aa64isar1_gpi, id_aa64isar1_gpi_caps),
1034 	MRS_FIELD_HWCAP(ID_AA64ISAR1, GPA, false, MRS_LOWER, MRS_USERSPACE,
1035 	    id_aa64isar1_gpa, id_aa64isar1_gpa_caps),
1036 	MRS_FIELD_HWCAP(ID_AA64ISAR1, LRCPC, false, MRS_LOWER, MRS_USERSPACE,
1037 	    id_aa64isar1_lrcpc, id_aa64isar1_lrcpc_caps),
1038 	MRS_FIELD_HWCAP(ID_AA64ISAR1, FCMA, false, MRS_LOWER, MRS_USERSPACE,
1039 	    id_aa64isar1_fcma, id_aa64isar1_fcma_caps),
1040 	MRS_FIELD_HWCAP(ID_AA64ISAR1, JSCVT, false, MRS_LOWER, MRS_USERSPACE,
1041 	    id_aa64isar1_jscvt, id_aa64isar1_jscvt_caps),
1042 	MRS_FIELD_HWCAP(ID_AA64ISAR1, API, false, MRS_LOWER, MRS_USERSPACE,
1043 	    id_aa64isar1_api, id_aa64isar1_api_caps),
1044 	MRS_FIELD_HWCAP(ID_AA64ISAR1, APA, false, MRS_LOWER, MRS_USERSPACE,
1045 	    id_aa64isar1_apa, id_aa64isar1_apa_caps),
1046 	MRS_FIELD_HWCAP(ID_AA64ISAR1, DPB, false, MRS_LOWER, MRS_USERSPACE,
1047 	    id_aa64isar1_dpb, id_aa64isar1_dpb_caps),
1048 	MRS_FIELD_END,
1049 };
1050 
1051 
1052 /* ID_AA64ISAR2_EL1 */
1053 static const struct mrs_field_value id_aa64isar2_ats1a[] = {
1054 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR2, ATS1A, NONE, IMPL),
1055 	MRS_FIELD_VALUE_END,
1056 };
1057 
1058 static const struct mrs_field_value id_aa64isar2_cssc[] = {
1059 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR2, CSSC, NONE, IMPL),
1060 	MRS_FIELD_VALUE_END,
1061 };
1062 
1063 static const struct mrs_field_value id_aa64isar2_rprfm[] = {
1064 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR2, RPRFM, NONE, IMPL),
1065 	MRS_FIELD_VALUE_END,
1066 };
1067 
1068 static const struct mrs_field_value id_aa64isar2_prfmslc[] = {
1069 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR2, PRFMSLC, NONE, IMPL),
1070 	MRS_FIELD_VALUE_END,
1071 };
1072 
1073 static const struct mrs_field_value id_aa64isar2_clrbhb[] = {
1074 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR2, CLRBHB, NONE, IMPL),
1075 	MRS_FIELD_VALUE_END,
1076 };
1077 
1078 static const struct mrs_field_value id_aa64isar2_pac_frac[] = {
1079 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR2, PAC_frac, NONE, IMPL),
1080 	MRS_FIELD_VALUE_END,
1081 };
1082 
1083 static const struct mrs_field_value id_aa64isar2_bc[] = {
1084 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR2, BC, NONE, IMPL),
1085 	MRS_FIELD_VALUE_END,
1086 };
1087 
1088 static const struct mrs_field_value id_aa64isar2_mops[] = {
1089 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR2, MOPS, NONE, IMPL),
1090 	MRS_FIELD_VALUE_END,
1091 };
1092 
1093 static const struct mrs_field_value id_aa64isar2_apa3[] = {
1094 	MRS_FIELD_VALUE(ID_AA64ISAR2_APA3_NONE, ""),
1095 	MRS_FIELD_VALUE(ID_AA64ISAR2_APA3_PAC, "APA3 PAC"),
1096 	MRS_FIELD_VALUE(ID_AA64ISAR2_APA3_EPAC, "APA3 EPAC"),
1097 	MRS_FIELD_VALUE(ID_AA64ISAR2_APA3_EPAC2, "APA3 EPAC2"),
1098 	MRS_FIELD_VALUE(ID_AA64ISAR2_APA3_FPAC, "APA3 FPAC"),
1099 	MRS_FIELD_VALUE(ID_AA64ISAR2_APA3_FPAC_COMBINED,
1100 	    "APA3 FPAC+Combined"),
1101 	MRS_FIELD_VALUE_END,
1102 };
1103 
1104 static const struct mrs_field_hwcap id_aa64isar2_apa3_caps[] = {
1105 	MRS_HWCAP(1, HWCAP_PACA, ID_AA64ISAR2_APA3_PAC),
1106 	MRS_HWCAP_END
1107 };
1108 
1109 static const struct mrs_field_value id_aa64isar2_gpa3[] = {
1110 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR2, GPA3, NONE, IMPL),
1111 	MRS_FIELD_VALUE_END,
1112 };
1113 
1114 static const struct mrs_field_hwcap id_aa64isar2_gpa3_caps[] = {
1115 	MRS_HWCAP(1, HWCAP_PACG, ID_AA64ISAR2_GPA3_IMPL),
1116 	MRS_HWCAP_END
1117 };
1118 
1119 static const struct mrs_field_value id_aa64isar2_rpres[] = {
1120 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR2, RPRES, NONE, IMPL),
1121 	MRS_FIELD_VALUE_END,
1122 };
1123 
1124 static const struct mrs_field_hwcap id_aa64isar2_rpres_caps[] = {
1125 	MRS_HWCAP(2, HWCAP2_RPRES, ID_AA64ISAR2_RPRES_IMPL),
1126 	MRS_HWCAP_END
1127 };
1128 
1129 static const struct mrs_field_value id_aa64isar2_wfxt[] = {
1130 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ISAR2, WFxT, NONE, IMPL),
1131 	MRS_FIELD_VALUE_END,
1132 };
1133 
1134 static const struct mrs_field_hwcap id_aa64isar2_wfxt_caps[] = {
1135 	MRS_HWCAP(2, HWCAP2_WFXT, ID_AA64ISAR2_WFxT_IMPL),
1136 	MRS_HWCAP_END
1137 };
1138 
1139 static const struct mrs_field id_aa64isar2_fields[] = {
1140 	MRS_FIELD(ID_AA64ISAR2, ATS1A, false, MRS_LOWER, 0, id_aa64isar2_ats1a),
1141 	MRS_FIELD(ID_AA64ISAR2, CSSC, false, MRS_LOWER, 0, id_aa64isar2_cssc),
1142 	MRS_FIELD(ID_AA64ISAR2, RPRFM, false, MRS_LOWER, 0, id_aa64isar2_rprfm),
1143 	MRS_FIELD(ID_AA64ISAR2, PRFMSLC, false, MRS_LOWER, 0, id_aa64isar2_prfmslc),
1144 	MRS_FIELD(ID_AA64ISAR2, CLRBHB, false, MRS_LOWER, 0, id_aa64isar2_clrbhb),
1145 	MRS_FIELD(ID_AA64ISAR2, PAC_frac, false, MRS_LOWER, 0,
1146 	    id_aa64isar2_pac_frac),
1147 	MRS_FIELD(ID_AA64ISAR2, BC, false, MRS_LOWER, 0, id_aa64isar2_bc),
1148 	MRS_FIELD(ID_AA64ISAR2, MOPS, false, MRS_LOWER, 0, id_aa64isar2_mops),
1149 	MRS_FIELD_HWCAP(ID_AA64ISAR2, APA3, false, MRS_LOWER, MRS_USERSPACE,
1150 	    id_aa64isar2_apa3, id_aa64isar2_apa3_caps),
1151 	MRS_FIELD_HWCAP(ID_AA64ISAR2, GPA3, false, MRS_LOWER, MRS_USERSPACE,
1152 	    id_aa64isar2_gpa3, id_aa64isar2_gpa3_caps),
1153 	MRS_FIELD_HWCAP(ID_AA64ISAR2, RPRES, false, MRS_LOWER, MRS_USERSPACE,
1154 	    id_aa64isar2_rpres, id_aa64isar2_rpres_caps),
1155 	MRS_FIELD_HWCAP(ID_AA64ISAR2, WFxT, false, MRS_LOWER, 0,
1156 		id_aa64isar2_wfxt, id_aa64isar2_wfxt_caps),
1157 	MRS_FIELD_END,
1158 };
1159 
1160 
1161 /* ID_AA64MMFR0_EL1 */
1162 static const struct mrs_field_value id_aa64mmfr0_ecv[] = {
1163 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR0, ECV, NONE, IMPL),
1164 	MRS_FIELD_VALUE(ID_AA64MMFR0_ECV_CNTHCTL, "ECV+CNTHCTL"),
1165 	MRS_FIELD_VALUE_END,
1166 };
1167 
1168 static const struct mrs_field_value id_aa64mmfr0_fgt[] = {
1169 	MRS_FIELD_VALUE(ID_AA64MMFR0_FGT_NONE, ""),
1170 	MRS_FIELD_VALUE(ID_AA64MMFR0_FGT_8_6, "FGT v8.6"),
1171 	MRS_FIELD_VALUE(ID_AA64MMFR0_FGT_8_9, "FGT v8.9"),
1172 	MRS_FIELD_VALUE_END,
1173 };
1174 
1175 static const struct mrs_field_value id_aa64mmfr0_exs[] = {
1176 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR0, ExS, ALL, IMPL),
1177 	MRS_FIELD_VALUE_END,
1178 };
1179 
1180 static const struct mrs_field_value id_aa64mmfr0_tgran4_2[] = {
1181 	MRS_FIELD_VALUE(ID_AA64MMFR0_TGran4_2_TGran4, ""),
1182 	MRS_FIELD_VALUE(ID_AA64MMFR0_TGran4_2_NONE, "No S2 TGran4"),
1183 	MRS_FIELD_VALUE(ID_AA64MMFR0_TGran4_2_IMPL, "S2 TGran4"),
1184 	MRS_FIELD_VALUE(ID_AA64MMFR0_TGran4_2_LPA2, "S2 TGran4+LPA2"),
1185 	MRS_FIELD_VALUE_END,
1186 };
1187 
1188 static const struct mrs_field_value id_aa64mmfr0_tgran64_2[] = {
1189 	MRS_FIELD_VALUE(ID_AA64MMFR0_TGran64_2_TGran64, ""),
1190 	MRS_FIELD_VALUE(ID_AA64MMFR0_TGran64_2_NONE, "No S2 TGran64"),
1191 	MRS_FIELD_VALUE(ID_AA64MMFR0_TGran64_2_IMPL, "S2 TGran64"),
1192 	MRS_FIELD_VALUE_END,
1193 };
1194 
1195 static const struct mrs_field_value id_aa64mmfr0_tgran16_2[] = {
1196 	MRS_FIELD_VALUE(ID_AA64MMFR0_TGran16_2_TGran16, ""),
1197 	MRS_FIELD_VALUE(ID_AA64MMFR0_TGran16_2_NONE, "No S2 TGran16"),
1198 	MRS_FIELD_VALUE(ID_AA64MMFR0_TGran16_2_IMPL, "S2 TGran16"),
1199 	MRS_FIELD_VALUE(ID_AA64MMFR0_TGran16_2_LPA2, "S2 TGran16+LPA2"),
1200 	MRS_FIELD_VALUE_END,
1201 };
1202 
1203 static const struct mrs_field_value id_aa64mmfr0_tgran4[] = {
1204 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR0, TGran4, NONE, IMPL),
1205 	MRS_FIELD_VALUE(ID_AA64MMFR0_TGran4_LPA2, "TGran4+LPA2"),
1206 	MRS_FIELD_VALUE_END,
1207 };
1208 
1209 static const struct mrs_field_value id_aa64mmfr0_tgran64[] = {
1210 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR0, TGran64, NONE, IMPL),
1211 	MRS_FIELD_VALUE_END,
1212 };
1213 
1214 static const struct mrs_field_value id_aa64mmfr0_tgran16[] = {
1215 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR0, TGran16, NONE, IMPL),
1216 	MRS_FIELD_VALUE(ID_AA64MMFR0_TGran16_LPA2, "TGran16+LPA2"),
1217 	MRS_FIELD_VALUE_END,
1218 };
1219 
1220 static const struct mrs_field_value id_aa64mmfr0_bigendel0[] = {
1221 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR0, BigEndEL0, FIXED, MIXED),
1222 	MRS_FIELD_VALUE_END,
1223 };
1224 
1225 static const struct mrs_field_value id_aa64mmfr0_snsmem[] = {
1226 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR0, SNSMem, NONE, DISTINCT),
1227 	MRS_FIELD_VALUE_END,
1228 };
1229 
1230 static const struct mrs_field_value id_aa64mmfr0_bigend[] = {
1231 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR0, BigEnd, FIXED, MIXED),
1232 	MRS_FIELD_VALUE_END,
1233 };
1234 
1235 static const struct mrs_field_value id_aa64mmfr0_asidbits[] = {
1236 	MRS_FIELD_VALUE(ID_AA64MMFR0_ASIDBits_8, "8bit ASID"),
1237 	MRS_FIELD_VALUE(ID_AA64MMFR0_ASIDBits_16, "16bit ASID"),
1238 	MRS_FIELD_VALUE_END,
1239 };
1240 
1241 static const struct mrs_field_value id_aa64mmfr0_parange[] = {
1242 	MRS_FIELD_VALUE(ID_AA64MMFR0_PARange_4G, "4GB PA"),
1243 	MRS_FIELD_VALUE(ID_AA64MMFR0_PARange_64G, "64GB PA"),
1244 	MRS_FIELD_VALUE(ID_AA64MMFR0_PARange_1T, "1TB PA"),
1245 	MRS_FIELD_VALUE(ID_AA64MMFR0_PARange_4T, "4TB PA"),
1246 	MRS_FIELD_VALUE(ID_AA64MMFR0_PARange_16T, "16TB PA"),
1247 	MRS_FIELD_VALUE(ID_AA64MMFR0_PARange_256T, "256TB PA"),
1248 	MRS_FIELD_VALUE(ID_AA64MMFR0_PARange_4P, "4PB PA"),
1249 	MRS_FIELD_VALUE_END,
1250 };
1251 
1252 static const struct mrs_field id_aa64mmfr0_fields[] = {
1253 	MRS_FIELD(ID_AA64MMFR0, ECV, false, MRS_LOWER, 0, id_aa64mmfr0_ecv),
1254 	MRS_FIELD(ID_AA64MMFR0, FGT, false, MRS_LOWER, 0, id_aa64mmfr0_fgt),
1255 	MRS_FIELD(ID_AA64MMFR0, ExS, false, MRS_LOWER, 0, id_aa64mmfr0_exs),
1256 	MRS_FIELD(ID_AA64MMFR0, TGran4_2, false, MRS_LOWER, 0,
1257 	    id_aa64mmfr0_tgran4_2),
1258 	MRS_FIELD(ID_AA64MMFR0, TGran64_2, false, MRS_LOWER, 0,
1259 	    id_aa64mmfr0_tgran64_2),
1260 	MRS_FIELD(ID_AA64MMFR0, TGran16_2, false, MRS_LOWER, 0,
1261 	    id_aa64mmfr0_tgran16_2),
1262 	MRS_FIELD(ID_AA64MMFR0, TGran4, false, MRS_LOWER, 0,
1263 	    id_aa64mmfr0_tgran4),
1264 	MRS_FIELD(ID_AA64MMFR0, TGran64, false, MRS_LOWER, 0,
1265 	    id_aa64mmfr0_tgran64),
1266 	MRS_FIELD(ID_AA64MMFR0, TGran16, false, MRS_LOWER, 0,
1267 	    id_aa64mmfr0_tgran16),
1268 	MRS_FIELD(ID_AA64MMFR0, BigEndEL0, false, MRS_LOWER, 0,
1269 	    id_aa64mmfr0_bigendel0),
1270 	MRS_FIELD(ID_AA64MMFR0, SNSMem, false, MRS_LOWER, 0,
1271 	    id_aa64mmfr0_snsmem),
1272 	MRS_FIELD(ID_AA64MMFR0, BigEnd, false, MRS_LOWER, 0,
1273 	    id_aa64mmfr0_bigend),
1274 	MRS_FIELD(ID_AA64MMFR0, ASIDBits, false, MRS_LOWER, 0,
1275 	    id_aa64mmfr0_asidbits),
1276 	MRS_FIELD(ID_AA64MMFR0, PARange, false, MRS_LOWER, 0,
1277 	    id_aa64mmfr0_parange),
1278 	MRS_FIELD_END,
1279 };
1280 
1281 
1282 /* ID_AA64MMFR1_EL1 */
1283 static const struct mrs_field_value id_aa64mmfr1_ecbhb[] = {
1284 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR1, ECBHB, NONE, IMPL),
1285 	MRS_FIELD_VALUE_END,
1286 };
1287 
1288 static const struct mrs_field_value id_aa64mmfr1_cmovw[] = {
1289 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR1, CMOVW, NONE, IMPL),
1290 	MRS_FIELD_VALUE_END,
1291 };
1292 
1293 static const struct mrs_field_value id_aa64mmfr1_tidcp1[] = {
1294 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR1, TIDCP1, NONE, IMPL),
1295 	MRS_FIELD_VALUE_END,
1296 };
1297 
1298 static const struct mrs_field_value id_aa64mmfr1_ntlbpa[] = {
1299 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR1, nTLBPA, NONE, IMPL),
1300 	MRS_FIELD_VALUE_END,
1301 };
1302 
1303 static const struct mrs_field_value id_aa64mmfr1_afp[] = {
1304 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR1, AFP, NONE, IMPL),
1305 	MRS_FIELD_VALUE_END,
1306 };
1307 
1308 static const struct mrs_field_hwcap id_aa64mmfr1_afp_caps[] = {
1309 	MRS_HWCAP(2, HWCAP2_AFP, ID_AA64MMFR1_AFP_IMPL),
1310 	MRS_HWCAP_END
1311 };
1312 
1313 static const struct mrs_field_value id_aa64mmfr1_hcx[] = {
1314 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR1, HCX, NONE, IMPL),
1315 	MRS_FIELD_VALUE_END,
1316 };
1317 
1318 static const struct mrs_field_value id_aa64mmfr1_ets[] = {
1319 	MRS_FIELD_VALUE(ID_AA64MMFR1_ETS_NONE, ""),
1320 	MRS_FIELD_VALUE(ID_AA64MMFR1_ETS_NONE2, ""),
1321 	MRS_FIELD_VALUE(ID_AA64MMFR1_ETS_IMPL, "ETS2"),
1322 	MRS_FIELD_VALUE_END,
1323 };
1324 
1325 static const struct mrs_field_value id_aa64mmfr1_twed[] = {
1326 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR1, TWED, NONE, IMPL),
1327 	MRS_FIELD_VALUE_END,
1328 };
1329 
1330 static const struct mrs_field_value id_aa64mmfr1_xnx[] = {
1331 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR1, XNX, NONE, IMPL),
1332 	MRS_FIELD_VALUE_END,
1333 };
1334 
1335 static const struct mrs_field_value id_aa64mmfr1_specsei[] = {
1336 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR1, SpecSEI, NONE, IMPL),
1337 	MRS_FIELD_VALUE_END,
1338 };
1339 
1340 static const struct mrs_field_value id_aa64mmfr1_pan[] = {
1341 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR1, PAN, NONE, IMPL),
1342 	MRS_FIELD_VALUE(ID_AA64MMFR1_PAN_ATS1E1, "PAN+ATS1E1"),
1343 	MRS_FIELD_VALUE(ID_AA64MMFR1_PAN_EPAN, "EPAN"),
1344 	MRS_FIELD_VALUE_END,
1345 };
1346 
1347 static const struct mrs_field_value id_aa64mmfr1_lo[] = {
1348 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR1, LO, NONE, IMPL),
1349 	MRS_FIELD_VALUE_END,
1350 };
1351 
1352 static const struct mrs_field_value id_aa64mmfr1_hpds[] = {
1353 	MRS_FIELD_VALUE(ID_AA64MMFR1_HPDS_NONE, ""),
1354 	MRS_FIELD_VALUE(ID_AA64MMFR1_HPDS_HPD, "HPD"),
1355 	MRS_FIELD_VALUE(ID_AA64MMFR1_HPDS_TTPBHA, "HPD+TTPBHA"),
1356 	MRS_FIELD_VALUE_END,
1357 };
1358 
1359 static const struct mrs_field_value id_aa64mmfr1_vh[] = {
1360 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR1, VH, NONE, IMPL),
1361 	MRS_FIELD_VALUE_END,
1362 };
1363 
1364 static const struct mrs_field_value id_aa64mmfr1_vmidbits[] = {
1365 	MRS_FIELD_VALUE(ID_AA64MMFR1_VMIDBits_8, "8bit VMID"),
1366 	MRS_FIELD_VALUE(ID_AA64MMFR1_VMIDBits_16, "16bit VMID"),
1367 	MRS_FIELD_VALUE_END,
1368 };
1369 
1370 static const struct mrs_field_value id_aa64mmfr1_hafdbs[] = {
1371 	MRS_FIELD_VALUE(ID_AA64MMFR1_HAFDBS_NONE, ""),
1372 	MRS_FIELD_VALUE(ID_AA64MMFR1_HAFDBS_AF, "HAF"),
1373 	MRS_FIELD_VALUE(ID_AA64MMFR1_HAFDBS_AF_DBS, "HAF+DS"),
1374 	MRS_FIELD_VALUE_END,
1375 };
1376 
1377 static const struct mrs_field id_aa64mmfr1_fields[] = {
1378 	MRS_FIELD(ID_AA64MMFR1, ECBHB, false, MRS_LOWER, 0, id_aa64mmfr1_ecbhb),
1379 	MRS_FIELD(ID_AA64MMFR1, CMOVW, false, MRS_LOWER, 0, id_aa64mmfr1_cmovw),
1380 	MRS_FIELD(ID_AA64MMFR1, TIDCP1, false, MRS_LOWER, 0,
1381 	    id_aa64mmfr1_tidcp1),
1382 	MRS_FIELD(ID_AA64MMFR1, nTLBPA, false, MRS_LOWER, 0,
1383 	    id_aa64mmfr1_ntlbpa),
1384 	MRS_FIELD_HWCAP(ID_AA64MMFR1, AFP, false, MRS_LOWER, 0,
1385 	    id_aa64mmfr1_afp, id_aa64mmfr1_afp_caps),
1386 	MRS_FIELD(ID_AA64MMFR1, HCX, false, MRS_LOWER, 0, id_aa64mmfr1_hcx),
1387 	MRS_FIELD(ID_AA64MMFR1, ETS, false, MRS_LOWER, 0, id_aa64mmfr1_ets),
1388 	MRS_FIELD(ID_AA64MMFR1, TWED, false, MRS_LOWER, 0, id_aa64mmfr1_twed),
1389 	MRS_FIELD(ID_AA64MMFR1, XNX, false, MRS_LOWER, 0, id_aa64mmfr1_xnx),
1390 	/*
1391 	 * SpecSEI != 0 indicates the CPU might generate an external abort
1392 	 * under speculation, while 0 indicates it can't happen. It's safer
1393 	 * to incorrectly indicate it might happen when it can't rather than
1394 	 * say it can't happen when it could. As such use the largest value
1395 	 * found in the system.
1396 	 */
1397 	MRS_FIELD(ID_AA64MMFR1, SpecSEI, false, MRS_HIGHER, 0,
1398 	    id_aa64mmfr1_specsei),
1399 	MRS_FIELD(ID_AA64MMFR1, PAN, false, MRS_LOWER, 0, id_aa64mmfr1_pan),
1400 	MRS_FIELD(ID_AA64MMFR1, LO, false, MRS_LOWER, 0, id_aa64mmfr1_lo),
1401 	MRS_FIELD(ID_AA64MMFR1, HPDS, false, MRS_LOWER, 0, id_aa64mmfr1_hpds),
1402 	MRS_FIELD(ID_AA64MMFR1, VH, false, MRS_LOWER, 0, id_aa64mmfr1_vh),
1403 	MRS_FIELD(ID_AA64MMFR1, VMIDBits, false, MRS_LOWER, 0,
1404 	    id_aa64mmfr1_vmidbits),
1405 	MRS_FIELD(ID_AA64MMFR1, HAFDBS, false, MRS_LOWER, 0, id_aa64mmfr1_hafdbs),
1406 	MRS_FIELD_END,
1407 };
1408 
1409 
1410 /* ID_AA64MMFR2_EL1 */
1411 static const struct mrs_field_value id_aa64mmfr2_e0pd[] = {
1412 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR2, E0PD, NONE, IMPL),
1413 	MRS_FIELD_VALUE_END,
1414 };
1415 
1416 static const struct mrs_field_value id_aa64mmfr2_evt[] = {
1417 	MRS_FIELD_VALUE(ID_AA64MMFR2_EVT_NONE, ""),
1418 	MRS_FIELD_VALUE(ID_AA64MMFR2_EVT_8_2, "EVT-8.2"),
1419 	MRS_FIELD_VALUE(ID_AA64MMFR2_EVT_8_5, "EVT-8.5"),
1420 	MRS_FIELD_VALUE_END,
1421 };
1422 
1423 static const struct mrs_field_value id_aa64mmfr2_bbm[] = {
1424 	MRS_FIELD_VALUE(ID_AA64MMFR2_BBM_LEVEL0, ""),
1425 	MRS_FIELD_VALUE(ID_AA64MMFR2_BBM_LEVEL1, "BBM level 1"),
1426 	MRS_FIELD_VALUE(ID_AA64MMFR2_BBM_LEVEL2, "BBM level 2"),
1427 	MRS_FIELD_VALUE_END,
1428 };
1429 
1430 static const struct mrs_field_value id_aa64mmfr2_ttl[] = {
1431 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR2, TTL, NONE, IMPL),
1432 	MRS_FIELD_VALUE_END,
1433 };
1434 
1435 static const struct mrs_field_value id_aa64mmfr2_fwb[] = {
1436 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR2, FWB, NONE, IMPL),
1437 	MRS_FIELD_VALUE_END,
1438 };
1439 
1440 static const struct mrs_field_value id_aa64mmfr2_ids[] = {
1441 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR2, IDS, NONE, IMPL),
1442 	MRS_FIELD_VALUE_END,
1443 };
1444 
1445 static const struct mrs_field_value id_aa64mmfr2_at[] = {
1446 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR2, AT, NONE, IMPL),
1447 	MRS_FIELD_VALUE_END,
1448 };
1449 
1450 static const struct mrs_field_hwcap id_aa64mmfr2_at_caps[] = {
1451 	MRS_HWCAP(1, HWCAP_USCAT, ID_AA64MMFR2_AT_IMPL),
1452 	MRS_HWCAP_END
1453 };
1454 
1455 static const struct mrs_field_value id_aa64mmfr2_st[] = {
1456 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR2, ST, NONE, IMPL),
1457 	MRS_FIELD_VALUE_END,
1458 };
1459 
1460 static const struct mrs_field_value id_aa64mmfr2_nv[] = {
1461 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR2, NV, NONE, 8_3),
1462 	MRS_FIELD_VALUE(ID_AA64MMFR2_NV_8_4, "NV v8.4"),
1463 	MRS_FIELD_VALUE_END,
1464 };
1465 
1466 static const struct mrs_field_value id_aa64mmfr2_ccidx[] = {
1467 	MRS_FIELD_VALUE(ID_AA64MMFR2_CCIDX_32, "32bit CCIDX"),
1468 	MRS_FIELD_VALUE(ID_AA64MMFR2_CCIDX_64, "64bit CCIDX"),
1469 	MRS_FIELD_VALUE_END,
1470 };
1471 
1472 static const struct mrs_field_value id_aa64mmfr2_varange[] = {
1473 	MRS_FIELD_VALUE(ID_AA64MMFR2_VARange_48, "48bit VA"),
1474 	MRS_FIELD_VALUE(ID_AA64MMFR2_VARange_52, "52bit VA"),
1475 	MRS_FIELD_VALUE_END,
1476 };
1477 
1478 static const struct mrs_field_value id_aa64mmfr2_iesb[] = {
1479 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR2, IESB, NONE, IMPL),
1480 	MRS_FIELD_VALUE_END,
1481 };
1482 
1483 static const struct mrs_field_value id_aa64mmfr2_lsm[] = {
1484 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR2, LSM, NONE, IMPL),
1485 	MRS_FIELD_VALUE_END,
1486 };
1487 
1488 static const struct mrs_field_value id_aa64mmfr2_uao[] = {
1489 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR2, UAO, NONE, IMPL),
1490 	MRS_FIELD_VALUE_END,
1491 };
1492 
1493 static const struct mrs_field_value id_aa64mmfr2_cnp[] = {
1494 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR2, CnP, NONE, IMPL),
1495 	MRS_FIELD_VALUE_END,
1496 };
1497 
1498 static const struct mrs_field id_aa64mmfr2_fields[] = {
1499 	MRS_FIELD(ID_AA64MMFR2, E0PD, false, MRS_LOWER, 0, id_aa64mmfr2_e0pd),
1500 	MRS_FIELD(ID_AA64MMFR2, EVT, false, MRS_LOWER, 0, id_aa64mmfr2_evt),
1501 	MRS_FIELD(ID_AA64MMFR2, BBM, false, MRS_LOWER, 0, id_aa64mmfr2_bbm),
1502 	MRS_FIELD(ID_AA64MMFR2, TTL, false, MRS_LOWER, 0, id_aa64mmfr2_ttl),
1503 	MRS_FIELD(ID_AA64MMFR2, FWB, false, MRS_LOWER, 0, id_aa64mmfr2_fwb),
1504 	MRS_FIELD(ID_AA64MMFR2, IDS, false, MRS_LOWER, 0, id_aa64mmfr2_ids),
1505 	MRS_FIELD_HWCAP(ID_AA64MMFR2, AT, false, MRS_LOWER, MRS_USERSPACE,
1506 	    id_aa64mmfr2_at, id_aa64mmfr2_at_caps),
1507 	MRS_FIELD(ID_AA64MMFR2, ST, false, MRS_LOWER, 0, id_aa64mmfr2_st),
1508 	MRS_FIELD(ID_AA64MMFR2, NV, false, MRS_LOWER, 0, id_aa64mmfr2_nv),
1509 	MRS_FIELD(ID_AA64MMFR2, CCIDX, false, MRS_LOWER, 0, id_aa64mmfr2_ccidx),
1510 	MRS_FIELD(ID_AA64MMFR2, VARange, false, MRS_LOWER, 0,
1511 	    id_aa64mmfr2_varange),
1512 	MRS_FIELD(ID_AA64MMFR2, IESB, false, MRS_LOWER, 0, id_aa64mmfr2_iesb),
1513 	MRS_FIELD(ID_AA64MMFR2, LSM, false, MRS_LOWER, 0, id_aa64mmfr2_lsm),
1514 	MRS_FIELD(ID_AA64MMFR2, UAO, false, MRS_LOWER, 0, id_aa64mmfr2_uao),
1515 	MRS_FIELD(ID_AA64MMFR2, CnP, false, MRS_LOWER, 0, id_aa64mmfr2_cnp),
1516 	MRS_FIELD_END,
1517 };
1518 
1519 
1520 /* ID_AA64MMFR2_EL1 */
1521 static const struct mrs_field_value id_aa64mmfr3_spec_fpacc[] = {
1522 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR3, Spec_FPACC, NONE, IMPL),
1523 	MRS_FIELD_VALUE_END,
1524 };
1525 
1526 static const struct mrs_field_value id_aa64mmfr3_aderr[] = {
1527 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR3, ADERR, NONE, SOME),
1528 	MRS_FIELD_VALUE_END,
1529 };
1530 
1531 static const struct mrs_field_value id_aa64mmfr3_sderr[] = {
1532 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR3, SDERR, NONE, ALL),
1533 	MRS_FIELD_VALUE_END,
1534 };
1535 
1536 static const struct mrs_field_value id_aa64mmfr3_anerr[] = {
1537 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR3, ANERR, NONE, SOME),
1538 	MRS_FIELD_VALUE_END,
1539 };
1540 
1541 static const struct mrs_field_value id_aa64mmfr3_snerr[] = {
1542 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR3, SNERR, NONE, ALL),
1543 	MRS_FIELD_VALUE_END,
1544 };
1545 
1546 static const struct mrs_field_value id_aa64mmfr3_mec[] = {
1547 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR3, MEC, NONE, IMPL),
1548 	MRS_FIELD_VALUE_END,
1549 };
1550 
1551 static const struct mrs_field_value id_aa64mmfr3_aie[] = {
1552 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR3, AIE, NONE, IMPL),
1553 	MRS_FIELD_VALUE_END,
1554 };
1555 
1556 static const struct mrs_field_value id_aa64mmfr3_s2poe[] = {
1557 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR3, S2POE, NONE, IMPL),
1558 	MRS_FIELD_VALUE_END,
1559 };
1560 
1561 static const struct mrs_field_value id_aa64mmfr3_s1poe[] = {
1562 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR3, S1POE, NONE, IMPL),
1563 	MRS_FIELD_VALUE_END,
1564 };
1565 
1566 static const struct mrs_field_value id_aa64mmfr3_s2pie[] = {
1567 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR3, S2PIE, NONE, IMPL),
1568 	MRS_FIELD_VALUE_END,
1569 };
1570 
1571 static const struct mrs_field_value id_aa64mmfr3_s1pie[] = {
1572 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR3, S1PIE, NONE, IMPL),
1573 	MRS_FIELD_VALUE_END,
1574 };
1575 
1576 static const struct mrs_field_value id_aa64mmfr3_sctlrx[] = {
1577 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR3, SCTLRX, NONE, IMPL),
1578 	MRS_FIELD_VALUE_END,
1579 };
1580 
1581 static const struct mrs_field_value id_aa64mmfr3_tcrx[] = {
1582 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64MMFR3, TCRX, NONE, IMPL),
1583 	MRS_FIELD_VALUE_END,
1584 };
1585 
1586 static const struct mrs_field id_aa64mmfr3_fields[] = {
1587 	MRS_FIELD(ID_AA64MMFR3, Spec_FPACC, false, MRS_LOWER, 0,
1588 	    id_aa64mmfr3_spec_fpacc),
1589 	MRS_FIELD(ID_AA64MMFR3, ADERR, false, MRS_LOWER, 0, id_aa64mmfr3_aderr),
1590 	MRS_FIELD(ID_AA64MMFR3, SDERR, false, MRS_LOWER, 0, id_aa64mmfr3_sderr),
1591 	MRS_FIELD(ID_AA64MMFR3, ANERR, false, MRS_LOWER, 0, id_aa64mmfr3_anerr),
1592 	MRS_FIELD(ID_AA64MMFR3, SNERR, false, MRS_LOWER, 0, id_aa64mmfr3_snerr),
1593 	MRS_FIELD(ID_AA64MMFR3, MEC, false, MRS_LOWER, 0, id_aa64mmfr3_mec),
1594 	MRS_FIELD(ID_AA64MMFR3, AIE, false, MRS_LOWER, 0, id_aa64mmfr3_aie),
1595 	MRS_FIELD(ID_AA64MMFR3, S2POE, false, MRS_LOWER, 0, id_aa64mmfr3_s2poe),
1596 	MRS_FIELD(ID_AA64MMFR3, S1POE, false, MRS_LOWER, 0, id_aa64mmfr3_s1poe),
1597 	MRS_FIELD(ID_AA64MMFR3, S2PIE, false, MRS_LOWER, 0, id_aa64mmfr3_s2pie),
1598 	MRS_FIELD(ID_AA64MMFR3, S1PIE, false, MRS_LOWER, 0, id_aa64mmfr3_s1pie),
1599 	MRS_FIELD(ID_AA64MMFR3, SCTLRX, false, MRS_LOWER, 0,
1600 	    id_aa64mmfr3_sctlrx),
1601 	MRS_FIELD(ID_AA64MMFR3, TCRX, false, MRS_LOWER, 0, id_aa64mmfr3_tcrx),
1602 	MRS_FIELD_END,
1603 };
1604 
1605 
1606 /* ID_AA64MMFR4_EL1 */
1607 static const struct mrs_field id_aa64mmfr4_fields[] = {
1608 	MRS_FIELD_END,
1609 };
1610 
1611 
1612 /* ID_AA64PFR0_EL1 */
1613 static const struct mrs_field_value id_aa64pfr0_csv3[] = {
1614 	MRS_FIELD_VALUE(ID_AA64PFR0_CSV3_NONE, ""),
1615 	MRS_FIELD_VALUE(ID_AA64PFR0_CSV3_ISOLATED, "CSV3"),
1616 	MRS_FIELD_VALUE_END,
1617 };
1618 
1619 static const struct mrs_field_value id_aa64pfr0_csv2[] = {
1620 	MRS_FIELD_VALUE(ID_AA64PFR0_CSV2_NONE, ""),
1621 	MRS_FIELD_VALUE(ID_AA64PFR0_CSV2_ISOLATED, "CSV2"),
1622 	MRS_FIELD_VALUE(ID_AA64PFR0_CSV2_SCXTNUM, "CSV2_2"),
1623 	MRS_FIELD_VALUE(ID_AA64PFR0_CSV2_3, "CSV2_3"),
1624 	MRS_FIELD_VALUE_END,
1625 };
1626 
1627 static const struct mrs_field_value id_aa64pfr0_rme[] = {
1628 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64PFR0, RME, NONE, IMPL),
1629 	MRS_FIELD_VALUE_END,
1630 };
1631 
1632 static const struct mrs_field_value id_aa64pfr0_dit[] = {
1633 	MRS_FIELD_VALUE(ID_AA64PFR0_DIT_NONE, ""),
1634 	MRS_FIELD_VALUE(ID_AA64PFR0_DIT_PSTATE, "PSTATE.DIT"),
1635 	MRS_FIELD_VALUE_END,
1636 };
1637 
1638 static const struct mrs_field_hwcap id_aa64pfr0_dit_caps[] = {
1639 	MRS_HWCAP(1, HWCAP_DIT, ID_AA64PFR0_DIT_PSTATE),
1640 	MRS_HWCAP_END
1641 };
1642 
1643 static const struct mrs_field_value id_aa64pfr0_amu[] = {
1644 	MRS_FIELD_VALUE(ID_AA64PFR0_AMU_NONE, ""),
1645 	MRS_FIELD_VALUE(ID_AA64PFR0_AMU_V1, "AMUv1"),
1646 	MRS_FIELD_VALUE(ID_AA64PFR0_AMU_V1_1, "AMUv1p1"),
1647 	MRS_FIELD_VALUE_END,
1648 };
1649 
1650 static const struct mrs_field_value id_aa64pfr0_mpam[] = {
1651 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64PFR0, MPAM, NONE, IMPL),
1652 	MRS_FIELD_VALUE_END,
1653 };
1654 
1655 static const struct mrs_field_value id_aa64pfr0_sel2[] = {
1656 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64PFR0, SEL2, NONE, IMPL),
1657 	MRS_FIELD_VALUE_END,
1658 };
1659 
1660 static const struct mrs_field_value id_aa64pfr0_sve[] = {
1661 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64PFR0, SVE, NONE, IMPL),
1662 	MRS_FIELD_VALUE_END,
1663 };
1664 
1665 static const struct mrs_field_hwcap id_aa64pfr0_sve_caps[] = {
1666 	MRS_HWCAP(1, HWCAP_SVE, ID_AA64PFR0_SVE_IMPL),
1667 	MRS_HWCAP_END
1668 };
1669 
1670 static const struct mrs_field_value id_aa64pfr0_ras[] = {
1671 	MRS_FIELD_VALUE(ID_AA64PFR0_RAS_NONE, ""),
1672 	MRS_FIELD_VALUE(ID_AA64PFR0_RAS_IMPL, "RAS"),
1673 	MRS_FIELD_VALUE(ID_AA64PFR0_RAS_8_4, "RAS v8.4"),
1674 	MRS_FIELD_VALUE(ID_AA64PFR0_RAS_8_9, "RAS v8.9"),
1675 	MRS_FIELD_VALUE_END,
1676 };
1677 
1678 static const struct mrs_field_value id_aa64pfr0_gic[] = {
1679 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64PFR0, GIC, CPUIF_NONE, CPUIF_EN),
1680 	MRS_FIELD_VALUE(ID_AA64PFR0_GIC_CPUIF_NONE, ""),
1681 	MRS_FIELD_VALUE(ID_AA64PFR0_GIC_CPUIF_EN, "GIC"),
1682 	MRS_FIELD_VALUE(ID_AA64PFR0_GIC_CPUIF_4_1, "GIC 4.1"),
1683 	MRS_FIELD_VALUE_END,
1684 };
1685 
1686 static const struct mrs_field_value id_aa64pfr0_advsimd[] = {
1687 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64PFR0, AdvSIMD, NONE, IMPL),
1688 	MRS_FIELD_VALUE(ID_AA64PFR0_AdvSIMD_HP, "AdvSIMD+HP"),
1689 	MRS_FIELD_VALUE_END,
1690 };
1691 
1692 static const struct mrs_field_hwcap id_aa64pfr0_advsimd_caps[] = {
1693 	MRS_HWCAP(1, HWCAP_ASIMD, ID_AA64PFR0_AdvSIMD_IMPL),
1694 	MRS_HWCAP(1, HWCAP_ASIMDHP, ID_AA64PFR0_AdvSIMD_HP),
1695 	MRS_HWCAP_END
1696 };
1697 
1698 static const struct mrs_field_value id_aa64pfr0_fp[] = {
1699 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64PFR0, FP, NONE, IMPL),
1700 	MRS_FIELD_VALUE(ID_AA64PFR0_FP_HP, "FP+HP"),
1701 	MRS_FIELD_VALUE_END,
1702 };
1703 
1704 static const struct mrs_field_hwcap id_aa64pfr0_fp_caps[] = {
1705 	MRS_HWCAP(1, HWCAP_FP, ID_AA64PFR0_FP_IMPL),
1706 	MRS_HWCAP(1, HWCAP_FPHP, ID_AA64PFR0_FP_HP),
1707 	MRS_HWCAP_END
1708 };
1709 
1710 static const struct mrs_field_value id_aa64pfr0_el3[] = {
1711 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64PFR0, EL3, NONE, 64),
1712 	MRS_FIELD_VALUE(ID_AA64PFR0_EL3_64_32, "EL3 32"),
1713 	MRS_FIELD_VALUE_END,
1714 };
1715 
1716 static const struct mrs_field_value id_aa64pfr0_el2[] = {
1717 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64PFR0, EL2, NONE, 64),
1718 	MRS_FIELD_VALUE(ID_AA64PFR0_EL2_64_32, "EL2 32"),
1719 	MRS_FIELD_VALUE_END,
1720 };
1721 
1722 static const struct mrs_field_value id_aa64pfr0_el1[] = {
1723 	MRS_FIELD_VALUE(ID_AA64PFR0_EL1_64, "EL1"),
1724 	MRS_FIELD_VALUE(ID_AA64PFR0_EL1_64_32, "EL1 32"),
1725 	MRS_FIELD_VALUE_END,
1726 };
1727 
1728 static const struct mrs_field_value id_aa64pfr0_el0[] = {
1729 	MRS_FIELD_VALUE(ID_AA64PFR0_EL0_64, "EL0"),
1730 	MRS_FIELD_VALUE(ID_AA64PFR0_EL0_64_32, "EL0 32"),
1731 	MRS_FIELD_VALUE_END,
1732 };
1733 
1734 static const struct mrs_field id_aa64pfr0_fields[] = {
1735 	MRS_FIELD(ID_AA64PFR0, CSV3, false, MRS_LOWER, 0, id_aa64pfr0_csv3),
1736 	MRS_FIELD(ID_AA64PFR0, CSV2, false, MRS_LOWER, 0, id_aa64pfr0_csv2),
1737 	MRS_FIELD(ID_AA64PFR0, RME, false, MRS_LOWER, 0, id_aa64pfr0_rme),
1738 	MRS_FIELD_HWCAP(ID_AA64PFR0, DIT, false, MRS_LOWER, MRS_USERSPACE,
1739 	    id_aa64pfr0_dit, id_aa64pfr0_dit_caps),
1740 	MRS_FIELD(ID_AA64PFR0, AMU, false, MRS_LOWER, 0, id_aa64pfr0_amu),
1741 	MRS_FIELD(ID_AA64PFR0, MPAM, false, MRS_LOWER, 0, id_aa64pfr0_mpam),
1742 	MRS_FIELD(ID_AA64PFR0, SEL2, false, MRS_LOWER, 0, id_aa64pfr0_sel2),
1743 	MRS_FIELD_HWCAP(ID_AA64PFR0, SVE, false, MRS_LOWER,
1744 	    MRS_FREEBSD, id_aa64pfr0_sve, id_aa64pfr0_sve_caps),
1745 	MRS_FIELD(ID_AA64PFR0, RAS, false, MRS_LOWER, 0, id_aa64pfr0_ras),
1746 	MRS_FIELD(ID_AA64PFR0, GIC, false, MRS_LOWER, 0, id_aa64pfr0_gic),
1747 	MRS_FIELD_HWCAP(ID_AA64PFR0, AdvSIMD, true, MRS_LOWER, MRS_USERSPACE,
1748 	    id_aa64pfr0_advsimd, id_aa64pfr0_advsimd_caps),
1749 	MRS_FIELD_HWCAP(ID_AA64PFR0, FP, true,  MRS_LOWER, MRS_USERSPACE,
1750 	    id_aa64pfr0_fp, id_aa64pfr0_fp_caps),
1751 	MRS_FIELD(ID_AA64PFR0, EL3, false, MRS_LOWER, 0, id_aa64pfr0_el3),
1752 	MRS_FIELD(ID_AA64PFR0, EL2, false, MRS_LOWER, 0, id_aa64pfr0_el2),
1753 	MRS_FIELD(ID_AA64PFR0, EL1, false, MRS_LOWER, MRS_USERSPACE,
1754 	    id_aa64pfr0_el1),
1755 	MRS_FIELD(ID_AA64PFR0, EL0, false, MRS_LOWER, MRS_USERSPACE,
1756 	    id_aa64pfr0_el0),
1757 	MRS_FIELD_END,
1758 };
1759 
1760 
1761 /* ID_AA64PFR1_EL1 */
1762 static const struct mrs_field_value id_aa64pfr1_pfar[] = {
1763 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64PFR1, PFAR, NONE, IMPL),
1764 	MRS_FIELD_VALUE_END,
1765 };
1766 
1767 static const struct mrs_field_value id_aa64pfr1_df2[] = {
1768 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64PFR1, DF2, NONE, IMPL),
1769 	MRS_FIELD_VALUE_END,
1770 };
1771 
1772 static const struct mrs_field_value id_aa64pfr1_mtex[] = {
1773 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64PFR1, MTEX, NONE, IMPL),
1774 	MRS_FIELD_VALUE_END,
1775 };
1776 
1777 static const struct mrs_field_value id_aa64pfr1_the[] = {
1778 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64PFR1, THE, NONE, IMPL),
1779 	MRS_FIELD_VALUE_END,
1780 };
1781 
1782 static const struct mrs_field_value id_aa64pfr1_mtefrac[] = {
1783 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64PFR1, MTE_frac, NONE, IMPL),
1784 	MRS_FIELD_VALUE_END,
1785 };
1786 
1787 static const struct mrs_field_value id_aa64pfr1_nmi[] = {
1788 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64PFR1, NMI, NONE, IMPL),
1789 	MRS_FIELD_VALUE_END,
1790 };
1791 
1792 static const struct mrs_field_value id_aa64pfr1_csv2_frac[] = {
1793 	MRS_FIELD_VALUE(ID_AA64PFR1_CSV2_frac_p0, ""),
1794 	MRS_FIELD_VALUE(ID_AA64PFR1_CSV2_frac_p1, "CSV2 p1"),
1795 	MRS_FIELD_VALUE(ID_AA64PFR1_CSV2_frac_p2, "CSV2 p2"),
1796 	MRS_FIELD_VALUE_END,
1797 };
1798 
1799 static const struct mrs_field_value id_aa64pfr1_rndr_trap[] = {
1800 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64PFR1, RNDR_trap, NONE, IMPL),
1801 	MRS_FIELD_VALUE_END,
1802 };
1803 
1804 static const struct mrs_field_value id_aa64pfr1_sme[] = {
1805 	MRS_FIELD_VALUE(ID_AA64PFR1_SME_NONE, ""),
1806 	MRS_FIELD_VALUE(ID_AA64PFR1_SME_SME, "SME"),
1807 	MRS_FIELD_VALUE(ID_AA64PFR1_SME_SME2, "SME2"),
1808 	MRS_FIELD_VALUE_END,
1809 };
1810 
1811 static const struct mrs_field_value id_aa64pfr1_mpam_frac[] = {
1812 	MRS_FIELD_VALUE(ID_AA64PFR1_MPAM_frac_p0, ""),
1813 	MRS_FIELD_VALUE(ID_AA64PFR1_MPAM_frac_p1, "MPAM p1"),
1814 	MRS_FIELD_VALUE_END,
1815 };
1816 
1817 static const struct mrs_field_value id_aa64pfr1_ras_frac[] = {
1818 	MRS_FIELD_VALUE(ID_AA64PFR1_RAS_frac_p0, ""),
1819 	MRS_FIELD_VALUE(ID_AA64PFR1_RAS_frac_p1, "RAS p1"),
1820 	MRS_FIELD_VALUE_END,
1821 };
1822 
1823 static const struct mrs_field_value id_aa64pfr1_mte[] = {
1824 	MRS_FIELD_VALUE(ID_AA64PFR1_MTE_NONE, ""),
1825 	MRS_FIELD_VALUE(ID_AA64PFR1_MTE_MTE, "MTE"),
1826 	MRS_FIELD_VALUE(ID_AA64PFR1_MTE_MTE2, "MTE2"),
1827 	MRS_FIELD_VALUE(ID_AA64PFR1_MTE_MTE3, "MTE3"),
1828 	MRS_FIELD_VALUE_END,
1829 };
1830 
1831 static const struct mrs_field_value id_aa64pfr1_ssbs[] = {
1832 	MRS_FIELD_VALUE(ID_AA64PFR1_SSBS_NONE, ""),
1833 	MRS_FIELD_VALUE(ID_AA64PFR1_SSBS_PSTATE, "PSTATE.SSBS"),
1834 	MRS_FIELD_VALUE(ID_AA64PFR1_SSBS_PSTATE_MSR, "PSTATE.SSBS MSR"),
1835 	MRS_FIELD_VALUE_END,
1836 };
1837 
1838 static const struct mrs_field_hwcap id_aa64pfr1_ssbs_caps[] = {
1839 	MRS_HWCAP(1, HWCAP_SSBS, ID_AA64PFR1_SSBS_PSTATE),
1840 	MRS_HWCAP_END
1841 };
1842 
1843 static const struct mrs_field_value id_aa64pfr1_bt[] = {
1844 	MRS_FIELD_VALUE(ID_AA64PFR1_BT_NONE, ""),
1845 	MRS_FIELD_VALUE(ID_AA64PFR1_BT_IMPL, "BTI"),
1846 	MRS_FIELD_VALUE_END,
1847 };
1848 
1849 static const struct mrs_field_hwcap id_aa64pfr1_bt_caps[] = {
1850 	MRS_HWCAP(2, HWCAP2_BTI, ID_AA64PFR1_BT_IMPL),
1851 	MRS_HWCAP_END
1852 };
1853 
1854 static const struct mrs_field id_aa64pfr1_fields[] = {
1855 	MRS_FIELD(ID_AA64PFR1, PFAR, false, MRS_LOWER, 0, id_aa64pfr1_pfar),
1856 	MRS_FIELD(ID_AA64PFR1, DF2, false, MRS_LOWER, 0, id_aa64pfr1_df2),
1857 	MRS_FIELD(ID_AA64PFR1, MTEX, false, MRS_LOWER, 0, id_aa64pfr1_mtex),
1858 	MRS_FIELD(ID_AA64PFR1, THE, false, MRS_LOWER, 0, id_aa64pfr1_the),
1859 	MRS_FIELD(ID_AA64PFR1, MTE_frac, false, MRS_LOWER, 0, id_aa64pfr1_mtefrac),
1860 	MRS_FIELD(ID_AA64PFR1, NMI, false, MRS_LOWER, 0, id_aa64pfr1_nmi),
1861 	MRS_FIELD(ID_AA64PFR1, CSV2_frac, false, MRS_LOWER, 0,
1862 	    id_aa64pfr1_csv2_frac),
1863 	MRS_FIELD(ID_AA64PFR1, RNDR_trap, false, MRS_LOWER, 0,
1864 	    id_aa64pfr1_rndr_trap),
1865 	MRS_FIELD(ID_AA64PFR1, SME, false, MRS_LOWER, 0, id_aa64pfr1_sme),
1866 	MRS_FIELD(ID_AA64PFR1, MPAM_frac, false, MRS_LOWER, 0,
1867 	    id_aa64pfr1_mpam_frac),
1868 	MRS_FIELD(ID_AA64PFR1, RAS_frac, false, MRS_LOWER, 0,
1869 	    id_aa64pfr1_ras_frac),
1870 	MRS_FIELD(ID_AA64PFR1, MTE, false, MRS_LOWER, 0, id_aa64pfr1_mte),
1871 	MRS_FIELD_HWCAP(ID_AA64PFR1, SSBS, false, MRS_LOWER, MRS_USERSPACE,
1872 	    id_aa64pfr1_ssbs, id_aa64pfr1_ssbs_caps),
1873 	MRS_FIELD_HWCAP(ID_AA64PFR1, BT, false, MRS_LOWER,
1874 	    MRS_FREEBSD, id_aa64pfr1_bt, id_aa64pfr1_bt_caps),
1875 	MRS_FIELD_END,
1876 };
1877 
1878 
1879 /* ID_AA64PFR2_EL1 */
1880 static const struct mrs_field id_aa64pfr2_fields[] = {
1881 	MRS_FIELD_END,
1882 };
1883 
1884 
1885 /* ID_AA64ZFR0_EL1 */
1886 static const struct mrs_field_value id_aa64zfr0_f64mm[] = {
1887 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ZFR0, F64MM, NONE, IMPL),
1888 	MRS_FIELD_VALUE_END,
1889 };
1890 
1891 static const struct mrs_field_hwcap id_aa64zfr0_f64mm_caps[] = {
1892 	MRS_HWCAP(2, HWCAP2_SVEF64MM, ID_AA64ZFR0_F64MM_IMPL),
1893 	MRS_HWCAP_END,
1894 };
1895 
1896 static const struct mrs_field_value id_aa64zfr0_f32mm[] = {
1897 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ZFR0, F32MM, NONE, IMPL),
1898 	MRS_FIELD_VALUE_END,
1899 };
1900 
1901 static const struct mrs_field_hwcap id_aa64zfr0_f32mm_caps[] = {
1902 	MRS_HWCAP(2, HWCAP2_SVEF32MM, ID_AA64ZFR0_F32MM_IMPL),
1903 	MRS_HWCAP_END,
1904 };
1905 
1906 static const struct mrs_field_value id_aa64zfr0_i8mm[] = {
1907 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ZFR0, I8MM, NONE, IMPL),
1908 	MRS_FIELD_VALUE_END,
1909 };
1910 
1911 static const struct mrs_field_hwcap id_aa64zfr0_i8mm_caps[] = {
1912 	MRS_HWCAP(2, HWCAP2_SVEI8MM, ID_AA64ZFR0_I8MM_IMPL),
1913 	MRS_HWCAP_END,
1914 };
1915 
1916 static const struct mrs_field_value id_aa64zfr0_sm4[] = {
1917 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ZFR0, SM4, NONE, IMPL),
1918 	MRS_FIELD_VALUE_END,
1919 };
1920 
1921 static const struct mrs_field_hwcap id_aa64zfr0_sm4_caps[] = {
1922 	MRS_HWCAP(2, HWCAP2_SVESM4, ID_AA64ZFR0_SM4_IMPL),
1923 	MRS_HWCAP_END,
1924 };
1925 
1926 static const struct mrs_field_value id_aa64zfr0_sha3[] = {
1927 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ZFR0, SHA3, NONE, IMPL),
1928 	MRS_FIELD_VALUE_END,
1929 };
1930 
1931 static const struct mrs_field_hwcap id_aa64zfr0_sha3_caps[] = {
1932 	MRS_HWCAP(2, HWCAP2_SVESHA3, ID_AA64ZFR0_SHA3_IMPL),
1933 	MRS_HWCAP_END,
1934 };
1935 
1936 static const struct mrs_field_value id_aa64zfr0_bf16[] = {
1937 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ZFR0, BF16, NONE, BASE),
1938 	MRS_FIELD_VALUE(ID_AA64ZFR0_BF16_EBF, "BF16+EBF"),
1939 	MRS_FIELD_VALUE_END,
1940 };
1941 
1942 static const struct mrs_field_hwcap id_aa64zfr0_bf16_caps[] = {
1943 	MRS_HWCAP(2, HWCAP2_SVEBF16, ID_AA64ZFR0_BF16_BASE),
1944 	MRS_HWCAP(2, HWCAP2_SVE_EBF16, ID_AA64ZFR0_BF16_EBF),
1945 	MRS_HWCAP_END,
1946 };
1947 
1948 static const struct mrs_field_value id_aa64zfr0_bitperm[] = {
1949 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ZFR0, BitPerm, NONE, IMPL),
1950 	MRS_FIELD_VALUE_END,
1951 };
1952 
1953 static const struct mrs_field_hwcap id_aa64zfr0_bitperm_caps[] = {
1954 	MRS_HWCAP(2, HWCAP2_SVEBITPERM, ID_AA64ZFR0_BitPerm_IMPL),
1955 	MRS_HWCAP_END,
1956 };
1957 
1958 static const struct mrs_field_value id_aa64zfr0_aes[] = {
1959 	MRS_FIELD_VALUE_NONE_IMPL(ID_AA64ZFR0, AES, NONE, BASE),
1960 	MRS_FIELD_VALUE(ID_AA64ZFR0_AES_PMULL, "AES+PMULL"),
1961 	MRS_FIELD_VALUE_END,
1962 };
1963 
1964 static const struct mrs_field_hwcap id_aa64zfr0_aes_caps[] = {
1965 	MRS_HWCAP(2, HWCAP2_SVEAES, ID_AA64ZFR0_AES_BASE),
1966 	MRS_HWCAP(2, HWCAP2_SVEPMULL, ID_AA64ZFR0_AES_PMULL),
1967 	MRS_HWCAP_END,
1968 };
1969 
1970 static const struct mrs_field_value id_aa64zfr0_svever[] = {
1971 	MRS_FIELD_VALUE(ID_AA64ZFR0_SVEver_SVE1, "SVE1"),
1972 	MRS_FIELD_VALUE(ID_AA64ZFR0_SVEver_SVE2, "SVE2"),
1973 	MRS_FIELD_VALUE(ID_AA64ZFR0_SVEver_SVE2P1, "SVE2P1"),
1974 	MRS_FIELD_VALUE_END,
1975 };
1976 
1977 static const struct mrs_field_hwcap id_aa64zfr0_svever_caps[] = {
1978 	MRS_HWCAP(2, HWCAP2_SVE2, ID_AA64ZFR0_SVEver_SVE2),
1979 	MRS_HWCAP(2, HWCAP2_SVE2P1, ID_AA64ZFR0_SVEver_SVE2P1),
1980 	MRS_HWCAP_END,
1981 };
1982 
1983 static const struct mrs_field id_aa64zfr0_fields[] = {
1984 	MRS_FIELD_HWCAP(ID_AA64ZFR0, F64MM, false, MRS_LOWER, MRS_USERSPACE,
1985 	    id_aa64zfr0_f64mm, id_aa64zfr0_f64mm_caps),
1986 	MRS_FIELD_HWCAP(ID_AA64ZFR0, F32MM, false, MRS_LOWER, MRS_USERSPACE,
1987 	    id_aa64zfr0_f32mm, id_aa64zfr0_f32mm_caps),
1988 	MRS_FIELD_HWCAP(ID_AA64ZFR0, I8MM, false, MRS_LOWER, MRS_USERSPACE,
1989 	    id_aa64zfr0_i8mm, id_aa64zfr0_i8mm_caps),
1990 	MRS_FIELD_HWCAP(ID_AA64ZFR0, SM4, false, MRS_LOWER, MRS_USERSPACE,
1991 	    id_aa64zfr0_sm4, id_aa64zfr0_sm4_caps),
1992 	MRS_FIELD_HWCAP(ID_AA64ZFR0, SHA3, false, MRS_LOWER, MRS_USERSPACE,
1993 	    id_aa64zfr0_sha3, id_aa64zfr0_sha3_caps),
1994 	MRS_FIELD_HWCAP(ID_AA64ZFR0, BF16, false, MRS_LOWER, MRS_USERSPACE,
1995 	    id_aa64zfr0_bf16, id_aa64zfr0_bf16_caps),
1996 	MRS_FIELD_HWCAP(ID_AA64ZFR0, BitPerm, false, MRS_LOWER, MRS_USERSPACE,
1997 	    id_aa64zfr0_bitperm, id_aa64zfr0_bitperm_caps),
1998 	MRS_FIELD_HWCAP(ID_AA64ZFR0, AES, false, MRS_LOWER, MRS_USERSPACE,
1999 	    id_aa64zfr0_aes, id_aa64zfr0_aes_caps),
2000 	MRS_FIELD_HWCAP(ID_AA64ZFR0, SVEver, false, MRS_LOWER, MRS_USERSPACE,
2001 	    id_aa64zfr0_svever, id_aa64zfr0_svever_caps),
2002 	MRS_FIELD_END,
2003 };
2004 
2005 
2006 #ifdef COMPAT_FREEBSD32
2007 /* ID_ISAR5_EL1 */
2008 static const struct mrs_field_value id_isar5_vcma[] = {
2009 	MRS_FIELD_VALUE_NONE_IMPL(ID_ISAR5, VCMA, NONE, IMPL),
2010 	MRS_FIELD_VALUE_END,
2011 };
2012 
2013 static const struct mrs_field_value id_isar5_rdm[] = {
2014 	MRS_FIELD_VALUE_NONE_IMPL(ID_ISAR5, RDM, NONE, IMPL),
2015 	MRS_FIELD_VALUE_END,
2016 };
2017 
2018 static const struct mrs_field_value id_isar5_crc32[] = {
2019 	MRS_FIELD_VALUE_NONE_IMPL(ID_ISAR5, CRC32, NONE, IMPL),
2020 	MRS_FIELD_VALUE_END,
2021 };
2022 
2023 static const struct mrs_field_hwcap id_isar5_crc32_caps[] = {
2024 	MRS_HWCAP(2, HWCAP32_2_CRC32, ID_ISAR5_CRC32_IMPL),
2025 	MRS_HWCAP_END
2026 };
2027 
2028 static const struct mrs_field_value id_isar5_sha2[] = {
2029 	MRS_FIELD_VALUE_NONE_IMPL(ID_ISAR5, SHA2, NONE, IMPL),
2030 	MRS_FIELD_VALUE_END,
2031 };
2032 
2033 static const struct mrs_field_hwcap id_isar5_sha2_caps[] = {
2034 	MRS_HWCAP(2, HWCAP32_2_SHA2, ID_ISAR5_SHA2_IMPL),
2035 	MRS_HWCAP_END
2036 };
2037 
2038 static const struct mrs_field_value id_isar5_sha1[] = {
2039 	MRS_FIELD_VALUE_NONE_IMPL(ID_ISAR5, SHA1, NONE, IMPL),
2040 	MRS_FIELD_VALUE_END,
2041 };
2042 
2043 static const struct mrs_field_hwcap id_isar5_sha1_caps[] = {
2044 	MRS_HWCAP(2, HWCAP32_2_SHA1, ID_ISAR5_SHA1_IMPL),
2045 	MRS_HWCAP_END
2046 };
2047 
2048 static const struct mrs_field_value id_isar5_aes[] = {
2049 	MRS_FIELD_VALUE_NONE_IMPL(ID_ISAR5, AES, NONE, BASE),
2050 	MRS_FIELD_VALUE(ID_ISAR5_AES_VMULL, "AES+VMULL"),
2051 	MRS_FIELD_VALUE_END,
2052 };
2053 
2054 static const struct mrs_field_hwcap id_isar5_aes_caps[] = {
2055 	MRS_HWCAP(2, HWCAP32_2_AES, ID_ISAR5_AES_BASE),
2056 	MRS_HWCAP(2, HWCAP32_2_PMULL, ID_ISAR5_AES_VMULL),
2057 	MRS_HWCAP_END
2058 };
2059 
2060 static const struct mrs_field_value id_isar5_sevl[] = {
2061 	MRS_FIELD_VALUE_NONE_IMPL(ID_ISAR5, SEVL, NOP, IMPL),
2062 	MRS_FIELD_VALUE_END,
2063 };
2064 
2065 static const struct mrs_field id_isar5_fields[] = {
2066 	MRS_FIELD(ID_ISAR5, VCMA, false, MRS_LOWER,MRS_USERSPACE,
2067 	    id_isar5_vcma),
2068 	MRS_FIELD(ID_ISAR5, RDM, false, MRS_LOWER, MRS_USERSPACE, id_isar5_rdm),
2069 	MRS_FIELD_HWCAP(ID_ISAR5, CRC32, false, MRS_LOWER, MRS_USERSPACE,
2070 	    id_isar5_crc32, id_isar5_crc32_caps),
2071 	MRS_FIELD_HWCAP(ID_ISAR5, SHA2, false, MRS_LOWER, MRS_USERSPACE,
2072 	    id_isar5_sha2, id_isar5_sha2_caps),
2073 	MRS_FIELD_HWCAP(ID_ISAR5, SHA1, false, MRS_LOWER, MRS_USERSPACE,
2074 	    id_isar5_sha1, id_isar5_sha1_caps),
2075 	MRS_FIELD_HWCAP(ID_ISAR5, AES, false, MRS_LOWER, MRS_USERSPACE,
2076 	    id_isar5_aes, id_isar5_aes_caps),
2077 	MRS_FIELD(ID_ISAR5, SEVL, false, MRS_LOWER, MRS_USERSPACE,
2078 	    id_isar5_sevl),
2079 	MRS_FIELD_END,
2080 };
2081 
2082 /* MVFR0 */
2083 static const struct mrs_field_value mvfr0_fpround[] = {
2084 	MRS_FIELD_VALUE_NONE_IMPL(MVFR0, FPRound, NONE, IMPL),
2085 	MRS_FIELD_VALUE_END,
2086 };
2087 
2088 static const struct mrs_field_value mvfr0_fpsqrt[] = {
2089 	MRS_FIELD_VALUE_NONE_IMPL(MVFR0, FPSqrt, NONE, IMPL),
2090 	MRS_FIELD_VALUE_END,
2091 };
2092 
2093 static const struct mrs_field_value mvfr0_fpdivide[] = {
2094 	MRS_FIELD_VALUE_NONE_IMPL(MVFR0, FPDivide, NONE, IMPL),
2095 	MRS_FIELD_VALUE_END,
2096 };
2097 
2098 static const struct mrs_field_value mvfr0_fptrap[] = {
2099 	MRS_FIELD_VALUE_NONE_IMPL(MVFR0, FPTrap, NONE, IMPL),
2100 	MRS_FIELD_VALUE_END,
2101 };
2102 
2103 static const struct mrs_field_value mvfr0_fpdp[] = {
2104 	MRS_FIELD_VALUE(MVFR0_FPDP_NONE, ""),
2105 	MRS_FIELD_VALUE(MVFR0_FPDP_VFP_v2, "DP VFPv2"),
2106 	MRS_FIELD_VALUE(MVFR0_FPDP_VFP_v3_v4, "DP VFPv3+v4"),
2107 	MRS_FIELD_VALUE_END,
2108 };
2109 
2110 static const struct mrs_field_hwcap mvfr0_fpdp_caps[] = {
2111 	MRS_HWCAP(1, HWCAP32_VFP, MVFR0_FPDP_VFP_v2),
2112 	MRS_HWCAP(1, HWCAP32_VFPv3, MVFR0_FPDP_VFP_v3_v4),
2113 	MRS_HWCAP_END
2114 };
2115 
2116 static const struct mrs_field_value mvfr0_fpsp[] = {
2117 	MRS_FIELD_VALUE(MVFR0_FPSP_NONE, ""),
2118 	MRS_FIELD_VALUE(MVFR0_FPSP_VFP_v2, "SP VFPv2"),
2119 	MRS_FIELD_VALUE(MVFR0_FPSP_VFP_v3_v4, "SP VFPv3+v4"),
2120 	MRS_FIELD_VALUE_END,
2121 };
2122 
2123 static const struct mrs_field_value mvfr0_simdreg[] = {
2124 	MRS_FIELD_VALUE(MVFR0_SIMDReg_NONE, ""),
2125 	MRS_FIELD_VALUE(MVFR0_SIMDReg_FP, "FP 16x64"),
2126 	MRS_FIELD_VALUE(MVFR0_SIMDReg_AdvSIMD, "AdvSIMD"),
2127 	MRS_FIELD_VALUE_END,
2128 };
2129 
2130 static const struct mrs_field mvfr0_fields[] = {
2131 	MRS_FIELD(MVFR0, FPRound, false, MRS_LOWER, MRS_USERSPACE,
2132 	    mvfr0_fpround),
2133 	MRS_FIELD(MVFR0, FPSqrt, false, MRS_LOWER, MRS_USERSPACE,
2134 	    mvfr0_fpsqrt),
2135 	MRS_FIELD(MVFR0, FPDivide, false, MRS_LOWER, MRS_USERSPACE,
2136 	    mvfr0_fpdivide),
2137 	MRS_FIELD(MVFR0, FPTrap, false, MRS_LOWER, MRS_USERSPACE,
2138 	    mvfr0_fptrap),
2139 	MRS_FIELD_HWCAP(MVFR0, FPDP, false, MRS_LOWER, MRS_USERSPACE,
2140 	    mvfr0_fpdp, mvfr0_fpdp_caps),
2141 	MRS_FIELD(MVFR0, FPSP, false, MRS_LOWER, MRS_USERSPACE, mvfr0_fpsp),
2142 	MRS_FIELD(MVFR0, SIMDReg, false, MRS_LOWER, MRS_USERSPACE,
2143 	    mvfr0_simdreg),
2144 	MRS_FIELD_END,
2145 };
2146 
2147 /* MVFR1 */
2148 static const struct mrs_field_value mvfr1_simdfmac[] = {
2149 	MRS_FIELD_VALUE_NONE_IMPL(MVFR1, SIMDFMAC, NONE, IMPL),
2150 	MRS_FIELD_VALUE_END,
2151 };
2152 
2153 static const struct mrs_field_hwcap mvfr1_simdfmac_caps[] = {
2154 	MRS_HWCAP(1, HWCAP32_VFPv4, MVFR1_SIMDFMAC_IMPL),
2155 	MRS_HWCAP_END
2156 };
2157 
2158 static const struct mrs_field_value mvfr1_fphp[] = {
2159 	MRS_FIELD_VALUE(MVFR1_FPHP_NONE, ""),
2160 	MRS_FIELD_VALUE(MVFR1_FPHP_CONV_SP, "FPHP SP Conv"),
2161 	MRS_FIELD_VALUE(MVFR1_FPHP_CONV_DP, "FPHP DP Conv"),
2162 	MRS_FIELD_VALUE(MVFR1_FPHP_ARITH, "FPHP Arith"),
2163 	MRS_FIELD_VALUE_END,
2164 };
2165 
2166 static const struct mrs_field_value mvfr1_simdhp[] = {
2167 	MRS_FIELD_VALUE(MVFR1_SIMDHP_NONE, ""),
2168 	MRS_FIELD_VALUE(MVFR1_SIMDHP_CONV_SP, "SIMDHP SP Conv"),
2169 	MRS_FIELD_VALUE(MVFR1_SIMDHP_ARITH, "SIMDHP Arith"),
2170 	MRS_FIELD_VALUE_END,
2171 };
2172 
2173 static const struct mrs_field_value mvfr1_simdsp[] = {
2174 	MRS_FIELD_VALUE_NONE_IMPL(MVFR1, SIMDSP, NONE, IMPL),
2175 	MRS_FIELD_VALUE_END,
2176 };
2177 
2178 static const struct mrs_field_value mvfr1_simdint[] = {
2179 	MRS_FIELD_VALUE_NONE_IMPL(MVFR1, SIMDInt, NONE, IMPL),
2180 	MRS_FIELD_VALUE_END,
2181 };
2182 
2183 static const struct mrs_field_value mvfr1_simdls[] = {
2184 	MRS_FIELD_VALUE_NONE_IMPL(MVFR1, SIMDLS, NONE, IMPL),
2185 	MRS_FIELD_VALUE_END,
2186 };
2187 
2188 static const struct mrs_field_hwcap mvfr1_simdls_caps[] = {
2189 	MRS_HWCAP(1, HWCAP32_VFPv4, MVFR1_SIMDFMAC_IMPL),
2190 	MRS_HWCAP_END
2191 };
2192 
2193 static const struct mrs_field_value mvfr1_fpdnan[] = {
2194 	MRS_FIELD_VALUE_NONE_IMPL(MVFR1, FPDNaN, NONE, IMPL),
2195 	MRS_FIELD_VALUE_END,
2196 };
2197 
2198 static const struct mrs_field_value mvfr1_fpftz[] = {
2199 	MRS_FIELD_VALUE_NONE_IMPL(MVFR1, FPFtZ, NONE, IMPL),
2200 	MRS_FIELD_VALUE_END,
2201 };
2202 
2203 static const struct mrs_field mvfr1_fields[] = {
2204 	MRS_FIELD_HWCAP(MVFR1, SIMDFMAC, false, MRS_LOWER, MRS_USERSPACE,
2205 	    mvfr1_simdfmac, mvfr1_simdfmac_caps),
2206 	MRS_FIELD(MVFR1, FPHP, false, MRS_LOWER, MRS_USERSPACE, mvfr1_fphp),
2207 	MRS_FIELD(MVFR1, SIMDHP, false, MRS_LOWER, MRS_USERSPACE, mvfr1_simdhp),
2208 	MRS_FIELD(MVFR1, SIMDSP, false, MRS_LOWER, MRS_USERSPACE, mvfr1_simdsp),
2209 	MRS_FIELD(MVFR1, SIMDInt, false, MRS_LOWER, MRS_USERSPACE,
2210 	    mvfr1_simdint),
2211 	MRS_FIELD_HWCAP(MVFR1, SIMDLS, false, MRS_LOWER, MRS_USERSPACE,
2212 	    mvfr1_simdls, mvfr1_simdls_caps),
2213 	MRS_FIELD(MVFR1, FPDNaN, false, MRS_LOWER, MRS_USERSPACE,
2214 	    mvfr1_fpdnan),
2215 	MRS_FIELD(MVFR1, FPFtZ, false, MRS_LOWER, MRS_USERSPACE,
2216 	    mvfr1_fpftz),
2217 	MRS_FIELD_END,
2218 };
2219 #endif /* COMPAT_FREEBSD32 */
2220 
2221 struct mrs_user_reg {
2222 	u_int		iss;
2223 	bool		is64bit;
2224 	size_t		offset;
2225 	const struct mrs_field *fields;
2226 };
2227 
2228 #define	USER_REG(name, field_name, _is64bit)				\
2229 	{								\
2230 		.iss = name##_ISS,					\
2231 		.offset = __offsetof(struct cpu_desc, field_name),	\
2232 		.fields = field_name##_fields,				\
2233 		.is64bit = _is64bit,					\
2234 	}
2235 static const struct mrs_user_reg user_regs[] = {
2236 	USER_REG(ID_AA64AFR0_EL1, id_aa64afr0, true),
2237 	USER_REG(ID_AA64AFR1_EL1, id_aa64afr1, true),
2238 
2239 	USER_REG(ID_AA64DFR0_EL1, id_aa64dfr0, true),
2240 	USER_REG(ID_AA64DFR1_EL1, id_aa64dfr1, true),
2241 
2242 	USER_REG(ID_AA64ISAR0_EL1, id_aa64isar0, true),
2243 	USER_REG(ID_AA64ISAR1_EL1, id_aa64isar1, true),
2244 	USER_REG(ID_AA64ISAR2_EL1, id_aa64isar2, true),
2245 
2246 	USER_REG(ID_AA64MMFR0_EL1, id_aa64mmfr0, true),
2247 	USER_REG(ID_AA64MMFR1_EL1, id_aa64mmfr1, true),
2248 	USER_REG(ID_AA64MMFR2_EL1, id_aa64mmfr2, true),
2249 	USER_REG(ID_AA64MMFR3_EL1, id_aa64mmfr3, true),
2250 	USER_REG(ID_AA64MMFR4_EL1, id_aa64mmfr4, true),
2251 
2252 	USER_REG(ID_AA64PFR0_EL1, id_aa64pfr0, true),
2253 	USER_REG(ID_AA64PFR1_EL1, id_aa64pfr1, true),
2254 	USER_REG(ID_AA64PFR2_EL1, id_aa64pfr2, true),
2255 
2256 	USER_REG(ID_AA64ZFR0_EL1, id_aa64zfr0, true),
2257 
2258 	USER_REG(CTR_EL0, ctr, true),
2259 
2260 #ifdef COMPAT_FREEBSD32
2261 	USER_REG(ID_ISAR5_EL1, id_isar5, false),
2262 
2263 	USER_REG(MVFR0_EL1, mvfr0, false),
2264 	USER_REG(MVFR1_EL1, mvfr1, false),
2265 #endif /* COMPAT_FREEBSD32 */
2266 };
2267 
2268 #define	CPU_DESC_FIELD(desc, idx)					\
2269     *(uint64_t *)((char *)&(desc) + user_regs[(idx)].offset)
2270 
2271 static bool
user_ctr_has_neoverse_n1_1542419(uint32_t midr,uint64_t ctr)2272 user_ctr_has_neoverse_n1_1542419(uint32_t midr, uint64_t ctr)
2273 {
2274 	/* Skip non-Neoverse-N1 */
2275 	if (!CPU_MATCH(CPU_IMPL_MASK | CPU_PART_MASK, CPU_IMPL_ARM,
2276 	    CPU_PART_NEOVERSE_N1, 0, 0))
2277 		return (false);
2278 
2279 	switch (CPU_VAR(midr)) {
2280 	default:
2281 		break;
2282 	case 4:
2283 		/* Fixed in r4p1 */
2284 		if (CPU_REV(midr) > 0)
2285 			break;
2286 		/* FALLTHROUGH */
2287 	case 3:
2288 		/* If DIC is enabled (coherent icache) then we are affected */
2289 		return (CTR_DIC_VAL(ctr) != 0);
2290 	}
2291 
2292 	return (false);
2293 }
2294 
2295 static bool
user_ctr_check(const struct cpu_feat * feat __unused,u_int midr __unused)2296 user_ctr_check(const struct cpu_feat *feat __unused, u_int midr __unused)
2297 {
2298 	if (emulate_ctr)
2299 		return (true);
2300 
2301 	if (user_ctr_has_neoverse_n1_1542419(midr, READ_SPECIALREG(ctr_el0)))
2302 		return (true);
2303 
2304 	return (false);
2305 }
2306 
2307 static bool
user_ctr_has_errata(const struct cpu_feat * feat __unused,u_int midr,u_int ** errata_list,u_int * errata_count)2308 user_ctr_has_errata(const struct cpu_feat *feat __unused, u_int midr,
2309     u_int **errata_list, u_int *errata_count)
2310 {
2311 	if (user_ctr_has_neoverse_n1_1542419(midr, READ_SPECIALREG(ctr_el0))) {
2312 		static u_int errata_id = 1542419;
2313 
2314 		*errata_list = &errata_id;
2315 		*errata_count = 1;
2316 		return (true);
2317 	}
2318 
2319 	return (false);
2320 }
2321 
2322 static void
user_ctr_enable(const struct cpu_feat * feat __unused,cpu_feat_errata errata_status,u_int * errata_list,u_int errata_count)2323 user_ctr_enable(const struct cpu_feat *feat __unused,
2324     cpu_feat_errata errata_status, u_int *errata_list, u_int errata_count)
2325 {
2326 	MPASS(emulate_ctr || errata_status != ERRATA_NONE);
2327 
2328 	/*
2329 	 * The Errata Management Firmware Interface may incorrectly mark
2330 	 * this as firmware mitigated. We should ignore that as there is
2331 	 * a kernel component to the mitigation.
2332 	 */
2333 	if (errata_status != ERRATA_NONE && PCPU_GET(cpuid) == 0 &&
2334 	    cpu_feat_has_erratum(errata_list, errata_count, 1542419)) {
2335 		/* Clear fields we will change */
2336 		user_cpu_desc.ctr &= ~(CTR_DIC_MASK | CTR_ILINE_WIDTH);
2337 
2338 		/*
2339 		 * Set DIC to none so userspace will execute an 'ic ivau'
2340 		 * instruction that can be trapped by EL3.
2341 		 */
2342 		user_cpu_desc.ctr |= CTR_DIC_NONE;
2343 		/*
2344 		 * Set the i-cache line size to be page size to reduce the
2345 		 * number of times userspace needs to execute the 'ic ivau'
2346 		 * instruction. The ctr_el0.IminLine is log2 the number of
2347 		 * 4-byte words the instruction covers. As PAGE_SHIFT is log2
2348 		 * of the number of bytes in a page we need to subtract 2.
2349 		 */
2350 		user_cpu_desc.ctr |= (PAGE_SHIFT - 2) << CTR_ILINE_SHIFT;
2351 
2352 		l_user_cpu_desc.ctr = user_cpu_desc.ctr;
2353 	}
2354 
2355 	WRITE_SPECIALREG(sctlr_el1,
2356 	    READ_SPECIALREG(sctlr_el1) & ~SCTLR_UCT);
2357 	isb();
2358 }
2359 
2360 static struct cpu_feat user_ctr = {
2361 	.feat_name		= "Trap CTR_EL0",
2362 	.feat_check		= user_ctr_check,
2363 	.feat_has_errata	= user_ctr_has_errata,
2364 	.feat_enable		= user_ctr_enable,
2365 	.feat_flags		= CPU_FEAT_AFTER_DEV | CPU_FEAT_PER_CPU,
2366 };
2367 DATA_SET(cpu_feat_set, user_ctr);
2368 
2369 static bool
user_ctr_handler(uint64_t esr,struct trapframe * frame)2370 user_ctr_handler(uint64_t esr, struct trapframe *frame)
2371 {
2372 	uint64_t value;
2373 	int reg;
2374 
2375 	if (ESR_ELx_EXCEPTION(esr) != EXCP_MSR)
2376 		return (false);
2377 
2378 	/* Only support reading from ctr_el0 */
2379 	if ((esr & ISS_MSR_DIR) == 0)
2380 		return (false);
2381 
2382 	/* Check if this is the ctr_el0 register */
2383 	if ((esr & ISS_MSR_REG_MASK) != CTR_EL0_ISS)
2384 		return (false);
2385 
2386 	if (SV_CURPROC_ABI() == SV_ABI_FREEBSD)
2387 		value = user_cpu_desc.ctr;
2388 	else
2389 		value = l_user_cpu_desc.ctr;
2390 	/*
2391 	 * We will handle this instruction, move to the next so we
2392 	 * don't trap here again.
2393 	 */
2394 	frame->tf_elr += INSN_SIZE;
2395 
2396 	reg = ISS_MSR_Rt(esr);
2397 	/* If reg is 31 then write to xzr, i.e. do nothing */
2398 	if (reg == 31)
2399 		return (true);
2400 
2401 	if (reg < nitems(frame->tf_x))
2402 		frame->tf_x[reg] = value;
2403 	else if (reg == 30)
2404 		frame->tf_lr = value;
2405 
2406 	return (true);
2407 }
2408 
2409 static bool
user_idreg_handler(uint64_t esr,struct trapframe * frame)2410 user_idreg_handler(uint64_t esr, struct trapframe *frame)
2411 {
2412 	uint64_t value;
2413 	int reg;
2414 
2415 	if (ESR_ELx_EXCEPTION(esr) != EXCP_MSR)
2416 		return (false);
2417 
2418 	/* Only support reading from ID registers */
2419 	if ((esr & ISS_MSR_DIR) == 0)
2420 		return (false);
2421 
2422 	/*
2423 	 * This only handles the ID register space and a few registers that
2424 	 * are safe to pass through to userspace.
2425 	 *
2426 	 * These registers are all in the space op0 == 3, op1 == 0,
2427 	 * CRn == 0. We support the following CRm:
2428 	 *  - CRm == 0: midr_el1, mpidr_el1, and revidr_el1.
2429 	 *  - CRm in {4-7}: sanitized ID registers.
2430 	 *
2431 	 * Registers in the ID register space (CRm in {4-7}) are all
2432 	 * read-only and have either defined fields, or are read as
2433 	 * zero (RAZ). For these we return 0 for any unknown register.
2434 	 */
2435 	if (ISS_MSR_OP0(esr) != 3 || ISS_MSR_OP1(esr) != 0 ||
2436 	    ISS_MSR_CRn(esr) != 0)
2437 		return (false);
2438 
2439 	value = 0;
2440 	if (ISS_MSR_CRm(esr) >= 4 && ISS_MSR_CRm(esr) <= 7) {
2441 		for (int i = 0; i < nitems(user_regs); i++) {
2442 			if (user_regs[i].iss == (esr & ISS_MSR_REG_MASK)) {
2443 				if (SV_CURPROC_ABI() == SV_ABI_FREEBSD)
2444 					value = CPU_DESC_FIELD(user_cpu_desc, i);
2445 				else
2446 					value = CPU_DESC_FIELD(l_user_cpu_desc, i);
2447 				break;
2448 			}
2449 		}
2450 	} else if (ISS_MSR_CRm(esr) == 0) {
2451 		switch (ISS_MSR_OP2(esr)) {
2452 		case 0:
2453 			value = READ_SPECIALREG(midr_el1);
2454 			break;
2455 		case 5:
2456 			value = READ_SPECIALREG(mpidr_el1);
2457 			break;
2458 		case 6:
2459 			value = READ_SPECIALREG(revidr_el1);
2460 			break;
2461 		default:
2462 			return (false);
2463 		}
2464 	} else {
2465 		return (false);
2466 	}
2467 
2468 	/*
2469 	 * We will handle this instruction, move to the next so we
2470 	 * don't trap here again.
2471 	 */
2472 	frame->tf_elr += INSN_SIZE;
2473 
2474 	reg = ISS_MSR_Rt(esr);
2475 	/* If reg is 31 then write to xzr, i.e. do nothing */
2476 	if (reg == 31)
2477 		return (1);
2478 
2479 	if (reg < nitems(frame->tf_x))
2480 		frame->tf_x[reg] = value;
2481 	else if (reg == 30)
2482 		frame->tf_lr = value;
2483 
2484 	return (true);
2485 }
2486 
2487 /*
2488  * Compares two field values that may be signed or unsigned.
2489  * Returns:
2490  *  < 0 when a is less than b
2491  *  = 0 when a equals b
2492  *  > 0 when a is greater than b
2493  */
2494 static int
mrs_field_cmp(uint64_t a,uint64_t b,u_int shift,int width,bool sign)2495 mrs_field_cmp(uint64_t a, uint64_t b, u_int shift, int width, bool sign)
2496 {
2497 	uint64_t mask;
2498 
2499 	KASSERT(width > 0 && width < 64, ("%s: Invalid width %d", __func__,
2500 	    width));
2501 
2502 	mask = (1ul << width) - 1;
2503 	/* Move the field to the lower bits */
2504 	a = (a >> shift) & mask;
2505 	b = (b >> shift) & mask;
2506 
2507 	if (sign) {
2508 		/*
2509 		 * The field is signed. Toggle the upper bit so the comparison
2510 		 * works on unsigned values as this makes positive numbers,
2511 		 * i.e. those with a 0 bit, larger than negative numbers,
2512 		 * i.e. those with a 1 bit, in an unsigned comparison.
2513 		 */
2514 		a ^= 1ul << (width - 1);
2515 		b ^= 1ul << (width - 1);
2516 	}
2517 
2518 	return (a - b);
2519 }
2520 
2521 bool
get_kernel_reg_iss(u_int iss,uint64_t * val)2522 get_kernel_reg_iss(u_int iss, uint64_t *val)
2523 {
2524 	int i;
2525 
2526 	for (i = 0; i < nitems(user_regs); i++) {
2527 		if (user_regs[i].iss == iss) {
2528 			*val = CPU_DESC_FIELD(kern_cpu_desc, i);
2529 			return (true);
2530 		}
2531 	}
2532 
2533 	return (false);
2534 }
2535 
2536 /*
2537  * Fetch the specified register's value, ensuring that individual field values
2538  * do not exceed those in the mask.
2539  */
2540 bool
get_kernel_reg_iss_masked(u_int iss,uint64_t * valp,uint64_t mask)2541 get_kernel_reg_iss_masked(u_int iss, uint64_t *valp, uint64_t mask)
2542 {
2543 	const struct mrs_field *fields;
2544 	uint64_t val;
2545 
2546 	for (int i = 0; i < nitems(user_regs); i++) {
2547 		if (user_regs[i].iss == iss) {
2548 			val = CPU_DESC_FIELD(kern_cpu_desc, i);
2549 			fields = user_regs[i].fields;
2550 			for (int j = 0; fields[j].type != 0; j++) {
2551 				mask = update_special_reg_field(mask,
2552 				    fields[j].type, val, fields[j].width,
2553 				    fields[j].shift, fields[j].sign);
2554 			}
2555 			*valp = mask;
2556 			return (true);
2557 		}
2558 	}
2559 
2560 	return (false);
2561 }
2562 
2563 bool
get_user_reg_iss(u_int iss,uint64_t * val,bool fbsd)2564 get_user_reg_iss(u_int iss, uint64_t *val, bool fbsd)
2565 {
2566 	int i;
2567 
2568 	for (i = 0; i < nitems(user_regs); i++) {
2569 		if (user_regs[i].iss == iss) {
2570 			if (fbsd)
2571 				*val = CPU_DESC_FIELD(user_cpu_desc, i);
2572 			else
2573 				*val = CPU_DESC_FIELD(l_user_cpu_desc, i);
2574 			return (true);
2575 		}
2576 	}
2577 
2578 	return (false);
2579 }
2580 
2581 static uint64_t
update_special_reg_field(uint64_t user_reg,u_int type,uint64_t value,u_int width,u_int shift,bool sign)2582 update_special_reg_field(uint64_t user_reg, u_int type, uint64_t value,
2583     u_int width, u_int shift, bool sign)
2584 {
2585 	uint64_t cur, mask, new_val;
2586 
2587 	mask = ((1ul << width) - 1) << shift;
2588 	cur = user_reg & mask;
2589 	new_val = value & mask;
2590 
2591 	switch (type & MRS_TYPE_MASK) {
2592 	case MRS_EXACT_IF_DIFFERENT:
2593 		if (mrs_field_cmp(new_val, cur, shift, width, sign) == 0)
2594 			break;
2595 		/* FALLTHROUGH */
2596 	case MRS_EXACT:
2597 		cur = (uint64_t)MRS_SAFE_VAL(type) << shift;
2598 		break;
2599 	case MRS_LOWER:
2600 		if (mrs_field_cmp(new_val, cur, shift, width, sign) < 0)
2601 			cur = new_val;
2602 		break;
2603 	case MRS_HIGHER_OR_ZERO:
2604 		if (cur == 0 || new_val == 0) {
2605 			cur = 0;
2606 			break;
2607 		}
2608 		/* FALLTHROUGH */
2609 	case MRS_HIGHER:
2610 		if (mrs_field_cmp(new_val, cur, shift, width, sign) > 0)
2611 			cur = new_val;
2612 		break;
2613 	default:
2614 		panic("Invalid field type: %d", type);
2615 	}
2616 
2617 	user_reg &= ~mask;
2618 	user_reg |= cur;
2619 
2620 	return (user_reg);
2621 }
2622 
2623 static void
clear_set_special_reg_idx(int idx,uint64_t clear,uint64_t set)2624 clear_set_special_reg_idx(int idx, uint64_t clear, uint64_t set)
2625 {
2626 	const struct mrs_field *fields;
2627 	uint64_t k_old, k_new;
2628 	uint64_t f_old, f_new;
2629 	uint64_t l_old, l_new;
2630 
2631 	MPASS(idx < nitems(user_regs));
2632 
2633 	k_old = CPU_DESC_FIELD(kern_cpu_desc, idx);
2634 	k_new = (k_old & ~clear) | set;
2635 
2636 	f_old = CPU_DESC_FIELD(user_cpu_desc, idx);
2637 	f_new = (f_old & ~clear) | set;
2638 
2639 	l_old = CPU_DESC_FIELD(l_user_cpu_desc, idx);
2640 	l_new = (l_old & ~clear) | set;
2641 
2642 	fields = user_regs[idx].fields;
2643 	for (int j = 0; fields[j].type != 0; j++) {
2644 		u_int type;
2645 
2646 		/* Update the FreeBSD userspace ID register view */
2647 		type = ((fields[j].type & MRS_FREEBSD) != 0) ?
2648 		    fields[j].type :
2649 		    (MRS_EXACT | (fields[j].type & MRS_SAFE_MASK));
2650 		f_new = update_special_reg_field(f_new,
2651 		    type, f_old, fields[j].width, fields[j].shift,
2652 		    fields[j].sign);
2653 
2654 		/* Update the Linux userspace ID register view */
2655 		type = ((fields[j].type & MRS_LINUX) != 0) ?
2656 		    fields[j].type :
2657 		    (MRS_EXACT | (fields[j].type & MRS_SAFE_MASK));
2658 		l_new = update_special_reg_field(l_new,
2659 		    type, l_old, fields[j].width, fields[j].shift,
2660 		    fields[j].sign);
2661 
2662 		/* Update the kernel ID register view */
2663 		k_new = update_special_reg_field(k_new,
2664 		    fields[j].type, k_old, fields[j].width,
2665 		    fields[j].shift, fields[j].sign);
2666 	}
2667 
2668 	CPU_DESC_FIELD(kern_cpu_desc, idx) = k_new;
2669 	CPU_DESC_FIELD(user_cpu_desc, idx) = f_new;
2670 	CPU_DESC_FIELD(l_user_cpu_desc, idx) = l_new;
2671 }
2672 
2673 void
update_special_regs(u_int cpu)2674 update_special_regs(u_int cpu)
2675 {
2676 	struct cpu_desc *desc;
2677 	uint64_t value;
2678 	int i;
2679 
2680 	if (cpu == 0) {
2681 		/* Create a user visible cpu description with safe values */
2682 		memset(&user_cpu_desc, 0, sizeof(user_cpu_desc));
2683 		/* Safe values for these registers */
2684 		user_cpu_desc.id_aa64pfr0 = ID_AA64PFR0_AdvSIMD_NONE |
2685 		    ID_AA64PFR0_FP_NONE | ID_AA64PFR0_EL1_64 |
2686 		    ID_AA64PFR0_EL0_64;
2687 		user_cpu_desc.id_aa64dfr0 = ID_AA64DFR0_DebugVer_8;
2688 		/* Create the Linux user visible cpu description */
2689 		memcpy(&l_user_cpu_desc, &user_cpu_desc, sizeof(user_cpu_desc));
2690 	}
2691 
2692 	desc = get_cpu_desc(cpu);
2693 	for (i = 0; i < nitems(user_regs); i++) {
2694 		value = CPU_DESC_FIELD(*desc, i);
2695 		if (cpu == 0) {
2696 			CPU_DESC_FIELD(kern_cpu_desc, i) = value;
2697 			CPU_DESC_FIELD(user_cpu_desc, i) = value;
2698 			CPU_DESC_FIELD(l_user_cpu_desc, i) = value;
2699 		}
2700 
2701 		clear_set_special_reg_idx(i, UINT64_MAX, value);
2702 	}
2703 }
2704 
2705 /*
2706  * Updates a special register in all views. This creates a copy of the
2707  * register then clears it and sets new bits. It will then compare this
2708  * with the old version as if it was the ID register for a new CPU.
2709  *
2710  * It is intended to let code that disables features, e.g. due to errata,
2711  * to clear the user visible field.
2712  *
2713  * This needs to be called before the HWCAPs are set. If called from a CPU
2714  * feature handler this safe to call from CPU_FEAT_EARLY_BOOT. It also needs
2715  * to be before link_elf_late_ireloc is called. As this is called after the
2716  * HWCAPs are set the check for these is enough.
2717  */
2718 void
update_special_reg_iss(u_int iss,uint64_t clear,uint64_t set)2719 update_special_reg_iss(u_int iss, uint64_t clear, uint64_t set)
2720 {
2721 	MPASS(hwcaps_set == false);
2722 	/* There is no locking here, so we only support changing this on CPU0 */
2723 	/* TODO: Add said locking */
2724 	MPASS(PCPU_GET(cpuid) == 0);
2725 
2726 	for (int i = 0; i < nitems(user_regs); i++) {
2727 		if (user_regs[i].iss != iss)
2728 			continue;
2729 
2730 		clear_set_special_reg_idx(i, clear, set);
2731 		return;
2732 	}
2733 }
2734 
2735 void
cpu_desc_init(void)2736 cpu_desc_init(void)
2737 {
2738 	if (mp_ncpus == 1)
2739 		return;
2740 
2741 	/*
2742 	 * Allocate memory for the non-boot CPUs to store their registers.
2743 	 * As this is indexed by CPU ID we need to allocate space for CPUs
2744 	 * 1 to mp_maxid. Because of this mp_maxid is already the correct
2745 	 * number of elements.
2746 	 */
2747 	cpu_desc = mallocarray(mp_maxid, sizeof(*cpu_desc), M_IDENTCPU,
2748 	    M_ZERO | M_WAITOK);
2749 }
2750 
2751 /* HWCAP */
2752 bool __read_frequently lse_supported = false;
2753 
2754 bool __read_frequently icache_aliasing = false;
2755 bool __read_frequently icache_vmid = false;
2756 
2757 int64_t dcache_line_size;	/* The minimum D cache line size */
2758 int64_t icache_line_size;	/* The minimum I cache line size */
2759 int64_t idcache_line_size;	/* The minimum cache line size */
2760 
2761 /*
2762  * Find the values to export to userspace as AT_HWCAP and AT_HWCAP2.
2763  */
2764 static void
parse_cpu_features(bool is64bit,struct cpu_desc * cpu_desc,u_long * hwcap,u_long * hwcap2)2765 parse_cpu_features(bool is64bit, struct cpu_desc *cpu_desc, u_long *hwcap,
2766     u_long *hwcap2)
2767 {
2768 	const struct mrs_field_hwcap *hwcaps;
2769 	const struct mrs_field *fields;
2770 	uint64_t min, reg;
2771 	u_long *cur_hwcap;
2772 	int i, j, k;
2773 
2774 	for (i = 0; i < nitems(user_regs); i++) {
2775 		if (user_regs[i].is64bit != is64bit)
2776 			continue;
2777 
2778 		reg = CPU_DESC_FIELD(*cpu_desc, i);
2779 		fields = user_regs[i].fields;
2780 		for (j = 0; fields[j].type != 0; j++) {
2781 			hwcaps = fields[j].hwcaps;
2782 			if (hwcaps == NULL)
2783 				continue;
2784 
2785 			for (k = 0; hwcaps[k].hwcap_id != 0; k++) {
2786 				KASSERT(hwcaps[k].hwcap_id == 1 ||
2787 				    hwcaps[k].hwcap_id == 2,
2788 				    ("%s: Invalid HWCAP ID %d", __func__,
2789 				    hwcaps[k].hwcap_id));
2790 
2791 				cur_hwcap = hwcaps[k].hwcap_id == 1 ?
2792 				    hwcap : hwcap2;
2793 				min = hwcaps[k].min;
2794 
2795 				/*
2796 				 * If the field is greater than the minimum
2797 				 * value we can set the hwcap;
2798 				 */
2799 				if (mrs_field_cmp(reg, min, fields[j].shift,
2800 				    4, fields[j].sign) >= 0) {
2801 					*cur_hwcap |= hwcaps[k].hwcap_val;
2802 				}
2803 			}
2804 		}
2805 	}
2806 }
2807 
2808 static void
identify_cpu_sysinit(void * dummy __unused)2809 identify_cpu_sysinit(void *dummy __unused)
2810 {
2811 	struct cpu_desc *desc, *prev_desc;
2812 	int cpu;
2813 	bool dic, idc;
2814 
2815 	dic = (allow_dic != 0);
2816 	idc = (allow_idc != 0);
2817 
2818 	prev_desc = NULL;
2819 	CPU_FOREACH(cpu) {
2820 		desc = get_cpu_desc(cpu);
2821 		if (cpu != 0) {
2822 			check_cpu_regs(cpu, desc, prev_desc);
2823 			update_special_regs(cpu);
2824 		}
2825 
2826 		if (CTR_DIC_VAL(desc->ctr) == 0)
2827 			dic = false;
2828 		if (CTR_IDC_VAL(desc->ctr) == 0)
2829 			idc = false;
2830 		prev_desc = desc;
2831 	}
2832 
2833 #ifdef INVARIANTS
2834 	/* Check we dont update the special registers after this point */
2835 	hwcaps_set = true;
2836 #endif
2837 
2838 	/* Find the values to export to userspace as AT_HWCAP and AT_HWCAP2 */
2839 	parse_cpu_features(true, &user_cpu_desc, &elf_hwcap, &elf_hwcap2);
2840 	parse_cpu_features(true, &l_user_cpu_desc, &linux_elf_hwcap,
2841 	    &linux_elf_hwcap2);
2842 #ifdef COMPAT_FREEBSD32
2843 	parse_cpu_features(false, &user_cpu_desc, &elf32_hwcap, &elf32_hwcap2);
2844 #endif
2845 
2846 	/* We export the CPUID registers */
2847 	elf_hwcap |= HWCAP_CPUID;
2848 	linux_elf_hwcap |= HWCAP_CPUID;
2849 
2850 #ifdef COMPAT_FREEBSD32
2851 	/* Set the default caps and any that need to check multiple fields */
2852 	elf32_hwcap |= parse_cpu_features_hwcap32();
2853 #endif
2854 
2855 	if (dic && idc) {
2856 		arm64_icache_sync_range = &arm64_dic_idc_icache_sync_range;
2857 		if (bootverbose)
2858 			printf("Enabling DIC & IDC ICache sync\n");
2859 	} else if (idc) {
2860 		arm64_icache_sync_range = &arm64_idc_aliasing_icache_sync_range;
2861 		if (bootverbose)
2862 			printf("Enabling IDC ICache sync\n");
2863 	}
2864 
2865 	if ((elf_hwcap & HWCAP_ATOMICS) != 0) {
2866 		lse_supported = true;
2867 		if (bootverbose)
2868 			printf("Enabling LSE atomics in the kernel\n");
2869 	}
2870 #ifdef LSE_ATOMICS
2871 	if (!lse_supported)
2872 		panic("CPU does not support LSE atomic instructions");
2873 #endif
2874 
2875 	install_sys_handler(user_ctr_handler);
2876 	install_sys_handler(user_idreg_handler);
2877 }
2878 /*
2879  * This needs to be after the APs have stareted as they may have errata that
2880  * means we need to mask out ID registers & that could affect hwcaps, etc.
2881  */
2882 SYSINIT(identify_cpu, SI_SUB_CONFIGURE, SI_ORDER_ANY, identify_cpu_sysinit,
2883     NULL);
2884 
2885 static void
cpu_features_sysinit(void * dummy __unused)2886 cpu_features_sysinit(void *dummy __unused)
2887 {
2888 	struct sbuf sb;
2889 	struct cpu_desc *desc, *prev_desc;
2890 	u_int cpu;
2891 
2892 	prev_desc = NULL;
2893 	CPU_FOREACH(cpu) {
2894 		desc = get_cpu_desc(cpu);
2895 		print_cpu_features(cpu, desc, prev_desc);
2896 		prev_desc = desc;
2897 	}
2898 
2899 	/* Fill in cpu_model for the hw.model sysctl */
2900 	sbuf_new(&sb, cpu_model, sizeof(cpu_model), SBUF_FIXEDLEN);
2901 	print_cpu_midr(&sb, 0);
2902 
2903 	sbuf_finish(&sb);
2904 	sbuf_delete(&sb);
2905 
2906 	free(cpu_desc, M_IDENTCPU);
2907 }
2908 /* Log features before APs are released and start printing to the dmesg. */
2909 SYSINIT(cpu_features, SI_SUB_SMP - 1, SI_ORDER_ANY, cpu_features_sysinit, NULL);
2910 
2911 static void
tcr_set_e0pd1(void * arg __unused)2912 tcr_set_e0pd1(void *arg __unused)
2913 {
2914 	uint64_t tcr;
2915 
2916 	tcr = READ_SPECIALREG(tcr_el1);
2917 	tcr |= TCR_E0PD1;
2918 	WRITE_SPECIALREG(tcr_el1, tcr);
2919 	isb();
2920 }
2921 
2922 /* Enable support for more recent architecture features */
2923 static void
cpu_feat_support(void * arg __unused)2924 cpu_feat_support(void *arg __unused)
2925 {
2926 	/*
2927 	 * If FEAT_E0PD is supported use it to cause faults without a page
2928 	 * table walk if userspace tries to access kernel memory.
2929 	 */
2930 	if (ID_AA64MMFR2_E0PD_VAL(kern_cpu_desc.id_aa64mmfr2) !=
2931 	    ID_AA64MMFR2_E0PD_NONE)
2932 		smp_rendezvous(NULL, tcr_set_e0pd1, NULL, NULL);
2933 }
2934 SYSINIT(cpu_feat_support, SI_SUB_SMP, SI_ORDER_ANY, cpu_feat_support, NULL);
2935 
2936 #ifdef COMPAT_FREEBSD32
2937 static u_long
parse_cpu_features_hwcap32(void)2938 parse_cpu_features_hwcap32(void)
2939 {
2940 	u_long hwcap = HWCAP32_DEFAULT;
2941 
2942 	if ((MVFR1_SIMDLS_VAL(user_cpu_desc.mvfr1) >=
2943 	     MVFR1_SIMDLS_IMPL) &&
2944 	    (MVFR1_SIMDInt_VAL(user_cpu_desc.mvfr1) >=
2945 	     MVFR1_SIMDInt_IMPL) &&
2946 	    (MVFR1_SIMDSP_VAL(user_cpu_desc.mvfr1) >=
2947 	     MVFR1_SIMDSP_IMPL))
2948 		hwcap |= HWCAP32_NEON;
2949 
2950 	return (hwcap);
2951 }
2952 #endif /* COMPAT_FREEBSD32 */
2953 
2954 static void
print_register(struct sbuf * sb,const char * reg_name,uint64_t reg,void (* print_fields)(struct sbuf *,uint64_t,const void *),const void * arg)2955 print_register(struct sbuf *sb, const char *reg_name, uint64_t reg,
2956     void (*print_fields)(struct sbuf *, uint64_t, const void *),
2957     const void *arg)
2958 {
2959 
2960 	sbuf_printf(sb, "%29s = <", reg_name);
2961 
2962 	print_fields(sb, reg, arg);
2963 
2964 	sbuf_finish(sb);
2965 	printf("%s>\n", sbuf_data(sb));
2966 	sbuf_clear(sb);
2967 }
2968 
2969 static void
print_id_fields(struct sbuf * sb,uint64_t reg,const void * arg)2970 print_id_fields(struct sbuf *sb, uint64_t reg, const void *arg)
2971 {
2972 	const struct mrs_field *fields = arg;
2973 	const struct mrs_field_value *fv;
2974 	int field, i, j, printed;
2975 
2976 #define SEP_STR	((printed++) == 0) ? "" : ","
2977 	printed = 0;
2978 	for (i = 0; fields[i].type != 0; i++) {
2979 		fv = fields[i].values;
2980 
2981 		if (fv == NULL)
2982 			goto next;
2983 
2984 		field = (reg & fields[i].mask) >> fields[i].shift;
2985 		for (j = 0; fv[j].desc != NULL; j++) {
2986 			if ((fv[j].value >> fields[i].shift) != field)
2987 				continue;
2988 
2989 			if (fv[j].desc[0] != '\0')
2990 				sbuf_printf(sb, "%s%s", SEP_STR, fv[j].desc);
2991 			break;
2992 		}
2993 		if (fv[j].desc == NULL)
2994 			sbuf_printf(sb, "%sUnknown %s(%x)", SEP_STR,
2995 			    fields[i].name, field);
2996 
2997 next:
2998 		reg &= ~(((1ul << fields[i].width) - 1) << fields[i].shift);
2999 	}
3000 
3001 	if (reg != 0)
3002 		sbuf_printf(sb, "%s%#lx", SEP_STR, reg);
3003 #undef SEP_STR
3004 }
3005 
3006 static void
print_id_register(struct sbuf * sb,const char * reg_name,uint64_t reg,const struct mrs_field * fields)3007 print_id_register(struct sbuf *sb, const char *reg_name, uint64_t reg,
3008     const struct mrs_field *fields)
3009 {
3010 
3011 	print_register(sb, reg_name, reg, print_id_fields, fields);
3012 }
3013 
3014 static void
print_cpu_midr(struct sbuf * sb,u_int cpu)3015 print_cpu_midr(struct sbuf *sb, u_int cpu)
3016 {
3017 	const struct cpu_parts *cpu_partsp;
3018 	const char *cpu_impl_name;
3019 	const char *cpu_part_name;
3020 	u_int midr;
3021 	u_int impl_id;
3022 	u_int part_id;
3023 
3024 	midr = pcpu_find(cpu)->pc_midr;
3025 
3026 	cpu_impl_name = NULL;
3027 	cpu_partsp = NULL;
3028 	impl_id = CPU_IMPL(midr);
3029 	for (int i = 0; cpu_implementers[i].impl_name != NULL; i++) {
3030 		if (impl_id == cpu_implementers[i].impl_id) {
3031 			cpu_impl_name = cpu_implementers[i].impl_name;
3032 			cpu_partsp = cpu_implementers[i].cpu_parts;
3033 			break;
3034 		}
3035 	}
3036 	/* Unknown implementer, so unknown part */
3037 	if (cpu_impl_name == NULL) {
3038 		sbuf_printf(sb, "Unknown Implementer (midr: %08x)", midr);
3039 		return;
3040 	}
3041 
3042 	KASSERT(cpu_partsp != NULL, ("%s: No parts table for implementer %s",
3043 	    __func__, cpu_impl_name));
3044 
3045 	cpu_part_name = NULL;
3046 	part_id = CPU_PART(midr);
3047 	for (int i = 0; cpu_partsp[i].part_name != NULL; i++) {
3048 		if (part_id == cpu_partsp[i].part_id) {
3049 			cpu_part_name = cpu_partsp[i].part_name;
3050 			break;
3051 		}
3052 	}
3053 	/* Known Implementer, Unknown part */
3054 	if (cpu_part_name == NULL) {
3055 		sbuf_printf(sb, "%s Unknown CPU r%dp%d (midr: %08x)",
3056 		    cpu_impl_name, CPU_VAR(midr), CPU_REV(midr), midr);
3057 		return;
3058 	}
3059 
3060 	sbuf_printf(sb, "%s %s r%dp%d", cpu_impl_name,
3061 	    cpu_part_name, CPU_VAR(midr), CPU_REV(midr));
3062 }
3063 
3064 static void
print_cpu_cache(struct cpu_desc * desc,struct sbuf * sb,uint64_t ccs,bool icache,bool unified)3065 print_cpu_cache(struct cpu_desc *desc, struct sbuf *sb, uint64_t ccs,
3066     bool icache, bool unified)
3067 {
3068 	size_t cache_size;
3069 	size_t line_size;
3070 
3071 	/* LineSize is Log2(S) - 4. */
3072 	line_size = 1 << ((ccs & CCSIDR_LineSize_MASK) + 4);
3073 	/*
3074 	 * Calculate cache size (sets * ways * line size).  There are different
3075 	 * formats depending on the FEAT_CCIDX bit in ID_AA64MMFR2 feature
3076 	 * register.
3077 	 */
3078 	if ((desc->id_aa64mmfr2 & ID_AA64MMFR2_CCIDX_64))
3079 		cache_size = (CCSIDR_NSETS_64(ccs) + 1) *
3080 		    (CCSIDR_ASSOC_64(ccs) + 1);
3081 	else
3082 		cache_size = (CCSIDR_NSETS(ccs) + 1) * (CCSIDR_ASSOC(ccs) + 1);
3083 
3084 	cache_size *= line_size;
3085 	sbuf_printf(sb, "%zuKB (%s)", cache_size / 1024,
3086 	    icache ? "instruction" : unified ? "unified" : "data");
3087 }
3088 
3089 static void
print_cpu_caches(struct sbuf * sb,struct cpu_desc * desc)3090 print_cpu_caches(struct sbuf *sb, struct cpu_desc *desc)
3091 {
3092 	/* Print out each cache combination */
3093 	uint64_t clidr;
3094 	int i = 1;
3095 	clidr = desc->clidr;
3096 
3097 	for (i = 0; (clidr & CLIDR_CTYPE_MASK) != 0; i++, clidr >>= 3) {
3098 		int j = 0;
3099 		int ctype_m = (clidr & CLIDR_CTYPE_MASK);
3100 
3101 		sbuf_printf(sb, " L%d cache: ", i + 1);
3102 		if ((clidr & CLIDR_CTYPE_IO)) {
3103 			print_cpu_cache(desc, sb, desc->ccsidr[i][j++], true,
3104 			    false);
3105 			/* If there's more, add to the line. */
3106 			if ((ctype_m & ~CLIDR_CTYPE_IO) != 0)
3107 				sbuf_printf(sb, ", ");
3108 		}
3109 		if ((ctype_m & ~CLIDR_CTYPE_IO) != 0) {
3110 			print_cpu_cache(desc, sb, desc->ccsidr[i][j], false,
3111 			    (clidr & CLIDR_CTYPE_UNIFIED));
3112 		}
3113 		sbuf_printf(sb, "\n");
3114 
3115 	}
3116 	sbuf_finish(sb);
3117 	printf("%s", sbuf_data(sb));
3118 }
3119 
3120 static void
print_cpu_features(u_int cpu,struct cpu_desc * desc,struct cpu_desc * prev_desc)3121 print_cpu_features(u_int cpu, struct cpu_desc *desc,
3122     struct cpu_desc *prev_desc)
3123 {
3124 	struct sbuf *sb;
3125 
3126 	sb = sbuf_new_auto();
3127 	sbuf_printf(sb, "CPU%3u: ", cpu);
3128 	print_cpu_midr(sb, cpu);
3129 
3130 	sbuf_cat(sb, " affinity:");
3131 	switch(cpu_aff_levels) {
3132 	default:
3133 	case 4:
3134 		sbuf_printf(sb, " %2d", CPU_AFF3(desc->mpidr));
3135 		/* FALLTHROUGH */
3136 	case 3:
3137 		sbuf_printf(sb, " %2d", CPU_AFF2(desc->mpidr));
3138 		/* FALLTHROUGH */
3139 	case 2:
3140 		sbuf_printf(sb, " %2d", CPU_AFF1(desc->mpidr));
3141 		/* FALLTHROUGH */
3142 	case 1:
3143 	case 0: /* On UP this will be zero */
3144 		sbuf_printf(sb, " %2d", CPU_AFF0(desc->mpidr));
3145 		break;
3146 	}
3147 	sbuf_finish(sb);
3148 	printf("%s\n", sbuf_data(sb));
3149 	sbuf_clear(sb);
3150 
3151 	/*
3152 	 * There is a hardware errata where, if one CPU is performing a TLB
3153 	 * invalidation while another is performing a store-exclusive the
3154 	 * store-exclusive may return the wrong status. A workaround seems
3155 	 * to be to use an IPI to invalidate on each CPU, however given the
3156 	 * limited number of affected units (pass 1.1 is the evaluation
3157 	 * hardware revision), and the lack of information from Cavium
3158 	 * this has not been implemented.
3159 	 *
3160 	 * At the time of writing this the only information is from:
3161 	 * https://lkml.org/lkml/2016/8/4/722
3162 	 */
3163 	/*
3164 	 * XXX: CPU_MATCH_ERRATA_CAVIUM_THUNDERX_1_1 on its own also
3165 	 * triggers on pass 2.0+.
3166 	 */
3167 	if (cpu == 0 && CPU_VAR(PCPU_GET(midr)) == 0 &&
3168 	    CPU_MATCH_ERRATA_CAVIUM_THUNDERX_1_1)
3169 		printf("WARNING: ThunderX Pass 1.1 detected.\nThis has known "
3170 		    "hardware bugs that may cause the incorrect operation of "
3171 		    "atomic operations.\n");
3172 
3173 #define	SHOULD_PRINT_REG(_reg)						\
3174     (prev_desc == NULL || desc->_reg != prev_desc->_reg)
3175 
3176 	/* Cache Type Register */
3177 	if (SHOULD_PRINT_REG(ctr))
3178 		print_id_register(sb, "Cache Type", desc->ctr, ctr_fields);
3179 
3180 	/* AArch64 Instruction Set Attribute Register 0 */
3181 	if (SHOULD_PRINT_REG(id_aa64isar0))
3182 		print_id_register(sb, "Instruction Set Attributes 0",
3183 		    desc->id_aa64isar0, id_aa64isar0_fields);
3184 
3185 	/* AArch64 Instruction Set Attribute Register 1 */
3186 	if (SHOULD_PRINT_REG(id_aa64isar1))
3187 		print_id_register(sb, "Instruction Set Attributes 1",
3188 		    desc->id_aa64isar1, id_aa64isar1_fields);
3189 
3190 	/* AArch64 Instruction Set Attribute Register 2 */
3191 	if (SHOULD_PRINT_REG(id_aa64isar2))
3192 		print_id_register(sb, "Instruction Set Attributes 2",
3193 		    desc->id_aa64isar2, id_aa64isar2_fields);
3194 
3195 	/* AArch64 Processor Feature Register 0 */
3196 	if (SHOULD_PRINT_REG(id_aa64pfr0))
3197 		print_id_register(sb, "Processor Features 0",
3198 		    desc->id_aa64pfr0, id_aa64pfr0_fields);
3199 
3200 	/* AArch64 Processor Feature Register 1 */
3201 	if (SHOULD_PRINT_REG(id_aa64pfr1))
3202 		print_id_register(sb, "Processor Features 1",
3203 		    desc->id_aa64pfr1, id_aa64pfr1_fields);
3204 
3205 	/* AArch64 Processor Feature Register 2 */
3206 	if (SHOULD_PRINT_REG(id_aa64pfr2))
3207 		print_id_register(sb, "Processor Features 2",
3208 		    desc->id_aa64pfr2, id_aa64pfr2_fields);
3209 
3210 	/* AArch64 Memory Model Feature Register 0 */
3211 	if (SHOULD_PRINT_REG(id_aa64mmfr0))
3212 		print_id_register(sb, "Memory Model Features 0",
3213 		    desc->id_aa64mmfr0, id_aa64mmfr0_fields);
3214 
3215 	/* AArch64 Memory Model Feature Register 1 */
3216 	if (SHOULD_PRINT_REG(id_aa64mmfr1))
3217 		print_id_register(sb, "Memory Model Features 1",
3218 		    desc->id_aa64mmfr1, id_aa64mmfr1_fields);
3219 
3220 	/* AArch64 Memory Model Feature Register 2 */
3221 	if (SHOULD_PRINT_REG(id_aa64mmfr2))
3222 		print_id_register(sb, "Memory Model Features 2",
3223 		    desc->id_aa64mmfr2, id_aa64mmfr2_fields);
3224 
3225 	/* AArch64 Memory Model Feature Register 3 */
3226 	if (SHOULD_PRINT_REG(id_aa64mmfr3))
3227 		print_id_register(sb, "Memory Model Features 3",
3228 		    desc->id_aa64mmfr3, id_aa64mmfr3_fields);
3229 
3230 	/* AArch64 Memory Model Feature Register 4 */
3231 	if (SHOULD_PRINT_REG(id_aa64mmfr4))
3232 		print_id_register(sb, "Memory Model Features 4",
3233 		    desc->id_aa64mmfr4, id_aa64mmfr4_fields);
3234 
3235 	/* AArch64 Debug Feature Register 0 */
3236 	if (SHOULD_PRINT_REG(id_aa64dfr0))
3237 		print_id_register(sb, "Debug Features 0",
3238 		    desc->id_aa64dfr0, id_aa64dfr0_fields);
3239 
3240 	/* AArch64 Memory Model Feature Register 1 */
3241 	if (SHOULD_PRINT_REG(id_aa64dfr1))
3242 		print_id_register(sb, "Debug Features 1",
3243 		    desc->id_aa64dfr1, id_aa64dfr1_fields);
3244 
3245 	/* AArch64 Auxiliary Feature Register 0 */
3246 	if (SHOULD_PRINT_REG(id_aa64afr0))
3247 		print_id_register(sb, "Auxiliary Features 0",
3248 		    desc->id_aa64afr0, id_aa64afr0_fields);
3249 
3250 	/* AArch64 Auxiliary Feature Register 1 */
3251 	if (SHOULD_PRINT_REG(id_aa64afr1))
3252 		print_id_register(sb, "Auxiliary Features 1",
3253 		    desc->id_aa64afr1, id_aa64afr1_fields);
3254 
3255 	/* AArch64 SVE Feature Register 0 */
3256 	if (desc->have_sve) {
3257 		if (SHOULD_PRINT_REG(id_aa64zfr0) ||
3258 		    !prev_desc->have_sve) {
3259 			print_id_register(sb, "SVE Features 0",
3260 			    desc->id_aa64zfr0, id_aa64zfr0_fields);
3261 		}
3262 	}
3263 
3264 #ifdef COMPAT_FREEBSD32
3265 	/* AArch32 Instruction Set Attribute Register 5 */
3266 	if (SHOULD_PRINT_REG(id_isar5))
3267 		print_id_register(sb, "AArch32 Instruction Set Attributes 5",
3268 		     desc->id_isar5, id_isar5_fields);
3269 
3270 	/* AArch32 Media and VFP Feature Register 0 */
3271 	if (SHOULD_PRINT_REG(mvfr0))
3272 		print_id_register(sb, "AArch32 Media and VFP Features 0",
3273 		     desc->mvfr0, mvfr0_fields);
3274 
3275 	/* AArch32 Media and VFP Feature Register 1 */
3276 	if (SHOULD_PRINT_REG(mvfr1))
3277 		print_id_register(sb, "AArch32 Media and VFP Features 1",
3278 		     desc->mvfr1, mvfr1_fields);
3279 #endif
3280 	if (bootverbose)
3281 		print_cpu_caches(sb, desc);
3282 
3283 	sbuf_delete(sb);
3284 	sb = NULL;
3285 #undef SHOULD_PRINT_REG
3286 #undef SEP_STR
3287 }
3288 
3289 void
identify_cache(uint64_t ctr)3290 identify_cache(uint64_t ctr)
3291 {
3292 
3293 	/* Identify the L1 cache type */
3294 	switch (CTR_L1IP_VAL(ctr)) {
3295 	case CTR_L1IP_PIPT:
3296 		break;
3297 	default:
3298 	case CTR_L1IP_VIPT:
3299 		icache_aliasing = true;
3300 		break;
3301 	}
3302 
3303 	if (dcache_line_size == 0) {
3304 		KASSERT(icache_line_size == 0, ("%s: i-cacheline size set: %ld",
3305 		    __func__, icache_line_size));
3306 
3307 		/* Get the D cache line size */
3308 		dcache_line_size = CTR_DLINE_SIZE(ctr);
3309 		/* And the same for the I cache */
3310 		icache_line_size = CTR_ILINE_SIZE(ctr);
3311 
3312 		idcache_line_size = MIN(dcache_line_size, icache_line_size);
3313 	}
3314 
3315 	if (dcache_line_size != CTR_DLINE_SIZE(ctr)) {
3316 		printf("WARNING: D-cacheline size mismatch %ld != %d\n",
3317 		    dcache_line_size, CTR_DLINE_SIZE(ctr));
3318 	}
3319 
3320 	if (icache_line_size != CTR_ILINE_SIZE(ctr)) {
3321 		printf("WARNING: I-cacheline size mismatch %ld != %d\n",
3322 		    icache_line_size, CTR_ILINE_SIZE(ctr));
3323 	}
3324 }
3325 
3326 void
identify_cpu(u_int cpu)3327 identify_cpu(u_int cpu)
3328 {
3329 	struct cpu_desc *desc;
3330 	uint64_t clidr;
3331 
3332 	desc = get_cpu_desc(cpu);
3333 	/* Save affinity for current CPU */
3334 	desc->mpidr = get_mpidr();
3335 	CPU_AFFINITY(cpu) = desc->mpidr & CPU_AFF_MASK;
3336 
3337 	desc->ctr = READ_SPECIALREG(ctr_el0);
3338 	desc->id_aa64dfr0 = READ_SPECIALREG(ID_AA64DFR0_EL1_REG);
3339 	desc->id_aa64dfr1 = READ_SPECIALREG(ID_AA64DFR1_EL1_REG);
3340 	desc->id_aa64isar0 = READ_SPECIALREG(ID_AA64ISAR0_EL1_REG);
3341 	desc->id_aa64isar1 = READ_SPECIALREG(ID_AA64ISAR1_EL1_REG);
3342 	desc->id_aa64isar2 = READ_SPECIALREG(ID_AA64ISAR2_EL1_REG);
3343 	desc->id_aa64mmfr0 = READ_SPECIALREG(ID_AA64MMFR0_EL1_REG);
3344 	desc->id_aa64mmfr1 = READ_SPECIALREG(ID_AA64MMFR1_EL1_REG);
3345 	desc->id_aa64mmfr2 = READ_SPECIALREG(ID_AA64MMFR2_EL1_REG);
3346 	desc->id_aa64mmfr3 = READ_SPECIALREG(ID_AA64MMFR3_EL1_REG);
3347 	desc->id_aa64mmfr4 = READ_SPECIALREG(ID_AA64MMFR4_EL1_REG);
3348 	desc->id_aa64pfr0 = READ_SPECIALREG(ID_AA64PFR0_EL1_REG);
3349 	desc->id_aa64pfr1 = READ_SPECIALREG(ID_AA64PFR1_EL1_REG);
3350 	desc->id_aa64pfr2 = READ_SPECIALREG(ID_AA64PFR2_EL1_REG);
3351 
3352 	/*
3353 	 * ID_AA64ZFR0_EL1 is only valid when at least one of:
3354 	 *  - ID_AA64PFR0_EL1.SVE is non-zero
3355 	 *  - ID_AA64PFR1_EL1.SME is non-zero
3356 	 * In other cases it is zero, but still safe to read
3357 	 */
3358 	desc->have_sve =
3359 	    (ID_AA64PFR0_SVE_VAL(desc->id_aa64pfr0) != 0);
3360 	desc->id_aa64zfr0 = READ_SPECIALREG(ID_AA64ZFR0_EL1_REG);
3361 
3362 	desc->clidr = READ_SPECIALREG(clidr_el1);
3363 
3364 	clidr = desc->clidr;
3365 
3366 	for (int i = 0; (clidr & CLIDR_CTYPE_MASK) != 0; i++, clidr >>= 3) {
3367 		int j = 0;
3368 		if ((clidr & CLIDR_CTYPE_IO)) {
3369 			WRITE_SPECIALREG(csselr_el1,
3370 			    CSSELR_Level(i) | CSSELR_InD);
3371 			desc->ccsidr[i][j++] =
3372 			    READ_SPECIALREG(ccsidr_el1);
3373 		}
3374 		if ((clidr & ~CLIDR_CTYPE_IO) == 0)
3375 			continue;
3376 		WRITE_SPECIALREG(csselr_el1, CSSELR_Level(i));
3377 		desc->ccsidr[i][j] = READ_SPECIALREG(ccsidr_el1);
3378 	}
3379 
3380 #ifdef COMPAT_FREEBSD32
3381 	/* Only read aarch32 SRs if EL0-32 is available */
3382 	if (ID_AA64PFR0_EL0_VAL(desc->id_aa64pfr0) == ID_AA64PFR0_EL0_64_32) {
3383 		desc->id_isar5 = READ_SPECIALREG(id_isar5_el1);
3384 		desc->mvfr0 = READ_SPECIALREG(mvfr0_el1);
3385 		desc->mvfr1 = READ_SPECIALREG(mvfr1_el1);
3386 	}
3387 #endif
3388 }
3389 
3390 static void
check_cpu_regs(u_int cpu,struct cpu_desc * desc,struct cpu_desc * prev_desc)3391 check_cpu_regs(u_int cpu, struct cpu_desc *desc, struct cpu_desc *prev_desc)
3392 {
3393 	switch (cpu_aff_levels) {
3394 	case 0:
3395 		if (CPU_AFF0(desc->mpidr) != CPU_AFF0(prev_desc->mpidr))
3396 			cpu_aff_levels = 1;
3397 		/* FALLTHROUGH */
3398 	case 1:
3399 		if (CPU_AFF1(desc->mpidr) != CPU_AFF1(prev_desc->mpidr))
3400 			cpu_aff_levels = 2;
3401 		/* FALLTHROUGH */
3402 	case 2:
3403 		if (CPU_AFF2(desc->mpidr) != CPU_AFF2(prev_desc->mpidr))
3404 			cpu_aff_levels = 3;
3405 		/* FALLTHROUGH */
3406 	case 3:
3407 		if (CPU_AFF3(desc->mpidr) != CPU_AFF3(prev_desc->mpidr))
3408 			cpu_aff_levels = 4;
3409 		break;
3410 	}
3411 
3412 	if (desc->ctr != prev_desc->ctr) {
3413 		/*
3414 		 * If the cache is different on different cores we should
3415 		 * emulate for userspace to provide a uniform value
3416 		 */
3417 		emulate_ctr = true;
3418 
3419 		/*
3420 		 * If the cache type register is different we may
3421 		 * have a different l1 cache type.
3422 		 */
3423 		identify_cache(desc->ctr);
3424 	}
3425 }
3426