Skip to content

Commit 2117654

Browse files
skoralahbp3tk0v
authored andcommitted
x86/mce: Define a function to extract ErrorAddr from MCA_ADDR
Move MCA_ADDR[ErrorAddr] extraction into a separate helper function. This will be further refactored to support extended ErrorAddr bits in MCA_ADDR in newer AMD CPUs. [ bp: Massage. ] Signed-off-by: Smita Koralahalli <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Yazen Ghannam <[email protected]> Link: https://lore.kernel.org/all/[email protected]/
1 parent 1b929c0 commit 2117654

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -736,15 +736,7 @@ static void __log_error(unsigned int bank, u64 status, u64 addr, u64 misc)
736736
if (m.status & MCI_STATUS_ADDRV) {
737737
m.addr = addr;
738738

739-
/*
740-
* Extract [55:<lsb>] where lsb is the least significant
741-
* *valid* bit of the address bits.
742-
*/
743-
if (mce_flags.smca) {
744-
u8 lsb = (m.addr >> 56) & 0x3f;
745-
746-
m.addr &= GENMASK_ULL(55, lsb);
747-
}
739+
smca_extract_err_addr(&m);
748740
}
749741

750742
if (mce_flags.smca) {

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -633,15 +633,7 @@ static noinstr void mce_read_aux(struct mce *m, int i)
633633
m->addr <<= shift;
634634
}
635635

636-
/*
637-
* Extract [55:<lsb>] where lsb is the least significant
638-
* *valid* bit of the address bits.
639-
*/
640-
if (mce_flags.smca) {
641-
u8 lsb = (m->addr >> 56) & 0x3f;
642-
643-
m->addr &= GENMASK_ULL(55, lsb);
644-
}
636+
smca_extract_err_addr(m);
645637
}
646638

647639
if (mce_flags.smca) {

arch/x86/kernel/cpu/mce/internal.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,23 @@ extern bool filter_mce(struct mce *m);
189189

190190
#ifdef CONFIG_X86_MCE_AMD
191191
extern bool amd_filter_mce(struct mce *m);
192+
193+
/* Extract [55:<lsb>] where lsb is the LS-*valid* bit of the address bits. */
194+
static __always_inline void smca_extract_err_addr(struct mce *m)
195+
{
196+
u8 lsb;
197+
198+
if (!mce_flags.smca)
199+
return;
200+
201+
lsb = (m->addr >> 56) & 0x3f;
202+
203+
m->addr &= GENMASK_ULL(55, lsb);
204+
}
205+
192206
#else
193207
static inline bool amd_filter_mce(struct mce *m) { return false; }
208+
static inline void smca_extract_err_addr(struct mce *m) { }
194209
#endif
195210

196211
#ifdef CONFIG_X86_ANCIENT_MCE

0 commit comments

Comments
 (0)