Skip to contentSkip to conversation

arc: Re-enable MMU upon a Machine Check exception

PATCH New Jose Abreu 2 participants 3 messages Sep 1, 2017 Synopsys ARC architecture

lore
Share & tools
lore

Jose Abreu

author
#0 lore raw

PATCH v3 1/1 arc: Re-enable MMU upon a Machine Check exception

I recently came upon a scenario where I would get a double fault after a machine check error. It turns out that for Ksymbol lookup to work with modules we need to have MMU enabled because module address is mapped in the cached space.

This patch re-enables the MMU before calling die() so that stacktracing of modules work when a machine check exception happens.

Signed-off-by Jose Abreu <joabreu at synopsys.com>
Cc Vineet Gupta <vgupta at synopsys.com>
Cc Alexey Brodkin <abrodkin at synopsys.com>

Changes from v2:
- Rephrased commit title and description
Changes from v1:
- Moved MMU re-enable to machine check exception handler

---
 arch/arc/kernel/traps.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/arc/kernel/traps.c +5 -0
index ff83e78..d92f161 100644
@@ -19,6 +19,8 @@
 #include <linux/ptrace.h>
 #include <linux/kprobes.h>
 #include <linux/kgdb.h>
+#include <asm/arcregs.h>
+#include <asm/mmu.h>
 #include <asm/setup.h>
 #include <asm/unaligned.h>
 #include <asm/kprobes.h>
@@ -103,6 +105,9 @@ int do_misaligned_access(unsigned long address, struct pt_regs *regs,
  */
 void do_machine_check_fault(unsigned long address, struct pt_regs *regs)
 {
+	/* MMU must be enabled for Ksymbol lookup in modules */
+	write_aux_reg(ARC_REG_PID, MMU_ENABLE | read_aux_reg(ARC_REG_PID));
+
 	die("Machine Check Exception", regs, address);
 }
 
Signature · 1 line
1.9.1
#1 lore raw

PATCH v3 1/1 arc: Re-enable MMU upon a Machine Check exception

Hi Jose,

Some very minor nit picks to keep in mind for future patches.

1. all arc patches start with uppercase ARC:

Quoted 12 lines · Jose Abreu

I recently came upon a scenario where I would get a double fault after a machine check error. It turns out that for Ksymbol lookup to work with modules we need to have MMU enabled because module address is mapped in the cached space.

This patch re-enables the MMU before calling die() so that stacktracing of modules work when a machine check exception happens.

Signed-off-by Jose Abreu <joabreu at synopsys.com>
Cc Vineet Gupta <vgupta at synopsys.com>
Cc Alexey Brodkin <abrodkin at synopsys.com>
Quoted 5 lines

Changes from v2:
- Rephrased commit title and description
Changes from v1:
- Moved MMU re-enable to machine check exception handler
---

2. The patch revision history needs to be added *after* the line with ---, that way git am automatically strips them off when patch is applied.

-Vineet

#2 lore raw

PATCH 1/1 ARC: Machine Check Exception: enable MMU in single place

In reply to Jose Abreu

Machine check Exception is handled in distinc ways depending on cause
- Duplicate TLB Entry (relevent mostly for ARC700)
- everything else

Currently we re-enable MMU seperately for each of these cases, which can be consolidated by dign this before we fork off the handling in low level handler.

Signed-off-by Vineet Gupta <vgupta at synopsys.com>
---
 arch/arc/kernel/entry.S | 6 ++++++
 arch/arc/kernel/traps.c | 6 ------
 arch/arc/mm/tlb.c       | 3 ---
 3 files changed, 6 insertions(+), 9 deletions(-)
arch/arc/kernel/entry.S +6 -0
index 1eea99beecc3..85d9ea4a0acc 100644
@@ -92,6 +92,12 @@ ENTRY(EV_MachineCheck)
 	lr  r0, [efa]
 	mov r1, sp
 
+	; hardware auto-disables MMU, re-enable it to allow kernel vaddr
+	; access for say stack unwinding of modules for crash dumps
+	lr	r3, [ARC_REG_PID]
+	or	r3, r3, MMU_ENABLE
+	sr	r3, [ARC_REG_PID]
+
 	lsr  	r3, r2, 8
 	bmsk 	r3, r3, 7
 	brne    r3, ECR_C_MCHK_DUP_TLB, 1f
arch/arc/kernel/traps.c +0 -6
index b636dfe8ee9e..b03daa7a9a2b 100644
@@ -105,12 +105,6 @@ int do_misaligned_access(unsigned long address, struct pt_regs *regs,
  */
 void do_machine_check_fault(unsigned long address, struct pt_regs *regs)
 {
-	/*
-	 * Hardware auto-disables MMU upon this exception hence re-enabled
-	 * for ksym lookup in modules to work (in kernel vaddr space)
-	 */
-	write_aux_reg(ARC_REG_PID, MMU_ENABLE | read_aux_reg(ARC_REG_PID));
-
 	die("Unhandled Machine Check Exception", regs, address);
 }
 
arch/arc/mm/tlb.c +0 -3
index edc59a0a9c9b..8ceefbf72fb0 100644
@@ -908,9 +908,6 @@ void do_tlb_overlap_fault(unsigned long cause, unsigned long address,
 
 	local_irq_save(flags);
 
-	/* re-enable the MMU */
-	write_aux_reg(ARC_REG_PID, MMU_ENABLE | read_aux_reg(ARC_REG_PID));
-
 	/* loop thru all sets of TLB */
 	for (set = 0; set < mmu->sets; set++) {
 
Signature · 1 line
2.7.4