diff options
author | Sean Christopherson <seanjc@google.com> | 2023-04-05 16:45:55 -0700 |
---|---|---|
committer | Sean Christopherson <seanjc@google.com> | 2023-06-02 10:10:54 -0700 |
commit | 5e50082c8c21cd32ef21f523c149939668954ab6 (patch) | |
tree | 01f355575fa5f06247878d1955c99cbc336aea40 /arch/x86/kvm/vmx/sgx.c | |
parent | 331f229768160dceec5b5694ea32ecf66e2e2452 (diff) | |
download | lwn-5e50082c8c21cd32ef21f523c149939668954ab6.tar.gz lwn-5e50082c8c21cd32ef21f523c149939668954ab6.zip |
KVM: VMX: Inject #GP on ENCLS if vCPU has paging disabled (CR0.PG==0)
Inject a #GP when emulating/forwarding a valid ENCLS leaf if the vCPU has
paging disabled, e.g. if KVM is intercepting ECREATE to enforce additional
restrictions. The pseudocode in the SDM lists all #GP triggers, including
CR0.PG=0, as being checked after the ENLCS-exiting checks, i.e. the
VM-Exit will occur before the CPU performs the CR0.PG check.
Fixes: 70210c044b4e ("KVM: VMX: Add SGX ENCLS[ECREATE] handler to enforce CPUID restrictions")
Cc: Binbin Wu <binbin.wu@linux.intel.com>
Cc: Kai Huang <kai.huang@intel.com>
Tested-by: Kai Huang <kai.huang@intel.com>
Reviewed-by: Kai Huang <kai.huang@intel.com>
Link: https://lore.kernel.org/r/20230405234556.696927-2-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'arch/x86/kvm/vmx/sgx.c')
-rw-r--r-- | arch/x86/kvm/vmx/sgx.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/x86/kvm/vmx/sgx.c b/arch/x86/kvm/vmx/sgx.c index 2261b684a7d4..137088a663ff 100644 --- a/arch/x86/kvm/vmx/sgx.c +++ b/arch/x86/kvm/vmx/sgx.c @@ -382,7 +382,7 @@ int handle_encls(struct kvm_vcpu *vcpu) if (!encls_leaf_enabled_in_guest(vcpu, leaf)) { kvm_queue_exception(vcpu, UD_VECTOR); - } else if (!sgx_enabled_in_guest_bios(vcpu)) { + } else if (!sgx_enabled_in_guest_bios(vcpu) || !is_paging(vcpu)) { kvm_inject_gp(vcpu, 0); } else { if (leaf == ECREATE) |