lkml.org 
[lkml]   [2021]   [Jul]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH v3 03/11] x86/cpufeatures: Add TDX Guest CPU feature
    From
    Date
    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");
    > +}
    >

    \
     
     \ /
      Last update: 2021-07-15 13:57    [W:4.181 / U:0.072 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site