[0/2] KVM: VMX: Fixes for faults on ENCLS emulation

Message ID 20230405234556.696927-1-seanjc@google.com
Headers
Series KVM: VMX: Fixes for faults on ENCLS emulation |

Message

Sean Christopherson April 5, 2023, 11:45 p.m. UTC
  Found-by-inspection (when reviewing Binbin's patch) fixes for incorrect
emulation of faults when KVMintercepts and emulates (sort of) ENCLS.

Very much compile tested only.  Ideally, someone with SGX hardware can
confirm that these patches are correct, e.g. my assessment that KVM needs
to manually check CR0.PG is based purely of SDM pseudocode.

Sean Christopherson (2):
  KVM: VMX: Inject #GP on ENCLS if vCPU has paging disabled (CR0.PG==0)
  KVM: VMX: Inject #GP, not #UD, if SGX2 ENCLS leafs are unsupported

 arch/x86/kvm/vmx/sgx.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)


base-commit: 27d6845d258b67f4eb3debe062b7dacc67e0c393
  

Comments

Kai Huang April 6, 2023, 9:19 a.m. UTC | #1
On Wed, 2023-04-05 at 16:45 -0700, Sean Christopherson wrote:
> Found-by-inspection (when reviewing Binbin's patch) fixes for incorrect
> emulation of faults when KVMintercepts and emulates (sort of) ENCLS.
> 
> Very much compile tested only.  Ideally, someone with SGX hardware can
> confirm that these patches are correct, e.g. my assessment that KVM needs
> to manually check CR0.PG is based purely of SDM pseudocode.

Thanks for the patches.  I don't have a "ready" SGX environment at hand, but
I'll try to test or ask someone else to test after Easter holiday.

> 
> Sean Christopherson (2):
>   KVM: VMX: Inject #GP on ENCLS if vCPU has paging disabled (CR0.PG==0)
>   KVM: VMX: Inject #GP, not #UD, if SGX2 ENCLS leafs are unsupported
> 
>  arch/x86/kvm/vmx/sgx.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> 
> base-commit: 27d6845d258b67f4eb3debe062b7dacc67e0c393
> -- 
> 2.40.0.348.gf938b09366-goog
>
  
Sean Christopherson June 3, 2023, 12:55 a.m. UTC | #2
On Wed, 05 Apr 2023 16:45:54 -0700, Sean Christopherson wrote:
> Found-by-inspection (when reviewing Binbin's patch) fixes for incorrect
> emulation of faults when KVMintercepts and emulates (sort of) ENCLS.
> 
> Very much compile tested only.  Ideally, someone with SGX hardware can
> confirm that these patches are correct, e.g. my assessment that KVM needs
> to manually check CR0.PG is based purely of SDM pseudocode.
> 
> [...]

Applied to kvm-x86 vmx, thanks!

[1/2] KVM: VMX: Inject #GP on ENCLS if vCPU has paging disabled (CR0.PG==0)
      https://github.com/kvm-x86/linux/commit/5e50082c8c21
[2/2] KVM: VMX: Inject #GP, not #UD, if SGX2 ENCLS leafs are unsupported
      https://github.com/kvm-x86/linux/commit/c3a1e119a343

--
https://github.com/kvm-x86/linux/tree/next
https://github.com/kvm-x86/linux/tree/fixes