Re: [PATCH v8 0/3] x86/earlyprintk: setup serial earlyprintk as early as possible

From: Alexander Kuleshov
Date: Tue Jun 02 2015 - 07:26:14 EST


2015-05-29 22:55 GMT+06:00 Borislav Petkov <bp@xxxxxxx>:
>
> You can boot with "ignore_loglevel" to see that message. Provided
> ignore_loglevel is even parsed that early.
>

But ignore_loglevel is early_param too...

>
> Yes, I meant a testing patch which is used only for testing and which
> issues a bunch of early_printk() calls.
>

Maybe I just remove 'if' clause and just leave:

early_printk("Early printk is initialized\n");

In the arch/x86/kernel/head{32,64}.c? Call of the early_printk
is safe here, even earlyprintk is not enabled and it must
be good for testing this patchset.

> But, before you do that, your patchset has more problems. Booting in
> qemu+kvm gives this:
>
> early console in setup code
> early console in decompress_kernel
>
> Decompressing Linux... Parsing ELF... done.
> Booting the kernel.
> [ 0.000000] bootconsole [earlyser0] enabled
> [ 0.000000] ERROR: earlyprintk= earlyser already used
> ^^^^^^

Yes, thanks. This is because we go though a buffer in a loop
and after the earlyprintk=ttyS0, it finds console=ttyS0. So,
I think we can add additional check, something like this:

if (!strncmp(buf, "serial", 6) &&
early_serial_console.index == -1) {
...
...
...
}

and for the "ttyS...". Just tested it and it works without
"ERROR: earlyprintk= earlyser already used".

>
> [ 0.000000] per task-struct memory footprint: 2688 bytes
> [ 0.000000] WARNING: lockdep init error! lock-(console_sem).lock was acquiredbefore lockdep_init
> [ 0.000000] Call stack leading to lockdep invocation was:
> [ 0.000000] [<ffffffff81013f0f>] save_stack_trace+0x2f/0x50
> [ 0.000000] [<ffffffff810a364c>] __lock_acquire+0xa2c/0xf00
> [ 0.000000] [<ffffffff810a440b>] lock_acquire+0xdb/0x2b0
> [ 0.000000] [<ffffffff81676b33>] _raw_spin_lock_irqsave+0x53/0x90
> [ 0.000000] [<ffffffff8109b146>] down+0x16/0x50
> [ 0.000000] [<ffffffff810b4d49>] console_lock+0x19/0x60
> [ 0.000000] [<ffffffff810b78e6>] register_console+0x116/0x350
> [ 0.000000] [<ffffffff81c36162>] setup_early_printk+0x165/0x467
> [ 0.000000] [<ffffffff81c364ba>] setup_early_serial_console+0x56/0x58
> [ 0.000000] [<ffffffff81c24565>] x86_64_start_kernel+0xce/0x110
> [ 0.000000] [<ffffffffffffffff>] 0xffffffffffffffff
> [ 0.000000] ------------------------
>
> This last one shows that you'd need to look into lockdep first. It also
> shows that early boot order is pretty fragile so one has to be very
> careful when changing stuff there.
>

What if I add call of the lockdep_init before the setup_early_serial_console?
It must be safe because there is check in the lockdep_init:

if (lockdep_initialized)
return;

and some architectures (powerpc, microblaze, s390) already do it in
the same way.

What do you think about it?

Thank you.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/