Skip to contentSkip to conversation

arc: Re-enable MMU upon die()

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

lore
Share & tools
lore

Jose Abreu

author
#0 lore raw

PATCH v2 1/1 arc: Re-enable MMU upon die()

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 start printing the stacktrace making stacktracing of modules work upon a fatal exception.

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 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
author
#1 lore raw

PATCH v2 1/1 arc: Re-enable MMU upon die()

Oops, the commit title is now a little bit odd. Let me rephrase and send a new version.

Quoted 41 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 start printing the stacktrace making stacktracing of modules work upon a fatal exception.

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 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);
 }
 
#2 lore raw

PATCH v2 1/1 arc: Re-enable MMU upon die()

Quoted 2 lines · Jose Abreu

Oops, the commit title is now a little bit odd. Let me rephrase and send a new version.

Don't worry - I'll fix it up here !

Thx,
-Vineet

Quoted 44 lines · Jose Abreu
Quoted 41 lines

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 start printing the stacktrace making stacktracing of modules work upon a fatal exception.

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 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);
  }