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

Merge tag 'ras_core_for_v5.18_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull RAS updates from Borislav Petkov:

- More noinstr fixes

- Add an erratum workaround for Intel CPUs which, in certain
circumstances, end up consuming an unrelated uncorrectable memory
error when using fast string copy insns

- Remove the MCE tolerance level control as it is not really needed or
used anymore

* tag 'ras_core_for_v5.18_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/mce: Remove the tolerance level control
x86/mce: Work around an erratum on fast string copy instructions
x86/mce: Use arch atomic and bit helpers

+177 -132
+37
Documentation/ABI/removed/sysfs-mce
··· 1 + What: /sys/devices/system/machinecheck/machinecheckX/tolerant 2 + Contact: Borislav Petkov <bp@suse.de> 3 + Date: Dec, 2021 4 + Description: 5 + Unused and obsolete after the advent of recoverable machine 6 + checks (see last sentence below) and those are present since 7 + 2010 (Nehalem). 8 + 9 + Original description: 10 + 11 + The entries appear for each CPU, but they are truly shared 12 + between all CPUs. 13 + 14 + Tolerance level. When a machine check exception occurs for a 15 + non corrected machine check the kernel can take different 16 + actions. 17 + 18 + Since machine check exceptions can happen any time it is 19 + sometimes risky for the kernel to kill a process because it 20 + defies normal kernel locking rules. The tolerance level 21 + configures how hard the kernel tries to recover even at some 22 + risk of deadlock. Higher tolerant values trade potentially 23 + better uptime with the risk of a crash or even corruption 24 + (for tolerant >= 3). 25 + 26 + == =========================================================== 27 + 0 always panic on uncorrected errors, log corrected errors 28 + 1 panic or SIGBUS on uncorrected errors, log corrected errors 29 + 2 SIGBUS or log uncorrected errors, log corrected errors 30 + 3 never panic or SIGBUS, log all errors (for testing only) 31 + == =========================================================== 32 + 33 + Default: 1 34 + 35 + Note this only makes a difference if the CPU allows recovery 36 + from a machine check exception. Current x86 CPUs generally 37 + do not.
-32
Documentation/ABI/testing/sysfs-mce
··· 53 53 (but some corrected errors might be still reported 54 54 in other ways) 55 55 56 - What: /sys/devices/system/machinecheck/machinecheckX/tolerant 57 - Contact: Andi Kleen <ak@linux.intel.com> 58 - Date: Feb, 2007 59 - Description: 60 - The entries appear for each CPU, but they are truly shared 61 - between all CPUs. 62 - 63 - Tolerance level. When a machine check exception occurs for a 64 - non corrected machine check the kernel can take different 65 - actions. 66 - 67 - Since machine check exceptions can happen any time it is 68 - sometimes risky for the kernel to kill a process because it 69 - defies normal kernel locking rules. The tolerance level 70 - configures how hard the kernel tries to recover even at some 71 - risk of deadlock. Higher tolerant values trade potentially 72 - better uptime with the risk of a crash or even corruption 73 - (for tolerant >= 3). 74 - 75 - == =========================================================== 76 - 0 always panic on uncorrected errors, log corrected errors 77 - 1 panic or SIGBUS on uncorrected errors, log corrected errors 78 - 2 SIGBUS or log uncorrected errors, log corrected errors 79 - 3 never panic or SIGBUS, log all errors (for testing only) 80 - == =========================================================== 81 - 82 - Default: 1 83 - 84 - Note this only makes a difference if the CPU allows recovery 85 - from a machine check exception. Current x86 CPUs generally 86 - do not. 87 - 88 56 What: /sys/devices/system/machinecheck/machinecheckX/trigger 89 57 Contact: Andi Kleen <ak@linux.intel.com> 90 58 Date: Feb, 2007
-2
Documentation/vm/hwpoison.rst
··· 60 60 61 61 vm.memory_failure_recovery sysctl set to zero: 62 62 All memory failures cause a panic. Do not attempt recovery. 63 - (on x86 this can be also affected by the tolerant level of the 64 - MCE subsystem) 65 63 66 64 early kill 67 65 (can be controlled globally and per process)
+1 -8
Documentation/x86/x86_64/boot-options.rst
··· 47 47 in a reboot. On Intel systems it is enabled by default. 48 48 mce=nobootlog 49 49 Disable boot machine check logging. 50 - mce=tolerancelevel[,monarchtimeout] (number,number) 51 - tolerance levels: 52 - 0: always panic on uncorrected errors, log corrected errors 53 - 1: panic or SIGBUS on uncorrected errors, log corrected errors 54 - 2: SIGBUS or log uncorrected errors, log corrected errors 55 - 3: never panic or SIGBUS, log all errors (for testing only) 56 - Default is 1 57 - Can be also set using sysfs which is preferable. 50 + mce=monarchtimeout (number) 58 51 monarchtimeout: 59 52 Sets the time in us to wait for other CPUs on machine checks. 0 60 53 to disable.
+103 -72
arch/x86/kernel/cpu/mce/core.c
··· 86 86 87 87 struct mca_config mca_cfg __read_mostly = { 88 88 .bootlog = -1, 89 - /* 90 - * Tolerant levels: 91 - * 0: always panic on uncorrected errors, log corrected errors 92 - * 1: panic or SIGBUS on uncorrected errors, log corrected errors 93 - * 2: SIGBUS or log uncorrected errors (if possible), log corr. errors 94 - * 3: never panic or SIGBUS, log all errors (for testing only) 95 - */ 96 - .tolerant = 1, 97 89 .monarch_timeout = -1 98 90 }; 99 91 ··· 159 167 blocking_notifier_chain_unregister(&x86_mce_decoder_chain, nb); 160 168 } 161 169 EXPORT_SYMBOL_GPL(mce_unregister_decode_chain); 162 - 163 - u32 mca_msr_reg(int bank, enum mca_msr reg) 164 - { 165 - if (mce_flags.smca) { 166 - switch (reg) { 167 - case MCA_CTL: return MSR_AMD64_SMCA_MCx_CTL(bank); 168 - case MCA_ADDR: return MSR_AMD64_SMCA_MCx_ADDR(bank); 169 - case MCA_MISC: return MSR_AMD64_SMCA_MCx_MISC(bank); 170 - case MCA_STATUS: return MSR_AMD64_SMCA_MCx_STATUS(bank); 171 - } 172 - } 173 - 174 - switch (reg) { 175 - case MCA_CTL: return MSR_IA32_MCx_CTL(bank); 176 - case MCA_ADDR: return MSR_IA32_MCx_ADDR(bank); 177 - case MCA_MISC: return MSR_IA32_MCx_MISC(bank); 178 - case MCA_STATUS: return MSR_IA32_MCx_STATUS(bank); 179 - } 180 - 181 - return 0; 182 - } 183 170 184 171 static void __print_mce(struct mce *m) 185 172 { ··· 740 769 goto clear_it; 741 770 742 771 mce_read_aux(&m, i); 743 - m.severity = mce_severity(&m, NULL, mca_cfg.tolerant, NULL, false); 772 + m.severity = mce_severity(&m, NULL, NULL, false); 744 773 /* 745 774 * Don't get the IP here because it's unlikely to 746 775 * have anything to do with the actual error location. ··· 780 809 * the severity assessment code. Pretend that EIPV was set, and take the 781 810 * ip/cs values from the pt_regs that mce_gather_info() ignored earlier. 782 811 */ 783 - static void quirk_sandybridge_ifu(int bank, struct mce *m, struct pt_regs *regs) 812 + static __always_inline void 813 + quirk_sandybridge_ifu(int bank, struct mce *m, struct pt_regs *regs) 784 814 { 785 815 if (bank != 0) 786 816 return; ··· 802 830 } 803 831 804 832 /* 833 + * Disable fast string copy and return from the MCE handler upon the first SRAR 834 + * MCE on bank 1 due to a CPU erratum on Intel Skylake/Cascade Lake/Cooper Lake 835 + * CPUs. 836 + * The fast string copy instructions ("REP; MOVS*") could consume an 837 + * uncorrectable memory error in the cache line _right after_ the desired region 838 + * to copy and raise an MCE with RIP pointing to the instruction _after_ the 839 + * "REP; MOVS*". 840 + * This mitigation addresses the issue completely with the caveat of performance 841 + * degradation on the CPU affected. This is still better than the OS crashing on 842 + * MCEs raised on an irrelevant process due to "REP; MOVS*" accesses from a 843 + * kernel context (e.g., copy_page). 844 + * 845 + * Returns true when fast string copy on CPU has been disabled. 846 + */ 847 + static noinstr bool quirk_skylake_repmov(void) 848 + { 849 + u64 mcgstatus = mce_rdmsrl(MSR_IA32_MCG_STATUS); 850 + u64 misc_enable = mce_rdmsrl(MSR_IA32_MISC_ENABLE); 851 + u64 mc1_status; 852 + 853 + /* 854 + * Apply the quirk only to local machine checks, i.e., no broadcast 855 + * sync is needed. 856 + */ 857 + if (!(mcgstatus & MCG_STATUS_LMCES) || 858 + !(misc_enable & MSR_IA32_MISC_ENABLE_FAST_STRING)) 859 + return false; 860 + 861 + mc1_status = mce_rdmsrl(MSR_IA32_MCx_STATUS(1)); 862 + 863 + /* Check for a software-recoverable data fetch error. */ 864 + if ((mc1_status & 865 + (MCI_STATUS_VAL | MCI_STATUS_OVER | MCI_STATUS_UC | MCI_STATUS_EN | 866 + MCI_STATUS_ADDRV | MCI_STATUS_MISCV | MCI_STATUS_PCC | 867 + MCI_STATUS_AR | MCI_STATUS_S)) == 868 + (MCI_STATUS_VAL | MCI_STATUS_UC | MCI_STATUS_EN | 869 + MCI_STATUS_ADDRV | MCI_STATUS_MISCV | 870 + MCI_STATUS_AR | MCI_STATUS_S)) { 871 + misc_enable &= ~MSR_IA32_MISC_ENABLE_FAST_STRING; 872 + mce_wrmsrl(MSR_IA32_MISC_ENABLE, misc_enable); 873 + mce_wrmsrl(MSR_IA32_MCx_STATUS(1), 0); 874 + 875 + instrumentation_begin(); 876 + pr_err_once("Erratum detected, disable fast string copy instructions.\n"); 877 + instrumentation_end(); 878 + 879 + return true; 880 + } 881 + 882 + return false; 883 + } 884 + 885 + /* 805 886 * Do a quick check if any of the events requires a panic. 806 887 * This decides if we keep the events around or clear them. 807 888 */ 808 - static int mce_no_way_out(struct mce *m, char **msg, unsigned long *validp, 809 - struct pt_regs *regs) 889 + static __always_inline int mce_no_way_out(struct mce *m, char **msg, unsigned long *validp, 890 + struct pt_regs *regs) 810 891 { 811 892 char *tmp = *msg; 812 893 int i; ··· 869 844 if (!(m->status & MCI_STATUS_VAL)) 870 845 continue; 871 846 872 - __set_bit(i, validp); 847 + arch___set_bit(i, validp); 873 848 if (mce_flags.snb_ifu_quirk) 874 849 quirk_sandybridge_ifu(i, m, regs); 875 850 876 851 m->bank = i; 877 - if (mce_severity(m, regs, mca_cfg.tolerant, &tmp, true) >= MCE_PANIC_SEVERITY) { 852 + if (mce_severity(m, regs, &tmp, true) >= MCE_PANIC_SEVERITY) { 878 853 mce_read_aux(m, i); 879 854 *msg = tmp; 880 855 return 1; ··· 922 897 if (!mca_cfg.monarch_timeout) 923 898 goto out; 924 899 if ((s64)*t < SPINUNIT) { 925 - if (mca_cfg.tolerant <= 1) { 926 - if (cpumask_and(&mce_missing_cpus, cpu_online_mask, &mce_missing_cpus)) 927 - pr_emerg("CPUs not responding to MCE broadcast (may include false positives): %*pbl\n", 928 - cpumask_pr_args(&mce_missing_cpus)); 929 - mce_panic(msg, NULL, NULL); 930 - } 900 + if (cpumask_and(&mce_missing_cpus, cpu_online_mask, &mce_missing_cpus)) 901 + pr_emerg("CPUs not responding to MCE broadcast (may include false positives): %*pbl\n", 902 + cpumask_pr_args(&mce_missing_cpus)); 903 + mce_panic(msg, NULL, NULL); 904 + 931 905 ret = 1; 932 906 goto out; 933 907 } ··· 990 966 * This dumps all the mces in the log buffer and stops the 991 967 * other CPUs. 992 968 */ 993 - if (m && global_worst >= MCE_PANIC_SEVERITY && mca_cfg.tolerant < 3) { 969 + if (m && global_worst >= MCE_PANIC_SEVERITY) { 994 970 /* call mce_severity() to get "msg" for panic */ 995 - mce_severity(m, NULL, mca_cfg.tolerant, &msg, true); 971 + mce_severity(m, NULL, &msg, true); 996 972 mce_panic("Fatal machine check", m, msg); 997 973 } 998 974 ··· 1006 982 * No machine check event found. Must be some external 1007 983 * source or one CPU is hung. Panic. 1008 984 */ 1009 - if (global_worst <= MCE_KEEP_SEVERITY && mca_cfg.tolerant < 3) 985 + if (global_worst <= MCE_KEEP_SEVERITY) 1010 986 mce_panic("Fatal machine check from unknown source", NULL, NULL); 1011 987 1012 988 /* ··· 1034 1010 if (!timeout) 1035 1011 return ret; 1036 1012 1037 - atomic_add(*no_way_out, &global_nwo); 1013 + arch_atomic_add(*no_way_out, &global_nwo); 1038 1014 /* 1039 1015 * Rely on the implied barrier below, such that global_nwo 1040 1016 * is updated before mce_callin. 1041 1017 */ 1042 - order = atomic_inc_return(&mce_callin); 1043 - cpumask_clear_cpu(smp_processor_id(), &mce_missing_cpus); 1018 + order = arch_atomic_inc_return(&mce_callin); 1019 + arch_cpumask_clear_cpu(smp_processor_id(), &mce_missing_cpus); 1044 1020 1045 1021 /* Enable instrumentation around calls to external facilities */ 1046 1022 instrumentation_begin(); ··· 1048 1024 /* 1049 1025 * Wait for everyone. 1050 1026 */ 1051 - while (atomic_read(&mce_callin) != num_online_cpus()) { 1027 + while (arch_atomic_read(&mce_callin) != num_online_cpus()) { 1052 1028 if (mce_timed_out(&timeout, 1053 1029 "Timeout: Not all CPUs entered broadcast exception handler")) { 1054 - atomic_set(&global_nwo, 0); 1030 + arch_atomic_set(&global_nwo, 0); 1055 1031 goto out; 1056 1032 } 1057 1033 ndelay(SPINUNIT); ··· 1066 1042 /* 1067 1043 * Monarch: Starts executing now, the others wait. 1068 1044 */ 1069 - atomic_set(&mce_executing, 1); 1045 + arch_atomic_set(&mce_executing, 1); 1070 1046 } else { 1071 1047 /* 1072 1048 * Subject: Now start the scanning loop one by one in ··· 1074 1050 * This way when there are any shared banks it will be 1075 1051 * only seen by one CPU before cleared, avoiding duplicates. 1076 1052 */ 1077 - while (atomic_read(&mce_executing) < order) { 1053 + while (arch_atomic_read(&mce_executing) < order) { 1078 1054 if (mce_timed_out(&timeout, 1079 1055 "Timeout: Subject CPUs unable to finish machine check processing")) { 1080 - atomic_set(&global_nwo, 0); 1056 + arch_atomic_set(&global_nwo, 0); 1081 1057 goto out; 1082 1058 } 1083 1059 ndelay(SPINUNIT); ··· 1087 1063 /* 1088 1064 * Cache the global no_way_out state. 1089 1065 */ 1090 - *no_way_out = atomic_read(&global_nwo); 1066 + *no_way_out = arch_atomic_read(&global_nwo); 1091 1067 1092 1068 ret = order; 1093 1069 ··· 1172 1148 return ret; 1173 1149 } 1174 1150 1175 - static void mce_clear_state(unsigned long *toclear) 1151 + static __always_inline void mce_clear_state(unsigned long *toclear) 1176 1152 { 1177 1153 int i; 1178 1154 1179 1155 for (i = 0; i < this_cpu_read(mce_num_banks); i++) { 1180 - if (test_bit(i, toclear)) 1156 + if (arch_test_bit(i, toclear)) 1181 1157 mce_wrmsrl(mca_msr_reg(i, MCA_STATUS), 0); 1182 1158 } 1183 1159 } ··· 1227 1203 int severity, i, taint = 0; 1228 1204 1229 1205 for (i = 0; i < this_cpu_read(mce_num_banks); i++) { 1230 - __clear_bit(i, toclear); 1231 - if (!test_bit(i, valid_banks)) 1206 + arch___clear_bit(i, toclear); 1207 + if (!arch_test_bit(i, valid_banks)) 1232 1208 continue; 1233 1209 1234 1210 if (!mce_banks[i].ctl) ··· 1253 1229 /* Set taint even when machine check was not enabled. */ 1254 1230 taint++; 1255 1231 1256 - severity = mce_severity(m, regs, cfg->tolerant, NULL, true); 1232 + severity = mce_severity(m, regs, NULL, true); 1257 1233 1258 1234 /* 1259 1235 * When machine check was for corrected/deferred handler don't ··· 1263 1239 severity == MCE_UCNA_SEVERITY) && !no_way_out) 1264 1240 continue; 1265 1241 1266 - __set_bit(i, toclear); 1242 + arch___set_bit(i, toclear); 1267 1243 1268 1244 /* Machine check event was not enabled. Clear, but ignore. */ 1269 1245 if (severity == MCE_NO_SEVERITY) ··· 1413 1389 int worst = 0, order, no_way_out, kill_current_task, lmce, taint = 0; 1414 1390 DECLARE_BITMAP(valid_banks, MAX_NR_BANKS) = { 0 }; 1415 1391 DECLARE_BITMAP(toclear, MAX_NR_BANKS) = { 0 }; 1416 - struct mca_config *cfg = &mca_cfg; 1417 1392 struct mce m, *final; 1418 1393 char *msg = NULL; 1419 1394 ··· 1423 1400 else if (unlikely(!mca_cfg.initialized)) 1424 1401 return unexpected_machine_check(regs); 1425 1402 1403 + if (mce_flags.skx_repmov_quirk && quirk_skylake_repmov()) 1404 + goto clear; 1405 + 1426 1406 /* 1427 1407 * Establish sequential order between the CPUs entering the machine 1428 1408 * check handler. ··· 1434 1408 1435 1409 /* 1436 1410 * If no_way_out gets set, there is no safe way to recover from this 1437 - * MCE. If mca_cfg.tolerant is cranked up, we'll try anyway. 1411 + * MCE. 1438 1412 */ 1439 1413 no_way_out = 0; 1440 1414 ··· 1468 1442 * severity is MCE_AR_SEVERITY we have other options. 1469 1443 */ 1470 1444 if (!(m.mcgstatus & MCG_STATUS_RIPV)) 1471 - kill_current_task = (cfg->tolerant == 3) ? 0 : 1; 1445 + kill_current_task = 1; 1472 1446 /* 1473 1447 * Check if this MCE is signaled to only this logical processor, 1474 1448 * on Intel, Zhaoxin only. ··· 1485 1459 * to see it will clear it. 1486 1460 */ 1487 1461 if (lmce) { 1488 - if (no_way_out && cfg->tolerant < 3) 1462 + if (no_way_out) 1489 1463 mce_panic("Fatal local machine check", &m, msg); 1490 1464 } else { 1491 1465 order = mce_start(&no_way_out); ··· 1505 1479 if (!no_way_out) 1506 1480 no_way_out = worst >= MCE_PANIC_SEVERITY; 1507 1481 1508 - if (no_way_out && cfg->tolerant < 3) 1482 + if (no_way_out) 1509 1483 mce_panic("Fatal machine check on current CPU", &m, msg); 1510 1484 } 1511 1485 } else { ··· 1517 1491 * fatal error. We call "mce_severity()" again to 1518 1492 * make sure we have the right "msg". 1519 1493 */ 1520 - if (worst >= MCE_PANIC_SEVERITY && mca_cfg.tolerant < 3) { 1521 - mce_severity(&m, regs, cfg->tolerant, &msg, true); 1494 + if (worst >= MCE_PANIC_SEVERITY) { 1495 + mce_severity(&m, regs, &msg, true); 1522 1496 mce_panic("Local fatal machine check!", &m, msg); 1523 1497 } 1524 1498 } ··· 1568 1542 out: 1569 1543 instrumentation_end(); 1570 1544 1545 + clear: 1571 1546 mce_wrmsrl(MSR_IA32_MCG_STATUS, 0); 1572 1547 } 1573 1548 EXPORT_SYMBOL_GPL(do_machine_check); ··· 1882 1855 1883 1856 if (c->x86 == 6 && c->x86_model == 45) 1884 1857 mce_flags.snb_ifu_quirk = 1; 1858 + 1859 + /* 1860 + * Skylake, Cascacde Lake and Cooper Lake require a quirk on 1861 + * rep movs. 1862 + */ 1863 + if (c->x86 == 6 && c->x86_model == INTEL_FAM6_SKYLAKE_X) 1864 + mce_flags.skx_repmov_quirk = 1; 1885 1865 } 1886 1866 1887 1867 if (c->x86_vendor == X86_VENDOR_ZHAOXIN) { ··· 2254 2220 cfg->bios_cmci_threshold = 1; 2255 2221 else if (!strcmp(str, "recovery")) 2256 2222 cfg->recovery = 1; 2257 - else if (isdigit(str[0])) { 2258 - if (get_option(&str, &cfg->tolerant) == 2) 2259 - get_option(&str, &(cfg->monarch_timeout)); 2260 - } else { 2223 + else if (isdigit(str[0])) 2224 + get_option(&str, &(cfg->monarch_timeout)); 2225 + else { 2261 2226 pr_info("mce argument %s ignored. Please use /sys\n", str); 2262 2227 return 0; 2263 2228 } ··· 2506 2473 return ret; 2507 2474 } 2508 2475 2509 - static DEVICE_INT_ATTR(tolerant, 0644, mca_cfg.tolerant); 2510 2476 static DEVICE_INT_ATTR(monarch_timeout, 0644, mca_cfg.monarch_timeout); 2511 2477 static DEVICE_BOOL_ATTR(dont_log_ce, 0644, mca_cfg.dont_log_ce); 2512 2478 static DEVICE_BOOL_ATTR(print_all, 0644, mca_cfg.print_all); ··· 2526 2494 }; 2527 2495 2528 2496 static struct device_attribute *mce_device_attrs[] = { 2529 - &dev_attr_tolerant.attr, 2530 2497 &dev_attr_check_interval.attr, 2531 2498 #ifdef CONFIG_X86_MCELOG_LEGACY 2532 2499 &dev_attr_trigger,
+26 -5
arch/x86/kernel/cpu/mce/internal.h
··· 35 35 int mce_gen_pool_init(void); 36 36 struct llist_node *mce_gen_pool_prepare_records(void); 37 37 38 - int mce_severity(struct mce *a, struct pt_regs *regs, int tolerant, char **msg, bool is_excp); 38 + int mce_severity(struct mce *a, struct pt_regs *regs, char **msg, bool is_excp); 39 39 struct dentry *mce_get_debugfs_dir(void); 40 40 41 41 extern mce_banks_t mce_banks_ce_disabled; ··· 127 127 bool ignore_ce; 128 128 bool print_all; 129 129 130 - int tolerant; 131 130 int monarch_timeout; 132 131 int panic_timeout; 133 132 u32 rip_msr; ··· 169 170 /* SandyBridge IFU quirk */ 170 171 snb_ifu_quirk : 1, 171 172 172 - __reserved_0 : 57; 173 + /* Skylake, Cascade Lake, Cooper Lake REP;MOVS* quirk */ 174 + skx_repmov_quirk : 1, 175 + 176 + __reserved_0 : 56; 173 177 }; 174 178 175 179 extern struct mce_vendor_flags mce_flags; ··· 183 181 MCA_ADDR, 184 182 MCA_MISC, 185 183 }; 186 - 187 - u32 mca_msr_reg(int bank, enum mca_msr reg); 188 184 189 185 /* Decide whether to add MCE record to MCE event pool or filter it out. */ 190 186 extern bool filter_mce(struct mce *m); ··· 208 208 #endif 209 209 210 210 noinstr u64 mce_rdmsrl(u32 msr); 211 + 212 + static __always_inline u32 mca_msr_reg(int bank, enum mca_msr reg) 213 + { 214 + if (mce_flags.smca) { 215 + switch (reg) { 216 + case MCA_CTL: return MSR_AMD64_SMCA_MCx_CTL(bank); 217 + case MCA_ADDR: return MSR_AMD64_SMCA_MCx_ADDR(bank); 218 + case MCA_MISC: return MSR_AMD64_SMCA_MCx_MISC(bank); 219 + case MCA_STATUS: return MSR_AMD64_SMCA_MCx_STATUS(bank); 220 + } 221 + } 222 + 223 + switch (reg) { 224 + case MCA_CTL: return MSR_IA32_MCx_CTL(bank); 225 + case MCA_ADDR: return MSR_IA32_MCx_ADDR(bank); 226 + case MCA_MISC: return MSR_IA32_MCx_MISC(bank); 227 + case MCA_STATUS: return MSR_IA32_MCx_STATUS(bank); 228 + } 229 + 230 + return 0; 231 + } 211 232 212 233 #endif /* __X86_MCE_INTERNAL_H__ */
+10 -13
arch/x86/kernel/cpu/mce/severity.c
··· 301 301 } 302 302 } 303 303 304 - static int mce_severity_amd_smca(struct mce *m, enum context err_ctx) 304 + static __always_inline int mce_severity_amd_smca(struct mce *m, enum context err_ctx) 305 305 { 306 306 u64 mcx_cfg; 307 307 ··· 330 330 * See AMD Error Scope Hierarchy table in a newer BKDG. For example 331 331 * 49125_15h_Models_30h-3Fh_BKDG.pdf, section "RAS Features" 332 332 */ 333 - static noinstr int mce_severity_amd(struct mce *m, struct pt_regs *regs, int tolerant, 334 - char **msg, bool is_excp) 333 + static noinstr int mce_severity_amd(struct mce *m, struct pt_regs *regs, char **msg, bool is_excp) 335 334 { 336 335 enum context ctx = error_context(m, regs); 337 336 ··· 382 383 return MCE_KEEP_SEVERITY; 383 384 } 384 385 385 - static noinstr int mce_severity_intel(struct mce *m, struct pt_regs *regs, 386 - int tolerant, char **msg, bool is_excp) 386 + static noinstr int mce_severity_intel(struct mce *m, struct pt_regs *regs, char **msg, bool is_excp) 387 387 { 388 388 enum exception excp = (is_excp ? EXCP_CONTEXT : NO_EXCP); 389 389 enum context ctx = error_context(m, regs); ··· 410 412 if (msg) 411 413 *msg = s->msg; 412 414 s->covered = 1; 413 - if (s->sev >= MCE_UC_SEVERITY && ctx == IN_KERNEL) { 414 - if (tolerant < 1) 415 - return MCE_PANIC_SEVERITY; 416 - } 415 + 416 + if (s->sev >= MCE_UC_SEVERITY && ctx == IN_KERNEL) 417 + return MCE_PANIC_SEVERITY; 418 + 417 419 return s->sev; 418 420 } 419 421 } 420 422 421 - int noinstr mce_severity(struct mce *m, struct pt_regs *regs, int tolerant, char **msg, 422 - bool is_excp) 423 + int noinstr mce_severity(struct mce *m, struct pt_regs *regs, char **msg, bool is_excp) 423 424 { 424 425 if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD || 425 426 boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) 426 - return mce_severity_amd(m, regs, tolerant, msg, is_excp); 427 + return mce_severity_amd(m, regs, msg, is_excp); 427 428 else 428 - return mce_severity_intel(m, regs, tolerant, msg, is_excp); 429 + return mce_severity_intel(m, regs, msg, is_excp); 429 430 } 430 431 431 432 #ifdef CONFIG_DEBUG_FS