]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
KVM: VMX: Always reflect SGX EPCM #PFs back into the guest
authorSean Christopherson <seanjc@google.com>
Fri, 21 Nov 2025 22:20:18 +0000 (14:20 -0800)
committerSean Christopherson <seanjc@google.com>
Thu, 8 Jan 2026 18:51:46 +0000 (10:51 -0800)
commitff8071eb3aa54e96336ecce7c88b25f9a4d62383
treef8bedb7b54eff052578dd0e14d00f883f1ef7a75
parent9ace4753a5202b02191d54e9fdf7f9e3d02b85eb
KVM: VMX: Always reflect SGX EPCM #PFs back into the guest

When handling intercepted #PFs, reflect EPCM (Enclave Page Cache Map)
violations, i.e. #PFs with the SGX flag set, back into the guest.  KVM
doesn't shadow EPCM entries (the EPCM deals only with virtual/linear
addresses), and so EPCM violation cannot be due to KVM interference,
and more importantly can't be resolved by KVM.

On pre-SGX2 hardware, EPCM violations are delivered as #GP(0) faults, but
on SGX2+ hardware, they are delivered as #PF(SGX).  Failure to account for
the SGX2 behavior could put a vCPU into an infinite loop due to KVM not
realizing the #PF is the guest's responsibility.

Take care to deliver the EPCM violation as a #GP(0) if the _guest_ CPU
model is only SGX1.

Fixes: 72add915fbd5 ("KVM: VMX: Enable SGX virtualization for SGX1, SGX2 and LC")
Cc: Kai Huang <kai.huang@intel.com>
Reviewed-by: Richard Lyu <richard.lyu@suse.com>
Reviewed-by: Kai Huang <kai.huang@intel.com>
Link: https://patch.msgid.link/20251121222018.348987-1-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/vmx/vmx.c