Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'ras_core_for_v6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 RAS updates from Borislav Petkov:

- Convert the hw error storm handling into a finer-grained, per-bank
solution which allows for more timely detection and reporting of
errors

- Start a documentation section which will hold down relevant RAS
features description and how they should be used

- Add new AMD error bank types

- Slim down and remove error type descriptions from the kernel side of
error decoding to rasdaemon which can be used from now on to decode
hw errors on AMD

- Mark pages containing uncorrectable errors as poison so that kdump
can avoid them and thus not cause another panic

- The usual cleanups and fixlets

* tag 'ras_core_for_v6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/mce: Handle Intel threshold interrupt storms
x86/mce: Add per-bank CMCI storm mitigation
x86/mce: Remove old CMCI storm mitigation code
Documentation: Begin a RAS section
x86/MCE/AMD: Add new MA_LLC, USR_DP, and USR_CP bank types
EDAC/mce_amd: Remove SMCA Extended Error code descriptions
x86/mce/amd, EDAC/mce_amd: Move long names to decoder module
x86/mce/inject: Clear test status value
x86/mce: Remove redundant check from mce_device_create()
x86/mce: Mark fatal MCE's page as poison to avoid panic in the kdump kernel

+468 -749
+26
Documentation/RAS/ras.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0 2 + 3 + Reliability, Availability and Serviceability features 4 + ===================================================== 5 + 6 + This documents different aspects of the RAS functionality present in the 7 + kernel. 8 + 9 + Error decoding 10 + --------------- 11 + 12 + * x86 13 + 14 + Error decoding on AMD systems should be done using the rasdaemon tool: 15 + https://github.com/mchehab/rasdaemon/ 16 + 17 + While the daemon is running, it would automatically log and decode 18 + errors. If not, one can still decode such errors by supplying the 19 + hardware information from the error:: 20 + 21 + $ rasdaemon -p --status <STATUS> --ipid <IPID> --smca 22 + 23 + Also, the user can pass particular family and model to decode the error 24 + string:: 25 + 26 + $ rasdaemon -p --status <STATUS> --ipid <IPID> --smca --family <CPU Family> --model <CPU Model> --bank <BANK_NUM>
+1
Documentation/index.rst
··· 113 113 :maxdepth: 1 114 114 115 115 staging/index 116 + RAS/ras 116 117 117 118 118 119 Translations
+3 -1
arch/x86/include/asm/mce.h
··· 311 311 SMCA_PIE, /* Power, Interrupts, etc. */ 312 312 SMCA_UMC, /* Unified Memory Controller */ 313 313 SMCA_UMC_V2, 314 + SMCA_MA_LLC, /* Memory Attached Last Level Cache */ 314 315 SMCA_PB, /* Parameter Block */ 315 316 SMCA_PSP, /* Platform Security Processor */ 316 317 SMCA_PSP_V2, ··· 327 326 SMCA_SHUB, /* System HUB Unit */ 328 327 SMCA_SATA, /* SATA Unit */ 329 328 SMCA_USB, /* USB Unit */ 329 + SMCA_USR_DP, /* Ultra Short Reach Data Plane Controller */ 330 + SMCA_USR_CP, /* Ultra Short Reach Control Plane Controller */ 330 331 SMCA_GMI_PCS, /* GMI PCS Unit */ 331 332 SMCA_XGMI_PHY, /* xGMI PHY Unit */ 332 333 SMCA_WAFL_PHY, /* WAFL PHY Unit */ ··· 336 333 N_SMCA_BANK_TYPES 337 334 }; 338 335 339 - extern const char *smca_get_long_name(enum smca_bank_types t); 340 336 extern bool amd_mce_is_memory_error(struct mce *m); 341 337 342 338 extern int mce_threshold_create_device(unsigned int cpu);
+36 -44
arch/x86/kernel/cpu/mce/amd.c
··· 87 87 static DEFINE_PER_CPU_READ_MOSTLY(struct smca_bank[MAX_NR_BANKS], smca_banks); 88 88 static DEFINE_PER_CPU_READ_MOSTLY(u8[N_SMCA_BANK_TYPES], smca_bank_counts); 89 89 90 - struct smca_bank_name { 91 - const char *name; /* Short name for sysfs */ 92 - const char *long_name; /* Long name for pretty-printing */ 93 - }; 94 - 95 - static struct smca_bank_name smca_names[] = { 96 - [SMCA_LS ... SMCA_LS_V2] = { "load_store", "Load Store Unit" }, 97 - [SMCA_IF] = { "insn_fetch", "Instruction Fetch Unit" }, 98 - [SMCA_L2_CACHE] = { "l2_cache", "L2 Cache" }, 99 - [SMCA_DE] = { "decode_unit", "Decode Unit" }, 100 - [SMCA_RESERVED] = { "reserved", "Reserved" }, 101 - [SMCA_EX] = { "execution_unit", "Execution Unit" }, 102 - [SMCA_FP] = { "floating_point", "Floating Point Unit" }, 103 - [SMCA_L3_CACHE] = { "l3_cache", "L3 Cache" }, 104 - [SMCA_CS ... SMCA_CS_V2] = { "coherent_slave", "Coherent Slave" }, 105 - [SMCA_PIE] = { "pie", "Power, Interrupts, etc." }, 90 + static const char * const smca_names[] = { 91 + [SMCA_LS ... SMCA_LS_V2] = "load_store", 92 + [SMCA_IF] = "insn_fetch", 93 + [SMCA_L2_CACHE] = "l2_cache", 94 + [SMCA_DE] = "decode_unit", 95 + [SMCA_RESERVED] = "reserved", 96 + [SMCA_EX] = "execution_unit", 97 + [SMCA_FP] = "floating_point", 98 + [SMCA_L3_CACHE] = "l3_cache", 99 + [SMCA_CS ... SMCA_CS_V2] = "coherent_slave", 100 + [SMCA_PIE] = "pie", 106 101 107 102 /* UMC v2 is separate because both of them can exist in a single system. */ 108 - [SMCA_UMC] = { "umc", "Unified Memory Controller" }, 109 - [SMCA_UMC_V2] = { "umc_v2", "Unified Memory Controller v2" }, 110 - [SMCA_PB] = { "param_block", "Parameter Block" }, 111 - [SMCA_PSP ... SMCA_PSP_V2] = { "psp", "Platform Security Processor" }, 112 - [SMCA_SMU ... SMCA_SMU_V2] = { "smu", "System Management Unit" }, 113 - [SMCA_MP5] = { "mp5", "Microprocessor 5 Unit" }, 114 - [SMCA_MPDMA] = { "mpdma", "MPDMA Unit" }, 115 - [SMCA_NBIO] = { "nbio", "Northbridge IO Unit" }, 116 - [SMCA_PCIE ... SMCA_PCIE_V2] = { "pcie", "PCI Express Unit" }, 117 - [SMCA_XGMI_PCS] = { "xgmi_pcs", "Ext Global Memory Interconnect PCS Unit" }, 118 - [SMCA_NBIF] = { "nbif", "NBIF Unit" }, 119 - [SMCA_SHUB] = { "shub", "System Hub Unit" }, 120 - [SMCA_SATA] = { "sata", "SATA Unit" }, 121 - [SMCA_USB] = { "usb", "USB Unit" }, 122 - [SMCA_GMI_PCS] = { "gmi_pcs", "Global Memory Interconnect PCS Unit" }, 123 - [SMCA_XGMI_PHY] = { "xgmi_phy", "Ext Global Memory Interconnect PHY Unit" }, 124 - [SMCA_WAFL_PHY] = { "wafl_phy", "WAFL PHY Unit" }, 125 - [SMCA_GMI_PHY] = { "gmi_phy", "Global Memory Interconnect PHY Unit" }, 103 + [SMCA_UMC] = "umc", 104 + [SMCA_UMC_V2] = "umc_v2", 105 + [SMCA_MA_LLC] = "ma_llc", 106 + [SMCA_PB] = "param_block", 107 + [SMCA_PSP ... SMCA_PSP_V2] = "psp", 108 + [SMCA_SMU ... SMCA_SMU_V2] = "smu", 109 + [SMCA_MP5] = "mp5", 110 + [SMCA_MPDMA] = "mpdma", 111 + [SMCA_NBIO] = "nbio", 112 + [SMCA_PCIE ... SMCA_PCIE_V2] = "pcie", 113 + [SMCA_XGMI_PCS] = "xgmi_pcs", 114 + [SMCA_NBIF] = "nbif", 115 + [SMCA_SHUB] = "shub", 116 + [SMCA_SATA] = "sata", 117 + [SMCA_USB] = "usb", 118 + [SMCA_USR_DP] = "usr_dp", 119 + [SMCA_USR_CP] = "usr_cp", 120 + [SMCA_GMI_PCS] = "gmi_pcs", 121 + [SMCA_XGMI_PHY] = "xgmi_phy", 122 + [SMCA_WAFL_PHY] = "wafl_phy", 123 + [SMCA_GMI_PHY] = "gmi_phy", 126 124 }; 127 125 128 126 static const char *smca_get_name(enum smca_bank_types t) ··· 128 130 if (t >= N_SMCA_BANK_TYPES) 129 131 return NULL; 130 132 131 - return smca_names[t].name; 133 + return smca_names[t]; 132 134 } 133 - 134 - const char *smca_get_long_name(enum smca_bank_types t) 135 - { 136 - if (t >= N_SMCA_BANK_TYPES) 137 - return NULL; 138 - 139 - return smca_names[t].long_name; 140 - } 141 - EXPORT_SYMBOL_GPL(smca_get_long_name); 142 135 143 136 enum smca_bank_types smca_get_bank_type(unsigned int cpu, unsigned int bank) 144 137 { ··· 167 178 { SMCA_CS, HWID_MCATYPE(0x2E, 0x0) }, 168 179 { SMCA_PIE, HWID_MCATYPE(0x2E, 0x1) }, 169 180 { SMCA_CS_V2, HWID_MCATYPE(0x2E, 0x2) }, 181 + { SMCA_MA_LLC, HWID_MCATYPE(0x2E, 0x4) }, 170 182 171 183 /* Unified Memory Controller MCA type */ 172 184 { SMCA_UMC, HWID_MCATYPE(0x96, 0x0) }, ··· 202 212 { SMCA_SHUB, HWID_MCATYPE(0x80, 0x0) }, 203 213 { SMCA_SATA, HWID_MCATYPE(0xA8, 0x0) }, 204 214 { SMCA_USB, HWID_MCATYPE(0xAA, 0x0) }, 215 + { SMCA_USR_DP, HWID_MCATYPE(0x170, 0x0) }, 216 + { SMCA_USR_CP, HWID_MCATYPE(0x180, 0x0) }, 205 217 { SMCA_GMI_PCS, HWID_MCATYPE(0x241, 0x0) }, 206 218 { SMCA_XGMI_PHY, HWID_MCATYPE(0x259, 0x0) }, 207 219 { SMCA_WAFL_PHY, HWID_MCATYPE(0x267, 0x0) },
+42 -30
arch/x86/kernel/cpu/mce/core.c
··· 44 44 #include <linux/sync_core.h> 45 45 #include <linux/task_work.h> 46 46 #include <linux/hardirq.h> 47 + #include <linux/kexec.h> 47 48 48 49 #include <asm/intel-family.h> 49 50 #include <asm/processor.h> ··· 234 233 struct llist_node *pending; 235 234 struct mce_evt_llist *l; 236 235 int apei_err = 0; 236 + struct page *p; 237 237 238 238 /* 239 239 * Allow instrumentation around external facilities usage. Not that it ··· 288 286 if (!fake_panic) { 289 287 if (panic_timeout == 0) 290 288 panic_timeout = mca_cfg.panic_timeout; 289 + 290 + /* 291 + * Kdump skips the poisoned page in order to avoid 292 + * touching the error bits again. Poison the page even 293 + * if the error is fatal and the machine is about to 294 + * panic. 295 + */ 296 + if (kexec_crash_loaded()) { 297 + if (final && (final->status & MCI_STATUS_ADDRV)) { 298 + p = pfn_to_online_page(final->addr >> PAGE_SHIFT); 299 + if (p) 300 + SetPageHWPoison(p); 301 + } 302 + } 291 303 panic(msg); 292 304 } else 293 305 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg); ··· 685 669 686 670 barrier(); 687 671 m.status = mce_rdmsrl(mca_msr_reg(i, MCA_STATUS)); 672 + 673 + /* 674 + * Update storm tracking here, before checking for the 675 + * MCI_STATUS_VAL bit. Valid corrected errors count 676 + * towards declaring, or maintaining, storm status. No 677 + * error in a bank counts towards avoiding, or ending, 678 + * storm status. 679 + */ 680 + if (!mca_cfg.cmci_disabled) 681 + mce_track_storm(&m); 688 682 689 683 /* If this entry is not valid, ignore it */ 690 684 if (!(m.status & MCI_STATUS_VAL)) ··· 1627 1601 static DEFINE_PER_CPU(unsigned long, mce_next_interval); /* in jiffies */ 1628 1602 static DEFINE_PER_CPU(struct timer_list, mce_timer); 1629 1603 1630 - static unsigned long mce_adjust_timer_default(unsigned long interval) 1631 - { 1632 - return interval; 1633 - } 1634 - 1635 - static unsigned long (*mce_adjust_timer)(unsigned long interval) = mce_adjust_timer_default; 1636 - 1637 1604 static void __start_timer(struct timer_list *t, unsigned long interval) 1638 1605 { 1639 1606 unsigned long when = jiffies + interval; ··· 1656 1637 1657 1638 iv = __this_cpu_read(mce_next_interval); 1658 1639 1659 - if (mce_available(this_cpu_ptr(&cpu_info))) { 1640 + if (mce_available(this_cpu_ptr(&cpu_info))) 1660 1641 mc_poll_banks(); 1661 - 1662 - if (mce_intel_cmci_poll()) { 1663 - iv = mce_adjust_timer(iv); 1664 - goto done; 1665 - } 1666 - } 1667 1642 1668 1643 /* 1669 1644 * Alert userspace if needed. If we logged an MCE, reduce the polling ··· 1668 1655 else 1669 1656 iv = min(iv * 2, round_jiffies_relative(check_interval * HZ)); 1670 1657 1671 - done: 1672 - __this_cpu_write(mce_next_interval, iv); 1673 - __start_timer(t, iv); 1658 + if (mce_get_storm_mode()) { 1659 + __start_timer(t, HZ); 1660 + } else { 1661 + __this_cpu_write(mce_next_interval, iv); 1662 + __start_timer(t, iv); 1663 + } 1674 1664 } 1675 1665 1676 1666 /* 1677 - * Ensure that the timer is firing in @interval from now. 1667 + * When a storm starts on any bank on this CPU, switch to polling 1668 + * once per second. When the storm ends, revert to the default 1669 + * polling interval. 1678 1670 */ 1679 - void mce_timer_kick(unsigned long interval) 1671 + void mce_timer_kick(bool storm) 1680 1672 { 1681 1673 struct timer_list *t = this_cpu_ptr(&mce_timer); 1682 - unsigned long iv = __this_cpu_read(mce_next_interval); 1683 1674 1684 - __start_timer(t, interval); 1675 + mce_set_storm_mode(storm); 1685 1676 1686 - if (interval < iv) 1687 - __this_cpu_write(mce_next_interval, interval); 1677 + if (storm) 1678 + __start_timer(t, HZ); 1679 + else 1680 + __this_cpu_write(mce_next_interval, check_interval * HZ); 1688 1681 } 1689 1682 1690 1683 /* Must not be called in IRQ context where del_timer_sync() can deadlock */ ··· 2014 1995 2015 1996 intel_init_cmci(); 2016 1997 intel_init_lmce(); 2017 - mce_adjust_timer = cmci_intel_adjust_timer; 2018 1998 } 2019 1999 2020 2000 static void mce_zhaoxin_feature_clear(struct cpuinfo_x86 *c) ··· 2026 2008 switch (c->x86_vendor) { 2027 2009 case X86_VENDOR_INTEL: 2028 2010 mce_intel_feature_init(c); 2029 - mce_adjust_timer = cmci_intel_adjust_timer; 2030 2011 break; 2031 2012 2032 2013 case X86_VENDOR_AMD: { ··· 2585 2568 int err; 2586 2569 int i, j; 2587 2570 2588 - if (!mce_available(&boot_cpu_data)) 2589 - return -EIO; 2590 - 2591 2571 dev = per_cpu(mce_device, cpu); 2592 2572 if (dev) 2593 2573 return 0; ··· 2679 2665 2680 2666 static int mce_cpu_dead(unsigned int cpu) 2681 2667 { 2682 - mce_intel_hcpu_update(cpu); 2683 - 2684 2668 /* intentionally ignoring frozen here */ 2685 2669 if (!cpuhp_tasks_frozen) 2686 2670 cmci_rediscover();
+1
arch/x86/kernel/cpu/mce/inject.c
··· 746 746 747 747 wrmsrl_safe(mca_msr_reg(bank, MCA_STATUS), status); 748 748 rdmsrl_safe(mca_msr_reg(bank, MCA_STATUS), &status); 749 + wrmsrl_safe(mca_msr_reg(bank, MCA_STATUS), 0); 749 750 750 751 if (!status) { 751 752 hw_injection_possible = false;
+143 -183
arch/x86/kernel/cpu/mce/intel.c
··· 42 42 static DEFINE_PER_CPU(mce_banks_t, mce_banks_owned); 43 43 44 44 /* 45 - * CMCI storm detection backoff counter 46 - * 47 - * During storm, we reset this counter to INITIAL_CHECK_INTERVAL in case we've 48 - * encountered an error. If not, we decrement it by one. We signal the end of 49 - * the CMCI storm when it reaches 0. 50 - */ 51 - static DEFINE_PER_CPU(int, cmci_backoff_cnt); 52 - 53 - /* 54 45 * cmci_discover_lock protects against parallel discovery attempts 55 46 * which could race against each other. 56 47 */ ··· 54 63 */ 55 64 static DEFINE_SPINLOCK(cmci_poll_lock); 56 65 66 + /* Linux non-storm CMCI threshold (may be overridden by BIOS) */ 57 67 #define CMCI_THRESHOLD 1 58 - #define CMCI_POLL_INTERVAL (30 * HZ) 59 - #define CMCI_STORM_INTERVAL (HZ) 60 - #define CMCI_STORM_THRESHOLD 15 61 68 62 - static DEFINE_PER_CPU(unsigned long, cmci_time_stamp); 63 - static DEFINE_PER_CPU(unsigned int, cmci_storm_cnt); 64 - static DEFINE_PER_CPU(unsigned int, cmci_storm_state); 69 + /* 70 + * MCi_CTL2 threshold for each bank when there is no storm. 71 + * Default value for each bank may have been set by BIOS. 72 + */ 73 + static u16 cmci_threshold[MAX_NR_BANKS]; 65 74 66 - enum { 67 - CMCI_STORM_NONE, 68 - CMCI_STORM_ACTIVE, 69 - CMCI_STORM_SUBSIDED, 70 - }; 71 - 72 - static atomic_t cmci_storm_on_cpus; 75 + /* 76 + * High threshold to limit CMCI rate during storms. Max supported is 77 + * 0x7FFF. Use this slightly smaller value so it has a distinctive 78 + * signature when some asks "Why am I not seeing all corrected errors?" 79 + * A high threshold is used instead of just disabling CMCI for a 80 + * bank because both corrected and uncorrected errors may be logged 81 + * in the same bank and signalled with CMCI. The threshold only applies 82 + * to corrected errors, so keeping CMCI enabled means that uncorrected 83 + * errors will still be processed in a timely fashion. 84 + */ 85 + #define CMCI_STORM_THRESHOLD 32749 73 86 74 87 static int cmci_supported(int *banks) 75 88 { ··· 129 134 return tmp & FEAT_CTL_LMCE_ENABLED; 130 135 } 131 136 132 - bool mce_intel_cmci_poll(void) 137 + /* 138 + * Set a new CMCI threshold value. Preserve the state of the 139 + * MCI_CTL2_CMCI_EN bit in case this happens during a 140 + * cmci_rediscover() operation. 141 + */ 142 + static void cmci_set_threshold(int bank, int thresh) 133 143 { 134 - if (__this_cpu_read(cmci_storm_state) == CMCI_STORM_NONE) 135 - return false; 136 - 137 - /* 138 - * Reset the counter if we've logged an error in the last poll 139 - * during the storm. 140 - */ 141 - if (machine_check_poll(0, this_cpu_ptr(&mce_banks_owned))) 142 - this_cpu_write(cmci_backoff_cnt, INITIAL_CHECK_INTERVAL); 143 - else 144 - this_cpu_dec(cmci_backoff_cnt); 145 - 146 - return true; 147 - } 148 - 149 - void mce_intel_hcpu_update(unsigned long cpu) 150 - { 151 - if (per_cpu(cmci_storm_state, cpu) == CMCI_STORM_ACTIVE) 152 - atomic_dec(&cmci_storm_on_cpus); 153 - 154 - per_cpu(cmci_storm_state, cpu) = CMCI_STORM_NONE; 155 - } 156 - 157 - static void cmci_toggle_interrupt_mode(bool on) 158 - { 159 - unsigned long flags, *owned; 160 - int bank; 144 + unsigned long flags; 161 145 u64 val; 162 146 163 147 raw_spin_lock_irqsave(&cmci_discover_lock, flags); 164 - owned = this_cpu_ptr(mce_banks_owned); 165 - for_each_set_bit(bank, owned, MAX_NR_BANKS) { 166 - rdmsrl(MSR_IA32_MCx_CTL2(bank), val); 167 - 168 - if (on) 169 - val |= MCI_CTL2_CMCI_EN; 170 - else 171 - val &= ~MCI_CTL2_CMCI_EN; 172 - 173 - wrmsrl(MSR_IA32_MCx_CTL2(bank), val); 174 - } 148 + rdmsrl(MSR_IA32_MCx_CTL2(bank), val); 149 + val &= ~MCI_CTL2_CMCI_THRESHOLD_MASK; 150 + wrmsrl(MSR_IA32_MCx_CTL2(bank), val | thresh); 175 151 raw_spin_unlock_irqrestore(&cmci_discover_lock, flags); 176 152 } 177 153 178 - unsigned long cmci_intel_adjust_timer(unsigned long interval) 154 + void mce_intel_handle_storm(int bank, bool on) 179 155 { 180 - if ((this_cpu_read(cmci_backoff_cnt) > 0) && 181 - (__this_cpu_read(cmci_storm_state) == CMCI_STORM_ACTIVE)) { 182 - mce_notify_irq(); 183 - return CMCI_STORM_INTERVAL; 184 - } 185 - 186 - switch (__this_cpu_read(cmci_storm_state)) { 187 - case CMCI_STORM_ACTIVE: 188 - 189 - /* 190 - * We switch back to interrupt mode once the poll timer has 191 - * silenced itself. That means no events recorded and the timer 192 - * interval is back to our poll interval. 193 - */ 194 - __this_cpu_write(cmci_storm_state, CMCI_STORM_SUBSIDED); 195 - if (!atomic_sub_return(1, &cmci_storm_on_cpus)) 196 - pr_notice("CMCI storm subsided: switching to interrupt mode\n"); 197 - 198 - fallthrough; 199 - 200 - case CMCI_STORM_SUBSIDED: 201 - /* 202 - * We wait for all CPUs to go back to SUBSIDED state. When that 203 - * happens we switch back to interrupt mode. 204 - */ 205 - if (!atomic_read(&cmci_storm_on_cpus)) { 206 - __this_cpu_write(cmci_storm_state, CMCI_STORM_NONE); 207 - cmci_toggle_interrupt_mode(true); 208 - cmci_recheck(); 209 - } 210 - return CMCI_POLL_INTERVAL; 211 - default: 212 - 213 - /* We have shiny weather. Let the poll do whatever it thinks. */ 214 - return interval; 215 - } 216 - } 217 - 218 - static bool cmci_storm_detect(void) 219 - { 220 - unsigned int cnt = __this_cpu_read(cmci_storm_cnt); 221 - unsigned long ts = __this_cpu_read(cmci_time_stamp); 222 - unsigned long now = jiffies; 223 - int r; 224 - 225 - if (__this_cpu_read(cmci_storm_state) != CMCI_STORM_NONE) 226 - return true; 227 - 228 - if (time_before_eq(now, ts + CMCI_STORM_INTERVAL)) { 229 - cnt++; 230 - } else { 231 - cnt = 1; 232 - __this_cpu_write(cmci_time_stamp, now); 233 - } 234 - __this_cpu_write(cmci_storm_cnt, cnt); 235 - 236 - if (cnt <= CMCI_STORM_THRESHOLD) 237 - return false; 238 - 239 - cmci_toggle_interrupt_mode(false); 240 - __this_cpu_write(cmci_storm_state, CMCI_STORM_ACTIVE); 241 - r = atomic_add_return(1, &cmci_storm_on_cpus); 242 - mce_timer_kick(CMCI_STORM_INTERVAL); 243 - this_cpu_write(cmci_backoff_cnt, INITIAL_CHECK_INTERVAL); 244 - 245 - if (r == 1) 246 - pr_notice("CMCI storm detected: switching to poll mode\n"); 247 - return true; 156 + if (on) 157 + cmci_set_threshold(bank, CMCI_STORM_THRESHOLD); 158 + else 159 + cmci_set_threshold(bank, cmci_threshold[bank]); 248 160 } 249 161 250 162 /* ··· 162 260 */ 163 261 static void intel_threshold_interrupt(void) 164 262 { 165 - if (cmci_storm_detect()) 166 - return; 167 - 168 263 machine_check_poll(MCP_TIMESTAMP, this_cpu_ptr(&mce_banks_owned)); 264 + } 265 + 266 + /* 267 + * Check all the reasons why current CPU cannot claim 268 + * ownership of a bank. 269 + * 1: CPU already owns this bank 270 + * 2: BIOS owns this bank 271 + * 3: Some other CPU owns this bank 272 + */ 273 + static bool cmci_skip_bank(int bank, u64 *val) 274 + { 275 + unsigned long *owned = (void *)this_cpu_ptr(&mce_banks_owned); 276 + 277 + if (test_bit(bank, owned)) 278 + return true; 279 + 280 + /* Skip banks in firmware first mode */ 281 + if (test_bit(bank, mce_banks_ce_disabled)) 282 + return true; 283 + 284 + rdmsrl(MSR_IA32_MCx_CTL2(bank), *val); 285 + 286 + /* Already owned by someone else? */ 287 + if (*val & MCI_CTL2_CMCI_EN) { 288 + clear_bit(bank, owned); 289 + __clear_bit(bank, this_cpu_ptr(mce_poll_banks)); 290 + return true; 291 + } 292 + 293 + return false; 294 + } 295 + 296 + /* 297 + * Decide which CMCI interrupt threshold to use: 298 + * 1: If this bank is in storm mode from whichever CPU was 299 + * the previous owner, stay in storm mode. 300 + * 2: If ignoring any threshold set by BIOS, set Linux default 301 + * 3: Try to honor BIOS threshold (unless buggy BIOS set it at zero). 302 + */ 303 + static u64 cmci_pick_threshold(u64 val, int *bios_zero_thresh) 304 + { 305 + if ((val & MCI_CTL2_CMCI_THRESHOLD_MASK) == CMCI_STORM_THRESHOLD) 306 + return val; 307 + 308 + if (!mca_cfg.bios_cmci_threshold) { 309 + val &= ~MCI_CTL2_CMCI_THRESHOLD_MASK; 310 + val |= CMCI_THRESHOLD; 311 + } else if (!(val & MCI_CTL2_CMCI_THRESHOLD_MASK)) { 312 + /* 313 + * If bios_cmci_threshold boot option was specified 314 + * but the threshold is zero, we'll try to initialize 315 + * it to 1. 316 + */ 317 + *bios_zero_thresh = 1; 318 + val |= CMCI_THRESHOLD; 319 + } 320 + 321 + return val; 322 + } 323 + 324 + /* 325 + * Try to claim ownership of a bank. 326 + */ 327 + static void cmci_claim_bank(int bank, u64 val, int bios_zero_thresh, int *bios_wrong_thresh) 328 + { 329 + struct mca_storm_desc *storm = this_cpu_ptr(&storm_desc); 330 + 331 + val |= MCI_CTL2_CMCI_EN; 332 + wrmsrl(MSR_IA32_MCx_CTL2(bank), val); 333 + rdmsrl(MSR_IA32_MCx_CTL2(bank), val); 334 + 335 + /* If the enable bit did not stick, this bank should be polled. */ 336 + if (!(val & MCI_CTL2_CMCI_EN)) { 337 + WARN_ON(!test_bit(bank, this_cpu_ptr(mce_poll_banks))); 338 + storm->banks[bank].poll_only = true; 339 + return; 340 + } 341 + 342 + /* This CPU successfully set the enable bit. */ 343 + set_bit(bank, (void *)this_cpu_ptr(&mce_banks_owned)); 344 + 345 + if ((val & MCI_CTL2_CMCI_THRESHOLD_MASK) == CMCI_STORM_THRESHOLD) { 346 + pr_notice("CPU%d BANK%d CMCI inherited storm\n", smp_processor_id(), bank); 347 + mce_inherit_storm(bank); 348 + cmci_storm_begin(bank); 349 + } else { 350 + __clear_bit(bank, this_cpu_ptr(mce_poll_banks)); 351 + } 352 + 353 + /* 354 + * We are able to set thresholds for some banks that 355 + * had a threshold of 0. This means the BIOS has not 356 + * set the thresholds properly or does not work with 357 + * this boot option. Note down now and report later. 358 + */ 359 + if (mca_cfg.bios_cmci_threshold && bios_zero_thresh && 360 + (val & MCI_CTL2_CMCI_THRESHOLD_MASK)) 361 + *bios_wrong_thresh = 1; 362 + 363 + /* Save default threshold for each bank */ 364 + if (cmci_threshold[bank] == 0) 365 + cmci_threshold[bank] = val & MCI_CTL2_CMCI_THRESHOLD_MASK; 169 366 } 170 367 171 368 /* 172 369 * Enable CMCI (Corrected Machine Check Interrupt) for available MCE banks 173 370 * on this CPU. Use the algorithm recommended in the SDM to discover shared 174 - * banks. 371 + * banks. Called during initial bootstrap, and also for hotplug CPU operations 372 + * to rediscover/reassign machine check banks. 175 373 */ 176 374 static void cmci_discover(int banks) 177 375 { 178 - unsigned long *owned = (void *)this_cpu_ptr(&mce_banks_owned); 376 + int bios_wrong_thresh = 0; 179 377 unsigned long flags; 180 378 int i; 181 - int bios_wrong_thresh = 0; 182 379 183 380 raw_spin_lock_irqsave(&cmci_discover_lock, flags); 184 381 for (i = 0; i < banks; i++) { 185 382 u64 val; 186 383 int bios_zero_thresh = 0; 187 384 188 - if (test_bit(i, owned)) 385 + if (cmci_skip_bank(i, &val)) 189 386 continue; 190 387 191 - /* Skip banks in firmware first mode */ 192 - if (test_bit(i, mce_banks_ce_disabled)) 193 - continue; 194 - 195 - rdmsrl(MSR_IA32_MCx_CTL2(i), val); 196 - 197 - /* Already owned by someone else? */ 198 - if (val & MCI_CTL2_CMCI_EN) { 199 - clear_bit(i, owned); 200 - __clear_bit(i, this_cpu_ptr(mce_poll_banks)); 201 - continue; 202 - } 203 - 204 - if (!mca_cfg.bios_cmci_threshold) { 205 - val &= ~MCI_CTL2_CMCI_THRESHOLD_MASK; 206 - val |= CMCI_THRESHOLD; 207 - } else if (!(val & MCI_CTL2_CMCI_THRESHOLD_MASK)) { 208 - /* 209 - * If bios_cmci_threshold boot option was specified 210 - * but the threshold is zero, we'll try to initialize 211 - * it to 1. 212 - */ 213 - bios_zero_thresh = 1; 214 - val |= CMCI_THRESHOLD; 215 - } 216 - 217 - val |= MCI_CTL2_CMCI_EN; 218 - wrmsrl(MSR_IA32_MCx_CTL2(i), val); 219 - rdmsrl(MSR_IA32_MCx_CTL2(i), val); 220 - 221 - /* Did the enable bit stick? -- the bank supports CMCI */ 222 - if (val & MCI_CTL2_CMCI_EN) { 223 - set_bit(i, owned); 224 - __clear_bit(i, this_cpu_ptr(mce_poll_banks)); 225 - /* 226 - * We are able to set thresholds for some banks that 227 - * had a threshold of 0. This means the BIOS has not 228 - * set the thresholds properly or does not work with 229 - * this boot option. Note down now and report later. 230 - */ 231 - if (mca_cfg.bios_cmci_threshold && bios_zero_thresh && 232 - (val & MCI_CTL2_CMCI_THRESHOLD_MASK)) 233 - bios_wrong_thresh = 1; 234 - } else { 235 - WARN_ON(!test_bit(i, this_cpu_ptr(mce_poll_banks))); 236 - } 388 + val = cmci_pick_threshold(val, &bios_zero_thresh); 389 + cmci_claim_bank(i, val, bios_zero_thresh, &bios_wrong_thresh); 237 390 } 238 391 raw_spin_unlock_irqrestore(&cmci_discover_lock, flags); 239 392 if (mca_cfg.bios_cmci_threshold && bios_wrong_thresh) { ··· 327 370 val &= ~MCI_CTL2_CMCI_EN; 328 371 wrmsrl(MSR_IA32_MCx_CTL2(bank), val); 329 372 __clear_bit(bank, this_cpu_ptr(mce_banks_owned)); 373 + 374 + if ((val & MCI_CTL2_CMCI_THRESHOLD_MASK) == CMCI_STORM_THRESHOLD) 375 + cmci_storm_end(bank); 330 376 } 331 377 332 378 /*
+59 -7
arch/x86/kernel/cpu/mce/internal.h
··· 41 41 extern mce_banks_t mce_banks_ce_disabled; 42 42 43 43 #ifdef CONFIG_X86_MCE_INTEL 44 - unsigned long cmci_intel_adjust_timer(unsigned long interval); 45 - bool mce_intel_cmci_poll(void); 46 - void mce_intel_hcpu_update(unsigned long cpu); 44 + void mce_intel_handle_storm(int bank, bool on); 47 45 void cmci_disable_bank(int bank); 48 46 void intel_init_cmci(void); 49 47 void intel_init_lmce(void); ··· 49 51 bool intel_filter_mce(struct mce *m); 50 52 bool intel_mce_usable_address(struct mce *m); 51 53 #else 52 - # define cmci_intel_adjust_timer mce_adjust_timer_default 53 - static inline bool mce_intel_cmci_poll(void) { return false; } 54 - static inline void mce_intel_hcpu_update(unsigned long cpu) { } 54 + static inline void mce_intel_handle_storm(int bank, bool on) { } 55 55 static inline void cmci_disable_bank(int bank) { } 56 56 static inline void intel_init_cmci(void) { } 57 57 static inline void intel_init_lmce(void) { } ··· 58 62 static inline bool intel_mce_usable_address(struct mce *m) { return false; } 59 63 #endif 60 64 61 - void mce_timer_kick(unsigned long interval); 65 + void mce_timer_kick(bool storm); 66 + 67 + #ifdef CONFIG_X86_MCE_THRESHOLD 68 + void cmci_storm_begin(unsigned int bank); 69 + void cmci_storm_end(unsigned int bank); 70 + void mce_track_storm(struct mce *mce); 71 + void mce_inherit_storm(unsigned int bank); 72 + bool mce_get_storm_mode(void); 73 + void mce_set_storm_mode(bool storm); 74 + #else 75 + static inline void cmci_storm_begin(unsigned int bank) {} 76 + static inline void cmci_storm_end(unsigned int bank) {} 77 + static inline void mce_track_storm(struct mce *mce) {} 78 + static inline void mce_inherit_storm(unsigned int bank) {} 79 + static inline bool mce_get_storm_mode(void) { return false; } 80 + static inline void mce_set_storm_mode(bool storm) {} 81 + #endif 82 + 83 + /* 84 + * history: Bitmask tracking errors occurrence. Each set bit 85 + * represents an error seen. 86 + * 87 + * timestamp: Last time (in jiffies) that the bank was polled. 88 + * in_storm_mode: Is this bank in storm mode? 89 + * poll_only: Bank does not support CMCI, skip storm tracking. 90 + */ 91 + struct storm_bank { 92 + u64 history; 93 + u64 timestamp; 94 + bool in_storm_mode; 95 + bool poll_only; 96 + }; 97 + 98 + #define NUM_HISTORY_BITS (sizeof(u64) * BITS_PER_BYTE) 99 + 100 + /* How many errors within the history buffer mark the start of a storm. */ 101 + #define STORM_BEGIN_THRESHOLD 5 102 + 103 + /* 104 + * How many polls of machine check bank without an error before declaring 105 + * the storm is over. Since it is tracked by the bitmasks in the history 106 + * field of struct storm_bank the mask is 30 bits [0 ... 29]. 107 + */ 108 + #define STORM_END_POLL_THRESHOLD 29 109 + 110 + /* 111 + * banks: per-cpu, per-bank details 112 + * stormy_bank_count: count of MC banks in storm state 113 + * poll_mode: CPU is in poll mode 114 + */ 115 + struct mca_storm_desc { 116 + struct storm_bank banks[MAX_NR_BANKS]; 117 + u8 stormy_bank_count; 118 + bool poll_mode; 119 + }; 120 + 121 + DECLARE_PER_CPU(struct mca_storm_desc, storm_desc); 62 122 63 123 #ifdef CONFIG_ACPI_APEI 64 124 int apei_write_mce(struct mce *m);
+115
arch/x86/kernel/cpu/mce/threshold.c
··· 29 29 trace_threshold_apic_exit(THRESHOLD_APIC_VECTOR); 30 30 apic_eoi(); 31 31 } 32 + 33 + DEFINE_PER_CPU(struct mca_storm_desc, storm_desc); 34 + 35 + void mce_inherit_storm(unsigned int bank) 36 + { 37 + struct mca_storm_desc *storm = this_cpu_ptr(&storm_desc); 38 + 39 + /* 40 + * Previous CPU owning this bank had put it into storm mode, 41 + * but the precise history of that storm is unknown. Assume 42 + * the worst (all recent polls of the bank found a valid error 43 + * logged). This will avoid the new owner prematurely declaring 44 + * the storm has ended. 45 + */ 46 + storm->banks[bank].history = ~0ull; 47 + storm->banks[bank].timestamp = jiffies; 48 + } 49 + 50 + bool mce_get_storm_mode(void) 51 + { 52 + return __this_cpu_read(storm_desc.poll_mode); 53 + } 54 + 55 + void mce_set_storm_mode(bool storm) 56 + { 57 + __this_cpu_write(storm_desc.poll_mode, storm); 58 + } 59 + 60 + static void mce_handle_storm(unsigned int bank, bool on) 61 + { 62 + switch (boot_cpu_data.x86_vendor) { 63 + case X86_VENDOR_INTEL: 64 + mce_intel_handle_storm(bank, on); 65 + break; 66 + } 67 + } 68 + 69 + void cmci_storm_begin(unsigned int bank) 70 + { 71 + struct mca_storm_desc *storm = this_cpu_ptr(&storm_desc); 72 + 73 + __set_bit(bank, this_cpu_ptr(mce_poll_banks)); 74 + storm->banks[bank].in_storm_mode = true; 75 + 76 + /* 77 + * If this is the first bank on this CPU to enter storm mode 78 + * start polling. 79 + */ 80 + if (++storm->stormy_bank_count == 1) 81 + mce_timer_kick(true); 82 + } 83 + 84 + void cmci_storm_end(unsigned int bank) 85 + { 86 + struct mca_storm_desc *storm = this_cpu_ptr(&storm_desc); 87 + 88 + __clear_bit(bank, this_cpu_ptr(mce_poll_banks)); 89 + storm->banks[bank].history = 0; 90 + storm->banks[bank].in_storm_mode = false; 91 + 92 + /* If no banks left in storm mode, stop polling. */ 93 + if (!this_cpu_dec_return(storm_desc.stormy_bank_count)) 94 + mce_timer_kick(false); 95 + } 96 + 97 + void mce_track_storm(struct mce *mce) 98 + { 99 + struct mca_storm_desc *storm = this_cpu_ptr(&storm_desc); 100 + unsigned long now = jiffies, delta; 101 + unsigned int shift = 1; 102 + u64 history = 0; 103 + 104 + /* No tracking needed for banks that do not support CMCI */ 105 + if (storm->banks[mce->bank].poll_only) 106 + return; 107 + 108 + /* 109 + * When a bank is in storm mode it is polled once per second and 110 + * the history mask will record about the last minute of poll results. 111 + * If it is not in storm mode, then the bank is only checked when 112 + * there is a CMCI interrupt. Check how long it has been since 113 + * this bank was last checked, and adjust the amount of "shift" 114 + * to apply to history. 115 + */ 116 + if (!storm->banks[mce->bank].in_storm_mode) { 117 + delta = now - storm->banks[mce->bank].timestamp; 118 + shift = (delta + HZ) / HZ; 119 + } 120 + 121 + /* If it has been a long time since the last poll, clear history. */ 122 + if (shift < NUM_HISTORY_BITS) 123 + history = storm->banks[mce->bank].history << shift; 124 + 125 + storm->banks[mce->bank].timestamp = now; 126 + 127 + /* History keeps track of corrected errors. VAL=1 && UC=0 */ 128 + if ((mce->status & MCI_STATUS_VAL) && mce_is_correctable(mce)) 129 + history |= 1; 130 + 131 + storm->banks[mce->bank].history = history; 132 + 133 + if (storm->banks[mce->bank].in_storm_mode) { 134 + if (history & GENMASK_ULL(STORM_END_POLL_THRESHOLD, 0)) 135 + return; 136 + printk_deferred(KERN_NOTICE "CPU%d BANK%d CMCI storm subsided\n", smp_processor_id(), mce->bank); 137 + mce_handle_storm(mce->bank, false); 138 + cmci_storm_end(mce->bank); 139 + } else { 140 + if (hweight64(history) < STORM_BEGIN_THRESHOLD) 141 + return; 142 + printk_deferred(KERN_NOTICE "CPU%d BANK%d CMCI storm detected\n", smp_processor_id(), mce->bank); 143 + mce_handle_storm(mce->bank, true); 144 + cmci_storm_begin(mce->bank); 145 + } 146 + }
+42 -484
drivers/edac/mce_amd.c
··· 143 143 "Status Register File", 144 144 }; 145 145 146 - /* Scalable MCA error strings */ 147 - static const char * const smca_ls_mce_desc[] = { 148 - "Load queue parity error", 149 - "Store queue parity error", 150 - "Miss address buffer payload parity error", 151 - "Level 1 TLB parity error", 152 - "DC Tag error type 5", 153 - "DC Tag error type 6", 154 - "DC Tag error type 1", 155 - "Internal error type 1", 156 - "Internal error type 2", 157 - "System Read Data Error Thread 0", 158 - "System Read Data Error Thread 1", 159 - "DC Tag error type 2", 160 - "DC Data error type 1 and poison consumption", 161 - "DC Data error type 2", 162 - "DC Data error type 3", 163 - "DC Tag error type 4", 164 - "Level 2 TLB parity error", 165 - "PDC parity error", 166 - "DC Tag error type 3", 167 - "DC Tag error type 5", 168 - "L2 Fill Data error", 169 - }; 170 - 171 - static const char * const smca_ls2_mce_desc[] = { 172 - "An ECC error was detected on a data cache read by a probe or victimization", 173 - "An ECC error or L2 poison was detected on a data cache read by a load", 174 - "An ECC error was detected on a data cache read-modify-write by a store", 175 - "An ECC error or poison bit mismatch was detected on a tag read by a probe or victimization", 176 - "An ECC error or poison bit mismatch was detected on a tag read by a load", 177 - "An ECC error or poison bit mismatch was detected on a tag read by a store", 178 - "An ECC error was detected on an EMEM read by a load", 179 - "An ECC error was detected on an EMEM read-modify-write by a store", 180 - "A parity error was detected in an L1 TLB entry by any access", 181 - "A parity error was detected in an L2 TLB entry by any access", 182 - "A parity error was detected in a PWC entry by any access", 183 - "A parity error was detected in an STQ entry by any access", 184 - "A parity error was detected in an LDQ entry by any access", 185 - "A parity error was detected in a MAB entry by any access", 186 - "A parity error was detected in an SCB entry state field by any access", 187 - "A parity error was detected in an SCB entry address field by any access", 188 - "A parity error was detected in an SCB entry data field by any access", 189 - "A parity error was detected in a WCB entry by any access", 190 - "A poisoned line was detected in an SCB entry by any access", 191 - "A SystemReadDataError error was reported on read data returned from L2 for a load", 192 - "A SystemReadDataError error was reported on read data returned from L2 for an SCB store", 193 - "A SystemReadDataError error was reported on read data returned from L2 for a WCB store", 194 - "A hardware assertion error was reported", 195 - "A parity error was detected in an STLF, SCB EMEM entry or SRB store data by any access", 196 - }; 197 - 198 - static const char * const smca_if_mce_desc[] = { 199 - "Op Cache Microtag Probe Port Parity Error", 200 - "IC Microtag or Full Tag Multi-hit Error", 201 - "IC Full Tag Parity Error", 202 - "IC Data Array Parity Error", 203 - "Decoupling Queue PhysAddr Parity Error", 204 - "L0 ITLB Parity Error", 205 - "L1 ITLB Parity Error", 206 - "L2 ITLB Parity Error", 207 - "BPQ Thread 0 Snoop Parity Error", 208 - "BPQ Thread 1 Snoop Parity Error", 209 - "L1 BTB Multi-Match Error", 210 - "L2 BTB Multi-Match Error", 211 - "L2 Cache Response Poison Error", 212 - "System Read Data Error", 213 - "Hardware Assertion Error", 214 - "L1-TLB Multi-Hit", 215 - "L2-TLB Multi-Hit", 216 - "BSR Parity Error", 217 - "CT MCE", 218 - }; 219 - 220 - static const char * const smca_l2_mce_desc[] = { 221 - "L2M Tag Multiple-Way-Hit error", 222 - "L2M Tag or State Array ECC Error", 223 - "L2M Data Array ECC Error", 224 - "Hardware Assert Error", 225 - }; 226 - 227 - static const char * const smca_de_mce_desc[] = { 228 - "Micro-op cache tag parity error", 229 - "Micro-op cache data parity error", 230 - "Instruction buffer parity error", 231 - "Micro-op queue parity error", 232 - "Instruction dispatch queue parity error", 233 - "Fetch address FIFO parity error", 234 - "Patch RAM data parity error", 235 - "Patch RAM sequencer parity error", 236 - "Micro-op buffer parity error", 237 - "Hardware Assertion MCA Error", 238 - }; 239 - 240 - static const char * const smca_ex_mce_desc[] = { 241 - "Watchdog Timeout error", 242 - "Physical register file parity error", 243 - "Flag register file parity error", 244 - "Immediate displacement register file parity error", 245 - "Address generator payload parity error", 246 - "EX payload parity error", 247 - "Checkpoint queue parity error", 248 - "Retire dispatch queue parity error", 249 - "Retire status queue parity error", 250 - "Scheduling queue parity error", 251 - "Branch buffer queue parity error", 252 - "Hardware Assertion error", 253 - "Spec Map parity error", 254 - "Retire Map parity error", 255 - }; 256 - 257 - static const char * const smca_fp_mce_desc[] = { 258 - "Physical register file (PRF) parity error", 259 - "Freelist (FL) parity error", 260 - "Schedule queue parity error", 261 - "NSQ parity error", 262 - "Retire queue (RQ) parity error", 263 - "Status register file (SRF) parity error", 264 - "Hardware assertion", 265 - }; 266 - 267 - static const char * const smca_l3_mce_desc[] = { 268 - "Shadow Tag Macro ECC Error", 269 - "Shadow Tag Macro Multi-way-hit Error", 270 - "L3M Tag ECC Error", 271 - "L3M Tag Multi-way-hit Error", 272 - "L3M Data ECC Error", 273 - "SDP Parity Error or SystemReadDataError from XI", 274 - "L3 Victim Queue Parity Error", 275 - "L3 Hardware Assertion", 276 - }; 277 - 278 - static const char * const smca_cs_mce_desc[] = { 279 - "Illegal Request", 280 - "Address Violation", 281 - "Security Violation", 282 - "Illegal Response", 283 - "Unexpected Response", 284 - "Request or Probe Parity Error", 285 - "Read Response Parity Error", 286 - "Atomic Request Parity Error", 287 - "Probe Filter ECC Error", 288 - }; 289 - 290 - static const char * const smca_cs2_mce_desc[] = { 291 - "Illegal Request", 292 - "Address Violation", 293 - "Security Violation", 294 - "Illegal Response", 295 - "Unexpected Response", 296 - "Request or Probe Parity Error", 297 - "Read Response Parity Error", 298 - "Atomic Request Parity Error", 299 - "SDP read response had no match in the CS queue", 300 - "Probe Filter Protocol Error", 301 - "Probe Filter ECC Error", 302 - "SDP read response had an unexpected RETRY error", 303 - "Counter overflow error", 304 - "Counter underflow error", 305 - }; 306 - 307 - static const char * const smca_pie_mce_desc[] = { 308 - "Hardware Assert", 309 - "Register security violation", 310 - "Link Error", 311 - "Poison data consumption", 312 - "A deferred error was detected in the DF" 313 - }; 314 - 315 - static const char * const smca_umc_mce_desc[] = { 316 - "DRAM ECC error", 317 - "Data poison error", 318 - "SDP parity error", 319 - "Advanced peripheral bus error", 320 - "Address/Command parity error", 321 - "Write data CRC error", 322 - "DCQ SRAM ECC error", 323 - "AES SRAM ECC error", 324 - }; 325 - 326 - static const char * const smca_umc2_mce_desc[] = { 327 - "DRAM ECC error", 328 - "Data poison error", 329 - "SDP parity error", 330 - "Reserved", 331 - "Address/Command parity error", 332 - "Write data parity error", 333 - "DCQ SRAM ECC error", 334 - "Reserved", 335 - "Read data parity error", 336 - "Rdb SRAM ECC error", 337 - "RdRsp SRAM ECC error", 338 - "LM32 MP errors", 339 - }; 340 - 341 - static const char * const smca_pb_mce_desc[] = { 342 - "An ECC error in the Parameter Block RAM array", 343 - }; 344 - 345 - static const char * const smca_psp_mce_desc[] = { 346 - "An ECC or parity error in a PSP RAM instance", 347 - }; 348 - 349 - static const char * const smca_psp2_mce_desc[] = { 350 - "High SRAM ECC or parity error", 351 - "Low SRAM ECC or parity error", 352 - "Instruction Cache Bank 0 ECC or parity error", 353 - "Instruction Cache Bank 1 ECC or parity error", 354 - "Instruction Tag Ram 0 parity error", 355 - "Instruction Tag Ram 1 parity error", 356 - "Data Cache Bank 0 ECC or parity error", 357 - "Data Cache Bank 1 ECC or parity error", 358 - "Data Cache Bank 2 ECC or parity error", 359 - "Data Cache Bank 3 ECC or parity error", 360 - "Data Tag Bank 0 parity error", 361 - "Data Tag Bank 1 parity error", 362 - "Data Tag Bank 2 parity error", 363 - "Data Tag Bank 3 parity error", 364 - "Dirty Data Ram parity error", 365 - "TLB Bank 0 parity error", 366 - "TLB Bank 1 parity error", 367 - "System Hub Read Buffer ECC or parity error", 368 - }; 369 - 370 - static const char * const smca_smu_mce_desc[] = { 371 - "An ECC or parity error in an SMU RAM instance", 372 - }; 373 - 374 - static const char * const smca_smu2_mce_desc[] = { 375 - "High SRAM ECC or parity error", 376 - "Low SRAM ECC or parity error", 377 - "Data Cache Bank A ECC or parity error", 378 - "Data Cache Bank B ECC or parity error", 379 - "Data Tag Cache Bank A ECC or parity error", 380 - "Data Tag Cache Bank B ECC or parity error", 381 - "Instruction Cache Bank A ECC or parity error", 382 - "Instruction Cache Bank B ECC or parity error", 383 - "Instruction Tag Cache Bank A ECC or parity error", 384 - "Instruction Tag Cache Bank B ECC or parity error", 385 - "System Hub Read Buffer ECC or parity error", 386 - "PHY RAM ECC error", 387 - }; 388 - 389 - static const char * const smca_mp5_mce_desc[] = { 390 - "High SRAM ECC or parity error", 391 - "Low SRAM ECC or parity error", 392 - "Data Cache Bank A ECC or parity error", 393 - "Data Cache Bank B ECC or parity error", 394 - "Data Tag Cache Bank A ECC or parity error", 395 - "Data Tag Cache Bank B ECC or parity error", 396 - "Instruction Cache Bank A ECC or parity error", 397 - "Instruction Cache Bank B ECC or parity error", 398 - "Instruction Tag Cache Bank A ECC or parity error", 399 - "Instruction Tag Cache Bank B ECC or parity error", 400 - }; 401 - 402 - static const char * const smca_mpdma_mce_desc[] = { 403 - "Main SRAM [31:0] bank ECC or parity error", 404 - "Main SRAM [63:32] bank ECC or parity error", 405 - "Main SRAM [95:64] bank ECC or parity error", 406 - "Main SRAM [127:96] bank ECC or parity error", 407 - "Data Cache Bank A ECC or parity error", 408 - "Data Cache Bank B ECC or parity error", 409 - "Data Tag Cache Bank A ECC or parity error", 410 - "Data Tag Cache Bank B ECC or parity error", 411 - "Instruction Cache Bank A ECC or parity error", 412 - "Instruction Cache Bank B ECC or parity error", 413 - "Instruction Tag Cache Bank A ECC or parity error", 414 - "Instruction Tag Cache Bank B ECC or parity error", 415 - "Data Cache Bank A ECC or parity error", 416 - "Data Cache Bank B ECC or parity error", 417 - "Data Tag Cache Bank A ECC or parity error", 418 - "Data Tag Cache Bank B ECC or parity error", 419 - "Instruction Cache Bank A ECC or parity error", 420 - "Instruction Cache Bank B ECC or parity error", 421 - "Instruction Tag Cache Bank A ECC or parity error", 422 - "Instruction Tag Cache Bank B ECC or parity error", 423 - "Data Cache Bank A ECC or parity error", 424 - "Data Cache Bank B ECC or parity error", 425 - "Data Tag Cache Bank A ECC or parity error", 426 - "Data Tag Cache Bank B ECC or parity error", 427 - "Instruction Cache Bank A ECC or parity error", 428 - "Instruction Cache Bank B ECC or parity error", 429 - "Instruction Tag Cache Bank A ECC or parity error", 430 - "Instruction Tag Cache Bank B ECC or parity error", 431 - "System Hub Read Buffer ECC or parity error", 432 - "MPDMA TVF DVSEC Memory ECC or parity error", 433 - "MPDMA TVF MMIO Mailbox0 ECC or parity error", 434 - "MPDMA TVF MMIO Mailbox1 ECC or parity error", 435 - "MPDMA TVF Doorbell Memory ECC or parity error", 436 - "MPDMA TVF SDP Slave Memory 0 ECC or parity error", 437 - "MPDMA TVF SDP Slave Memory 1 ECC or parity error", 438 - "MPDMA TVF SDP Slave Memory 2 ECC or parity error", 439 - "MPDMA TVF SDP Master Memory 0 ECC or parity error", 440 - "MPDMA TVF SDP Master Memory 1 ECC or parity error", 441 - "MPDMA TVF SDP Master Memory 2 ECC or parity error", 442 - "MPDMA TVF SDP Master Memory 3 ECC or parity error", 443 - "MPDMA TVF SDP Master Memory 4 ECC or parity error", 444 - "MPDMA TVF SDP Master Memory 5 ECC or parity error", 445 - "MPDMA TVF SDP Master Memory 6 ECC or parity error", 446 - "MPDMA PTE Command FIFO ECC or parity error", 447 - "MPDMA PTE Hub Data FIFO ECC or parity error", 448 - "MPDMA PTE Internal Data FIFO ECC or parity error", 449 - "MPDMA PTE Command Memory DMA ECC or parity error", 450 - "MPDMA PTE Command Memory Internal ECC or parity error", 451 - "MPDMA PTE DMA Completion FIFO ECC or parity error", 452 - "MPDMA PTE Tablewalk Completion FIFO ECC or parity error", 453 - "MPDMA PTE Descriptor Completion FIFO ECC or parity error", 454 - "MPDMA PTE ReadOnly Completion FIFO ECC or parity error", 455 - "MPDMA PTE DirectWrite Completion FIFO ECC or parity error", 456 - "SDP Watchdog Timer expired", 457 - }; 458 - 459 - static const char * const smca_nbio_mce_desc[] = { 460 - "ECC or Parity error", 461 - "PCIE error", 462 - "SDP ErrEvent error", 463 - "SDP Egress Poison Error", 464 - "IOHC Internal Poison Error", 465 - }; 466 - 467 - static const char * const smca_pcie_mce_desc[] = { 468 - "CCIX PER Message logging", 469 - "CCIX Read Response with Status: Non-Data Error", 470 - "CCIX Write Response with Status: Non-Data Error", 471 - "CCIX Read Response with Status: Data Error", 472 - "CCIX Non-okay write response with data error", 473 - }; 474 - 475 - static const char * const smca_pcie2_mce_desc[] = { 476 - "SDP Parity Error logging", 477 - }; 478 - 479 - static const char * const smca_xgmipcs_mce_desc[] = { 480 - "Data Loss Error", 481 - "Training Error", 482 - "Flow Control Acknowledge Error", 483 - "Rx Fifo Underflow Error", 484 - "Rx Fifo Overflow Error", 485 - "CRC Error", 486 - "BER Exceeded Error", 487 - "Tx Vcid Data Error", 488 - "Replay Buffer Parity Error", 489 - "Data Parity Error", 490 - "Replay Fifo Overflow Error", 491 - "Replay Fifo Underflow Error", 492 - "Elastic Fifo Overflow Error", 493 - "Deskew Error", 494 - "Flow Control CRC Error", 495 - "Data Startup Limit Error", 496 - "FC Init Timeout Error", 497 - "Recovery Timeout Error", 498 - "Ready Serial Timeout Error", 499 - "Ready Serial Attempt Error", 500 - "Recovery Attempt Error", 501 - "Recovery Relock Attempt Error", 502 - "Replay Attempt Error", 503 - "Sync Header Error", 504 - "Tx Replay Timeout Error", 505 - "Rx Replay Timeout Error", 506 - "LinkSub Tx Timeout Error", 507 - "LinkSub Rx Timeout Error", 508 - "Rx CMD Packet Error", 509 - }; 510 - 511 - static const char * const smca_xgmiphy_mce_desc[] = { 512 - "RAM ECC Error", 513 - "ARC instruction buffer parity error", 514 - "ARC data buffer parity error", 515 - "PHY APB error", 516 - }; 517 - 518 - static const char * const smca_nbif_mce_desc[] = { 519 - "Timeout error from GMI", 520 - "SRAM ECC error", 521 - "NTB Error Event", 522 - "SDP Parity error", 523 - }; 524 - 525 - static const char * const smca_sata_mce_desc[] = { 526 - "Parity error for port 0", 527 - "Parity error for port 1", 528 - "Parity error for port 2", 529 - "Parity error for port 3", 530 - "Parity error for port 4", 531 - "Parity error for port 5", 532 - "Parity error for port 6", 533 - "Parity error for port 7", 534 - }; 535 - 536 - static const char * const smca_usb_mce_desc[] = { 537 - "Parity error or ECC error for S0 RAM0", 538 - "Parity error or ECC error for S0 RAM1", 539 - "Parity error or ECC error for S0 RAM2", 540 - "Parity error for PHY RAM0", 541 - "Parity error for PHY RAM1", 542 - "AXI Slave Response error", 543 - }; 544 - 545 - static const char * const smca_gmipcs_mce_desc[] = { 546 - "Data Loss Error", 547 - "Training Error", 548 - "Replay Parity Error", 549 - "Rx Fifo Underflow Error", 550 - "Rx Fifo Overflow Error", 551 - "CRC Error", 552 - "BER Exceeded Error", 553 - "Tx Fifo Underflow Error", 554 - "Replay Buffer Parity Error", 555 - "Tx Overflow Error", 556 - "Replay Fifo Overflow Error", 557 - "Replay Fifo Underflow Error", 558 - "Elastic Fifo Overflow Error", 559 - "Deskew Error", 560 - "Offline Error", 561 - "Data Startup Limit Error", 562 - "FC Init Timeout Error", 563 - "Recovery Timeout Error", 564 - "Ready Serial Timeout Error", 565 - "Ready Serial Attempt Error", 566 - "Recovery Attempt Error", 567 - "Recovery Relock Attempt Error", 568 - "Deskew Abort Error", 569 - "Rx Buffer Error", 570 - "Rx LFDS Fifo Overflow Error", 571 - "Rx LFDS Fifo Underflow Error", 572 - "LinkSub Tx Timeout Error", 573 - "LinkSub Rx Timeout Error", 574 - "Rx CMD Packet Error", 575 - "LFDS Training Timeout Error", 576 - "LFDS FC Init Timeout Error", 577 - "Data Loss Error", 578 - }; 579 - 580 - struct smca_mce_desc { 581 - const char * const *descs; 582 - unsigned int num_descs; 583 - }; 584 - 585 - static struct smca_mce_desc smca_mce_descs[] = { 586 - [SMCA_LS] = { smca_ls_mce_desc, ARRAY_SIZE(smca_ls_mce_desc) }, 587 - [SMCA_LS_V2] = { smca_ls2_mce_desc, ARRAY_SIZE(smca_ls2_mce_desc) }, 588 - [SMCA_IF] = { smca_if_mce_desc, ARRAY_SIZE(smca_if_mce_desc) }, 589 - [SMCA_L2_CACHE] = { smca_l2_mce_desc, ARRAY_SIZE(smca_l2_mce_desc) }, 590 - [SMCA_DE] = { smca_de_mce_desc, ARRAY_SIZE(smca_de_mce_desc) }, 591 - [SMCA_EX] = { smca_ex_mce_desc, ARRAY_SIZE(smca_ex_mce_desc) }, 592 - [SMCA_FP] = { smca_fp_mce_desc, ARRAY_SIZE(smca_fp_mce_desc) }, 593 - [SMCA_L3_CACHE] = { smca_l3_mce_desc, ARRAY_SIZE(smca_l3_mce_desc) }, 594 - [SMCA_CS] = { smca_cs_mce_desc, ARRAY_SIZE(smca_cs_mce_desc) }, 595 - [SMCA_CS_V2] = { smca_cs2_mce_desc, ARRAY_SIZE(smca_cs2_mce_desc) }, 596 - [SMCA_PIE] = { smca_pie_mce_desc, ARRAY_SIZE(smca_pie_mce_desc) }, 597 - [SMCA_UMC] = { smca_umc_mce_desc, ARRAY_SIZE(smca_umc_mce_desc) }, 598 - [SMCA_UMC_V2] = { smca_umc2_mce_desc, ARRAY_SIZE(smca_umc2_mce_desc) }, 599 - [SMCA_PB] = { smca_pb_mce_desc, ARRAY_SIZE(smca_pb_mce_desc) }, 600 - [SMCA_PSP] = { smca_psp_mce_desc, ARRAY_SIZE(smca_psp_mce_desc) }, 601 - [SMCA_PSP_V2] = { smca_psp2_mce_desc, ARRAY_SIZE(smca_psp2_mce_desc) }, 602 - [SMCA_SMU] = { smca_smu_mce_desc, ARRAY_SIZE(smca_smu_mce_desc) }, 603 - [SMCA_SMU_V2] = { smca_smu2_mce_desc, ARRAY_SIZE(smca_smu2_mce_desc) }, 604 - [SMCA_MP5] = { smca_mp5_mce_desc, ARRAY_SIZE(smca_mp5_mce_desc) }, 605 - [SMCA_MPDMA] = { smca_mpdma_mce_desc, ARRAY_SIZE(smca_mpdma_mce_desc) }, 606 - [SMCA_NBIO] = { smca_nbio_mce_desc, ARRAY_SIZE(smca_nbio_mce_desc) }, 607 - [SMCA_PCIE] = { smca_pcie_mce_desc, ARRAY_SIZE(smca_pcie_mce_desc) }, 608 - [SMCA_PCIE_V2] = { smca_pcie2_mce_desc, ARRAY_SIZE(smca_pcie2_mce_desc) }, 609 - [SMCA_XGMI_PCS] = { smca_xgmipcs_mce_desc, ARRAY_SIZE(smca_xgmipcs_mce_desc) }, 610 - /* NBIF and SHUB have the same error descriptions, for now. */ 611 - [SMCA_NBIF] = { smca_nbif_mce_desc, ARRAY_SIZE(smca_nbif_mce_desc) }, 612 - [SMCA_SHUB] = { smca_nbif_mce_desc, ARRAY_SIZE(smca_nbif_mce_desc) }, 613 - [SMCA_SATA] = { smca_sata_mce_desc, ARRAY_SIZE(smca_sata_mce_desc) }, 614 - [SMCA_USB] = { smca_usb_mce_desc, ARRAY_SIZE(smca_usb_mce_desc) }, 615 - [SMCA_GMI_PCS] = { smca_gmipcs_mce_desc, ARRAY_SIZE(smca_gmipcs_mce_desc) }, 616 - /* All the PHY bank types have the same error descriptions, for now. */ 617 - [SMCA_XGMI_PHY] = { smca_xgmiphy_mce_desc, ARRAY_SIZE(smca_xgmiphy_mce_desc) }, 618 - [SMCA_WAFL_PHY] = { smca_xgmiphy_mce_desc, ARRAY_SIZE(smca_xgmiphy_mce_desc) }, 619 - [SMCA_GMI_PHY] = { smca_xgmiphy_mce_desc, ARRAY_SIZE(smca_xgmiphy_mce_desc) }, 620 - }; 621 - 622 146 static bool f12h_mc0_mce(u16 ec, u8 xec) 623 147 { 624 148 bool ret = false; ··· 687 1163 pr_emerg(HW_ERR "Corrupted MC6 MCE info?\n"); 688 1164 } 689 1165 1166 + static const char * const smca_long_names[] = { 1167 + [SMCA_LS ... SMCA_LS_V2] = "Load Store Unit", 1168 + [SMCA_IF] = "Instruction Fetch Unit", 1169 + [SMCA_L2_CACHE] = "L2 Cache", 1170 + [SMCA_DE] = "Decode Unit", 1171 + [SMCA_RESERVED] = "Reserved", 1172 + [SMCA_EX] = "Execution Unit", 1173 + [SMCA_FP] = "Floating Point Unit", 1174 + [SMCA_L3_CACHE] = "L3 Cache", 1175 + [SMCA_CS ... SMCA_CS_V2] = "Coherent Slave", 1176 + [SMCA_PIE] = "Power, Interrupts, etc.", 1177 + 1178 + /* UMC v2 is separate because both of them can exist in a single system. */ 1179 + [SMCA_UMC] = "Unified Memory Controller", 1180 + [SMCA_UMC_V2] = "Unified Memory Controller v2", 1181 + [SMCA_PB] = "Parameter Block", 1182 + [SMCA_PSP ... SMCA_PSP_V2] = "Platform Security Processor", 1183 + [SMCA_SMU ... SMCA_SMU_V2] = "System Management Unit", 1184 + [SMCA_MP5] = "Microprocessor 5 Unit", 1185 + [SMCA_MPDMA] = "MPDMA Unit", 1186 + [SMCA_NBIO] = "Northbridge IO Unit", 1187 + [SMCA_PCIE ... SMCA_PCIE_V2] = "PCI Express Unit", 1188 + [SMCA_XGMI_PCS] = "Ext Global Memory Interconnect PCS Unit", 1189 + [SMCA_NBIF] = "NBIF Unit", 1190 + [SMCA_SHUB] = "System Hub Unit", 1191 + [SMCA_SATA] = "SATA Unit", 1192 + [SMCA_USB] = "USB Unit", 1193 + [SMCA_GMI_PCS] = "Global Memory Interconnect PCS Unit", 1194 + [SMCA_XGMI_PHY] = "Ext Global Memory Interconnect PHY Unit", 1195 + [SMCA_WAFL_PHY] = "WAFL PHY Unit", 1196 + [SMCA_GMI_PHY] = "Global Memory Interconnect PHY Unit", 1197 + }; 1198 + 1199 + static const char *smca_get_long_name(enum smca_bank_types t) 1200 + { 1201 + if (t >= N_SMCA_BANK_TYPES) 1202 + return NULL; 1203 + 1204 + return smca_long_names[t]; 1205 + } 1206 + 690 1207 /* Decode errors according to Scalable MCA specification */ 691 1208 static void decode_smca_error(struct mce *m) 692 1209 { 693 1210 enum smca_bank_types bank_type = smca_get_bank_type(m->extcpu, m->bank); 694 - const char *ip_name; 695 1211 u8 xec = XEC(m->status, xec_mask); 696 1212 697 1213 if (bank_type >= N_SMCA_BANK_TYPES) ··· 742 1178 return; 743 1179 } 744 1180 745 - ip_name = smca_get_long_name(bank_type); 746 - 747 - pr_emerg(HW_ERR "%s Ext. Error Code: %d", ip_name, xec); 748 - 749 - /* Only print the decode of valid error codes */ 750 - if (xec < smca_mce_descs[bank_type].num_descs) 751 - pr_cont(", %s.\n", smca_mce_descs[bank_type].descs[xec]); 1181 + pr_emerg(HW_ERR "%s Ext. Error Code: %d", smca_get_long_name(bank_type), xec); 752 1182 753 1183 if ((bank_type == SMCA_UMC || bank_type == SMCA_UMC_V2) && 754 1184 xec == 0 && decode_dram_ecc)