All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jim Mattson <jmattson@google.com>
To: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: Krish Sadhukhan <krish.sadhukhan@oracle.com>,
	kvm list <kvm@vger.kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH 1/2 v2] KVM: nVMX: KVM needs to unset "unrestricted guest" VM-execution control in vmcs02 if vmcs12 doesn't set it
Date: Wed, 15 Apr 2020 13:18:00 -0700	[thread overview]
Message-ID: <CALMp9eRvZEzi3Ug0fL=ekMS_Weni6npwW+bXrJZjU8iLrppwEg@mail.gmail.com> (raw)
In-Reply-To: <20200415193016.GF30627@linux.intel.com>

On Wed, Apr 15, 2020 at 12:30 PM Sean Christopherson
<sean.j.christopherson@intel.com> wrote:
>
> On Wed, Apr 15, 2020 at 02:30:46PM -0400, Krish Sadhukhan wrote:
> > Currently, prepare_vmcs02_early() does not check if the "unrestricted guest"
> > VM-execution control in vmcs12 is turned off and leaves the corresponding
> > bit on in vmcs02. Due to this setting, vmentry checks which are supposed to
> > render the nested guest state as invalid when this VM-execution control is
> > not set, are passing in hardware.
> >
> > This patch turns off the "unrestricted guest" VM-execution control in vmcs02
> > if vmcs12 has turned it off.
> >
> > Suggested-by: Jim Mattson <jmattson@google.com>
> > Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
> > ---
> >  arch/x86/kvm/vmx/nested.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> > index cbc9ea2de28f..4fa5f8b51c82 100644
> > --- a/arch/x86/kvm/vmx/nested.c
> > +++ b/arch/x86/kvm/vmx/nested.c
> > @@ -2224,6 +2224,9 @@ static void prepare_vmcs02_early(struct vcpu_vmx *vmx, struct vmcs12 *vmcs12)
> >                       vmcs_write16(GUEST_INTR_STATUS,
> >                               vmcs12->guest_intr_status);
> >
> > +             if (!nested_cpu_has2(vmcs12, SECONDARY_EXEC_UNRESTRICTED_GUEST))
> > +                     exec_control &= ~SECONDARY_EXEC_UNRESTRICTED_GUEST;

Better, I think, would be to add SECONDARY_EXEC_UNRESTRICTED_GUEST to
the mask here:

/* Take the following fields only from vmcs12 */
exec_control &= ~(SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES |
  SECONDARY_EXEC_ENABLE_INVPCID |
  SECONDARY_EXEC_RDTSCP |
  SECONDARY_EXEC_XSAVES |
  SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE |
  SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY |
  SECONDARY_EXEC_APIC_REGISTER_VIRT |
  SECONDARY_EXEC_ENABLE_VMFUNC);

> Has anyone worked through all the flows to verify this won't break any
> assumptions with respect to enable_unrestricted_guest?  I would be
> (pleasantly) surprised if this was sufficient to run L2 without
> unrestricted guest when it's enabled for L1, e.g. vmx_set_cr0() looks
> suspect.

I think you're right to be concerned.

  reply	other threads:[~2020-04-15 20:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-15 18:30 [PATCH 0/2 v2] kvm-unit-test: nVMX: Test Selector and Base Address fields of Guest Segment registers Krish Sadhukhan
2020-04-15 18:30 ` [PATCH 1/2 v2] KVM: nVMX: KVM needs to unset "unrestricted guest" VM-execution control in vmcs02 if vmcs12 doesn't set it Krish Sadhukhan
2020-04-15 19:30   ` Sean Christopherson
2020-04-15 20:18     ` Jim Mattson [this message]
2020-04-16  9:18       ` Paolo Bonzini
2020-04-18  1:29         ` Krish Sadhukhan
2020-04-18  1:55           ` Sean Christopherson
2020-04-18  9:53             ` Paolo Bonzini
2020-04-20 15:12               ` Sean Christopherson
2020-04-28  7:25               ` Krish Sadhukhan
2020-04-28  8:14                 ` Paolo Bonzini
2020-04-28 17:38                   ` Krish Sadhukhan
2020-04-28 18:00                     ` Jim Mattson
2020-04-15 18:30 ` [PATCH 2/2 v2] kvm-unit-tests: nVMX: Test Selector and Base Address fields of Guest Segment Registers on vmentry of nested guests Krish Sadhukhan

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='CALMp9eRvZEzi3Ug0fL=ekMS_Weni6npwW+bXrJZjU8iLrppwEg@mail.gmail.com' \
    --to=jmattson@google.com \
    --cc=krish.sadhukhan@oracle.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=sean.j.christopherson@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.