On Tue, 2026-01-13 at 09:41 -0300, Marcos Paulo de Souza wrote: > On Mon, 2026-01-05 at 14:08 +0000, Daniel Thompson wrote: > > On Mon, Jan 05, 2026 at 12:52:14PM +0000, Daniel Thompson wrote: > > > Hi Marcos > > > > > > On Sat, Dec 27, 2025 at 09:16:07AM -0300, Marcos Paulo de Souza > > > wrote: > > > > The parts 1 and 2 can be found here [1] and here[2]. > > > > > > > > The changes proposed in this part 3 are mostly to clarify the > > > > usage of > > > > the interfaces for NBCON, and use the printk helpers more > > > > broadly. > > > > Besides it, it also introduces a new way to register consoles > > > > and drop thes the CON_ENABLED flag. It seems too much, but in > > > > reality > > > > the changes are not complex, and as the title says, it's > > > > basically a > > > > cleanup without changing the functional changes. > > > > > > I ran this patchset through the kgdb test suite and I'm afraid it > > > is > > > reporting functional changes. > > > > > > Specifically the earlycon support for kdb has regressed (FWIW the > > > problem bisects down to the final patch in the series where > > > CON_ENABLED > > > is removed). > > > > > > Reproduction on x86-64 KVM outside of the test suite should be > > > easy: > > > > > > make defconfig > > > scripts/config \ > > > --enable DEBUG_INFO \ > > > --enable DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT \ > > > --enable DEBUG_FS \ > > > --enable KALLSYMS_ALL \ > > > --enable MAGIC_SYSRQ \ > > > --enable KGDB \ > > > --enable KGDB_TESTS \ > > > --enable KGDB_KDB \ > > > --enable KDB_KEYBOARD \ > > > --enable LKDTM \ > > > --enable SECURITY_LOCKDOWN_LSM > > > make olddefconfig > > > make -j$(nproc) > > > qemu-system-x86_64 \ > > > -m 1G -smp 2 -nographic \ > > > -kernel arch/x86/boot/bzImage \ > > > -append "console=ttyS0,115200 kgdboc=ttyS0 > > > earlycon=uart8250,io,0x3f8 kgdboc_earlycon kgdbwait" > > > > Actually I realized there was a simpler reproduction (hinted at by > > the > > missing "printk: legacy bootconsole [uart8250] enabled" in the > > regressed > > case). It looks like the earlycon simply doesn't work and that > > means > > the > > reproduction doesn't require anything related to kgdb at all. > > Simply: > > > > make defconfig > > make -j$(nproc) > > qemu-system-x86_64 -m 1G -smp 2 -nographic -kernel > > arch/x86/boot/bzImage \ > > -append "earlycon=uart8250,io,0x3f8" > > > > With the part 3 patchset applied I get no output from the earlycon > > (without the patch set I get the early boot messages which, as > > expected, > > stop when tty0 comes up). > > Hi Daniel, sorry for the late reply! Lots of things to check lately > :) > > Ok, I reproduced here, thanks a lot for testing kgdboc, it's a quick > way to check that the new register_console_force is not working. Let > me > take a look to find what's wrong. Thanks a lot for finding this > issue!
Ok, I did a bisect and found out that the issue lies in the last commit, where CON_ENABLED was removed. After it, I then checked what was wrong, since everything was being plumbed correctly (tm), and then I found that it was not: On _register_console, the function try_enable_default_console is called when there are not registered consoles, and then it sets CON_ENABLED for the console. Later on, try_enable_preferred_console it checks if the console was specified by the user, and at the same time it had CON_ENABLED set. It worked by chance, but now, we don't have this flag anymore, and then we are not _marking_ the console on try_enable_default_console so try_enable_preferred_console returns ENOENT. I have added logs for both cases first the case with the patchset applied but the last one patch, and it works: $ vng --append "console=ttyS0,115200 earlyprintk=ttyS0,115200 kgdboc=ttyS0 earlycon=uart8250,io,0x3f8 kgdboc_earlycon kgdbwait" -- verbose Decompressing Linux... Parsing ELF... Performing relocations... done. Booting the kernel (entry_offset: 0x000000000450d530). XXX register_console earlyser XXX try_enable_default_console earlyser enabled XXX try_enable_preferred_console earlyser user_specified 1 returned - ENOENT XXX try_enable_preferred_console earlyser user_specified 0 returned 0 because flags was ENABLED ^^ here, returning 0 means that the console was accepted and will be registered XXX __register_console earlyser registered XXX register_console uart XXX try_enable_default_console uart enabled XXX try_enable_preferred_console uart user_specified 1 returned -ENOENT XXX try_enable_preferred_console uart user_specified 0 returned 0 because flags was ENABLED XXX __register_console uart registered ^^^^ same here Going to register kgdb with earlycon 'uart' Entering kdb (current=0x0000000000000000, pid 0) Now, the logs of the patchset with the last patch also applied: Decompressing Linux... Parsing ELF... Performing relocations... done. Booting the kernel (entry_offset: 0x000000000450d530). XXX register_console earlyser XXX try_enable_default_console earlyser enabled XXX try_enable_preferred_console earlyser user_specified 1 returned - ENOENT XXX try_enable_preferred_console earlyser user_specified 0 returned - ENOENT XXX register_console uart XXX try_enable_default_console uart enabled XXX try_enable_preferred_console uart user_specified 1 returned -ENOENT XXX try_enable_preferred_console uart user_specified 0 returned -ENOENT ^^^^ here, it should have registered the console XXX console_setup hvc0 XXX __add_preferred_console hvc added, idx 0 i 0 XXX console_setup ttyS0,115200 XXX __add_preferred_console ttyS added, idx 0 i 1 Poking KASLR using RDRAND RDTSC... XXX register_console tty XXX try_enable_preferred_console tty user_specified 1 returned -ENOENT XXX try_enable_preferred_console tty user_specified 0 returned -ENOENT ^^^ again, it fails because we don't flag the console with CON_ENABLED as before. XXX register_console hvc XXX register_console ttyS XXX try_enable_preferred_console ttyS user_specified 1 returned 0 with user specified XXX __register_console ttyS registered [ 0.000000] Linux version 6.18.0+ (mpdesouza@daedalus) (clang version 21.1.7, LLD 21.1.7) #374 SMP PREEMPT_RT Tue J an 13 21:08:34 -03 2026 reserved [ 0.000000] earlycon: uart8250 at I/O port 0x3f8 (options '') [ 0.000000] kgdboc: No suitable earlycon yet, will try later So, without any console kgdb is activated much later in the boot process, as you found it. I talked with Petr Mladek and it would need to rework the way that we register a console, and he's already working on it. For now I believe that we could take a look in all the patches besides the last one that currently breaks the earlycon with kgdb and maybe other usecases. Sorry for not catching this issue before. I'll use kgdb next time to make sure that it keeps working :)
