Re: [PATCH v10 03/11] x86/cpufeatures: Add TDX Guest CPU feature

From: Thomas Gleixner
Date: Wed Oct 13 2021 - 17:35:54 EST


Sathyanarayanan,

On Wed, Oct 13 2021 at 14:05, Sathyanarayanan Kuppuswamy wrote:
> On 10/13/21 1:44 PM, Thomas Gleixner wrote:
>> 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?
>
> is_tdx_guest() is also used by cc_platform_has() API. Please check
> the following patch [1]. cc_platform_has() will be called much earlier
> than x86_64_start_kernel() (like __startup_64() [2]).

That's just fundamentally wrong as I pointed out to Borislav already.

AMD has done it the right way.

__startup_64()
sme_enable()

x86_64_start_kernel()
sme_early_init()
copy_bootdata()
...

It's not that hard and we are not going to make this fundamentally
different just because Intel.

Thanks,

tglx