MIPS: SGI-IP27: print the NMI dump on an nbcon console
Subsystems (2)
PATCH v2 1/1 MIPS: SGI-IP27: print the NMI dump on an nbcon console
Since the 8250 console became nbcon, printk() in nmi_dump() only queues records for a printer thread that never runs, as no CPU leaves the NMI handler. Print from an emergency section and flush pending records before the hub reset.
---
v2: flush pending records before the hub reset (John Ogness)
v1: https://lore.kernel.org/all/[email protected]/
This conflicts by context with patch 14/38 of the IP35 series,
https://lore.kernel.org/all/76f2a9c32eba23de36817f0a186def01e009e1c7.1790857966.git.kaloz@kernel.org/
which rewrites the reset write. Whichever lands second places the printk_trigger_flush() call above the system_is_ip35 branch.
arch/mips/sgi-ip27/ip27-nmi.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/mips/sgi-ip27/ip27-nmi.c +8 -0
@@ -1,4 +1,5 @@// SPDX-License-Identifier: GPL-2.0 +#include <linux/console.h> #include <linux/kernel.h> #include <linux/mmzone.h> #include <linux/nodemask.h>
@@ -183,6 +184,12 @@ static void nmi_dump(void)*/ arch_spin_lock (&nmi_lock); +/* +* No CPU leaves the NMI handler before the hub reset below, so an +* nbcon console's printer thread would never print the dump. +*/ +nbcon_cpu_emergency_enter (); +#ifdef REAL_NMI_SIGNAL /* * Wait up to 15 seconds for the other cpus to respond to the NMI.
@@ -227,5 +234,6 @@ static void nmi_dump(void)* Save the nmi cpu registers for all cpu in the eframe format. */ nmi_eframes_save (); +printk_trigger_flush ();LOCAL_HUB_S (NI_PORT_RESET ,NPR_PORTRESET |NPR_LOCALRESET ); }
Signature · 1 line
2.47.3
Quoted 7 lines · Imre Kaloz
Since the 8250 console became nbcon,
printk()innmi_dump()only queues records for a printer thread that never runs, as no CPU leaves the NMI handler. Print from an emergency section and flush pending records before the hub reset.Fixes d3539347022a ("serial: 8250: Switch to nbcon console, take 2")Signed-off-by Imre Kaloz <[email protected]>
Quoted 7 lines · Imre Kaloz
Since the 8250 console became nbcon,
printk()innmi_dump()only queues records for a printer thread that never runs, as no CPU leaves the NMI handler. Print from an emergency section and flush pending records before the hub reset.Fixes d3539347022a ("serial: 8250: Switch to nbcon console, take 2")Signed-off-by Imre Kaloz <[email protected]>
Looks good to me:
I assume that it would go via mips or drivers tree. Please, let me know if you would prefer to push it via printk tree.
Best Regards,
Petr
Greg Kroah-Hartman
maintainerQuoted 9 lines · Petr Mladek
Quoted 7 lines · Imre Kaloz
Since the 8250 console became nbcon,
printk()innmi_dump()only queues records for a printer thread that never runs, as no CPU leaves the NMI handler. Print from an emergency section and flush pending records before the hub reset.Fixes d3539347022a ("serial: 8250: Switch to nbcon console, take 2")Signed-off-by Imre Kaloz <[email protected]>
Quoted 6 lines
Looks good to me:
Reviewed-by Petr Mladek <[email protected]>I assume that it would go via mips or drivers tree. Please, let me know if you would prefer to push it via printk tree.
Should probably go through a mips tree to resolve the conflicts.
thanks,
greg k-h
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] printk: NMI dump output lost due to nbcon timeout if console is in unsafe state --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] printk: NMI dump output lost due to nbcon timeout if console is in unsafe state --
commit f9358977a85eff3b02febdb716b027b3e2f5107f
Author: Imre Kaloz <[email protected]>
MIPS: SGI-IP27: print the NMI dump on an nbcon console
Since the 8250 console became nbcon, printk() in nmi_dump() only queues records for a printer thread that never runs, as no CPU leaves the NMI handler. Print from an emergency section and flush pending records before the hub reset.
arch/mips/sgi-ip27/ip27-nmi.c static void nmi_dump(void) · line 185
Quoted 7 lines
arch/mips/sgi-ip27/ip27-nmi.c +0
-0@@ -183,6 +184,12 @@ static void nmi_dump(void)*/ arch_spin_lock (&nmi_lock);
[Severity: High]
If another CPU was interrupted while holding an nbcon console in an unsafe state, will it be trapped here spinning indefinitely on nmi_lock?
If so, it would never be able to release the console.
arch/mips/sgi-ip27/ip27-nmi.c static void nmi_dump(void) · line 191
Quoted 6 lines
arch/mips/sgi-ip27/ip27-nmi.c +5
-0+/* +* No CPU leaves the NMI handler before the hub reset below, so an +* nbcon console's printer thread would never print the dump. +*/ +nbcon_cpu_emergency_enter ();
[Severity: High]
Does entering EMERGENCY priority here instead of PANIC prevent a hostile takeover of the console?
Hostile unsafe takeovers require panic_on_this_cpu() to be true via nbcon_allow_unsafe_takeover().
Since panic() is not called during this NMI dump sequence, it appears this would fall short of allowing a takeover if the console is locked.
Quoted 3 lines
arch/mips/sgi-ip27/ip27-nmi.c +1
-0+#ifdef REAL_NMI_SIGNAL /*
[ ... ]
arch/mips/sgi-ip27/ip27-nmi.c static void nmi_dump(void) · line 237
Quoted 5 lines
arch/mips/sgi-ip27/ip27-nmi.c +1
-0@@ -227,5 +234,6 @@ static void nmi_dump(void)* Save the nmi cpu registers for all cpu in the eframe format. */ nmi_eframes_save (); +printk_trigger_flush ();
[Severity: High]
Will this flush completely suppress the dump output if the console was held by one of the trapped CPUs?
If the system attempts a handover here, it will wait 2000us and time out because the other CPU is trapped on nmi_lock.
Following the timeout, nbcon_context_try_acquire_hostile() will fail with -EPERM because PANIC priority was not established.
Could this cause the flush to fail entirely, silently triggering a hardware reset via LOCAL_HUB_S() without outputting any diagnostic information?
Quoted 2 lines
arch/mips/sgi-ip27/ip27-nmi.c +0
-0LOCAL_HUB_S (NI_PORT_RESET ,NPR_PORTRESET |NPR_LOCALRESET ); }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 51 lines · Imre Kaloz
Since the 8250 console became nbcon,
printk()innmi_dump()only queues records for a printer thread that never runs, as no CPU leaves the NMI handler. Print from an emergency section and flush pending records before the hub reset.Fixes d3539347022a ("serial: 8250: Switch to nbcon console, take 2")Signed-off-by Imre Kaloz <[email protected]>---
v2: flush pending records before the hub reset (John Ogness)
v1: https://lore.kernel.org/all/[email protected]/This conflicts by context with patch 14/38 of the IP35 series,
https://lore.kernel.org/all/76f2a9c32eba23de36817f0a186def01e009e1c7.1790857966.git.kaloz@kernel.org/
which rewrites the reset write. Whichever lands second places theprintk_trigger_flush()call above thesystem_is_ip35branch.arch/mips/sgi-ip27/ip27-nmi.c | 8 ++++++++ 1 file changed, 8 insertions(+)arch/mips/sgi-ip27/ip27-nmi.c +8
-0@@ -1,4 +1,5 @@// SPDX-License-Identifier: GPL-2.0 +#include <linux/console.h> #include <linux/kernel.h> #include <linux/mmzone.h> #include <linux/nodemask.h> @@ -183,6 +184,12 @@ static void nmi_dump(void)*/ arch_spin_lock (&nmi_lock); +/* +* No CPU leaves the NMI handler before the hub reset below, so an +* nbcon console's printer thread would never print the dump. +*/ +nbcon_cpu_emergency_enter (); +#ifdef REAL_NMI_SIGNAL /* * Wait up to 15 seconds for the other cpus to respond to the NMI. @@ -227,5 +234,6 @@ static void nmi_dump(void)* Save the nmi cpu registers for all cpu in the eframe format. */ nmi_eframes_save (); +printk_trigger_flush ();LOCAL_HUB_S (NI_PORT_RESET ,NPR_PORTRESET |NPR_LOCALRESET ); }Signature · 1 line
2.47.3
applied to mips-fixes
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]