Skip to content

Commit 70f0c23

Browse files
Tony W Wang-ocsuryasaimadhu
authored andcommitted
x86/mce: Add Zhaoxin LMCE support
Newer Zhaoxin CPUs support LMCE compatible with Intel. Add support for that. [ bp: Export functions and massage. ] Signed-off-by: Tony W Wang-oc <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: "H. Peter Anvin" <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: linux-edac <[email protected]> Cc: [email protected] Cc: Thomas Gleixner <[email protected]> Cc: Tony Luck <[email protected]> Cc: x86-ml <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 5a3d56a commit 70f0c23

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,12 @@ static bool __mc_check_crashing_cpu(int cpu)
11321132
u64 mcgstatus;
11331133

11341134
mcgstatus = mce_rdmsrl(MSR_IA32_MCG_STATUS);
1135+
1136+
if (boot_cpu_data.x86_vendor == X86_VENDOR_ZHAOXIN) {
1137+
if (mcgstatus & MCG_STATUS_LMCES)
1138+
return false;
1139+
}
1140+
11351141
if (mcgstatus & MCG_STATUS_RIPV) {
11361142
mce_wrmsrl(MSR_IA32_MCG_STATUS, 0);
11371143
return true;
@@ -1282,9 +1288,10 @@ void do_machine_check(struct pt_regs *regs, long error_code)
12821288

12831289
/*
12841290
* Check if this MCE is signaled to only this logical processor,
1285-
* on Intel only.
1291+
* on Intel, Zhaoxin only.
12861292
*/
1287-
if (m.cpuvendor == X86_VENDOR_INTEL)
1293+
if (m.cpuvendor == X86_VENDOR_INTEL ||
1294+
m.cpuvendor == X86_VENDOR_ZHAOXIN)
12881295
lmce = m.mcgstatus & MCG_STATUS_LMCES;
12891296

12901297
/*
@@ -1797,9 +1804,15 @@ static void mce_zhaoxin_feature_init(struct cpuinfo_x86 *c)
17971804
}
17981805

17991806
intel_init_cmci();
1807+
intel_init_lmce();
18001808
mce_adjust_timer = cmci_intel_adjust_timer;
18011809
}
18021810

1811+
static void mce_zhaoxin_feature_clear(struct cpuinfo_x86 *c)
1812+
{
1813+
intel_clear_lmce();
1814+
}
1815+
18031816
static void __mcheck_cpu_init_vendor(struct cpuinfo_x86 *c)
18041817
{
18051818
switch (c->x86_vendor) {
@@ -1836,6 +1849,11 @@ static void __mcheck_cpu_clear_vendor(struct cpuinfo_x86 *c)
18361849
case X86_VENDOR_INTEL:
18371850
mce_intel_feature_clear(c);
18381851
break;
1852+
1853+
case X86_VENDOR_ZHAOXIN:
1854+
mce_zhaoxin_feature_clear(c);
1855+
break;
1856+
18391857
default:
18401858
break;
18411859
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ void intel_init_cmci(void)
444444
cmci_recheck();
445445
}
446446

447-
static void intel_init_lmce(void)
447+
void intel_init_lmce(void)
448448
{
449449
u64 val;
450450

@@ -457,7 +457,7 @@ static void intel_init_lmce(void)
457457
wrmsrl(MSR_IA32_MCG_EXT_CTL, val | MCG_EXT_CTL_LMCE_EN);
458458
}
459459

460-
static void intel_clear_lmce(void)
460+
void intel_clear_lmce(void)
461461
{
462462
u64 val;
463463

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,16 @@ bool mce_intel_cmci_poll(void);
4646
void mce_intel_hcpu_update(unsigned long cpu);
4747
void cmci_disable_bank(int bank);
4848
void intel_init_cmci(void);
49+
void intel_init_lmce(void);
50+
void intel_clear_lmce(void);
4951
#else
5052
# define cmci_intel_adjust_timer mce_adjust_timer_default
5153
static inline bool mce_intel_cmci_poll(void) { return false; }
5254
static inline void mce_intel_hcpu_update(unsigned long cpu) { }
5355
static inline void cmci_disable_bank(int bank) { }
5456
static inline void intel_init_cmci(void) { }
57+
static inline void intel_init_lmce(void) { }
58+
static inline void intel_clear_lmce(void) { }
5559
#endif
5660

5761
void mce_timer_kick(unsigned long interval);

0 commit comments

Comments
 (0)