Skip to contentSkip to conversation

RAS: 4.13 pile, part 2

PATCH New Borislav Petkov 2 participants 17 messages Jun 13, 2017 – Jun 14, 2017

Subsystems (3)
lore
Share & tools
lore

Borislav Petkov

author maintainer
#0 lore raw

cover RAS: 4.13 pile, part 2

From: Borislav Petkov <[email protected]>

Hi guys,

here's the second pile of RAS updates which merges the mce_amd_inj functionality into mce-inject. Now we have a single error injector module which we can use on anything.

Also, it is a true module now as we're getting rid of register_mce_write_callback() and replacing it with a normal notifier which /dev/mcelog invokes.

Also, a couple more fixes/cleanups from Yazen.

Please queue,
thanks.

Borislav Petkov (4):
x86/mce: Merge mce_amd_inj into mce-inject x86/mce: Get rid of register_mce_write_callback() x86/mce: Cleanup include files x86/mce/mce-inject: Preset the MCE injection struct

Yazen Ghannam (4):
x86/mce/AMD: Use msr_stat when clearing MCA_STATUS x86/mce/AMD: Use saved threshold block info in interrupt handler x86/mce: Don't disable MCA banks when offlining a CPU on AMD x86/mce: Update bootlog description to reflect behavior on AMD

 Documentation/x86/x86_64/boot-options.txt |   3 +-
 arch/x86/Kconfig                          |   2 +-
 arch/x86/Makefile                         |   2 -
 arch/x86/include/asm/mce.h                |   4 -
 arch/x86/include/asm/processor.h          |   5 +
 arch/x86/kernel/cpu/mcheck/dev-mcelog.c   |  47 ++-
 arch/x86/kernel/cpu/mcheck/mce-inject.c   | 569 +++++++++++++++++++++++++++---
 arch/x86/kernel/cpu/mcheck/mce-internal.h |   6 +-
 arch/x86/kernel/cpu/mcheck/mce.c          |  10 +-
 arch/x86/kernel/cpu/mcheck/mce_amd.c      |  68 ++--
 arch/x86/ras/Kconfig                      |  11 -
 arch/x86/ras/Makefile                     |   2 -
 arch/x86/ras/mce_amd_inj.c                | 492 --------------------------
 13 files changed, 617 insertions(+), 604 deletions(-)
 delete mode 100644 arch/x86/ras/Makefile
 delete mode 100644 arch/x86/ras/mce_amd_inj.c
Signature · 1 line
2.13.0
author maintainer
#1 lore raw

PATCH 1/8 x86/mce/AMD: Use msr_stat when clearing MCA_STATUS

From: Yazen Ghannam <[email protected]>

The value of MCA_STATUS is used as the MSR when clearing MCA_STATUS.

This may cause the following warning:
unchecked MSR access error: WRMSR to 0x11b (tried to write 0x0000000000000000)

 Call Trace:
  <IRQ>
  ? amd_threshold_interrupt+0x209/0x220
  smp_threshold_interrupt+0x1b/0x40
  threshold_interrupt+0x89/0x90

Use msr_stat instead which has the MSR address.

Fixes 37d43acfd79f ("x86/mce/AMD: Redo error logging from APIC LVT interrupt handlers")
Cc Tony Luck <[email protected]>
Cc linux-edac <[email protected]>
Cc x86-ml <[email protected]>
---
 arch/x86/kernel/cpu/mcheck/mce_amd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/mcheck/mce_amd.c +1 -1
index d00f299f2ada..d11f94e8e68a 100644
@@ -815,7 +815,7 @@ _log_error_bank(unsigned int bank, u32 msr_stat, u32 msr_addr, u64 misc)
 
 	__log_error(bank, status, addr, misc);
 
-	wrmsrl(status, 0);
+	wrmsrl(msr_stat, 0);
 
 	return status & MCI_STATUS_DEFERRED;
 }
Signature · 1 line
2.13.0
#2 lore raw

[tip:ras/core] x86/mce/AMD: Use msr_stat when clearing MCA_STATUS

x86/mce/AMD: Use msr_stat when clearing MCA_STATUS
Commit-ID:  a24b8c3409935bbc8e3c12131c473c92692403cd
Gitweb:     http://git.kernel.org/tip/a24b8c3409935bbc8e3c12131c473c92692403cd
Author:     Yazen Ghannam <[email protected]>
AuthorDate: Tue, 13 Jun 2017 18:28:28 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 14 Jun 2017 07:32:06 +0200

x86/mce/AMD: Use msr_stat when clearing MCA_STATUS

The value of MCA_STATUS is used as the MSR when clearing MCA_STATUS.

This may cause the following warning:

unchecked MSR access error: WRMSR to 0x11b (tried to write 0x0000000000000000)

 Call Trace:
  <IRQ>
  smp_threshold_interrupt()
  threshold_interrupt()

Use msr_stat instead which has the MSR address.

Cc Borislav Petkov <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Tony Luck <[email protected]>
Cc linux-edac <[email protected]>
Fixes 37d43acfd79f ("x86/mce/AMD: Redo error logging from APIC LVT interrupt handlers")
---
 arch/x86/kernel/cpu/mcheck/mce_amd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-edac" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

arch/x86/kernel/cpu/mcheck/mce_amd.c +1 -1
index d00f299..d11f94e 100644
@@ -815,7 +815,7 @@ _log_error_bank(unsigned int bank, u32 msr_stat, u32 msr_addr, u64 misc)
 
 	__log_error(bank, status, addr, misc);
 
-	wrmsrl(status, 0);
+	wrmsrl(msr_stat, 0);
 
 	return status & MCI_STATUS_DEFERRED;
 }
author maintainer
#3 lore raw

PATCH 2/8 x86/mce/AMD: Use saved threshold block info in interrupt handler

In reply to Borislav Petkov

From: Yazen Ghannam <[email protected]>

In the amd_threshold_interrupt() handler, we loop through every possible block in each bank and rediscover the block's address and if it's valid, e.g. valid, counter present and not locked.

However, we already have the address saved in the threshold blocks list for each CPU and bank. The list only contains blocks that have passed all the valid checks.

Besides the redundancy, there's also a smp_call_function* in get_block_address() which causes a warning when servicing the interrupt:

 WARNING: CPU: 0 PID: 0 at kernel/smp.c:281 smp_call_function_single+0xdd/0xf0
 ...
 Call Trace:
  <IRQ>
  rdmsr_safe_on_cpu+0x5d/0x90
  get_block_address.isra.2+0x97/0x100
  amd_threshold_interrupt+0xae/0x220
  smp_threshold_interrupt+0x1b/0x40
  threshold_interrupt+0x89/0x90

because we do get called in an interrupt handler *with* interrupts disabled, which can result in a deadlock.

Drop the redundant valid checks and move the overflow check, logging and block reset into a separate function.

Check the first block then iterate over the rest. This procedure is needed since the first block is used as the head of the list.

---
 arch/x86/kernel/cpu/mcheck/mce_amd.c | 66 +++++++++++++++++++-----------------
 1 file changed, 35 insertions(+), 31 deletions(-)
arch/x86/kernel/cpu/mcheck/mce_amd.c +35 -31
index d11f94e8e68a..9e314bcf67cc 100644
@@ -867,49 +867,53 @@ static void log_error_thresholding(unsigned int bank, u64 misc)
 	_log_error_bank(bank, msr_ops.status(bank), msr_ops.addr(bank), misc);
 }
 
+static void log_and_reset_block(struct threshold_block *block)
+{
+	struct thresh_restart tr;
+	u32 low = 0, high = 0;
+
+	if (!block)
+		return;
+
+	if (rdmsr_safe(block->address, &low, &high))
+		return;
+
+	if (!(high & MASK_OVERFLOW_HI))
+		return;
+
+	/* Log the MCE which caused the threshold event. */
+	log_error_thresholding(block->bank, ((u64)high << 32) | low);
+
+	/* Reset threshold block after logging error. */
+	memset(&tr, 0, sizeof(tr));
+	tr.b = block;
+	threshold_restart_bank(&tr);
+}
+
 /*
  * Threshold interrupt handler will service THRESHOLD_APIC_VECTOR. The interrupt
  * goes off when error_count reaches threshold_limit.
  */
 static void amd_threshold_interrupt(void)
 {
-	u32 low = 0, high = 0, address = 0;
-	unsigned int bank, block, cpu = smp_processor_id();
-	struct thresh_restart tr;
+	struct threshold_block *first_block = NULL, *block = NULL, *tmp = NULL;
+	unsigned int bank, cpu = smp_processor_id();
 
 	for (bank = 0; bank < mca_cfg.banks; ++bank) {
 		if (!(per_cpu(bank_map, cpu) & (1 << bank)))
 			continue;
-		for (block = 0; block < NR_BLOCKS; ++block) {
-			address = get_block_address(cpu, address, low, high, bank, block);
-			if (!address)
-				break;
-
-			if (rdmsr_safe(address, &low, &high))
-				break;
-
-			if (!(high & MASK_VALID_HI)) {
-				if (block)
-					continue;
-				else
-					break;
-			}
-
-			if (!(high & MASK_CNTP_HI)  ||
-			     (high & MASK_LOCKED_HI))
-				continue;
-
-			if (!(high & MASK_OVERFLOW_HI))
-				continue;
 
-			/* Log the MCE which caused the threshold event. */
-			log_error_thresholding(bank, ((u64)high << 32) | low);
+		first_block = per_cpu(threshold_banks, cpu)[bank]->blocks;
+		if (!first_block)
+			continue;
 
-			/* Reset threshold block after logging error. */
-			memset(&tr, 0, sizeof(tr));
-			tr.b = &per_cpu(threshold_banks, cpu)[bank]->blocks[block];
-			threshold_restart_bank(&tr);
-		}
+		/*
+		 * The first block is also the head of the list. Check it first
+		 * before iterating over the rest.
+		 */
+		log_and_reset_block(first_block);
+		list_for_each_entry_safe(block, tmp, &first_block->miscj, miscj)
+			log_and_reset_block(block);
 	}
 }
 
Signature · 1 line
2.13.0
#4 lore raw

[tip:ras/core] x86/mce/AMD: Use saved threshold block info in interrupt handler

x86/mce/AMD: Use saved threshold block info in interrupt handler
Commit-ID:  17ef4af0ec0f97b369f304dc04d61722f3591c4b
Gitweb:     http://git.kernel.org/tip/17ef4af0ec0f97b369f304dc04d61722f3591c4b
Author:     Yazen Ghannam <[email protected]>
AuthorDate: Tue, 13 Jun 2017 18:28:29 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 14 Jun 2017 07:32:06 +0200

x86/mce/AMD: Use saved threshold block info in interrupt handler

In the amd_threshold_interrupt() handler, we loop through every possible block in each bank and rediscover the block's address and if it's valid, e.g. valid, counter present and not locked.

However, we already have the address saved in the threshold blocks list for each CPU and bank. The list only contains blocks that have passed all the valid checks.

Besides the redundancy, there's also a smp_call_function* in get_block_address() which causes a warning when servicing the interrupt:

 WARNING: CPU: 0 PID: 0 at kernel/smp.c:281 smp_call_function_single+0xdd/0xf0
 ...
 Call Trace:
  <IRQ>
  rdmsr_safe_on_cpu()
  get_block_address.isra.2()
  amd_threshold_interrupt()
  smp_threshold_interrupt()
  threshold_interrupt()

because we do get called in an interrupt handler *with* interrupts disabled, which can result in a deadlock.

Drop the redundant valid checks and move the overflow check, logging and block reset into a separate function.

Check the first block then iterate over the rest. This procedure is needed since the first block is used as the head of the list.

---
 arch/x86/kernel/cpu/mcheck/mce_amd.c | 66 +++++++++++++++++++-----------------
 1 file changed, 35 insertions(+), 31 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-edac" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

arch/x86/kernel/cpu/mcheck/mce_amd.c +35 -31
index d11f94e..9e314bc 100644
@@ -867,49 +867,53 @@ static void log_error_thresholding(unsigned int bank, u64 misc)
 	_log_error_bank(bank, msr_ops.status(bank), msr_ops.addr(bank), misc);
 }
 
+static void log_and_reset_block(struct threshold_block *block)
+{
+	struct thresh_restart tr;
+	u32 low = 0, high = 0;
+
+	if (!block)
+		return;
+
+	if (rdmsr_safe(block->address, &low, &high))
+		return;
+
+	if (!(high & MASK_OVERFLOW_HI))
+		return;
+
+	/* Log the MCE which caused the threshold event. */
+	log_error_thresholding(block->bank, ((u64)high << 32) | low);
+
+	/* Reset threshold block after logging error. */
+	memset(&tr, 0, sizeof(tr));
+	tr.b = block;
+	threshold_restart_bank(&tr);
+}
+
 /*
  * Threshold interrupt handler will service THRESHOLD_APIC_VECTOR. The interrupt
  * goes off when error_count reaches threshold_limit.
  */
 static void amd_threshold_interrupt(void)
 {
-	u32 low = 0, high = 0, address = 0;
-	unsigned int bank, block, cpu = smp_processor_id();
-	struct thresh_restart tr;
+	struct threshold_block *first_block = NULL, *block = NULL, *tmp = NULL;
+	unsigned int bank, cpu = smp_processor_id();
 
 	for (bank = 0; bank < mca_cfg.banks; ++bank) {
 		if (!(per_cpu(bank_map, cpu) & (1 << bank)))
 			continue;
-		for (block = 0; block < NR_BLOCKS; ++block) {
-			address = get_block_address(cpu, address, low, high, bank, block);
-			if (!address)
-				break;
-
-			if (rdmsr_safe(address, &low, &high))
-				break;
-
-			if (!(high & MASK_VALID_HI)) {
-				if (block)
-					continue;
-				else
-					break;
-			}
-
-			if (!(high & MASK_CNTP_HI)  ||
-			     (high & MASK_LOCKED_HI))
-				continue;
-
-			if (!(high & MASK_OVERFLOW_HI))
-				continue;
 
-			/* Log the MCE which caused the threshold event. */
-			log_error_thresholding(bank, ((u64)high << 32) | low);
+		first_block = per_cpu(threshold_banks, cpu)[bank]->blocks;
+		if (!first_block)
+			continue;
 
-			/* Reset threshold block after logging error. */
-			memset(&tr, 0, sizeof(tr));
-			tr.b = &per_cpu(threshold_banks, cpu)[bank]->blocks[block];
-			threshold_restart_bank(&tr);
-		}
+		/*
+		 * The first block is also the head of the list. Check it first
+		 * before iterating over the rest.
+		 */
+		log_and_reset_block(first_block);
+		list_for_each_entry_safe(block, tmp, &first_block->miscj, miscj)
+			log_and_reset_block(block);
 	}
 }
 
author maintainer
#5 lore raw

PATCH 3/8 x86/mce: Merge mce_amd_inj into mce-inject

In reply to Borislav Petkov

From: Borislav Petkov <[email protected]>

Reuse mce_amd_inj's debugfs interface so that mce-inject can benefit from it too. The old functionality is still preserved under CONFIG_X86_MCELOG_LEGACY.

---
 arch/x86/Kconfig                        |   2 +-
 arch/x86/Makefile                       |   2 -
 arch/x86/include/asm/processor.h        |   5 +
 arch/x86/kernel/cpu/mcheck/mce-inject.c | 542 +++++++++++++++++++++++++++++++-
 arch/x86/ras/Kconfig                    |  11 -
 arch/x86/ras/Makefile                   |   2 -
 arch/x86/ras/mce_amd_inj.c              | 492 -----------------------------
 7 files changed, 532 insertions(+), 524 deletions(-)
 delete mode 100644 arch/x86/ras/Makefile
 delete mode 100644 arch/x86/ras/mce_amd_inj.c
arch/x86/Kconfig +1 -1
index cd18994a9555..e42875b2d905 100644
@@ -1082,7 +1082,7 @@ config X86_MCE_THRESHOLD
 	def_bool y
 
 config X86_MCE_INJECT
-	depends on X86_MCE && X86_LOCAL_APIC && X86_MCELOG_LEGACY
+	depends on X86_MCE && X86_LOCAL_APIC && DEBUG_FS
 	tristate "Machine check injector support"
 	---help---
 	  Provide support for injecting machine checks for testing purposes.
arch/x86/Makefile +0 -2
index 5851411e60fb..c80c0192789c 100644
@@ -257,8 +257,6 @@ drivers-$(CONFIG_PM) += arch/x86/power/
 
 drivers-$(CONFIG_FB) += arch/x86/video/
 
-drivers-$(CONFIG_RAS) += arch/x86/ras/
-
 ####
 # boot loader support. Several targets are kept for legacy purposes
 
arch/x86/include/asm/processor.h +5 -0
index 3cada998a402..71f6fba95aa6 100644
@@ -901,8 +901,13 @@ static inline int mpx_disable_management(void)
 }
 #endif /* CONFIG_X86_INTEL_MPX */
 
+#ifdef CONFIG_CPU_SUP_AMD
 extern u16 amd_get_nb_id(int cpu);
 extern u32 amd_get_nodes_per_socket(void);
+#else
+static inline u16 amd_get_nb_id(int cpu)		{ return 0; }
+static inline u32 amd_get_nodes_per_socket(void)	{ return 0; }
+#endif
 
 static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)
 {
arch/x86/kernel/cpu/mcheck/mce-inject.c +526 -16

583 lines not on this page · raw message

arch/x86/ras/Kconfig +0 -11
index 2a2d89d39af6..bb026699ad19 100644
@@ -1,13 +1,3 @@
-config MCE_AMD_INJ
-	tristate "Simple MCE injection interface for AMD processors"
-	depends on RAS && X86_MCE && DEBUG_FS && AMD_NB
-	default n
-	help
-	  This is a simple debugfs interface to inject MCEs and test different
-	  aspects of the MCE handling code.
-
-	  WARNING: Do not even assume this interface is staying stable!
-
 config RAS_CEC
 	bool "Correctable Errors Collector"
 	depends on X86_MCE && MEMORY_FAILURE && DEBUG_FS
@@ -20,4 +10,3 @@ config RAS_CEC
 
 	  Bear in mind that this is absolutely useless if your platform doesn't
 	  have ECC DIMMs and doesn't have DRAM ECC checking enabled in the BIOS.
-
arch/x86/ras/Makefile deleted +0 -2
deleted file mode 100644
index 5f94546db280..000000000000
@@ -1,2 +0,0 @@
-obj-$(CONFIG_MCE_AMD_INJ)		+= mce_amd_inj.o
-
arch/x86/ras/mce_amd_inj.c deleted +0 -492

492 lines not on this page · raw message

Signature · 1 line
2.13.0
#6 lore raw

[tip:ras/core] x86/mce: Merge mce_amd_inj into mce-inject

x86/mce: Merge mce_amd_inj into mce-inject
Commit-ID:  bc8e80d56c1ecb35e65df392d7601d1427d14efe
Gitweb:     http://git.kernel.org/tip/bc8e80d56c1ecb35e65df392d7601d1427d14efe
Author:     Borislav Petkov <[email protected]>
AuthorDate: Tue, 13 Jun 2017 18:28:30 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 14 Jun 2017 07:32:07 +0200

x86/mce: Merge mce_amd_inj into mce-inject

Reuse mce_amd_inj's debugfs interface so that mce-inject can benefit from it too. The old functionality is still preserved under CONFIG_X86_MCELOG_LEGACY.

---
 arch/x86/Kconfig                        |   2 +-
 arch/x86/Makefile                       |   2 -
 arch/x86/include/asm/processor.h        |   5 +
 arch/x86/kernel/cpu/mcheck/mce-inject.c | 542 +++++++++++++++++++++++++++++++-
 arch/x86/ras/Kconfig                    |  11 -
 arch/x86/ras/Makefile                   |   2 -
 arch/x86/ras/mce_amd_inj.c              | 492 -----------------------------
 7 files changed, 532 insertions(+), 524 deletions(-)
arch/x86/Kconfig +1 -1
index 0efb4c9..4371b6b 100644
@@ -1082,7 +1082,7 @@ config X86_MCE_THRESHOLD
 	def_bool y
 
 config X86_MCE_INJECT
-	depends on X86_MCE && X86_LOCAL_APIC && X86_MCELOG_LEGACY
+	depends on X86_MCE && X86_LOCAL_APIC && DEBUG_FS
 	tristate "Machine check injector support"
 	---help---
 	  Provide support for injecting machine checks for testing purposes.
arch/x86/Makefile +0 -2
index bf240b9..ad2db82 100644
@@ -257,8 +257,6 @@ drivers-$(CONFIG_PM) += arch/x86/power/
 
 drivers-$(CONFIG_FB) += arch/x86/video/
 
-drivers-$(CONFIG_RAS) += arch/x86/ras/
-
 ####
 # boot loader support. Several targets are kept for legacy purposes
 
arch/x86/include/asm/processor.h +5 -0
index 3cada99..71f6fba 100644
@@ -901,8 +901,13 @@ static inline int mpx_disable_management(void)
 }
 #endif /* CONFIG_X86_INTEL_MPX */
 
+#ifdef CONFIG_CPU_SUP_AMD
 extern u16 amd_get_nb_id(int cpu);
 extern u32 amd_get_nodes_per_socket(void);
+#else
+static inline u16 amd_get_nb_id(int cpu)		{ return 0; }
+static inline u32 amd_get_nodes_per_socket(void)	{ return 0; }
+#endif
 
 static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)
 {
arch/x86/kernel/cpu/mcheck/mce-inject.c +526 -16

583 lines not on this page · raw message

arch/x86/ras/Kconfig +0 -11
index 2a2d89d..bb02669 100644
@@ -1,13 +1,3 @@
-config MCE_AMD_INJ
-	tristate "Simple MCE injection interface for AMD processors"
-	depends on RAS && X86_MCE && DEBUG_FS && AMD_NB
-	default n
-	help
-	  This is a simple debugfs interface to inject MCEs and test different
-	  aspects of the MCE handling code.
-
-	  WARNING: Do not even assume this interface is staying stable!
-
 config RAS_CEC
 	bool "Correctable Errors Collector"
 	depends on X86_MCE && MEMORY_FAILURE && DEBUG_FS
@@ -20,4 +10,3 @@ config RAS_CEC
 
 	  Bear in mind that this is absolutely useless if your platform doesn't
 	  have ECC DIMMs and doesn't have DRAM ECC checking enabled in the BIOS.
-
arch/x86/ras/Makefile deleted +0 -2
deleted file mode 100644
index 5f94546..0000000
@@ -1,2 +0,0 @@
-obj-$(CONFIG_MCE_AMD_INJ)		+= mce_amd_inj.o
-
arch/x86/ras/mce_amd_inj.c deleted +0 -492

492 lines not on this page · raw message

author maintainer
#7 lore raw

PATCH 4/8 x86/mce: Get rid of register_mce_write_callback()

In reply to Borislav Petkov

From: Borislav Petkov <[email protected]>

Make the mcelog call a notifier which lands in the injector module and does the injection. This allows for mce-inject to be a normal kernel module now.

---
 arch/x86/include/asm/mce.h                |  4 --
 arch/x86/kernel/cpu/mcheck/dev-mcelog.c   | 47 +++++++++++++++++-----
 arch/x86/kernel/cpu/mcheck/mce-inject.c   | 66 +++++++++----------------------
 arch/x86/kernel/cpu/mcheck/mce-internal.h |  6 ++-
 4 files changed, 61 insertions(+), 62 deletions(-)
arch/x86/include/asm/mce.h +0 -4
index 3f9a3d2a5209..181264989db5 100644
@@ -285,10 +285,6 @@ int mce_notify_irq(void);
 
 DECLARE_PER_CPU(struct mce, injectm);
 
-extern void register_mce_write_callback(ssize_t (*)(struct file *filp,
-				    const char __user *ubuf,
-				    size_t usize, loff_t *off));
-
 /* Disable CMCI/polling for MCA bank claimed by firmware */
 extern void mce_disable_bank(int bank);
 
arch/x86/kernel/cpu/mcheck/dev-mcelog.c +37 -10

67 lines not on this page · raw message

arch/x86/kernel/cpu/mcheck/mce-inject.c +19 -47

105 lines not on this page · raw message

arch/x86/kernel/cpu/mcheck/mce-internal.h +5 -1
index 654ad0668d72..098530a93bb7 100644
@@ -100,7 +100,11 @@ static inline bool mce_cmp(struct mce *m1, struct mce *m2)
 extern struct device_attribute dev_attr_trigger;
 
 #ifdef CONFIG_X86_MCELOG_LEGACY
-extern void mce_work_trigger(void);
+void mce_work_trigger(void);
+void mce_register_injector_chain(struct notifier_block *nb);
+void mce_unregister_injector_chain(struct notifier_block *nb);
 #else
 static inline void mce_work_trigger(void)	{ }
+static inline void mce_register_injector_chain(struct notifier_block *nb)	{ }
+static inline void mce_unregister_injector_chain(struct notifier_block *nb)	{ }
 #endif
Signature · 1 line
2.13.0
#8 lore raw

[tip:ras/core] x86/mce: Get rid of register_mce_write_callback()

x86/mce: Get rid of register_mce_write_callback()
Commit-ID:  fbe9ff9eafb66b78b79c135ebc24fd2ca5498217
Gitweb:     http://git.kernel.org/tip/fbe9ff9eafb66b78b79c135ebc24fd2ca5498217
Author:     Borislav Petkov <[email protected]>
AuthorDate: Tue, 13 Jun 2017 18:28:31 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 14 Jun 2017 07:32:07 +0200

x86/mce: Get rid of register_mce_write_callback()

Make the mcelog call a notifier which lands in the injector module and does the injection. This allows for mce-inject to be a normal kernel module now.

---
 arch/x86/include/asm/mce.h                |  4 --
 arch/x86/kernel/cpu/mcheck/dev-mcelog.c   | 47 +++++++++++++++++-----
 arch/x86/kernel/cpu/mcheck/mce-inject.c   | 66 +++++++++----------------------
 arch/x86/kernel/cpu/mcheck/mce-internal.h |  6 ++-
 4 files changed, 61 insertions(+), 62 deletions(-)
arch/x86/include/asm/mce.h +0 -4
index 3f9a3d2..1812649 100644
@@ -285,10 +285,6 @@ int mce_notify_irq(void);
 
 DECLARE_PER_CPU(struct mce, injectm);
 
-extern void register_mce_write_callback(ssize_t (*)(struct file *filp,
-				    const char __user *ubuf,
-				    size_t usize, loff_t *off));
-
 /* Disable CMCI/polling for MCA bank claimed by firmware */
 extern void mce_disable_bank(int bank);
 
arch/x86/kernel/cpu/mcheck/dev-mcelog.c +37 -10

67 lines not on this page · raw message

arch/x86/kernel/cpu/mcheck/mce-inject.c +19 -47

105 lines not on this page · raw message

arch/x86/kernel/cpu/mcheck/mce-internal.h +5 -1
index 654ad06..098530a 100644
@@ -100,7 +100,11 @@ static inline bool mce_cmp(struct mce *m1, struct mce *m2)
 extern struct device_attribute dev_attr_trigger;
 
 #ifdef CONFIG_X86_MCELOG_LEGACY
-extern void mce_work_trigger(void);
+void mce_work_trigger(void);
+void mce_register_injector_chain(struct notifier_block *nb);
+void mce_unregister_injector_chain(struct notifier_block *nb);
 #else
 static inline void mce_work_trigger(void)	{ }
+static inline void mce_register_injector_chain(struct notifier_block *nb)	{ }
+static inline void mce_unregister_injector_chain(struct notifier_block *nb)	{ }
 #endif
author maintainer
#9 lore raw

PATCH 5/8 x86/mce: Cleanup include files

In reply to Borislav Petkov

From: Borislav Petkov <[email protected]>

Not really needed.

---
 arch/x86/kernel/cpu/mcheck/mce-inject.c | 10 ----------
 1 file changed, 10 deletions(-)
arch/x86/kernel/cpu/mcheck/mce-inject.c +0 -10
index c21c1a73712a..00af8dd8fc59 100644
@@ -25,20 +25,10 @@
 
 #include <linux/cpu.h>
 #include <linux/debugfs.h>
-#include <linux/device.h>
-#include <linux/fs.h>
-#include <linux/gfp.h>
-#include <linux/kdebug.h>
 #include <linux/kernel.h>
-#include <linux/kobject.h>
 #include <linux/module.h>
 #include <linux/notifier.h>
 #include <linux/pci.h>
-#include <linux/preempt.h>
-#include <linux/sched.h>
-#include <linux/smp.h>
-#include <linux/string.h>
-#include <linux/timer.h>
 #include <linux/uaccess.h>
 
 #include <asm/amd_nb.h>
Signature · 1 line
2.13.0
#10 lore raw

[tip:ras/core] x86/mce: Clean up include files

x86/mce: Clean up include files
Commit-ID:  5c99881b33b460c40ff3fbe0d6d1242f54b4f2ed
Gitweb:     http://git.kernel.org/tip/5c99881b33b460c40ff3fbe0d6d1242f54b4f2ed
Author:     Borislav Petkov <[email protected]>
AuthorDate: Tue, 13 Jun 2017 18:28:32 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 14 Jun 2017 07:32:08 +0200

x86/mce: Clean up include files

Not really needed.

---
 arch/x86/kernel/cpu/mcheck/mce-inject.c | 10 ----------
 1 file changed, 10 deletions(-)
arch/x86/kernel/cpu/mcheck/mce-inject.c +0 -10
index c21c1a7..00af8dd 100644
@@ -25,20 +25,10 @@
 
 #include <linux/cpu.h>
 #include <linux/debugfs.h>
-#include <linux/device.h>
-#include <linux/fs.h>
-#include <linux/gfp.h>
-#include <linux/kdebug.h>
 #include <linux/kernel.h>
-#include <linux/kobject.h>
 #include <linux/module.h>
 #include <linux/notifier.h>
 #include <linux/pci.h>
-#include <linux/preempt.h>
-#include <linux/sched.h>
-#include <linux/smp.h>
-#include <linux/string.h>
-#include <linux/timer.h>
 #include <linux/uaccess.h>
 
 #include <asm/amd_nb.h>
author maintainer
#11 lore raw

PATCH 6/8 x86/mce/mce-inject: Preset the MCE injection struct

In reply to Borislav Petkov

From: Borislav Petkov <[email protected]>

Populate the MCE injection struct before doing initial injection so that values which don't change have sane defaults.

---
 arch/x86/kernel/cpu/mcheck/mce-inject.c | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/x86/kernel/cpu/mcheck/mce-inject.c +9 -0
index 00af8dd8fc59..231ad23b24a9 100644
@@ -103,6 +103,13 @@ DEFINE_SIMPLE_ATTRIBUTE(misc_fops, inj_misc_get, inj_misc_set, "%llx\n");
 DEFINE_SIMPLE_ATTRIBUTE(addr_fops, inj_addr_get, inj_addr_set, "%llx\n");
 DEFINE_SIMPLE_ATTRIBUTE(synd_fops, inj_synd_get, inj_synd_set, "%llx\n");
 
+static void setup_inj_struct(struct mce *m)
+{
+	memset(m, 0, sizeof(struct mce));
+
+	m->cpuvendor = boot_cpu_data.x86_vendor;
+}
+
 /* Update fake mce registers on current CPU. */
 static void inject_mce(struct mce *m)
 {
@@ -700,6 +707,8 @@ static int __init inject_init(void)
 	register_nmi_handler(NMI_LOCAL, mce_raise_notify, 0, "mce_notify");
 	mce_register_injector_chain(&inject_nb);
 
+	setup_inj_struct(&i_mce);
+
 	pr_info("Machine check injector initialized\n");
 
 	return 0;
Signature · 1 line
2.13.0
#12 lore raw

[tip:ras/core] x86/mce/mce-inject: Preset the MCE injection struct

x86/mce/mce-inject: Preset the MCE injection struct
Commit-ID:  86d2eac5a7045933a88c97f0453f22106bb90b54
Gitweb:     http://git.kernel.org/tip/86d2eac5a7045933a88c97f0453f22106bb90b54
Author:     Borislav Petkov <[email protected]>
AuthorDate: Tue, 13 Jun 2017 18:28:33 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 14 Jun 2017 07:32:09 +0200

x86/mce/mce-inject: Preset the MCE injection struct

Populate the MCE injection struct before doing initial injection so that values which don't change have sane defaults.

---
 arch/x86/kernel/cpu/mcheck/mce-inject.c | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/x86/kernel/cpu/mcheck/mce-inject.c +9 -0
index 00af8dd..231ad23 100644
@@ -103,6 +103,13 @@ DEFINE_SIMPLE_ATTRIBUTE(misc_fops, inj_misc_get, inj_misc_set, "%llx\n");
 DEFINE_SIMPLE_ATTRIBUTE(addr_fops, inj_addr_get, inj_addr_set, "%llx\n");
 DEFINE_SIMPLE_ATTRIBUTE(synd_fops, inj_synd_get, inj_synd_set, "%llx\n");
 
+static void setup_inj_struct(struct mce *m)
+{
+	memset(m, 0, sizeof(struct mce));
+
+	m->cpuvendor = boot_cpu_data.x86_vendor;
+}
+
 /* Update fake mce registers on current CPU. */
 static void inject_mce(struct mce *m)
 {
@@ -700,6 +707,8 @@ static int __init inject_init(void)
 	register_nmi_handler(NMI_LOCAL, mce_raise_notify, 0, "mce_notify");
 	mce_register_injector_chain(&inject_nb);
 
+	setup_inj_struct(&i_mce);
+
 	pr_info("Machine check injector initialized\n");
 
 	return 0;
author maintainer
#13 lore raw

PATCH 7/8 x86/mce: Don't disable MCA banks when offlining a CPU on AMD

In reply to Borislav Petkov

From: Yazen Ghannam <[email protected]>

AMD systems have non-core, shared MCA banks within a die. These banks are controlled by a master CPU per die. If this CPU is offlined then all the shared banks are disabled in addition to the CPU's core banks.

Also, Fam17h systems may have SMT enabled. The MCA_CTL register is shared between SMT thread siblings. If a CPU is offlined then all its sibling's MCA banks are also disabled.

Extend the existing vendor check to AMD too.

---
 arch/x86/kernel/cpu/mcheck/mce.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/mcheck/mce.c +3 -2
index 5cfbaeb6529a..3c54c2b9efc2 100644
@@ -1912,12 +1912,13 @@ static void mce_disable_error_reporting(void)
 static void vendor_disable_error_reporting(void)
 {
 	/*
-	 * Don't clear on Intel CPUs. Some of these MSRs are socket-wide.
+	 * Don't clear on Intel or AMD CPUs. Some of these MSRs are socket-wide.
 	 * Disabling them for just a single offlined CPU is bad, since it will
 	 * inhibit reporting for all shared resources on the socket like the
 	 * last level cache (LLC), the integrated memory controller (iMC), etc.
 	 */
-	if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
+	if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL ||
+	    boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
 		return;
 
 	mce_disable_error_reporting();
Signature · 1 line
2.13.0
#14 lore raw

[tip:ras/core] x86/mce: Don't disable MCA banks when offlining a CPU on AMD

x86/mce: Don't disable MCA banks when offlining a CPU on AMD
Commit-ID:  ec33838244c8535b23b8d24b167996fd1318bb68
Gitweb:     http://git.kernel.org/tip/ec33838244c8535b23b8d24b167996fd1318bb68
Author:     Yazen Ghannam <[email protected]>
AuthorDate: Tue, 13 Jun 2017 18:28:34 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 14 Jun 2017 07:32:09 +0200

x86/mce: Don't disable MCA banks when offlining a CPU on AMD

AMD systems have non-core, shared MCA banks within a die. These banks are controlled by a master CPU per die. If this CPU is offlined then all the shared banks are disabled in addition to the CPU's core banks.

Also, Fam17h systems may have SMT enabled. The MCA_CTL register is shared between SMT thread siblings. If a CPU is offlined then all its sibling's MCA banks are also disabled.

Extend the existing vendor check to AMD too.

[ Fix up comment. ]
Cc Borislav Petkov <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Tony Luck <[email protected]>
Cc linux-edac <[email protected]>
---
 arch/x86/kernel/cpu/mcheck/mce.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-edac" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

arch/x86/kernel/cpu/mcheck/mce.c +3 -2
index 5cfbaeb..3c54c2b 100644
@@ -1912,12 +1912,13 @@ static void mce_disable_error_reporting(void)
 static void vendor_disable_error_reporting(void)
 {
 	/*
-	 * Don't clear on Intel CPUs. Some of these MSRs are socket-wide.
+	 * Don't clear on Intel or AMD CPUs. Some of these MSRs are socket-wide.
 	 * Disabling them for just a single offlined CPU is bad, since it will
 	 * inhibit reporting for all shared resources on the socket like the
 	 * last level cache (LLC), the integrated memory controller (iMC), etc.
 	 */
-	if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
+	if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL ||
+	    boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
 		return;
 
 	mce_disable_error_reporting();
author maintainer
#15 lore raw

PATCH 8/8 x86/mce: Update bootlog description to reflect behavior on AMD

In reply to Borislav Petkov

From: Yazen Ghannam <[email protected]>

The bootlog option is only disabled by default on AMD Fam10h and older systems.

Update bootlog description to say this. Change the family value to hex to avoid confusion.

---
 Documentation/x86/x86_64/boot-options.txt | 3 ++-
 arch/x86/kernel/cpu/mcheck/mce.c          | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)
Documentation/x86/x86_64/boot-options.txt +2 -1
index 61b611e9eeaf..b297c48389b9 100644
@@ -36,7 +36,8 @@ Machine check
 		to broadcast MCEs.
    mce=bootlog
 		Enable logging of machine checks left over from booting.
-		Disabled by default on AMD because some BIOS leave bogus ones.
+		Disabled by default on AMD Fam10h and older because some BIOS
+		leave bogus ones.
 		If your BIOS doesn't do that it's a good idea to enable though
 		to make sure you log even machine check events that result
 		in a reboot. On Intel systems it is enabled by default.
arch/x86/kernel/cpu/mcheck/mce.c +3 -2
index 3c54c2b9efc2..b58b77808ce4 100644
@@ -1550,7 +1550,7 @@ static int __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c)
 			 */
 			clear_bit(10, (unsigned long *)&mce_banks[4].ctl);
 		}
-		if (c->x86 < 17 && cfg->bootlog < 0) {
+		if (c->x86 < 0x11 && cfg->bootlog < 0) {
 			/*
 			 * Lots of broken BIOS around that don't clear them
 			 * by default and leave crap in there. Don't log:
@@ -1832,7 +1832,8 @@ void mce_disable_bank(int bank)
  * mce=TOLERANCELEVEL[,monarchtimeout] (number, see above)
  *	monarchtimeout is how long to wait for other CPUs on machine
  *	check, or 0 to not wait
- * mce=bootlog Log MCEs from before booting. Disabled by default on AMD.
+ * mce=bootlog Log MCEs from before booting. Disabled by default on AMD Fam10h
+	and older.
  * mce=nobootlog Don't log MCEs from before booting.
  * mce=bios_cmci_threshold Don't program the CMCI threshold
  * mce=recovery force enable memcpy_mcsafe()
Signature · 1 line
2.13.0
#16 lore raw

[tip:ras/core] x86/mce: Update bootlog description to reflect behavior on AMD

x86/mce: Update bootlog description to reflect behavior on AMD
Commit-ID:  6057077f6ebc0747c2f5b21dfb1eb782f489d0f6
Gitweb:     http://git.kernel.org/tip/6057077f6ebc0747c2f5b21dfb1eb782f489d0f6
Author:     Yazen Ghannam <[email protected]>
AuthorDate: Tue, 13 Jun 2017 18:28:35 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 14 Jun 2017 07:32:10 +0200

x86/mce: Update bootlog description to reflect behavior on AMD

The bootlog option is only disabled by default on AMD Fam10h and older systems.

Update bootlog description to say this. Change the family value to hex to avoid confusion.

---
 Documentation/x86/x86_64/boot-options.txt | 3 ++-
 arch/x86/kernel/cpu/mcheck/mce.c          | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-edac" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Documentation/x86/x86_64/boot-options.txt +2 -1
index 61b611e..b297c48 100644
@@ -36,7 +36,8 @@ Machine check
 		to broadcast MCEs.
    mce=bootlog
 		Enable logging of machine checks left over from booting.
-		Disabled by default on AMD because some BIOS leave bogus ones.
+		Disabled by default on AMD Fam10h and older because some BIOS
+		leave bogus ones.
 		If your BIOS doesn't do that it's a good idea to enable though
 		to make sure you log even machine check events that result
 		in a reboot. On Intel systems it is enabled by default.
arch/x86/kernel/cpu/mcheck/mce.c +3 -2
index 3c54c2b..b58b778 100644
@@ -1550,7 +1550,7 @@ static int __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c)
 			 */
 			clear_bit(10, (unsigned long *)&mce_banks[4].ctl);
 		}
-		if (c->x86 < 17 && cfg->bootlog < 0) {
+		if (c->x86 < 0x11 && cfg->bootlog < 0) {
 			/*
 			 * Lots of broken BIOS around that don't clear them
 			 * by default and leave crap in there. Don't log:
@@ -1832,7 +1832,8 @@ void mce_disable_bank(int bank)
  * mce=TOLERANCELEVEL[,monarchtimeout] (number, see above)
  *	monarchtimeout is how long to wait for other CPUs on machine
  *	check, or 0 to not wait
- * mce=bootlog Log MCEs from before booting. Disabled by default on AMD.
+ * mce=bootlog Log MCEs from before booting. Disabled by default on AMD Fam10h
+	and older.
  * mce=nobootlog Don't log MCEs from before booting.
  * mce=bios_cmci_threshold Don't program the CMCI threshold
  * mce=recovery force enable memcpy_mcsafe()