Skip to content

Commit 5e50082

Browse files
committed
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: 70210c0 ("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>
1 parent 331f229 commit 5e50082

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

arch/x86/kvm/vmx/sgx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ int handle_encls(struct kvm_vcpu *vcpu)
382382

383383
if (!encls_leaf_enabled_in_guest(vcpu, leaf)) {
384384
kvm_queue_exception(vcpu, UD_VECTOR);
385-
} else if (!sgx_enabled_in_guest_bios(vcpu)) {
385+
} else if (!sgx_enabled_in_guest_bios(vcpu) || !is_paging(vcpu)) {
386386
kvm_inject_gp(vcpu, 0);
387387
} else {
388388
if (leaf == ECREATE)

0 commit comments

Comments
 (0)