From: Jim Mattson <jmattson@google.com>
To: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
"Vitaly Kuznetsov" <vkuznets@redhat.com>,
"Wanpeng Li" <wanpengli@tencent.com>,
"Joerg Roedel" <joro@8bytes.org>,
"kvm list" <kvm@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
"Reto Buerki" <reet@codelabs.ch>,
"Liran Alon" <liran.alon@oracle.com>
Subject: Re: [PATCH v2 1/8] KVM: nVMX: Always write vmcs02.GUEST_CR3 during nested VM-Enter
Date: Fri, 27 Sep 2019 16:37:25 -0700 [thread overview]
Message-ID: <CALMp9eQ5M+GPyxo_9aNdaUZfwZLZcxdtmQKCo1JjnAL-Jdh4-w@mail.gmail.com> (raw)
In-Reply-To: <20190927214523.3376-2-sean.j.christopherson@intel.com>
On Fri, Sep 27, 2019 at 2:45 PM Sean Christopherson
<sean.j.christopherson@intel.com> wrote:
>
> Write the desired L2 CR3 into vmcs02.GUEST_CR3 during nested VM-Enter
> instead of deferring the VMWRITE until vmx_set_cr3(). If the VMWRITE
> is deferred, then KVM can consume a stale vmcs02.GUEST_CR3 when it
> refreshes vmcs12->guest_cr3 during nested_vmx_vmexit() if the emulated
> VM-Exit occurs without actually entering L2, e.g. if the nested run
> is squashed because nested VM-Enter (from L1) is putting L2 into HLT.
>
> Note, the above scenario can occur regardless of whether L1 is
> intercepting HLT, e.g. L1 can intercept HLT and then re-enter L2 with
> vmcs.GUEST_ACTIVITY_STATE=HALTED. But practically speaking, a VMM will
> likely put a guest into HALTED if and only if it's not intercepting HLT.
>
> In an ideal world where EPT *requires* unrestricted guest (and vice
> versa), VMX could handle CR3 similar to how it handles RSP and RIP,
> e.g. mark CR3 dirty and conditionally load it at vmx_vcpu_run(). But
> the unrestricted guest silliness complicates the dirty tracking logic
> to the point that explicitly handling vmcs02.GUEST_CR3 during nested
> VM-Enter is a simpler overall implementation.
>
> Cc: stable@vger.kernel.org
> Reported-and-tested-by: Reto Buerki <reet@codelabs.ch>
> Tested-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> Reviewed-by: Liran Alon <liran.alon@oracle.com>
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Reviewed-by: Jim Mattson <jmattson@google.com>
next prev parent reply other threads:[~2019-09-27 23:37 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-27 21:45 [PATCH v2 0/8] KVM: x86: nVMX GUEST_CR3 bug fix, and then some Sean Christopherson
2019-09-27 21:45 ` [PATCH v2 1/8] KVM: nVMX: Always write vmcs02.GUEST_CR3 during nested VM-Enter Sean Christopherson
2019-09-27 23:37 ` Jim Mattson [this message]
2019-09-27 21:45 ` [PATCH v2 2/8] KVM: VMX: Skip GUEST_CR3 VMREAD+VMWRITE if the VMCS is up-to-date Sean Christopherson
2019-09-27 21:45 ` [PATCH v2 3/8] KVM: VMX: Consolidate to_vmx() usage in RFLAGS accessors Sean Christopherson
2019-09-30 8:48 ` Vitaly Kuznetsov
2019-09-27 21:45 ` [PATCH v2 4/8] KVM: VMX: Optimize vmx_set_rflags() for unrestricted guest Sean Christopherson
2019-09-30 8:57 ` Vitaly Kuznetsov
2019-09-30 15:19 ` Sean Christopherson
2019-09-30 15:55 ` Vitaly Kuznetsov
2019-10-09 10:40 ` Paolo Bonzini
2019-10-09 16:38 ` Sean Christopherson
2019-10-09 20:59 ` Paolo Bonzini
2019-10-09 21:30 ` Sean Christopherson
2019-09-27 21:45 ` [PATCH v2 5/8] KVM: x86: Add WARNs to detect out-of-bounds register indices Sean Christopherson
2019-09-30 9:19 ` Vitaly Kuznetsov
2019-10-09 10:50 ` Paolo Bonzini
2019-10-09 16:36 ` Sean Christopherson
2019-09-27 21:45 ` [PATCH v2 6/8] KVM: x86: Fold 'enum kvm_ex_reg' definitions into 'enum kvm_reg' Sean Christopherson
2019-09-30 9:25 ` Vitaly Kuznetsov
2019-10-09 10:52 ` Paolo Bonzini
2019-10-09 11:27 ` Vitaly Kuznetsov
2019-09-27 21:45 ` [PATCH v2 7/8] KVM: x86: Add helpers to test/mark reg availability and dirtiness Sean Christopherson
2019-09-30 9:32 ` Vitaly Kuznetsov
2019-10-09 11:00 ` Paolo Bonzini
2019-09-27 21:45 ` [PATCH v2 8/8] KVM: x86: Fold decache_cr3() into cache_reg() Sean Christopherson
2019-09-30 10:58 ` Vitaly Kuznetsov
2019-09-30 15:04 ` Sean Christopherson
2019-09-30 15:27 ` Vitaly Kuznetsov
2019-09-30 15:33 ` Sean Christopherson
2019-10-09 11:03 ` Paolo Bonzini
2019-09-30 10:42 ` [PATCH v2 0/8] KVM: x86: nVMX GUEST_CR3 bug fix, and then some Reto Buerki
2019-10-29 15:03 ` Martin Lucina
2019-10-30 9:09 ` 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=CALMp9eQ5M+GPyxo_9aNdaUZfwZLZcxdtmQKCo1JjnAL-Jdh4-w@mail.gmail.com \
--to=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liran.alon@oracle.com \
--cc=pbonzini@redhat.com \
--cc=reet@codelabs.ch \
--cc=rkrcmar@redhat.com \
--cc=sean.j.christopherson@intel.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.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;
as well as URLs for NNTP newsgroup(s).