Skip to content

Commit 064a59b

Browse files
Jacob PanIngo Molnar
authored andcommitted
x86/mrst: Avoid reporting wrong nmi status
Moorestown/Medfield platform does not have port 0x61 to report NMI status, nor does it have external NMI sources. The only NMI sources are from lapic, as results of perf counter overflow or IPI, e.g. NMI watchdog or spin lock debug. Reading port 0x61 on Moorestown will return 0xff which misled NMI handlers to false critical errors such memory parity error. The subsequent ioport access for NMI handling can also cause undefined behavior on Moorestown. This patch allows kernel process NMI due to watchdog or backrace dump without unnecessary hangs. Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> [hand applied] Signed-off-by: Alan Cox <alan@linux.intel.com>
1 parent 0a91532 commit 064a59b

5 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎arch/x86/include/asm/mach_traps.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#define NMI_REASON_CLEAR_IOCHK 0x08
1818
#define NMI_REASON_CLEAR_MASK 0x0f
1919

20-
static inline unsigned char get_nmi_reason(void)
20+
static inline unsigned char default_get_nmi_reason(void)
2121
{
2222
return inb(NMI_REASON_PORT);
2323
}

‎arch/x86/include/asm/x86_init.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ struct x86_platform_ops {
167167
void (*iommu_shutdown)(void);
168168
bool (*is_untracked_pat_range)(u64 start, u64 end);
169169
void (*nmi_init)(void);
170+
unsigned char (*get_nmi_reason)(void);
170171
int (*i8042_detect)(void);
171172
};
172173

‎arch/x86/kernel/nmi.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static notrace __kprobes void default_do_nmi(struct pt_regs *regs)
348348

349349
/* Non-CPU-specific NMI: NMI sources can be processed on any CPU */
350350
raw_spin_lock(&nmi_reason_lock);
351-
reason = get_nmi_reason();
351+
reason = x86_platform.get_nmi_reason();
352352

353353
if (reason & NMI_REASON_MASK) {
354354
if (reason & NMI_REASON_SERR)

‎arch/x86/kernel/x86_init.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <asm/pat.h>
2222
#include <asm/tsc.h>
2323
#include <asm/iommu.h>
24+
#include <asm/mach_traps.h>
2425

2526
void __cpuinit x86_init_noop(void) { }
2627
void __init x86_init_uint_noop(unsigned int unused) { }
@@ -104,6 +105,7 @@ struct x86_platform_ops x86_platform = {
104105
.iommu_shutdown = iommu_shutdown_noop,
105106
.is_untracked_pat_range = is_ISA_range,
106107
.nmi_init = default_nmi_init,
108+
.get_nmi_reason = default_get_nmi_reason,
107109
.i8042_detect = default_i8042_detect
108110
};
109111

‎arch/x86/platform/mrst/mrst.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,17 @@ static void mrst_reboot(void)
276276
intel_scu_ipc_simple_command(0xf1, 0);
277277
}
278278

279+
/*
280+
* Moorestown does not have external NMI source nor port 0x61 to report
281+
* NMI status. The possible NMI sources are from pmu as a result of NMI
282+
* watchdog or lock debug. Reading io port 0x61 results in 0xff which
283+
* misled NMI handler.
284+
*/
285+
static unsigned char mrst_get_nmi_reason(void)
286+
{
287+
return 0;
288+
}
289+
279290
/*
280291
* Moorestown specific x86_init function overrides and early setup
281292
* calls.
@@ -297,6 +308,8 @@ void __init x86_mrst_early_setup(void)
297308
x86_platform.calibrate_tsc = mrst_calibrate_tsc;
298309
x86_platform.i8042_detect = mrst_i8042_detect;
299310
x86_init.timers.wallclock_init = mrst_rtc_init;
311+
x86_platform.get_nmi_reason = mrst_get_nmi_reason;
312+
300313
x86_init.pci.init = pci_mrst_init;
301314
x86_init.pci.fixup_irqs = x86_init_noop;
302315

0 commit comments

Comments
 (0)