Messages in this thread | | | From | Thomas Gleixner <> | Subject | Re: [PATCH v10 03/11] x86/cpufeatures: Add TDX Guest CPU feature | Date | Wed, 13 Oct 2021 23:25:35 +0200 |
| |
On Wed, Oct 13 2021 at 23:07, Borislav Petkov wrote: > On Wed, Oct 13, 2021 at 10:44:37PM +0200, Thomas Gleixner wrote: >> No. This is tasteless garbage, really. >> >> tdx_early_init() is invoked from x86_64_start_kernel() very early in the >> boot process __before__ is_tdx_guest() is invoked. >> >> So why on earth is it requried to keep those conditionals and cpuid() >> muck around after init? > > Yah, reportedly, they wanna parse cmdline options so it has to be after > copy_bootdata() but copy_bootdata() has a cc_platform_has() call which > ends up in is_tdx_guest() on Intel and there you have the catch 22 > because CPUID hasn't happened yet in tdx_early_init().
Seriously?
So this ends up in doing:
use(); init();
Can you spot what's wrong with that?
That's a clear violation of common sense and is simply not going to happen. Why? If you think about deep defensive programming then use() will look like this:
use() { assert(initialized); }
which is not something made up. It's a fundamental principle of programming and some languages enforce that for very good reasons.
Just because it can be done in C is no justification.
What's wrong with:
x86_64_start_kernel()
tdx_early_init();
copy_bootdata(); tdx_late_init();
Absolutely nothing. It's clear, simple and well defined.
Thanks,
tglx
| |