Skip to content

Commit 821f5fe

Browse files
Avadhut Naikbp3tk0v
authored andcommitted
x86/mce: Add support for physical address valid bit
Starting with Zen6, AMD's Scalable MCA systems will incorporate two new bits in MCA_STATUS and MCA_CONFIG MSRs. These bits will indicate if a valid System Physical Address (SPA) is present in MCA_ADDR. PhysAddrValidSupported bit (MCA_CONFIG[11]) serves as the architectural indicator and states if PhysAddrV bit (MCA_STATUS[54]) is Reserved or if it indicates validity of SPA in MCA_ADDR. PhysAddrV bit (MCA_STATUS[54]) advertises if MCA_ADDR contains valid SPA or if it is implementation specific. Use and prefer MCA_STATUS[PhysAddrV] when checking for a usable address. Signed-off-by: Avadhut Naik <avadhut.naik@amd.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://patch.msgid.link/20251118191731.181269-1-avadhut.naik@amd.com
1 parent eeb3f76 commit 821f5fe

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

arch/x86/include/asm/mce.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848

4949
/* AMD-specific bits */
5050
#define MCI_STATUS_TCC BIT_ULL(55) /* Task context corrupt */
51+
#define MCI_STATUS_PADDRV BIT_ULL(54) /* Valid System Physical Address */
5152
#define MCI_STATUS_SYNDV BIT_ULL(53) /* synd reg. valid */
5253
#define MCI_STATUS_DEFERRED BIT_ULL(44) /* uncorrected error, deferred exception */
5354
#define MCI_STATUS_POISON BIT_ULL(43) /* access poisonous data */
@@ -62,6 +63,7 @@
6263
*/
6364
#define MCI_CONFIG_MCAX 0x1
6465
#define MCI_CONFIG_FRUTEXT BIT_ULL(9)
66+
#define MCI_CONFIG_PADDRV BIT_ULL(11)
6567
#define MCI_IPID_MCATYPE 0xFFFF0000
6668
#define MCI_IPID_HWID 0xFFF
6769

arch/x86/kernel/cpu/mce/amd.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ struct smca_bank {
8787
const struct smca_hwid *hwid;
8888
u32 id; /* Value of MCA_IPID[InstanceId]. */
8989
u8 sysfs_id; /* Value used for sysfs name. */
90+
u64 paddrv :1, /* Physical Address Valid bit in MCA_CONFIG */
91+
__reserved :63;
9092
};
9193

9294
static DEFINE_PER_CPU_READ_MOSTLY(struct smca_bank[MAX_NR_BANKS], smca_banks);
@@ -327,6 +329,9 @@ static void smca_configure(unsigned int bank, unsigned int cpu)
327329

328330
this_cpu_ptr(mce_banks_array)[bank].lsb_in_status = !!(low & BIT(8));
329331

332+
if (low & MCI_CONFIG_PADDRV)
333+
this_cpu_ptr(smca_banks)[bank].paddrv = 1;
334+
330335
wrmsr(smca_config, low, high);
331336
}
332337

@@ -790,9 +795,9 @@ bool amd_mce_is_memory_error(struct mce *m)
790795
}
791796

792797
/*
793-
* AMD systems do not have an explicit indicator that the value in MCA_ADDR is
794-
* a system physical address. Therefore, individual cases need to be detected.
795-
* Future cases and checks will be added as needed.
798+
* Some AMD systems have an explicit indicator that the value in MCA_ADDR is a
799+
* system physical address. Individual cases though, need to be detected for
800+
* other systems. Future cases will be added as needed.
796801
*
797802
* 1) General case
798803
* a) Assume address is not usable.
@@ -806,6 +811,8 @@ bool amd_mce_is_memory_error(struct mce *m)
806811
* a) Reported in legacy bank 4 with extended error code (XEC) 8.
807812
* b) MCA_STATUS[43] is *not* defined as poison in legacy bank 4. Therefore,
808813
* this bit should not be checked.
814+
* 4) MCI_STATUS_PADDRVAL is set
815+
* a) Will provide a valid system physical address.
809816
*
810817
* NOTE: SMCA UMC memory errors fall into case #1.
811818
*/
@@ -819,6 +826,9 @@ bool amd_mce_usable_address(struct mce *m)
819826
return false;
820827
}
821828

829+
if (this_cpu_ptr(smca_banks)[m->bank].paddrv)
830+
return m->status & MCI_STATUS_PADDRV;
831+
822832
/* Check poison bit for all other bank types. */
823833
if (m->status & MCI_STATUS_POISON)
824834
return true;

0 commit comments

Comments
 (0)