Skip to content

Commit b986680

Browse files
committed
x86/mce: Define a function to extract ErrorAddr from MCA_ADDR
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2164637 Tested: by me, sanity commit 2117654 Author: Smita Koralahalli <Smita.KoralahalliChannabasappa@amd.com> Date: Tue Dec 6 11:36:06 2022 -0600 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 <Smita.KoralahalliChannabasappa@amd.com> Signed-off-by: Borislav Petkov <bp@suse.de> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Yazen Ghannam <yazen.ghannam@amd.com> Link: https://lore.kernel.org/all/20220225193342.215780-3-Smita.KoralahalliChannabasappa@amd.com/ Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>
1 parent 6381213 commit b986680

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
@@ -654,15 +654,7 @@ static noinstr void mce_read_aux(struct mce *m, int i)
654654
m->addr <<= shift;
655655
}
656656

657-
/*
658-
* Extract [55:<lsb>] where lsb is the least significant
659-
* *valid* bit of the address bits.
660-
*/
661-
if (mce_flags.smca) {
662-
u8 lsb = (m->addr >> 56) & 0x3f;
663-
664-
m->addr &= GENMASK_ULL(55, lsb);
665-
}
657+
smca_extract_err_addr(m);
666658
}
667659

668660
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
@@ -188,8 +188,23 @@ extern bool filter_mce(struct mce *m);
188188

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

195210
#ifdef CONFIG_X86_ANCIENT_MCE

0 commit comments

Comments
 (0)