Debian kernel regression, was Re: Modernizing a Macintosh LC III
Subsystems (2)
I gave linux-image-3.12-trunk-m68k_3.12-1~exp1_m68k.deb a try on my Amiga. Actually I tried my own first, using my current tree, and a config derived from config-3.12-1~exp1, as I couldn't find the Debian kernel. However, both gave the same result.
Surprise 1: There was no ABC...
head.S has this "interesting" piece of code, which plays foul of multi-platform kernels:
#ifdef CONFIG_MAC
#include <asm/machw.h>
#ifdef CONFIG_FRAMEBUFFER_CONSOLE
#define CONSOLE
#define CONSOLE_PENGUIN
#endif
#ifdef CONFIG_EARLY_PRINTK
#define SERIAL_DEBUG
#else
#undef SERIAL_DEBUG
#endif
#else /* !CONFIG_MAC */
#define SERIAL_DEBUG
#endif /* !CONFIG_MAC */
As CONFIG_MAC=y, and CONFIG_EARLY_PRINTK=n, SERIAL_DEBUG is not defined, and no one gets early serial debug output :-( Enabling CONFIG_EARLY_PRINTK fixes this.
Is there a good reason for this construct?
- Should it check for MACH_MAC_ONLY instead?
- Can we just unconditionally enable SERIAL_DEBUG?
Surprise 2: Instead of a deadly non-Mac driver, I found a deadly Mac driver. When passing "debug=ser", it crashes with:
Console: colour dummy device 80x25
Unable to handle kernel NULL pointer dereference at virtual address (null) Oops: 00000000 PC: [<0013ad28>] __pmz_startup+0x32/0x2a0 SR: 2010 SP: 0025ff10 a2: 00266300 d0: 00000080 d1: ffffffff d2: 00000000 d3: 002cbd32 d4: 00000000 d5: 000119a8 a0: 00000000 a1: 002c5cda
Process swapper (pid: 0, task=00266300)
Frame format=7 eff addr=0025ff5c ssw=04a5 faddr=00000000 wb 1 stat/addr/data: 0005 00000000 0013ad0c
wb 2 stat/addr/data: 00a5 00000000 00000009
wb 3 stat/addr/data: 0025 00000000 00000009 push data: 0013ad0c 002a9f7a 00000000 00000011 Stack from 0025ff78:
002a9ecc 002c5d3e 002a9ecc 00000000 002cbd32 0000000a 00283454 0029170e
0000006e 0000006e 00000008 00009600 0025fff8 000499f4 00283454 00000000
00000002 002d3b10 000fc4a8 00048b96 002c5cd4 00283454 002c5142 000fc39c
002b2728 002d4000 000000fa 00001538 0743ed40 07401000 07401000 002cbd32
00000000 002b07f8
Call Trace: [<002c5d3e>] pmz_console_setup+0x64/0xe4
[<00009600>] atari_keyboard_interrupt+0x164/0x2dc
[<000499f4>] register_console+0x104/0x2a6
[<000fc4a8>] strlen+0x0/0x14
[<00048b96>] printk+0x0/0x26
[<002c5cd4>] pmz_console_init+0x10/0x16
[<002c5142>] console_init+0x14/0x20
[<000fc39c>] strcpy+0x0/0x16
[<002b2728>] start_kernel+0x29a/0x3fc
[<00001538>] kernel_pg_dir+0x538/0x1000
[<002b07f8>] _sinittext+0x7f8/0x10dc
Code: 00c3 6604 103c 0040 206b 00c6 10bc 0009 <206b> 00c6 1080 206b
00c6 1010 223c 0000 a7c6 2039 0026 60bc 4c01 0401 2001 e988
Disabling lock debugging due to kernel taint
Kernel panic - not syncing: Attempted to kill the idle task!drivers/tty/serial/pmac_zilog.c needs some MACH_IS_MAC() tests.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Quoted 20 lines · Geert Uytterhoeven
head.Shas this "interesting" piece of code, which plays foul of multi-platform kernels:#ifdef
CONFIG_MAC#include <
asm/machw.h>#ifdef
CONFIG_FRAMEBUFFER_CONSOLE
#define CONSOLE
#defineCONSOLE_PENGUIN
#endif#ifdef
CONFIG_EARLY_PRINTK
#defineSERIAL_DEBUG
#else
#undefSERIAL_DEBUG
#endif#else /* !CONFIG_MAC */
Quoted 8 lines
#define
SERIAL_DEBUG#endif /* !CONFIG_MAC */
As
CONFIG_MAC=y, andCONFIG_EARLY_PRINTK=n,SERIAL_DEBUGis not defined, and no one gets early serial debug output :-( EnablingCONFIG_EARLY_PRINTKfixes this.
Is there a good reason for this construct?
Not if there's a good reason for multi-platform kernels. When I changed that logic, they weren't used except for build testing AFAIK.
Here's the relevant commit:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/arch/m68k/kernel/head.S?id=93edd023a7de1ea4fe6e5de631982b96156eef03
To be honest, the old logic never made a whole lot of sense to me.
Quoted 2 lines
- Should it check for
MACH_MAC_ONLYinstead?
- Can we just unconditionally enableSERIAL_DEBUG?
If multi-platform kernels are a good idea, then so is multi-platform config logic.
IMHO all platforms should respond to these obscure buried macros in the same way. That's why I eliminated MAC_SERIAL_DEBUG. (Certainly the new code in that commit would also benefit Atari machines with Zilog SCC.)
The comments make it clear that the author(s) of that file expected CONSOLE to be used cross-platform (though this never eventuated). My patch was an attempt to make SERIAL_CONSOLE work cross-platform also.
Moreover, the code you cited,
#ifdef CONFIG_EARLY_PRINTK
#define SERIAL_DEBUG
#else
#undef SERIAL_DEBUG
#endif
was written in the hope that CONFIG_EARLY_PRINTK would eventually be embraced as a better mechanism than the obscure SERIAL_DEBUG and CONSOLE macros. I guess that never eventuated either.
Quoted 2 lines
Surprise 2: Instead of a deadly non-Mac driver, I found a deadly Mac driver. When passing "debug=ser", it crashes with:
The __pmz_startup() crash could be expected regardless of "debug=ser", no? I wonder why no-one else reported it?
Quoted 3 lines
Unable to handle kernel NULL pointer dereference at virtual address (null) Oops: 00000000 PC: [<0013ad28>] __pmz_startup+0x32/0x2a0
...
Quoted 3 lines
drivers/tty/serial/pmac_zilog.cneeds someMACH_IS_MAC()tests.
Yes (given that Debian now ships multi-platform kernels). I'll send a patch.
Finn
Quoted 3 lines · Geert Uytterhoeven
Unable to handle kernel NULL pointer dereference at virtual address (null) Oops: 00000000 PC: [<0013ad28>] __pmz_startup+0x32/0x2a0
[snip]
Quoted 6 lines
Call Trace: [<002c5d3e>] pmz_console_setup+0x64/0xe4 [<00009600>] atari_keyboard_interrupt+0x164/0x2dc [<000499f4>] register_console+0x104/0x2a6 [<000fc4a8>] strlen+0x0/0x14 [<00048b96>] printk+0x0/0x26 [<002c5cd4>] pmz_console_init+0x10/0x16
[snip]
Quoted 3 lines
drivers/tty/serial/pmac_zilog.cneeds someMACH_IS_MAC()tests.
The platform devices pmz_ports[X].pdev aren't supposed to be used unless config_mac() first initializes them (when MACH_IS_MAC). Unfortunately the null pointer test in pmz_console_setup() never succeeds because pmz_probe() always sets those pointers, so make sure they remain null when the platform device isn't valid.
---
I haven't even compiled this. Geert, can you please build and test?
drivers/tty/serial/pmac_zilog.c +6 -2
@@ -1748,8 +1748,10 @@ static int __init pmz_probe(void) pmz_ports[0 ].flags =PMACZILOG_FLAG_IS_CHANNEL_A ; pmz_ports[0 ].pdev = &scc_a_pdev; err =pmz_init_port (&pmz_ports[0 ]); -if (err) +if (err) { + pmz_ports[0 ].pdev =NULL ;return err; + } pmz_ports_count++; pmz_ports[0 ].mate = &pmz_ports[1 ];
@@ -1758,8 +1760,10 @@ static int __init pmz_probe(void) pmz_ports[1 ].flags =0 ; pmz_ports[1 ].pdev = &scc_b_pdev; err =pmz_init_port (&pmz_ports[1 ]); -if (err) +if (err) { + pmz_ports[1 ].pdev =NULL ;return err; + } pmz_ports_count++;return 0 ;
Quoted 4 lines · Finn Thain
Quoted 2 lines
Surprise 2: Instead of a deadly non-Mac driver, I found a deadly Mac driver. When passing "debug=ser", it crashes with:
The
__pmz_startup()crash could be expected regardless of "debug=ser", no?
Yes, that's why I asked Thorsten if the image worked on ARAnyM.
Quoted 1 line
I wonder why no-one else reported it?
No one managed to boot those kernels far enough to notice? ;-)
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Quoted 7 lines · Geert Uytterhoeven
Quoted 4 lines · Finn Thain
Quoted 2 lines
Surprise 2: Instead of a deadly non-Mac driver, I found a deadly Mac driver. When passing "debug=ser", it crashes with:
The
__pmz_startup()crash could be expected regardless of "debug=ser", no?Yes, that's why I asked Thorsten if the image worked on ARAnyM.
I can trigger it on ARAnyM too, using "debug=par console=ttyS0".
init_pmz() doesn't crash because it re-checks pmz_ports_count after calling pmz_probe().
pmz_console_init() doesn't do that, so it still registered the console, and caused a crash later.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Quoted 27 lines · Finn Thain
Quoted 3 lines · Geert Uytterhoeven
Unable to handle kernel NULL pointer dereference at virtual address (null) Oops: 00000000 PC: [<0013ad28>] __pmz_startup+0x32/0x2a0[snip]
Quoted 6 lines
Call Trace: [<002c5d3e>] pmz_console_setup+0x64/0xe4 [<00009600>] atari_keyboard_interrupt+0x164/0x2dc [<000499f4>] register_console+0x104/0x2a6 [<000fc4a8>] strlen+0x0/0x14 [<00048b96>] printk+0x0/0x26 [<002c5cd4>] pmz_console_init+0x10/0x16[snip]
Quoted 3 lines
drivers/tty/serial/pmac_zilog.cneeds someMACH_IS_MAC()tests.The platform devices pmz_ports[X].pdev aren't supposed to be used unless
config_mac()first initializes them (whenMACH_IS_MAC). Unfortunately the null pointer test inpmz_console_setup()never succeeds becausepmz_probe()always sets those pointers, so make sure they remain null when the platform device isn't valid.
Quoted 5 lines
Signed-off-by Finn Thain <[email protected]>---
I haven't even compiled this. Geert, can you please build and test?
Worse, now it crashes without output.
Adding more debug code in printk() itself showed that pmz_console_setup() no longer crashes, but that it dies in serial_console_write() later, hiding all evidence.
Woops, serial_console_write() is the one from amiserial...
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Hi Finn,
Quoted 2 lines · Geert Uytterhoeven
pmz_console_init()doesn't do that, so it still registered the console, and caused a crash later.
Adding a check there is a simpler solution that also works.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds