• Sean Christopherson's avatar
    x86/cpu/intel: Detect SGX support · 224ab352
    Sean Christopherson authored
    Kernel support for SGX is ultimately decided by the state of the launch
    control bits in the feature control MSR (MSR_IA32_FEAT_CTL).  If the
    hardware supports SGX, but neglects to support flexible launch control, the
    kernel will not enable SGX.
    
    Enable SGX at feature control MSR initialization and update the associated
    X86_FEATURE flags accordingly.  Disable X86_FEATURE_SGX (and all
    derivatives) if the kernel is not able to establish itself as the authority
    over SGX Launch Control.
    
    All checks are performed for each logical CPU (not just boot CPU) in order
    to verify that MSR_IA32_FEATURE_CONTROL is correctly configured on all
    CPUs. All SGX code in this series expects the same configuration from all
    CPUs.
    
    This differs from VMX where X86_FEATURE_VMX is intentionally cleared only
    for the current CPU so that KVM can provide additional information if KVM
    fails to load like which CPU doesn't support VMX.  There’s not much the
    kernel or an administrator can do to fix the situation, so SGX neglects to
    convey additional details about these kinds of failures if they occur.
    Signed-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
    Co-developed-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
    Signed-off-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
    Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
    Acked-by: default avatarJethro Beekman <jethro@fortanix.com>
    Link: https://lkml.kernel.org/r/20201112220135.165028-8-jarkko@kernel.org
    224ab352
feat_ctl.c 5.21 KB