[PATCH] 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 Cc: Vineet Gupta Cc: Alexey Brodkin --- arch/arc/kernel/traps.c | 5 + 1 file changed, 5 insertions(+) diff --git a/arch/arc/kernel/traps.c b/arch/arc/kernel/traps.c index ff83e78..9533e06 100644 --- a/arch/arc/kernel/traps.c +++ b/arch/arc/kernel/traps.c @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include #include #include @@ -30,6 +32,9 @@ void __init trap_init(void) void die(const char *str, struct pt_regs *regs, unsigned long address) { + /* MMU must be enabled for Ksymbol lookup in modules */ + write_aux_reg(ARC_REG_PID, MMU_ENABLE | read_aux_reg(ARC_REG_PID)); + show_kernel_fault_diag(str, regs, address); /* DEAD END */ -- 1.9.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH] arc: Re-enable MMU upon die()
Hi Jose, On Fri, 2017-09-01 at 12:39 +0100, Jose Abreu wrote: > 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. I'm wondering how do we end up with MMU disabled? >From ARC700 databook I cannot find any condition on which MMU could be silently disabled by hardware and IIRC there's no code in Linux kernel that disables MMU. -Alexey ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH] arc: Re-enable MMU upon die()
Hi Alexey, On 01-09-2017 12:48, Alexey Brodkin wrote: > Hi Jose, > > On Fri, 2017-09-01 at 12:39 +0100, Jose Abreu wrote: >> 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. > I'm wondering how do we end up with MMU disabled? > From ARC700 databook I cannot find any condition on which MMU could be > silently disabled by hardware and IIRC there's no code in Linux kernel > that disables MMU. According to ARC 700 databook a machine check exception causes Global TLB enable to be cleared. (See ARC 700 databook, page 687). Best regards, Jose Miguel Abreu > > -Alexey ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH] arc: Re-enable MMU upon die()
Hi Jose, On Fri, 2017-09-01 at 13:33 +0100, Jose Abreu wrote: > Hi Alexey, > > On 01-09-2017 12:48, Alexey Brodkin wrote: > > > > Hi Jose, > > > > On Fri, 2017-09-01 at 12:39 +0100, Jose Abreu wrote: > > > > > > 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. > > I'm wondering how do we end up with MMU disabled? > > From ARC700 databook I cannot find any condition on which MMU could be > > silently disabled by hardware and IIRC there's no code in Linux kernel > > that disables MMU. > > According to ARC 700 databook a machine check exception causes > Global TLB enable to be cleared. (See ARC 700 databook, page 687). Thanks for pointing to that. I didn't expect to see that note far below "Global TLB enable" bit description. So then your change makes perfect sense. Reviwed-by: Alexey Brodkin ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH] arc: Re-enable MMU upon die()
On 09/01/2017 04:40 AM, Jose Abreu wrote: 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 Cc: Vineet Gupta Cc: Alexey Brodkin --- arch/arc/kernel/traps.c | 5 + 1 file changed, 5 insertions(+) diff --git a/arch/arc/kernel/traps.c b/arch/arc/kernel/traps.c index ff83e78..9533e06 100644 --- a/arch/arc/kernel/traps.c +++ b/arch/arc/kernel/traps.c @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include #include #include @@ -30,6 +32,9 @@ void __init trap_init(void) void die(const char *str, struct pt_regs *regs, unsigned long address) { + /* MMU must be enabled for Ksymbol lookup in modules */ + write_aux_reg(ARC_REG_PID, MMU_ENABLE | read_aux_reg(ARC_REG_PID)); die() is a *generic* API and can even be called from other places not necessarily coming from machine check. The problem with mmu disabling is specific to machine check for dup TLB exception and needs to be fixed there not in common code. -Vineet ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH v2] 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 Cc: Vineet Gupta Cc: Alexey Brodkin Changes from v1: - Moved MMU re-enable to machine check exception handler --- arch/arc/kernel/traps.c | 5 + 1 file changed, 5 insertions(+) diff --git a/arch/arc/kernel/traps.c b/arch/arc/kernel/traps.c index ff83e78..d92f161 100644 --- a/arch/arc/kernel/traps.c +++ b/arch/arc/kernel/traps.c @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include #include #include @@ -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); } -- 1.9.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH v2] arc: Re-enable MMU upon die()
Oops, the commit title is now a little bit odd. Let me rephrase and send a new version. On 01-09-2017 17:00, Jose Abreu wrote: > 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 > Cc: Vineet Gupta > Cc: Alexey Brodkin > > Changes from v1: > - Moved MMU re-enable to machine check exception handler > --- > arch/arc/kernel/traps.c | 5 + > 1 file changed, 5 insertions(+) > > diff --git a/arch/arc/kernel/traps.c b/arch/arc/kernel/traps.c > index ff83e78..d92f161 100644 > --- a/arch/arc/kernel/traps.c > +++ b/arch/arc/kernel/traps.c > @@ -19,6 +19,8 @@ > #include > #include > #include > +#include > +#include > #include > #include > #include > @@ -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); > } > ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH v3] 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 Cc: Vineet Gupta Cc: Alexey Brodkin 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(+) diff --git a/arch/arc/kernel/traps.c b/arch/arc/kernel/traps.c index ff83e78..d92f161 100644 --- a/arch/arc/kernel/traps.c +++ b/arch/arc/kernel/traps.c @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include #include #include @@ -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); } -- 1.9.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH v2] arc: Re-enable MMU upon die()
On 09/01/2017 09:01 AM, Jose Abreu wrote: 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 On 01-09-2017 17:00, Jose Abreu wrote: 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 Cc: Vineet Gupta Cc: Alexey Brodkin Changes from v1: - Moved MMU re-enable to machine check exception handler --- arch/arc/kernel/traps.c | 5 + 1 file changed, 5 insertions(+) diff --git a/arch/arc/kernel/traps.c b/arch/arc/kernel/traps.c index ff83e78..d92f161 100644 --- a/arch/arc/kernel/traps.c +++ b/arch/arc/kernel/traps.c @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include #include #include @@ -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); } ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH v3] 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: On 09/01/2017 09:05 AM, Jose Abreu wrote: 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 Cc: Vineet Gupta Cc: Alexey Brodkin 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 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[PATCH] ARC: Machine Check Exception: enable MMU in single place
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 --- 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(-) diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S index 1eea99beecc3..85d9ea4a0acc 100644 --- a/arch/arc/kernel/entry.S +++ b/arch/arc/kernel/entry.S @@ -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 bmskr3, r3, 7 brner3, ECR_C_MCHK_DUP_TLB, 1f diff --git a/arch/arc/kernel/traps.c b/arch/arc/kernel/traps.c index b636dfe8ee9e..b03daa7a9a2b 100644 --- a/arch/arc/kernel/traps.c +++ b/arch/arc/kernel/traps.c @@ -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); } diff --git a/arch/arc/mm/tlb.c b/arch/arc/mm/tlb.c index edc59a0a9c9b..8ceefbf72fb0 100644 --- a/arch/arc/mm/tlb.c +++ b/arch/arc/mm/tlb.c @@ -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++) { -- 2.7.4 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc