|
@@ -82,6 +82,7 @@ static struct smca_bank_name smca_names[] = {
|
|
|
[SMCA_IF] = { "insn_fetch", "Instruction Fetch Unit" },
|
|
|
[SMCA_L2_CACHE] = { "l2_cache", "L2 Cache" },
|
|
|
[SMCA_DE] = { "decode_unit", "Decode Unit" },
|
|
|
+ [SMCA_RESERVED] = { "reserved", "Reserved" },
|
|
|
[SMCA_EX] = { "execution_unit", "Execution Unit" },
|
|
|
[SMCA_FP] = { "floating_point", "Floating Point Unit" },
|
|
|
[SMCA_L3_CACHE] = { "l3_cache", "L3 Cache" },
|
|
@@ -110,14 +111,14 @@ const char *smca_get_long_name(enum smca_bank_types t)
|
|
|
}
|
|
|
EXPORT_SYMBOL_GPL(smca_get_long_name);
|
|
|
|
|
|
-static enum smca_bank_types smca_get_bank_type(struct mce *m)
|
|
|
+static enum smca_bank_types smca_get_bank_type(unsigned int bank)
|
|
|
{
|
|
|
struct smca_bank *b;
|
|
|
|
|
|
- if (m->bank >= N_SMCA_BANK_TYPES)
|
|
|
+ if (bank >= MAX_NR_BANKS)
|
|
|
return N_SMCA_BANK_TYPES;
|
|
|
|
|
|
- b = &smca_banks[m->bank];
|
|
|
+ b = &smca_banks[bank];
|
|
|
if (!b->hwid)
|
|
|
return N_SMCA_BANK_TYPES;
|
|
|
|
|
@@ -127,6 +128,9 @@ static enum smca_bank_types smca_get_bank_type(struct mce *m)
|
|
|
static struct smca_hwid smca_hwid_mcatypes[] = {
|
|
|
/* { bank_type, hwid_mcatype, xec_bitmap } */
|
|
|
|
|
|
+ /* Reserved type */
|
|
|
+ { SMCA_RESERVED, HWID_MCATYPE(0x00, 0x0), 0x0 },
|
|
|
+
|
|
|
/* ZN Core (HWID=0xB0) MCA types */
|
|
|
{ SMCA_LS, HWID_MCATYPE(0xB0, 0x0), 0x1FFFEF },
|
|
|
{ SMCA_IF, HWID_MCATYPE(0xB0, 0x1), 0x3FFF },
|
|
@@ -427,35 +431,58 @@ static void deferred_error_interrupt_enable(struct cpuinfo_x86 *c)
|
|
|
wrmsr(MSR_CU_DEF_ERR, low, high);
|
|
|
}
|
|
|
|
|
|
+static u32 smca_get_block_address(unsigned int cpu, unsigned int bank,
|
|
|
+ unsigned int block)
|
|
|
+{
|
|
|
+ u32 low, high;
|
|
|
+ u32 addr = 0;
|
|
|
+
|
|
|
+ if (smca_get_bank_type(bank) == SMCA_RESERVED)
|
|
|
+ return addr;
|
|
|
+
|
|
|
+ if (!block)
|
|
|
+ return MSR_AMD64_SMCA_MCx_MISC(bank);
|
|
|
+
|
|
|
+ /*
|
|
|
+ * For SMCA enabled processors, BLKPTR field of the first MISC register
|
|
|
+ * (MCx_MISC0) indicates presence of additional MISC regs set (MISC1-4).
|
|
|
+ */
|
|
|
+ if (rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_CONFIG(bank), &low, &high))
|
|
|
+ return addr;
|
|
|
+
|
|
|
+ if (!(low & MCI_CONFIG_MCAX))
|
|
|
+ return addr;
|
|
|
+
|
|
|
+ if (!rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_MISC(bank), &low, &high) &&
|
|
|
+ (low & MASK_BLKPTR_LO))
|
|
|
+ return MSR_AMD64_SMCA_MCx_MISCy(bank, block - 1);
|
|
|
+
|
|
|
+ return addr;
|
|
|
+}
|
|
|
+
|
|
|
static u32 get_block_address(unsigned int cpu, u32 current_addr, u32 low, u32 high,
|
|
|
unsigned int bank, unsigned int block)
|
|
|
{
|
|
|
u32 addr = 0, offset = 0;
|
|
|
|
|
|
- if (mce_flags.smca) {
|
|
|
- if (!block) {
|
|
|
- addr = MSR_AMD64_SMCA_MCx_MISC(bank);
|
|
|
- } else {
|
|
|
- /*
|
|
|
- * For SMCA enabled processors, BLKPTR field of the
|
|
|
- * first MISC register (MCx_MISC0) indicates presence of
|
|
|
- * additional MISC register set (MISC1-4).
|
|
|
- */
|
|
|
- u32 low, high;
|
|
|
+ if ((bank >= mca_cfg.banks) || (block >= NR_BLOCKS))
|
|
|
+ return addr;
|
|
|
|
|
|
- if (rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_CONFIG(bank), &low, &high))
|
|
|
- return addr;
|
|
|
+ /* Get address from already initialized block. */
|
|
|
+ if (per_cpu(threshold_banks, cpu)) {
|
|
|
+ struct threshold_bank *bankp = per_cpu(threshold_banks, cpu)[bank];
|
|
|
|
|
|
- if (!(low & MCI_CONFIG_MCAX))
|
|
|
- return addr;
|
|
|
+ if (bankp && bankp->blocks) {
|
|
|
+ struct threshold_block *blockp = &bankp->blocks[block];
|
|
|
|
|
|
- if (!rdmsr_safe_on_cpu(cpu, MSR_AMD64_SMCA_MCx_MISC(bank), &low, &high) &&
|
|
|
- (low & MASK_BLKPTR_LO))
|
|
|
- addr = MSR_AMD64_SMCA_MCx_MISCy(bank, block - 1);
|
|
|
+ if (blockp)
|
|
|
+ return blockp->address;
|
|
|
}
|
|
|
- return addr;
|
|
|
}
|
|
|
|
|
|
+ if (mce_flags.smca)
|
|
|
+ return smca_get_block_address(cpu, bank, block);
|
|
|
+
|
|
|
/* Fall back to method we used for older processors: */
|
|
|
switch (block) {
|
|
|
case 0:
|
|
@@ -760,7 +787,7 @@ bool amd_mce_is_memory_error(struct mce *m)
|
|
|
u8 xec = (m->status >> 16) & 0x1f;
|
|
|
|
|
|
if (mce_flags.smca)
|
|
|
- return smca_get_bank_type(m) == SMCA_UMC && xec == 0x0;
|
|
|
+ return smca_get_bank_type(m->bank) == SMCA_UMC && xec == 0x0;
|
|
|
|
|
|
return m->bank == 4 && xec == 0x8;
|
|
|
}
|
|
@@ -1063,7 +1090,7 @@ static struct kobj_type threshold_ktype = {
|
|
|
|
|
|
static const char *get_name(unsigned int bank, struct threshold_block *b)
|
|
|
{
|
|
|
- unsigned int bank_type;
|
|
|
+ enum smca_bank_types bank_type;
|
|
|
|
|
|
if (!mce_flags.smca) {
|
|
|
if (b && bank == 4)
|
|
@@ -1072,11 +1099,10 @@ static const char *get_name(unsigned int bank, struct threshold_block *b)
|
|
|
return th_names[bank];
|
|
|
}
|
|
|
|
|
|
- if (!smca_banks[bank].hwid)
|
|
|
+ bank_type = smca_get_bank_type(bank);
|
|
|
+ if (bank_type >= N_SMCA_BANK_TYPES)
|
|
|
return NULL;
|
|
|
|
|
|
- bank_type = smca_banks[bank].hwid->bank_type;
|
|
|
-
|
|
|
if (b && bank_type == SMCA_UMC) {
|
|
|
if (b->block < ARRAY_SIZE(smca_umc_block_names))
|
|
|
return smca_umc_block_names[b->block];
|