Messages in this thread | | | Subject | Re: [PATCH v3 03/11] x86/cpufeatures: Add TDX Guest CPU feature | From | Xiaoyao Li <> | Date | Thu, 15 Jul 2021 19:56:32 +0800 |
| |
On 6/19/2021 6:57 AM, Kuppuswamy Sathyanarayanan wrote: > Add CPU feature detection for Trusted Domain Extensions support. TDX > feature adds capabilities to keep guest register state and memory > isolated from hypervisor. > > For TDX guest platforms, executing CPUID(eax=0x21, ecx=0) will return > following values in EAX, EBX, ECX and EDX. > > EAX: Maximum sub-leaf number: 0 > EBX/EDX/ECX: Vendor string: > > EBX = "Inte" > EDX = "lTDX" > ECX = " " > > So when above condition is true, set X86_FEATURE_TDX_GUEST feature cap > bit. >
...
> +static inline bool cpuid_has_tdx_guest(void) > +{ > + u32 eax, sig[3]; > + > + if (cpuid_eax(0) < TDX_CPUID_LEAF_ID) > + return false; > + > + cpuid_count(TDX_CPUID_LEAF_ID, 0, &eax, &sig[0], &sig[1], &sig[2]);
As change log describes, EBX + EDX + ECX is "IntelTDX ", not EBX + ECX + EDX. So it should be
cpuid_count(TDX_CPUID_LEAF_ID, 0, &eax, &sig[0], &sig[2], &sig[1]);
Please also correct early_cpuid_has_tdx_guest()
> + > + return !memcmp("IntelTDX ", sig, 12); > +} > + > +void __init tdx_early_init(void) > +{ > + if (!cpuid_has_tdx_guest()) > + return; > + > + setup_force_cpu_cap(X86_FEATURE_TDX_GUEST); > + > + pr_info("Guest initialized\n"); > +} >
| |