hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/arch/x86/kernel/cpu/mce/amd.c
....@@ -197,10 +197,10 @@
197197 * A list of the banks enabled on each logical CPU. Controls which respective
198198 * descriptors to initialize later in mce_threshold_create_device().
199199 */
200
-static DEFINE_PER_CPU(unsigned int, bank_map);
200
+static DEFINE_PER_CPU(u64, bank_map);
201201
202202 /* Map of banks that have more than MCA_MISC0 available. */
203
-static DEFINE_PER_CPU(u32, smca_misc_banks_map);
203
+static DEFINE_PER_CPU(u64, smca_misc_banks_map);
204204
205205 static void amd_threshold_interrupt(void);
206206 static void amd_deferred_error_interrupt(void);
....@@ -229,7 +229,7 @@
229229 return;
230230
231231 if (low & MASK_BLKPTR_LO)
232
- per_cpu(smca_misc_banks_map, cpu) |= BIT(bank);
232
+ per_cpu(smca_misc_banks_map, cpu) |= BIT_ULL(bank);
233233
234234 }
235235
....@@ -492,7 +492,7 @@
492492 if (!block)
493493 return MSR_AMD64_SMCA_MCx_MISC(bank);
494494
495
- if (!(per_cpu(smca_misc_banks_map, cpu) & BIT(bank)))
495
+ if (!(per_cpu(smca_misc_banks_map, cpu) & BIT_ULL(bank)))
496496 return 0;
497497
498498 return MSR_AMD64_SMCA_MCx_MISCy(bank, block - 1);
....@@ -513,7 +513,7 @@
513513 /* Fall back to method we used for older processors: */
514514 switch (block) {
515515 case 0:
516
- addr = msr_ops.misc(bank);
516
+ addr = mca_msr_reg(bank, MCA_MISC);
517517 break;
518518 case 1:
519519 offset = ((low & MASK_BLKPTR_LO) >> 21);
....@@ -536,7 +536,7 @@
536536 int new;
537537
538538 if (!block)
539
- per_cpu(bank_map, cpu) |= (1 << bank);
539
+ per_cpu(bank_map, cpu) |= BIT_ULL(bank);
540540
541541 memset(&b, 0, sizeof(b));
542542 b.cpu = cpu;
....@@ -952,6 +952,24 @@
952952 return status & MCI_STATUS_DEFERRED;
953953 }
954954
955
+static bool _log_error_deferred(unsigned int bank, u32 misc)
956
+{
957
+ if (!_log_error_bank(bank, mca_msr_reg(bank, MCA_STATUS),
958
+ mca_msr_reg(bank, MCA_ADDR), misc))
959
+ return false;
960
+
961
+ /*
962
+ * Non-SMCA systems don't have MCA_DESTAT/MCA_DEADDR registers.
963
+ * Return true here to avoid accessing these registers.
964
+ */
965
+ if (!mce_flags.smca)
966
+ return true;
967
+
968
+ /* Clear MCA_DESTAT if the deferred error was logged from MCA_STATUS. */
969
+ wrmsrl(MSR_AMD64_SMCA_MCx_DESTAT(bank), 0);
970
+ return true;
971
+}
972
+
955973 /*
956974 * We have three scenarios for checking for Deferred errors:
957975 *
....@@ -963,19 +981,8 @@
963981 */
964982 static void log_error_deferred(unsigned int bank)
965983 {
966
- bool defrd;
967
-
968
- defrd = _log_error_bank(bank, msr_ops.status(bank),
969
- msr_ops.addr(bank), 0);
970
-
971
- if (!mce_flags.smca)
984
+ if (_log_error_deferred(bank, 0))
972985 return;
973
-
974
- /* Clear MCA_DESTAT if we logged the deferred error from MCA_STATUS. */
975
- if (defrd) {
976
- wrmsrl(MSR_AMD64_SMCA_MCx_DESTAT(bank), 0);
977
- return;
978
- }
979986
980987 /*
981988 * Only deferred errors are logged in MCA_DE{STAT,ADDR} so just check
....@@ -996,7 +1003,7 @@
9961003
9971004 static void log_error_thresholding(unsigned int bank, u64 misc)
9981005 {
999
- _log_error_bank(bank, msr_ops.status(bank), msr_ops.addr(bank), misc);
1006
+ _log_error_deferred(bank, misc);
10001007 }
10011008
10021009 static void log_and_reset_block(struct threshold_block *block)
....@@ -1041,7 +1048,7 @@
10411048 return;
10421049
10431050 for (bank = 0; bank < this_cpu_read(mce_num_banks); ++bank) {
1044
- if (!(per_cpu(bank_map, cpu) & (1 << bank)))
1051
+ if (!(per_cpu(bank_map, cpu) & BIT_ULL(bank)))
10451052 continue;
10461053
10471054 first_block = bp[bank]->blocks;
....@@ -1384,7 +1391,7 @@
13841391 }
13851392 }
13861393
1387
- err = allocate_threshold_blocks(cpu, b, bank, 0, msr_ops.misc(bank));
1394
+ err = allocate_threshold_blocks(cpu, b, bank, 0, mca_msr_reg(bank, MCA_MISC));
13881395 if (err)
13891396 goto out_kobj;
13901397
....@@ -1518,7 +1525,7 @@
15181525 return -ENOMEM;
15191526
15201527 for (bank = 0; bank < numbanks; ++bank) {
1521
- if (!(this_cpu_read(bank_map) & (1 << bank)))
1528
+ if (!(this_cpu_read(bank_map) & BIT_ULL(bank)))
15221529 continue;
15231530 err = threshold_create_bank(bp, cpu, bank);
15241531 if (err) {