• Sean Christopherson's avatar
    KVM: VMX: Add ENCLS[EINIT] handler to support SGX Launch Control (LC) · b6f084ca
    Sean Christopherson authored
    Add a VM-Exit handler to trap-and-execute EINIT when SGX LC is enabled
    in the host.  When SGX LC is enabled, the host kernel may rewrite the
    hardware values at will, e.g. to launch enclaves with different signers,
    thus KVM needs to intercept EINIT to ensure it is executed with the
    correct LE hash (even if the guest sees a hardwired hash).
    
    Switching the LE hash MSRs on VM-Enter/VM-Exit is not a viable option as
    writing the MSRs is prohibitively expensive, e.g. on SKL hardware each
    WRMSR is ~400 cycles.  And because EINIT takes tens of thousands of
    cycles to execute, the ~1500 cycle overhead to trap-and-execute EINIT is
    unlikely to be noticed by the guest, let alone impact its overall SGX
    performance.
    Signed-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
    Signed-off-by: default avatarKai Huang <kai.huang@intel.com>
    Message-Id: <57c92fa4d2083eb3be9e6355e3882fc90cffea87.1618196135.git.kai.huang@intel.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    b6f084ca
sgx.c 12.4 KB