Re: gcc-10: kernel stack is corrupted and fails to boot
From: Linus Torvalds
Date: Wed May 13 2020 - 19:14:20 EST
On Wed, May 13, 2020 at 3:20 PM Borislav Petkov <bp@xxxxxxx> wrote:
>
> Linus, shout if you'd prefer only the last three commits there:
>
> 950a37078aa0 x86/build: Use $(CONFIG_SHELL)
> f670269a42bf x86: Fix early boot crash on gcc-10, next try
> 73da86741e7f x86/build: Check whether the compiler is sane
Do we really need that sanity check?
Are there known compilers that fail that check? Because honestly, that
sounds unlikely to me to begin with, but if it does happen then that
just means that the prevent_tail_call_optimization() thing is broken.
The check itself doesn't seem worth it. If your worry is that an empty
asm() can be optimized away, then don't use an empty asm!
In other words, the only reason for that check seems to be a worry
that simply isn't worth having.
In fact, I think the check is wrong anyway, since the main thing I can
see that would do a tailcall despite the empty asm is link-time
optimizations that that check doesn't even check for!
So everything I see there just screams "the check is bogus" to me. The
check doesn't work, and if it were to work it only means that the
prevent_tail_call_optimization() thing is too fragile.
Just put a full memory barrier in there, with an actual "mfence"
instruction or whatever, so that you know that the check is pointless,
and so that you know that a link-time optimizer can't turn the
call+return into a tailcall.
Don't send me the broken check.
Linus