• S
    x86/{cpufeatures,msr}: Add Intel SGX Launch Control hardware bits · d205e0f1
    Sean Christopherson 提交于
    The SGX Launch Control hardware helps restrict which enclaves the
    hardware will run.  Launch control is intended to restrict what software
    can run with enclave protections, which helps protect the overall system
    from bad enclaves.
    
    For the kernel's purposes, there are effectively two modes in which the
    launch control hardware can operate: rigid and flexible. In its rigid
    mode, an entity other than the kernel has ultimate authority over which
    enclaves can be run (firmware, Intel, etc...). In its flexible mode, the
    kernel has ultimate authority over which enclaves can run.
    
    Enable X86_FEATURE_SGX_LC to enumerate when the CPU supports SGX Launch
    Control in general.
    
    Add MSR_IA32_SGXLEPUBKEYHASH{0, 1, 2, 3}, which when combined contain a
    SHA256 hash of a 3072-bit RSA public key. The hardware allows SGX enclaves
    signed with this public key to initialize and run [*]. Enclaves not signed
    with this key can not initialize and run.
    
    Add FEAT_CTL_SGX_LC_ENABLED, which informs whether the SGXLEPUBKEYHASH MSRs
    can be written by the kernel.
    
    If the MSRs do not exist or are read-only, the launch control hardware is
    operating in rigid mode. Linux does not and will not support creating
    enclaves when hardware is configured in rigid mode because it takes away
    the authority for launch decisions from the kernel. Note, this does not
    preclude KVM from virtualizing/exposing SGX to a KVM guest when launch
    control hardware is operating in rigid mode.
    
    [*] Intel SDM: 38.1.4 Intel SGX Launch Control Configuration
    Signed-off-by: NSean Christopherson <sean.j.christopherson@intel.com>
    Co-developed-by: NJarkko Sakkinen <jarkko@kernel.org>
    Signed-off-by: NJarkko Sakkinen <jarkko@kernel.org>
    Signed-off-by: NBorislav Petkov <bp@suse.de>
    Acked-by: NJethro Beekman <jethro@fortanix.com>
    Link: https://lkml.kernel.org/r/20201112220135.165028-5-jarkko@kernel.org
    d205e0f1
cpufeatures.h 26.6 KB