Re: [PATCH v7 02/10] x86/tdx: Add early_is_tdx_guest() interface

Thomas Gleixner
2021-10-17T19:28:45Z

On Tue, Oct 05 2021 at 13:41, Kuppuswamy Sathyanarayanan wrote:
> +
> +#define TDX_CPUID_LEAF_ID 0x21
> +
> +static int tdx_guest = -1;
> +
> +static inline bool early_cpuid_has_tdx_guest(void)
> +{
> + u32 eax = TDX_CPUID_LEAF_ID, sig[3] = {0};
> +
> + if (cpuid_eax(0) < TDX_CPUID_LEAF_ID)
> + return false;
> +
> + cpuid_count(TDX_CPUID_LEAF_ID, 0, &eax, &sig[0], &sig[2], &sig[1]);
> +
> + return !memcmp("IntelTDX ", sig, 12);
> +}
> +
> +bool early_is_tdx_guest(void)
> +{
> + if (tdx_guest < 0)
> + tdx_guest = early_cpuid_has_tdx_guest();
> +
> + return !!tdx_guest;
> +}

Sigh.