MIPS: add nmi_enter() + nmi_exit() to nmi_exception_handler()
PATCH 1/1 MIPS: add nmi_enter() + nmi_exit() to nmi_exception_handler()
We need to enter NMI context when NMI interrupt fires.
--- arch/mips/kernel/traps.c | 2 ++ 1 file changed, 2 insertions(+)
arch/mips/kernel/traps.c +2 -0
@@ -1856,12 +1856,14 @@ void __noreturn nmi_exception_handler(struct pt_regs *regs) {char str[100 ]; +nmi_enter ();raw_notifier_call_chain (&nmi_chain,0 , regs);bust_spinlocks (1 );snprintf (str,100 ,"CPU%d NMI taken, CP0_EPC=%lx\n" ,smp_processor_id (), regs->cp0_epc); regs->cp0_epc =read_c0_errorepc ();die (str, regs); +nmi_exit (); }#define VECTORSPACING 0x100/* for EI/VI mode */
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
Quoted 28 lines · Petri Gynther
We need to enter NMI context when NMI interrupt fires.
Signed-off-by Petri Gynther <[email protected]>--- arch/mips/kernel/traps.c | 2 ++ 1 file changed, 2 insertions(+)arch/mips/kernel/traps.c +2
-1@@ -1856,12 +1856,14 @@ void __noreturn nmi_exception_handler(struct pt_regs *regs) {char str[100 ]; +nmi_enter ();raw_notifier_call_chain (&nmi_chain,0 , regs);bust_spinlocks (1 );snprintf (str,100 ,"CPU%d NMI taken, CP0_EPC=%lx\n" ,smp_processor_id (), regs->cp0_epc); regs->cp0_epc =read_c0_errorepc ();die (str, regs); +nmi_exit (); }#define VECTORSPACING 0x100/* for EI/VI mode */ --
Quoted 2 lines
2.6.0.rc2.230.g3dd15c0
Any comments/concerns about this patch?
On our systems, we have seen stack traces like this:
<4>[158549.586000] : [<800103c0>] show_stack+0x78/0x90 <4>[158549.586000] : [<807340a0>] dump_stack+0xd0/0x144 <4>[158549.586000] : [<8006475c>] dequeue_task_idle+0x38/0x4c <4>[158549.586000] : [<80735c8c>] __schedule+0x49c/0xa68 <4>[158549.586000] : [<80736294>] schedule+0x3c/0x9c <4>[158549.586000] : [<80739930>] schedule_timeout+0x144/0x254 <4>[158549.586000] : [<800964f8>] msleep+0x40/0x54 <4>[158549.586000] : [<80010604>] die+0x124/0x130 <4>[158549.586000] : [<80012abc>] set_vi_handler+0x0/0x24 <4>[158549.586000] : <3>[158549.586000] bad: scheduling from the idle thread!
80012a24 <nmi_exception_handler>:
...
80012ab4: 0c004138 jal 800104e0 <die> 80012ab8: 02002821 move a1,s0
80012abc <set_vi_handler>:
...
Quoted 27 lines · Petri Gynther
Quoted 26 lines · Petri Gynther
We need to enter NMI context when NMI interrupt fires.
Signed-off-by Petri Gynther <[email protected]>--- arch/mips/kernel/traps.c | 2 ++ 1 file changed, 2 insertions(+)arch/mips/kernel/traps.c +2
-0@@ -1856,12 +1856,14 @@ void __noreturn nmi_exception_handler(struct pt_regs *regs) {char str[100 ]; +nmi_enter ();raw_notifier_call_chain (&nmi_chain,0 , regs);bust_spinlocks (1 );snprintf (str,100 ,"CPU%d NMI taken, CP0_EPC=%lx\n" ,smp_processor_id (), regs->cp0_epc); regs->cp0_epc =read_c0_errorepc ();die (str, regs); +nmi_exit (); }
Quoted 6 lines
Quoted 4 lines
arch/mips/kernel/traps.c +0
-1#define VECTORSPACING 0x100/* for EI/VI mode */ --2.6.0.rc2.230.g3dd15c0
Any comments/concerns about this patch?
Is NMI on your systems actually recoverable? I never bothered with nmi_enther / nmi_exit and other fine details of the NMI implementations because as defined by the MIPS architecture an NMI may be pretty destructive and closer to a reset than what other architectures describer as their NMI. Think what's going to happen if it hits during any phase when $k0 / $k1 are active.
Ralf
Quoted 25 lines · Ralf Baechle
Quoted 18 lines
Quoted 18 lines
arch/mips/kernel/traps.c +2
-0@@ -1856,12 +1856,14 @@ void __noreturn nmi_exception_handler(struct pt_regs *regs) {char str[100 ]; +nmi_enter ();raw_notifier_call_chain (&nmi_chain,0 , regs);bust_spinlocks (1 );snprintf (str,100 ,"CPU%d NMI taken, CP0_EPC=%lx\n" ,smp_processor_id (), regs->cp0_epc); regs->cp0_epc =read_c0_errorepc ();die (str, regs); +nmi_exit (); }Quoted 6 lines
Quoted 4 lines
arch/mips/kernel/traps.c +0
-1#define VECTORSPACING 0x100/* for EI/VI mode */ --2.6.0.rc2.230.g3dd15c0
Any comments/concerns about this patch?
Quoted 6 lines
Is NMI on your systems actually recoverable? I never bothered with
nmi_enther/nmi_exitand other fine details of the NMI implementations because as defined by the MIPS architecture an NMI may be pretty destructive and closer to a reset than what other architectures describer as their NMI. Think what's going to happen if it hits during any phase when $k0 / $k1 are active.
We could do better though, by having a register stash area defined
somewhere in low memory (0x0-0x7fff) -- of course if physical memory is actually available there in a given system. Remember that setting CP0.Status.ERL makes KUSEG identity mapped, making it possible to access its beginning off $zero and save all GPRs in a non-destructive manner.
That is however assuming we can take control at all in the first place as
the NMI vector is hardwired and points to a ROM location in a typical system.
Maciej
Quoted 40 lines · Maciej W. Rozycki
Quoted 25 lines · Ralf Baechle
Quoted 18 lines
Quoted 18 lines
arch/mips/kernel/traps.c +2
-0@@ -1856,12 +1856,14 @@ void __noreturn nmi_exception_handler(struct pt_regs *regs) {char str[100 ]; +nmi_enter ();raw_notifier_call_chain (&nmi_chain,0 , regs);bust_spinlocks (1 );snprintf (str,100 ,"CPU%d NMI taken, CP0_EPC=%lx\n" ,smp_processor_id (), regs->cp0_epc); regs->cp0_epc =read_c0_errorepc ();die (str, regs); +nmi_exit (); }Quoted 6 lines
Quoted 4 lines
arch/mips/kernel/traps.c +0
-1#define VECTORSPACING 0x100/* for EI/VI mode */ --2.6.0.rc2.230.g3dd15c0
Any comments/concerns about this patch?
Quoted 6 lines
Is NMI on your systems actually recoverable? I never bothered with
nmi_enther/nmi_exitand other fine details of the NMI implementations because as defined by the MIPS architecture an NMI may be pretty destructive and closer to a reset than what other architectures describer as their NMI. Think what's going to happen if it hits during any phase when $k0 / $k1 are active.We could do better though, by having a register stash area defined
somewhere in low memory (0x0-0x7fff) -- of course if physical memory is actually available there in a given system. Remember that setting CP0.Status.ERL makes KUSEG identity mapped, making it possible to access its beginning off $zero and save all GPRs in a non-destructive manner.
Quoted 3 lines
That is however assuming we can take control at all in the first place as
the NMI vector is hardwired and points to a ROM location in a typical system.
NMIs don't nest; the system is lost if it receives another NMI before the state of the first is saved. It's currently up to the system to avoid that probably by yes masking the non-maskable interrupt.
ErrorEPC is also used by cache errors so an NMI following a cache error exception before state has been saved might be fatal.
These are scenarios that are taken care of by CISC architectures but on a purebred RISC they're up to system implementors.
Ralf
Quoted 6 lines · Ralf Baechle
Quoted 6 lines
We could do better though, by having a register stash area defined
somewhere in low memory (0x0-0x7fff) -- of course if physical memory is actually available there in a given system. Remember that setting CP0.Status.ERL makes KUSEG identity mapped, making it possible to access its beginning off $zero and save all GPRs in a non-destructive manner.
Quoted 7 lines
Quoted 3 lines
That is however assuming we can take control at all in the first place as
the NMI vector is hardwired and points to a ROM location in a typical system.NMIs don't nest; the system is lost if it receives another NMI before the state of the first is saved. It's currently up to the system to avoid that probably by yes masking the non-maskable interrupt.
Indeed, ErrorEPC will be lost on a nested NMI. We should be able to
detect it and let the handler complete gracefully if it reaches to the end uninterrupted.
Quoted 2 lines
ErrorEPC is also used by cache errors so an NMI following a cache error exception before state has been saved might be fatal.
Hmm, I think a cache error is fatal by itself, so this scenario is
probably not of much concern -- just dumping the available state to the console and panicking should do.
Quoted 2 lines
These are scenarios that are taken care of by CISC architectures but on a purebred RISC they're up to system implementors.
E.g. x86 masks NMIs internally to avoid nesting, but it is able to notice
another incoming NMI and releases it as soon as the handling of the previous one has completed. We'd need to have external circuitry for any handling of this kind.
Maciej