18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci// Copyright (C) 2018, Advanced Micro Devices, Inc.
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#include <linux/cper.h>
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci/*
78c2ecf20Sopenharmony_ci * We don't need a "CPER_IA" prefix since these are all locally defined.
88c2ecf20Sopenharmony_ci * This will save us a lot of line space.
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci#define VALID_LAPIC_ID			BIT_ULL(0)
118c2ecf20Sopenharmony_ci#define VALID_CPUID_INFO		BIT_ULL(1)
128c2ecf20Sopenharmony_ci#define VALID_PROC_ERR_INFO_NUM(bits)	(((bits) & GENMASK_ULL(7, 2)) >> 2)
138c2ecf20Sopenharmony_ci#define VALID_PROC_CXT_INFO_NUM(bits)	(((bits) & GENMASK_ULL(13, 8)) >> 8)
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#define INFO_ERR_STRUCT_TYPE_CACHE					\
168c2ecf20Sopenharmony_ci	GUID_INIT(0xA55701F5, 0xE3EF, 0x43DE, 0xAC, 0x72, 0x24, 0x9B,	\
178c2ecf20Sopenharmony_ci		  0x57, 0x3F, 0xAD, 0x2C)
188c2ecf20Sopenharmony_ci#define INFO_ERR_STRUCT_TYPE_TLB					\
198c2ecf20Sopenharmony_ci	GUID_INIT(0xFC06B535, 0x5E1F, 0x4562, 0x9F, 0x25, 0x0A, 0x3B,	\
208c2ecf20Sopenharmony_ci		  0x9A, 0xDB, 0x63, 0xC3)
218c2ecf20Sopenharmony_ci#define INFO_ERR_STRUCT_TYPE_BUS					\
228c2ecf20Sopenharmony_ci	GUID_INIT(0x1CF3F8B3, 0xC5B1, 0x49a2, 0xAA, 0x59, 0x5E, 0xEF,	\
238c2ecf20Sopenharmony_ci		  0x92, 0xFF, 0xA6, 0x3C)
248c2ecf20Sopenharmony_ci#define INFO_ERR_STRUCT_TYPE_MS						\
258c2ecf20Sopenharmony_ci	GUID_INIT(0x48AB7F57, 0xDC34, 0x4f6c, 0xA7, 0xD3, 0xB0, 0xB5,	\
268c2ecf20Sopenharmony_ci		  0xB0, 0xA7, 0x43, 0x14)
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#define INFO_VALID_CHECK_INFO		BIT_ULL(0)
298c2ecf20Sopenharmony_ci#define INFO_VALID_TARGET_ID		BIT_ULL(1)
308c2ecf20Sopenharmony_ci#define INFO_VALID_REQUESTOR_ID		BIT_ULL(2)
318c2ecf20Sopenharmony_ci#define INFO_VALID_RESPONDER_ID		BIT_ULL(3)
328c2ecf20Sopenharmony_ci#define INFO_VALID_IP			BIT_ULL(4)
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#define CHECK_VALID_TRANS_TYPE		BIT_ULL(0)
358c2ecf20Sopenharmony_ci#define CHECK_VALID_OPERATION		BIT_ULL(1)
368c2ecf20Sopenharmony_ci#define CHECK_VALID_LEVEL		BIT_ULL(2)
378c2ecf20Sopenharmony_ci#define CHECK_VALID_PCC			BIT_ULL(3)
388c2ecf20Sopenharmony_ci#define CHECK_VALID_UNCORRECTED		BIT_ULL(4)
398c2ecf20Sopenharmony_ci#define CHECK_VALID_PRECISE_IP		BIT_ULL(5)
408c2ecf20Sopenharmony_ci#define CHECK_VALID_RESTARTABLE_IP	BIT_ULL(6)
418c2ecf20Sopenharmony_ci#define CHECK_VALID_OVERFLOW		BIT_ULL(7)
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#define CHECK_VALID_BUS_PART_TYPE	BIT_ULL(8)
448c2ecf20Sopenharmony_ci#define CHECK_VALID_BUS_TIME_OUT	BIT_ULL(9)
458c2ecf20Sopenharmony_ci#define CHECK_VALID_BUS_ADDR_SPACE	BIT_ULL(10)
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci#define CHECK_VALID_BITS(check)		(((check) & GENMASK_ULL(15, 0)))
488c2ecf20Sopenharmony_ci#define CHECK_TRANS_TYPE(check)		(((check) & GENMASK_ULL(17, 16)) >> 16)
498c2ecf20Sopenharmony_ci#define CHECK_OPERATION(check)		(((check) & GENMASK_ULL(21, 18)) >> 18)
508c2ecf20Sopenharmony_ci#define CHECK_LEVEL(check)		(((check) & GENMASK_ULL(24, 22)) >> 22)
518c2ecf20Sopenharmony_ci#define CHECK_PCC			BIT_ULL(25)
528c2ecf20Sopenharmony_ci#define CHECK_UNCORRECTED		BIT_ULL(26)
538c2ecf20Sopenharmony_ci#define CHECK_PRECISE_IP		BIT_ULL(27)
548c2ecf20Sopenharmony_ci#define CHECK_RESTARTABLE_IP		BIT_ULL(28)
558c2ecf20Sopenharmony_ci#define CHECK_OVERFLOW			BIT_ULL(29)
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci#define CHECK_BUS_PART_TYPE(check)	(((check) & GENMASK_ULL(31, 30)) >> 30)
588c2ecf20Sopenharmony_ci#define CHECK_BUS_TIME_OUT		BIT_ULL(32)
598c2ecf20Sopenharmony_ci#define CHECK_BUS_ADDR_SPACE(check)	(((check) & GENMASK_ULL(34, 33)) >> 33)
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#define CHECK_VALID_MS_ERR_TYPE		BIT_ULL(0)
628c2ecf20Sopenharmony_ci#define CHECK_VALID_MS_PCC		BIT_ULL(1)
638c2ecf20Sopenharmony_ci#define CHECK_VALID_MS_UNCORRECTED	BIT_ULL(2)
648c2ecf20Sopenharmony_ci#define CHECK_VALID_MS_PRECISE_IP	BIT_ULL(3)
658c2ecf20Sopenharmony_ci#define CHECK_VALID_MS_RESTARTABLE_IP	BIT_ULL(4)
668c2ecf20Sopenharmony_ci#define CHECK_VALID_MS_OVERFLOW		BIT_ULL(5)
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci#define CHECK_MS_ERR_TYPE(check)	(((check) & GENMASK_ULL(18, 16)) >> 16)
698c2ecf20Sopenharmony_ci#define CHECK_MS_PCC			BIT_ULL(19)
708c2ecf20Sopenharmony_ci#define CHECK_MS_UNCORRECTED		BIT_ULL(20)
718c2ecf20Sopenharmony_ci#define CHECK_MS_PRECISE_IP		BIT_ULL(21)
728c2ecf20Sopenharmony_ci#define CHECK_MS_RESTARTABLE_IP		BIT_ULL(22)
738c2ecf20Sopenharmony_ci#define CHECK_MS_OVERFLOW		BIT_ULL(23)
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci#define CTX_TYPE_MSR			1
768c2ecf20Sopenharmony_ci#define CTX_TYPE_MMREG			7
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_cienum err_types {
798c2ecf20Sopenharmony_ci	ERR_TYPE_CACHE = 0,
808c2ecf20Sopenharmony_ci	ERR_TYPE_TLB,
818c2ecf20Sopenharmony_ci	ERR_TYPE_BUS,
828c2ecf20Sopenharmony_ci	ERR_TYPE_MS,
838c2ecf20Sopenharmony_ci	N_ERR_TYPES
848c2ecf20Sopenharmony_ci};
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_cistatic enum err_types cper_get_err_type(const guid_t *err_type)
878c2ecf20Sopenharmony_ci{
888c2ecf20Sopenharmony_ci	if (guid_equal(err_type, &INFO_ERR_STRUCT_TYPE_CACHE))
898c2ecf20Sopenharmony_ci		return ERR_TYPE_CACHE;
908c2ecf20Sopenharmony_ci	else if (guid_equal(err_type, &INFO_ERR_STRUCT_TYPE_TLB))
918c2ecf20Sopenharmony_ci		return ERR_TYPE_TLB;
928c2ecf20Sopenharmony_ci	else if (guid_equal(err_type, &INFO_ERR_STRUCT_TYPE_BUS))
938c2ecf20Sopenharmony_ci		return ERR_TYPE_BUS;
948c2ecf20Sopenharmony_ci	else if (guid_equal(err_type, &INFO_ERR_STRUCT_TYPE_MS))
958c2ecf20Sopenharmony_ci		return ERR_TYPE_MS;
968c2ecf20Sopenharmony_ci	else
978c2ecf20Sopenharmony_ci		return N_ERR_TYPES;
988c2ecf20Sopenharmony_ci}
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_cistatic const char * const ia_check_trans_type_strs[] = {
1018c2ecf20Sopenharmony_ci	"Instruction",
1028c2ecf20Sopenharmony_ci	"Data Access",
1038c2ecf20Sopenharmony_ci	"Generic",
1048c2ecf20Sopenharmony_ci};
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_cistatic const char * const ia_check_op_strs[] = {
1078c2ecf20Sopenharmony_ci	"generic error",
1088c2ecf20Sopenharmony_ci	"generic read",
1098c2ecf20Sopenharmony_ci	"generic write",
1108c2ecf20Sopenharmony_ci	"data read",
1118c2ecf20Sopenharmony_ci	"data write",
1128c2ecf20Sopenharmony_ci	"instruction fetch",
1138c2ecf20Sopenharmony_ci	"prefetch",
1148c2ecf20Sopenharmony_ci	"eviction",
1158c2ecf20Sopenharmony_ci	"snoop",
1168c2ecf20Sopenharmony_ci};
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_cistatic const char * const ia_check_bus_part_type_strs[] = {
1198c2ecf20Sopenharmony_ci	"Local Processor originated request",
1208c2ecf20Sopenharmony_ci	"Local Processor responded to request",
1218c2ecf20Sopenharmony_ci	"Local Processor observed",
1228c2ecf20Sopenharmony_ci	"Generic",
1238c2ecf20Sopenharmony_ci};
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_cistatic const char * const ia_check_bus_addr_space_strs[] = {
1268c2ecf20Sopenharmony_ci	"Memory Access",
1278c2ecf20Sopenharmony_ci	"Reserved",
1288c2ecf20Sopenharmony_ci	"I/O",
1298c2ecf20Sopenharmony_ci	"Other Transaction",
1308c2ecf20Sopenharmony_ci};
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_cistatic const char * const ia_check_ms_error_type_strs[] = {
1338c2ecf20Sopenharmony_ci	"No Error",
1348c2ecf20Sopenharmony_ci	"Unclassified",
1358c2ecf20Sopenharmony_ci	"Microcode ROM Parity Error",
1368c2ecf20Sopenharmony_ci	"External Error",
1378c2ecf20Sopenharmony_ci	"FRC Error",
1388c2ecf20Sopenharmony_ci	"Internal Unclassified",
1398c2ecf20Sopenharmony_ci};
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_cistatic const char * const ia_reg_ctx_strs[] = {
1428c2ecf20Sopenharmony_ci	"Unclassified Data",
1438c2ecf20Sopenharmony_ci	"MSR Registers (Machine Check and other MSRs)",
1448c2ecf20Sopenharmony_ci	"32-bit Mode Execution Context",
1458c2ecf20Sopenharmony_ci	"64-bit Mode Execution Context",
1468c2ecf20Sopenharmony_ci	"FXSAVE Context",
1478c2ecf20Sopenharmony_ci	"32-bit Mode Debug Registers (DR0-DR7)",
1488c2ecf20Sopenharmony_ci	"64-bit Mode Debug Registers (DR0-DR7)",
1498c2ecf20Sopenharmony_ci	"Memory Mapped Registers",
1508c2ecf20Sopenharmony_ci};
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_cistatic inline void print_bool(char *str, const char *pfx, u64 check, u64 bit)
1538c2ecf20Sopenharmony_ci{
1548c2ecf20Sopenharmony_ci	printk("%s%s: %s\n", pfx, str, (check & bit) ? "true" : "false");
1558c2ecf20Sopenharmony_ci}
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_cistatic void print_err_info_ms(const char *pfx, u16 validation_bits, u64 check)
1588c2ecf20Sopenharmony_ci{
1598c2ecf20Sopenharmony_ci	if (validation_bits & CHECK_VALID_MS_ERR_TYPE) {
1608c2ecf20Sopenharmony_ci		u8 err_type = CHECK_MS_ERR_TYPE(check);
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci		printk("%sError Type: %u, %s\n", pfx, err_type,
1638c2ecf20Sopenharmony_ci		       err_type < ARRAY_SIZE(ia_check_ms_error_type_strs) ?
1648c2ecf20Sopenharmony_ci		       ia_check_ms_error_type_strs[err_type] : "unknown");
1658c2ecf20Sopenharmony_ci	}
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci	if (validation_bits & CHECK_VALID_MS_PCC)
1688c2ecf20Sopenharmony_ci		print_bool("Processor Context Corrupt", pfx, check, CHECK_MS_PCC);
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci	if (validation_bits & CHECK_VALID_MS_UNCORRECTED)
1718c2ecf20Sopenharmony_ci		print_bool("Uncorrected", pfx, check, CHECK_MS_UNCORRECTED);
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci	if (validation_bits & CHECK_VALID_MS_PRECISE_IP)
1748c2ecf20Sopenharmony_ci		print_bool("Precise IP", pfx, check, CHECK_MS_PRECISE_IP);
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci	if (validation_bits & CHECK_VALID_MS_RESTARTABLE_IP)
1778c2ecf20Sopenharmony_ci		print_bool("Restartable IP", pfx, check, CHECK_MS_RESTARTABLE_IP);
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci	if (validation_bits & CHECK_VALID_MS_OVERFLOW)
1808c2ecf20Sopenharmony_ci		print_bool("Overflow", pfx, check, CHECK_MS_OVERFLOW);
1818c2ecf20Sopenharmony_ci}
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_cistatic void print_err_info(const char *pfx, u8 err_type, u64 check)
1848c2ecf20Sopenharmony_ci{
1858c2ecf20Sopenharmony_ci	u16 validation_bits = CHECK_VALID_BITS(check);
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci	/*
1888c2ecf20Sopenharmony_ci	 * The MS Check structure varies a lot from the others, so use a
1898c2ecf20Sopenharmony_ci	 * separate function for decoding.
1908c2ecf20Sopenharmony_ci	 */
1918c2ecf20Sopenharmony_ci	if (err_type == ERR_TYPE_MS)
1928c2ecf20Sopenharmony_ci		return print_err_info_ms(pfx, validation_bits, check);
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci	if (validation_bits & CHECK_VALID_TRANS_TYPE) {
1958c2ecf20Sopenharmony_ci		u8 trans_type = CHECK_TRANS_TYPE(check);
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ci		printk("%sTransaction Type: %u, %s\n", pfx, trans_type,
1988c2ecf20Sopenharmony_ci		       trans_type < ARRAY_SIZE(ia_check_trans_type_strs) ?
1998c2ecf20Sopenharmony_ci		       ia_check_trans_type_strs[trans_type] : "unknown");
2008c2ecf20Sopenharmony_ci	}
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_ci	if (validation_bits & CHECK_VALID_OPERATION) {
2038c2ecf20Sopenharmony_ci		u8 op = CHECK_OPERATION(check);
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_ci		/*
2068c2ecf20Sopenharmony_ci		 * CACHE has more operation types than TLB or BUS, though the
2078c2ecf20Sopenharmony_ci		 * name and the order are the same.
2088c2ecf20Sopenharmony_ci		 */
2098c2ecf20Sopenharmony_ci		u8 max_ops = (err_type == ERR_TYPE_CACHE) ? 9 : 7;
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci		printk("%sOperation: %u, %s\n", pfx, op,
2128c2ecf20Sopenharmony_ci		       op < max_ops ? ia_check_op_strs[op] : "unknown");
2138c2ecf20Sopenharmony_ci	}
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_ci	if (validation_bits & CHECK_VALID_LEVEL)
2168c2ecf20Sopenharmony_ci		printk("%sLevel: %llu\n", pfx, CHECK_LEVEL(check));
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ci	if (validation_bits & CHECK_VALID_PCC)
2198c2ecf20Sopenharmony_ci		print_bool("Processor Context Corrupt", pfx, check, CHECK_PCC);
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_ci	if (validation_bits & CHECK_VALID_UNCORRECTED)
2228c2ecf20Sopenharmony_ci		print_bool("Uncorrected", pfx, check, CHECK_UNCORRECTED);
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci	if (validation_bits & CHECK_VALID_PRECISE_IP)
2258c2ecf20Sopenharmony_ci		print_bool("Precise IP", pfx, check, CHECK_PRECISE_IP);
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_ci	if (validation_bits & CHECK_VALID_RESTARTABLE_IP)
2288c2ecf20Sopenharmony_ci		print_bool("Restartable IP", pfx, check, CHECK_RESTARTABLE_IP);
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_ci	if (validation_bits & CHECK_VALID_OVERFLOW)
2318c2ecf20Sopenharmony_ci		print_bool("Overflow", pfx, check, CHECK_OVERFLOW);
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci	if (err_type != ERR_TYPE_BUS)
2348c2ecf20Sopenharmony_ci		return;
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_ci	if (validation_bits & CHECK_VALID_BUS_PART_TYPE) {
2378c2ecf20Sopenharmony_ci		u8 part_type = CHECK_BUS_PART_TYPE(check);
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci		printk("%sParticipation Type: %u, %s\n", pfx, part_type,
2408c2ecf20Sopenharmony_ci		       part_type < ARRAY_SIZE(ia_check_bus_part_type_strs) ?
2418c2ecf20Sopenharmony_ci		       ia_check_bus_part_type_strs[part_type] : "unknown");
2428c2ecf20Sopenharmony_ci	}
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ci	if (validation_bits & CHECK_VALID_BUS_TIME_OUT)
2458c2ecf20Sopenharmony_ci		print_bool("Time Out", pfx, check, CHECK_BUS_TIME_OUT);
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ci	if (validation_bits & CHECK_VALID_BUS_ADDR_SPACE) {
2488c2ecf20Sopenharmony_ci		u8 addr_space = CHECK_BUS_ADDR_SPACE(check);
2498c2ecf20Sopenharmony_ci
2508c2ecf20Sopenharmony_ci		printk("%sAddress Space: %u, %s\n", pfx, addr_space,
2518c2ecf20Sopenharmony_ci		       addr_space < ARRAY_SIZE(ia_check_bus_addr_space_strs) ?
2528c2ecf20Sopenharmony_ci		       ia_check_bus_addr_space_strs[addr_space] : "unknown");
2538c2ecf20Sopenharmony_ci	}
2548c2ecf20Sopenharmony_ci}
2558c2ecf20Sopenharmony_ci
2568c2ecf20Sopenharmony_civoid cper_print_proc_ia(const char *pfx, const struct cper_sec_proc_ia *proc)
2578c2ecf20Sopenharmony_ci{
2588c2ecf20Sopenharmony_ci	int i;
2598c2ecf20Sopenharmony_ci	struct cper_ia_err_info *err_info;
2608c2ecf20Sopenharmony_ci	struct cper_ia_proc_ctx *ctx_info;
2618c2ecf20Sopenharmony_ci	char newpfx[64], infopfx[64];
2628c2ecf20Sopenharmony_ci	u8 err_type;
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_ci	if (proc->validation_bits & VALID_LAPIC_ID)
2658c2ecf20Sopenharmony_ci		printk("%sLocal APIC_ID: 0x%llx\n", pfx, proc->lapic_id);
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_ci	if (proc->validation_bits & VALID_CPUID_INFO) {
2688c2ecf20Sopenharmony_ci		printk("%sCPUID Info:\n", pfx);
2698c2ecf20Sopenharmony_ci		print_hex_dump(pfx, "", DUMP_PREFIX_OFFSET, 16, 4, proc->cpuid,
2708c2ecf20Sopenharmony_ci			       sizeof(proc->cpuid), 0);
2718c2ecf20Sopenharmony_ci	}
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_ci	snprintf(newpfx, sizeof(newpfx), "%s ", pfx);
2748c2ecf20Sopenharmony_ci
2758c2ecf20Sopenharmony_ci	err_info = (struct cper_ia_err_info *)(proc + 1);
2768c2ecf20Sopenharmony_ci	for (i = 0; i < VALID_PROC_ERR_INFO_NUM(proc->validation_bits); i++) {
2778c2ecf20Sopenharmony_ci		printk("%sError Information Structure %d:\n", pfx, i);
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_ci		err_type = cper_get_err_type(&err_info->err_type);
2808c2ecf20Sopenharmony_ci		printk("%sError Structure Type: %s\n", newpfx,
2818c2ecf20Sopenharmony_ci		       err_type < ARRAY_SIZE(cper_proc_error_type_strs) ?
2828c2ecf20Sopenharmony_ci		       cper_proc_error_type_strs[err_type] : "unknown");
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_ci		if (err_type >= N_ERR_TYPES) {
2858c2ecf20Sopenharmony_ci			printk("%sError Structure Type: %pUl\n", newpfx,
2868c2ecf20Sopenharmony_ci			       &err_info->err_type);
2878c2ecf20Sopenharmony_ci		}
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_ci		if (err_info->validation_bits & INFO_VALID_CHECK_INFO) {
2908c2ecf20Sopenharmony_ci			printk("%sCheck Information: 0x%016llx\n", newpfx,
2918c2ecf20Sopenharmony_ci			       err_info->check_info);
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_ci			if (err_type < N_ERR_TYPES) {
2948c2ecf20Sopenharmony_ci				snprintf(infopfx, sizeof(infopfx), "%s ",
2958c2ecf20Sopenharmony_ci					 newpfx);
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_ci				print_err_info(infopfx, err_type,
2988c2ecf20Sopenharmony_ci					       err_info->check_info);
2998c2ecf20Sopenharmony_ci			}
3008c2ecf20Sopenharmony_ci		}
3018c2ecf20Sopenharmony_ci
3028c2ecf20Sopenharmony_ci		if (err_info->validation_bits & INFO_VALID_TARGET_ID) {
3038c2ecf20Sopenharmony_ci			printk("%sTarget Identifier: 0x%016llx\n",
3048c2ecf20Sopenharmony_ci			       newpfx, err_info->target_id);
3058c2ecf20Sopenharmony_ci		}
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_ci		if (err_info->validation_bits & INFO_VALID_REQUESTOR_ID) {
3088c2ecf20Sopenharmony_ci			printk("%sRequestor Identifier: 0x%016llx\n",
3098c2ecf20Sopenharmony_ci			       newpfx, err_info->requestor_id);
3108c2ecf20Sopenharmony_ci		}
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_ci		if (err_info->validation_bits & INFO_VALID_RESPONDER_ID) {
3138c2ecf20Sopenharmony_ci			printk("%sResponder Identifier: 0x%016llx\n",
3148c2ecf20Sopenharmony_ci			       newpfx, err_info->responder_id);
3158c2ecf20Sopenharmony_ci		}
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_ci		if (err_info->validation_bits & INFO_VALID_IP) {
3188c2ecf20Sopenharmony_ci			printk("%sInstruction Pointer: 0x%016llx\n",
3198c2ecf20Sopenharmony_ci			       newpfx, err_info->ip);
3208c2ecf20Sopenharmony_ci		}
3218c2ecf20Sopenharmony_ci
3228c2ecf20Sopenharmony_ci		err_info++;
3238c2ecf20Sopenharmony_ci	}
3248c2ecf20Sopenharmony_ci
3258c2ecf20Sopenharmony_ci	ctx_info = (struct cper_ia_proc_ctx *)err_info;
3268c2ecf20Sopenharmony_ci	for (i = 0; i < VALID_PROC_CXT_INFO_NUM(proc->validation_bits); i++) {
3278c2ecf20Sopenharmony_ci		int size = sizeof(*ctx_info) + ctx_info->reg_arr_size;
3288c2ecf20Sopenharmony_ci		int groupsize = 4;
3298c2ecf20Sopenharmony_ci
3308c2ecf20Sopenharmony_ci		printk("%sContext Information Structure %d:\n", pfx, i);
3318c2ecf20Sopenharmony_ci
3328c2ecf20Sopenharmony_ci		printk("%sRegister Context Type: %s\n", newpfx,
3338c2ecf20Sopenharmony_ci		       ctx_info->reg_ctx_type < ARRAY_SIZE(ia_reg_ctx_strs) ?
3348c2ecf20Sopenharmony_ci		       ia_reg_ctx_strs[ctx_info->reg_ctx_type] : "unknown");
3358c2ecf20Sopenharmony_ci
3368c2ecf20Sopenharmony_ci		printk("%sRegister Array Size: 0x%04x\n", newpfx,
3378c2ecf20Sopenharmony_ci		       ctx_info->reg_arr_size);
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ci		if (ctx_info->reg_ctx_type == CTX_TYPE_MSR) {
3408c2ecf20Sopenharmony_ci			groupsize = 8; /* MSRs are 8 bytes wide. */
3418c2ecf20Sopenharmony_ci			printk("%sMSR Address: 0x%08x\n", newpfx,
3428c2ecf20Sopenharmony_ci			       ctx_info->msr_addr);
3438c2ecf20Sopenharmony_ci		}
3448c2ecf20Sopenharmony_ci
3458c2ecf20Sopenharmony_ci		if (ctx_info->reg_ctx_type == CTX_TYPE_MMREG) {
3468c2ecf20Sopenharmony_ci			printk("%sMM Register Address: 0x%016llx\n", newpfx,
3478c2ecf20Sopenharmony_ci			       ctx_info->mm_reg_addr);
3488c2ecf20Sopenharmony_ci		}
3498c2ecf20Sopenharmony_ci
3508c2ecf20Sopenharmony_ci		printk("%sRegister Array:\n", newpfx);
3518c2ecf20Sopenharmony_ci		print_hex_dump(newpfx, "", DUMP_PREFIX_OFFSET, 16, groupsize,
3528c2ecf20Sopenharmony_ci			       (ctx_info + 1), ctx_info->reg_arr_size, 0);
3538c2ecf20Sopenharmony_ci
3548c2ecf20Sopenharmony_ci		ctx_info = (struct cper_ia_proc_ctx *)((long)ctx_info + size);
3558c2ecf20Sopenharmony_ci	}
3568c2ecf20Sopenharmony_ci}
357