^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * UEFI Common Platform Error Record (CPER) support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2010, Intel Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Author: Huang Ying <ying.huang@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * CPER is the format used to describe platform hardware error by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * various tables, such as ERST, BERT and HEST etc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * For more information about CPER, please refer to Appendix N of UEFI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Specification version 2.4.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/cper.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/dmi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/aer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/printk.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/bcd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <acpi/ghes.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <ras/ras_event.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * CPER record ID need to be unique even after reboot, because record
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * ID is used as index for ERST storage, while CPER records from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * multiple boot may co-exist in ERST.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) u64 cper_next_record_id(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) static atomic64_t seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) if (!atomic64_read(&seq)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) time64_t time = ktime_get_real_seconds();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * This code is unlikely to still be needed in year 2106,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * but just in case, let's use a few more bits for timestamps
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * after y2038 to be sure they keep increasing monotonically
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * for the next few hundred years...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) if (time < 0x80000000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) atomic64_set(&seq, (ktime_get_real_seconds()) << 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) atomic64_set(&seq, 0x8000000000000000ull |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) ktime_get_real_seconds() << 24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) return atomic64_inc_return(&seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) EXPORT_SYMBOL_GPL(cper_next_record_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) static const char * const severity_strs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) "recoverable",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) "fatal",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) "corrected",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) "info",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) const char *cper_severity_str(unsigned int severity)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) return severity < ARRAY_SIZE(severity_strs) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) severity_strs[severity] : "unknown";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) EXPORT_SYMBOL_GPL(cper_severity_str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) * cper_print_bits - print strings for set bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * @pfx: prefix for each line, including log level and prefix string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * @bits: bit mask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * @strs: string array, indexed by bit position
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * @strs_size: size of the string array: @strs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) * For each set bit in @bits, print the corresponding string in @strs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * If the output length is longer than 80, multiple line will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * printed, with @pfx is printed at the beginning of each line.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) void cper_print_bits(const char *pfx, unsigned int bits,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) const char * const strs[], unsigned int strs_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) int i, len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) const char *str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) char buf[84];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) for (i = 0; i < strs_size; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) if (!(bits & (1U << i)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) str = strs[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) if (!str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) if (len && len + strlen(str) + 2 > 80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) printk("%s\n", buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) if (!len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) len = snprintf(buf, sizeof(buf), "%s%s", pfx, str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) len += scnprintf(buf+len, sizeof(buf)-len, ", %s", str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) if (len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) printk("%s\n", buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) static const char * const proc_type_strs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) "IA32/X64",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) "IA64",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) "ARM",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) static const char * const proc_isa_strs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) "IA32",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) "IA64",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) "X64",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) "ARM A32/T32",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) "ARM A64",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) const char * const cper_proc_error_type_strs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) "cache error",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) "TLB error",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) "bus error",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) "micro-architectural error",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) static const char * const proc_op_strs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) "unknown or generic",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) "data read",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) "data write",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) "instruction execution",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) static const char * const proc_flag_strs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) "restartable",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) "precise IP",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) "overflow",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) "corrected",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static void cper_print_proc_generic(const char *pfx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) const struct cper_sec_proc_generic *proc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) if (proc->validation_bits & CPER_PROC_VALID_TYPE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) printk("%s""processor_type: %d, %s\n", pfx, proc->proc_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) proc->proc_type < ARRAY_SIZE(proc_type_strs) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) proc_type_strs[proc->proc_type] : "unknown");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) if (proc->validation_bits & CPER_PROC_VALID_ISA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) printk("%s""processor_isa: %d, %s\n", pfx, proc->proc_isa,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) proc->proc_isa < ARRAY_SIZE(proc_isa_strs) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) proc_isa_strs[proc->proc_isa] : "unknown");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) if (proc->validation_bits & CPER_PROC_VALID_ERROR_TYPE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) printk("%s""error_type: 0x%02x\n", pfx, proc->proc_error_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) cper_print_bits(pfx, proc->proc_error_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) cper_proc_error_type_strs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) ARRAY_SIZE(cper_proc_error_type_strs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) if (proc->validation_bits & CPER_PROC_VALID_OPERATION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) printk("%s""operation: %d, %s\n", pfx, proc->operation,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) proc->operation < ARRAY_SIZE(proc_op_strs) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) proc_op_strs[proc->operation] : "unknown");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) if (proc->validation_bits & CPER_PROC_VALID_FLAGS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) printk("%s""flags: 0x%02x\n", pfx, proc->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) cper_print_bits(pfx, proc->flags, proc_flag_strs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) ARRAY_SIZE(proc_flag_strs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) if (proc->validation_bits & CPER_PROC_VALID_LEVEL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) printk("%s""level: %d\n", pfx, proc->level);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) if (proc->validation_bits & CPER_PROC_VALID_VERSION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) printk("%s""version_info: 0x%016llx\n", pfx, proc->cpu_version);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) if (proc->validation_bits & CPER_PROC_VALID_ID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) printk("%s""processor_id: 0x%016llx\n", pfx, proc->proc_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) if (proc->validation_bits & CPER_PROC_VALID_TARGET_ADDRESS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) printk("%s""target_address: 0x%016llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) pfx, proc->target_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) if (proc->validation_bits & CPER_PROC_VALID_REQUESTOR_ID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) printk("%s""requestor_id: 0x%016llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) pfx, proc->requestor_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) if (proc->validation_bits & CPER_PROC_VALID_RESPONDER_ID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) printk("%s""responder_id: 0x%016llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) pfx, proc->responder_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) if (proc->validation_bits & CPER_PROC_VALID_IP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) printk("%s""IP: 0x%016llx\n", pfx, proc->ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) static const char * const mem_err_type_strs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) "unknown",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) "no error",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) "single-bit ECC",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) "multi-bit ECC",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) "single-symbol chipkill ECC",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) "multi-symbol chipkill ECC",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) "master abort",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) "target abort",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) "parity error",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) "watchdog timeout",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) "invalid address",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) "mirror Broken",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) "memory sparing",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) "scrub corrected error",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) "scrub uncorrected error",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) "physical memory map-out event",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) const char *cper_mem_err_type_str(unsigned int etype)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) return etype < ARRAY_SIZE(mem_err_type_strs) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) mem_err_type_strs[etype] : "unknown";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) EXPORT_SYMBOL_GPL(cper_mem_err_type_str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) static int cper_mem_err_location(struct cper_mem_err_compact *mem, char *msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) u32 len, n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) if (!msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) n = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) len = CPER_REC_LEN - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) if (mem->validation_bits & CPER_MEM_VALID_NODE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) n += scnprintf(msg + n, len - n, "node: %d ", mem->node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) if (mem->validation_bits & CPER_MEM_VALID_CARD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) n += scnprintf(msg + n, len - n, "card: %d ", mem->card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) if (mem->validation_bits & CPER_MEM_VALID_MODULE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) n += scnprintf(msg + n, len - n, "module: %d ", mem->module);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) if (mem->validation_bits & CPER_MEM_VALID_RANK_NUMBER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) n += scnprintf(msg + n, len - n, "rank: %d ", mem->rank);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) if (mem->validation_bits & CPER_MEM_VALID_BANK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) n += scnprintf(msg + n, len - n, "bank: %d ", mem->bank);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) if (mem->validation_bits & CPER_MEM_VALID_BANK_GROUP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) n += scnprintf(msg + n, len - n, "bank_group: %d ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) mem->bank >> CPER_MEM_BANK_GROUP_SHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) if (mem->validation_bits & CPER_MEM_VALID_BANK_ADDRESS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) n += scnprintf(msg + n, len - n, "bank_address: %d ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) mem->bank & CPER_MEM_BANK_ADDRESS_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) if (mem->validation_bits & CPER_MEM_VALID_DEVICE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) n += scnprintf(msg + n, len - n, "device: %d ", mem->device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) if (mem->validation_bits & (CPER_MEM_VALID_ROW | CPER_MEM_VALID_ROW_EXT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) u32 row = mem->row;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) row |= cper_get_mem_extension(mem->validation_bits, mem->extended);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) n += scnprintf(msg + n, len - n, "row: %d ", row);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) if (mem->validation_bits & CPER_MEM_VALID_COLUMN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) n += scnprintf(msg + n, len - n, "column: %d ", mem->column);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) if (mem->validation_bits & CPER_MEM_VALID_BIT_POSITION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) n += scnprintf(msg + n, len - n, "bit_position: %d ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) mem->bit_pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) if (mem->validation_bits & CPER_MEM_VALID_REQUESTOR_ID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) n += scnprintf(msg + n, len - n, "requestor_id: 0x%016llx ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) mem->requestor_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) if (mem->validation_bits & CPER_MEM_VALID_RESPONDER_ID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) n += scnprintf(msg + n, len - n, "responder_id: 0x%016llx ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) mem->responder_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) if (mem->validation_bits & CPER_MEM_VALID_TARGET_ID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) scnprintf(msg + n, len - n, "target_id: 0x%016llx ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) mem->target_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) if (mem->validation_bits & CPER_MEM_VALID_CHIP_ID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) scnprintf(msg + n, len - n, "chip_id: %d ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) mem->extended >> CPER_MEM_CHIP_ID_SHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) msg[n] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) return n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) static int cper_dimm_err_location(struct cper_mem_err_compact *mem, char *msg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) u32 len, n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) const char *bank = NULL, *device = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) if (!msg || !(mem->validation_bits & CPER_MEM_VALID_MODULE_HANDLE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) len = CPER_REC_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) dmi_memdev_name(mem->mem_dev_handle, &bank, &device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) if (bank && device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) n = snprintf(msg, len, "DIMM location: %s %s ", bank, device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) n = snprintf(msg, len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) "DIMM location: not present. DMI handle: 0x%.4x ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) mem->mem_dev_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) return n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) void cper_mem_err_pack(const struct cper_sec_mem_err *mem,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) struct cper_mem_err_compact *cmem)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) cmem->validation_bits = mem->validation_bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) cmem->node = mem->node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) cmem->card = mem->card;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) cmem->module = mem->module;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) cmem->bank = mem->bank;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) cmem->device = mem->device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) cmem->row = mem->row;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) cmem->column = mem->column;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) cmem->bit_pos = mem->bit_pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) cmem->requestor_id = mem->requestor_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) cmem->responder_id = mem->responder_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) cmem->target_id = mem->target_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) cmem->extended = mem->extended;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) cmem->rank = mem->rank;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) cmem->mem_array_handle = mem->mem_array_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) cmem->mem_dev_handle = mem->mem_dev_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) const char *cper_mem_err_unpack(struct trace_seq *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) struct cper_mem_err_compact *cmem)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) const char *ret = trace_seq_buffer_ptr(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) char rcd_decode_str[CPER_REC_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) if (cper_mem_err_location(cmem, rcd_decode_str))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) trace_seq_printf(p, "%s", rcd_decode_str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) if (cper_dimm_err_location(cmem, rcd_decode_str))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) trace_seq_printf(p, "%s", rcd_decode_str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) trace_seq_putc(p, '\0');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) static void cper_print_mem(const char *pfx, const struct cper_sec_mem_err *mem,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) struct cper_mem_err_compact cmem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) char rcd_decode_str[CPER_REC_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) /* Don't trust UEFI 2.1/2.2 structure with bad validation bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) if (len == sizeof(struct cper_sec_mem_err_old) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) (mem->validation_bits & ~(CPER_MEM_VALID_RANK_NUMBER - 1))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) pr_err(FW_WARN "valid bits set for fields beyond structure\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) if (mem->validation_bits & CPER_MEM_VALID_ERROR_STATUS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) printk("%s""error_status: 0x%016llx\n", pfx, mem->error_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) if (mem->validation_bits & CPER_MEM_VALID_PA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) printk("%s""physical_address: 0x%016llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) pfx, mem->physical_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) if (mem->validation_bits & CPER_MEM_VALID_PA_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) printk("%s""physical_address_mask: 0x%016llx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) pfx, mem->physical_addr_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) cper_mem_err_pack(mem, &cmem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) if (cper_mem_err_location(&cmem, rcd_decode_str))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) printk("%s%s\n", pfx, rcd_decode_str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) if (mem->validation_bits & CPER_MEM_VALID_ERROR_TYPE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) u8 etype = mem->error_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) printk("%s""error_type: %d, %s\n", pfx, etype,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) cper_mem_err_type_str(etype));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) if (cper_dimm_err_location(&cmem, rcd_decode_str))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) printk("%s%s\n", pfx, rcd_decode_str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) static const char * const pcie_port_type_strs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) "PCIe end point",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) "legacy PCI end point",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) "unknown",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) "unknown",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) "root port",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) "upstream switch port",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) "downstream switch port",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) "PCIe to PCI/PCI-X bridge",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) "PCI/PCI-X to PCIe bridge",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) "root complex integrated endpoint device",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) "root complex event collector",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) static void cper_print_pcie(const char *pfx, const struct cper_sec_pcie *pcie,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) const struct acpi_hest_generic_data *gdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) if (pcie->validation_bits & CPER_PCIE_VALID_PORT_TYPE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) printk("%s""port_type: %d, %s\n", pfx, pcie->port_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) pcie->port_type < ARRAY_SIZE(pcie_port_type_strs) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) pcie_port_type_strs[pcie->port_type] : "unknown");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) if (pcie->validation_bits & CPER_PCIE_VALID_VERSION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) printk("%s""version: %d.%d\n", pfx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) pcie->version.major, pcie->version.minor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) if (pcie->validation_bits & CPER_PCIE_VALID_COMMAND_STATUS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) printk("%s""command: 0x%04x, status: 0x%04x\n", pfx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) pcie->command, pcie->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) if (pcie->validation_bits & CPER_PCIE_VALID_DEVICE_ID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) const __u8 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) printk("%s""device_id: %04x:%02x:%02x.%x\n", pfx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) pcie->device_id.segment, pcie->device_id.bus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) pcie->device_id.device, pcie->device_id.function);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) printk("%s""slot: %d\n", pfx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) pcie->device_id.slot >> CPER_PCIE_SLOT_SHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) printk("%s""secondary_bus: 0x%02x\n", pfx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) pcie->device_id.secondary_bus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) printk("%s""vendor_id: 0x%04x, device_id: 0x%04x\n", pfx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) pcie->device_id.vendor_id, pcie->device_id.device_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) p = pcie->device_id.class_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) printk("%s""class_code: %02x%02x%02x\n", pfx, p[2], p[1], p[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) if (pcie->validation_bits & CPER_PCIE_VALID_SERIAL_NUMBER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) printk("%s""serial number: 0x%04x, 0x%04x\n", pfx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) pcie->serial_number.lower, pcie->serial_number.upper);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) if (pcie->validation_bits & CPER_PCIE_VALID_BRIDGE_CONTROL_STATUS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) printk(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) "%s""bridge: secondary_status: 0x%04x, control: 0x%04x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) pfx, pcie->bridge.secondary_status, pcie->bridge.control);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) /* Fatal errors call __ghes_panic() before AER handler prints this */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) if ((pcie->validation_bits & CPER_PCIE_VALID_AER_INFO) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) (gdata->error_severity & CPER_SEV_FATAL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) struct aer_capability_regs *aer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) aer = (struct aer_capability_regs *)pcie->aer_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) printk("%saer_uncor_status: 0x%08x, aer_uncor_mask: 0x%08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) pfx, aer->uncor_status, aer->uncor_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) printk("%saer_uncor_severity: 0x%08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) pfx, aer->uncor_severity);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) printk("%sTLP Header: %08x %08x %08x %08x\n", pfx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) aer->header_log.dw0, aer->header_log.dw1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) aer->header_log.dw2, aer->header_log.dw3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) static const char * const fw_err_rec_type_strs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) "IPF SAL Error Record",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) "SOC Firmware Error Record Type1 (Legacy CrashLog Support)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) "SOC Firmware Error Record Type2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) static void cper_print_fw_err(const char *pfx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) struct acpi_hest_generic_data *gdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) const struct cper_sec_fw_err_rec_ref *fw_err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) void *buf = acpi_hest_get_payload(gdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) u32 offset, length = gdata->error_data_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) printk("%s""Firmware Error Record Type: %s\n", pfx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) fw_err->record_type < ARRAY_SIZE(fw_err_rec_type_strs) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) fw_err_rec_type_strs[fw_err->record_type] : "unknown");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) printk("%s""Revision: %d\n", pfx, fw_err->revision);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) /* Record Type based on UEFI 2.7 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) if (fw_err->revision == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) printk("%s""Record Identifier: %08llx\n", pfx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) fw_err->record_identifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) } else if (fw_err->revision == 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) printk("%s""Record Identifier: %pUl\n", pfx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) &fw_err->record_identifier_guid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) * The FW error record may contain trailing data beyond the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) * structure defined by the specification. As the fields
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) * defined (and hence the offset of any trailing data) vary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) * with the revision, set the offset to account for this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) * variation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) if (fw_err->revision == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) /* record_identifier_guid not defined */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) offset = offsetof(struct cper_sec_fw_err_rec_ref,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) record_identifier_guid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) } else if (fw_err->revision == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) /* record_identifier not defined */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) offset = offsetof(struct cper_sec_fw_err_rec_ref,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) record_identifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) offset = sizeof(*fw_err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) buf += offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) length -= offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) print_hex_dump(pfx, "", DUMP_PREFIX_OFFSET, 16, 4, buf, length, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) static void cper_print_tstamp(const char *pfx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) struct acpi_hest_generic_data_v300 *gdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) __u8 hour, min, sec, day, mon, year, century, *timestamp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) if (gdata->validation_bits & ACPI_HEST_GEN_VALID_TIMESTAMP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) timestamp = (__u8 *)&(gdata->time_stamp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) sec = bcd2bin(timestamp[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) min = bcd2bin(timestamp[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) hour = bcd2bin(timestamp[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) day = bcd2bin(timestamp[4]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) mon = bcd2bin(timestamp[5]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) year = bcd2bin(timestamp[6]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) century = bcd2bin(timestamp[7]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) printk("%s%ststamp: %02d%02d-%02d-%02d %02d:%02d:%02d\n", pfx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) (timestamp[3] & 0x1 ? "precise " : "imprecise "),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) century, year, mon, day, hour, min, sec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) cper_estatus_print_section(const char *pfx, struct acpi_hest_generic_data *gdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) int sec_no)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) guid_t *sec_type = (guid_t *)gdata->section_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) __u16 severity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) char newpfx[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) if (acpi_hest_get_version(gdata) >= 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) cper_print_tstamp(pfx, (struct acpi_hest_generic_data_v300 *)gdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) severity = gdata->error_severity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) printk("%s""Error %d, type: %s\n", pfx, sec_no,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) cper_severity_str(severity));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) printk("%s""fru_id: %pUl\n", pfx, gdata->fru_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) printk("%s""fru_text: %.20s\n", pfx, gdata->fru_text);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) snprintf(newpfx, sizeof(newpfx), "%s ", pfx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) if (guid_equal(sec_type, &CPER_SEC_PROC_GENERIC)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) struct cper_sec_proc_generic *proc_err = acpi_hest_get_payload(gdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) printk("%s""section_type: general processor error\n", newpfx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) if (gdata->error_data_length >= sizeof(*proc_err))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) cper_print_proc_generic(newpfx, proc_err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) goto err_section_too_small;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) } else if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) struct cper_sec_mem_err *mem_err = acpi_hest_get_payload(gdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) printk("%s""section_type: memory error\n", newpfx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) if (gdata->error_data_length >=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) sizeof(struct cper_sec_mem_err_old))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) cper_print_mem(newpfx, mem_err,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) gdata->error_data_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) goto err_section_too_small;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) } else if (guid_equal(sec_type, &CPER_SEC_PCIE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) struct cper_sec_pcie *pcie = acpi_hest_get_payload(gdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) printk("%s""section_type: PCIe error\n", newpfx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) if (gdata->error_data_length >= sizeof(*pcie))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) cper_print_pcie(newpfx, pcie, gdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) goto err_section_too_small;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) #if defined(CONFIG_ARM64) || defined(CONFIG_ARM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) } else if (guid_equal(sec_type, &CPER_SEC_PROC_ARM)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) struct cper_sec_proc_arm *arm_err = acpi_hest_get_payload(gdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) printk("%ssection_type: ARM processor error\n", newpfx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) if (gdata->error_data_length >= sizeof(*arm_err))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) cper_print_proc_arm(newpfx, arm_err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) goto err_section_too_small;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) #if defined(CONFIG_UEFI_CPER_X86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) } else if (guid_equal(sec_type, &CPER_SEC_PROC_IA)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) struct cper_sec_proc_ia *ia_err = acpi_hest_get_payload(gdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) printk("%ssection_type: IA32/X64 processor error\n", newpfx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) if (gdata->error_data_length >= sizeof(*ia_err))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) cper_print_proc_ia(newpfx, ia_err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) goto err_section_too_small;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) } else if (guid_equal(sec_type, &CPER_SEC_FW_ERR_REC_REF)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) struct cper_sec_fw_err_rec_ref *fw_err = acpi_hest_get_payload(gdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) printk("%ssection_type: Firmware Error Record Reference\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) newpfx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) /* The minimal FW Error Record contains 16 bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) if (gdata->error_data_length >= SZ_16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) cper_print_fw_err(newpfx, gdata, fw_err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) goto err_section_too_small;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) const void *err = acpi_hest_get_payload(gdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) printk("%ssection type: unknown, %pUl\n", newpfx, sec_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) printk("%ssection length: %#x\n", newpfx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) gdata->error_data_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) print_hex_dump(newpfx, "", DUMP_PREFIX_OFFSET, 16, 4, err,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) gdata->error_data_length, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) err_section_too_small:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) pr_err(FW_WARN "error section length is too small\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) void cper_estatus_print(const char *pfx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) const struct acpi_hest_generic_status *estatus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) struct acpi_hest_generic_data *gdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) int sec_no = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) char newpfx[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) __u16 severity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) severity = estatus->error_severity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) if (severity == CPER_SEV_CORRECTED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) printk("%s%s\n", pfx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) "It has been corrected by h/w "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) "and requires no further action");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) printk("%s""event severity: %s\n", pfx, cper_severity_str(severity));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) snprintf(newpfx, sizeof(newpfx), "%s ", pfx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) apei_estatus_for_each_section(estatus, gdata) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) cper_estatus_print_section(newpfx, gdata, sec_no);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) sec_no++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) EXPORT_SYMBOL_GPL(cper_estatus_print);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) int cper_estatus_check_header(const struct acpi_hest_generic_status *estatus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) if (estatus->data_length &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) estatus->data_length < sizeof(struct acpi_hest_generic_data))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) if (estatus->raw_data_length &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) estatus->raw_data_offset < sizeof(*estatus) + estatus->data_length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) EXPORT_SYMBOL_GPL(cper_estatus_check_header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) int cper_estatus_check(const struct acpi_hest_generic_status *estatus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) struct acpi_hest_generic_data *gdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) unsigned int data_len, record_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) rc = cper_estatus_check_header(estatus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) data_len = estatus->data_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) apei_estatus_for_each_section(estatus, gdata) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) if (sizeof(struct acpi_hest_generic_data) > data_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) record_size = acpi_hest_get_record_size(gdata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) if (record_size > data_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) data_len -= record_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) if (data_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) EXPORT_SYMBOL_GPL(cper_estatus_check);