mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Huang, Kai" <kai.huang@intel.com>
To: "pbonzini@redhat.com" <pbonzini@redhat.com>, "Christopherson,,
	Sean" <seanjc@google.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"binbin.wu@linux.intel.com" <binbin.wu@linux.intel.com>
Subject: Re: [PATCH 1/2] KVM: VMX: Inject #GP on ENCLS if vCPU has paging disabled (CR0.PG==0)
Date: Thu, 6 Apr 2023 08:54:52 +0000	[thread overview]
Message-ID: <082ff217ecb7633ef4c1363bfd27a20f8afcbe0c.camel@intel.com> (raw)
In-Reply-To: <20230405234556.696927-2-seanjc@google.com>

On Wed, 2023-04-05 at 16:45 -0700, Sean Christopherson wrote:
> 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>
> Signed-off-by: Sean Christopherson <seanjc@google.com>

Reviewed-by: Kai Huang <kai.huang@intel.com>

> ---
>  arch/x86/kvm/vmx/sgx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/vmx/sgx.c b/arch/x86/kvm/vmx/sgx.c
> index aa53c98034bf..f881f6ff6408 100644
> --- a/arch/x86/kvm/vmx/sgx.c
> +++ b/arch/x86/kvm/vmx/sgx.c
> @@ -375,7 +375,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)
> -- 
> 2.40.0.348.gf938b09366-goog
> 


  reply	other threads:[~2023-04-06  8:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-05 23:45 [PATCH 0/2] KVM: VMX: Fixes for faults on ENCLS emulation Sean Christopherson
2023-04-05 23:45 ` [PATCH 1/2] KVM: VMX: Inject #GP on ENCLS if vCPU has paging disabled (CR0.PG==0) Sean Christopherson
2023-04-06  8:54   ` Huang, Kai [this message]
2023-04-21  9:18     ` Huang, Kai
2023-04-05 23:45 ` [PATCH 2/2] KVM: VMX: Inject #GP, not #UD, if SGX2 ENCLS leafs are unsupported Sean Christopherson
2023-04-06  9:17   ` Huang, Kai
2023-04-06 18:00     ` Sean Christopherson
2023-04-12 11:15       ` Huang, Kai
2023-04-12 14:38         ` Sean Christopherson
2023-04-12 22:28           ` Huang, Kai
2023-04-21  9:17         ` Huang, Kai
2023-04-06  9:19 ` [PATCH 0/2] KVM: VMX: Fixes for faults on ENCLS emulation Huang, Kai
2023-06-03  0:55 ` Sean Christopherson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=082ff217ecb7633ef4c1363bfd27a20f8afcbe0c.camel@intel.com \
    --to=kai.huang@intel.com \
    --cc=binbin.wu@linux.intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®