From: Yu Zhang <yu.c.zhang@linux.intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: seanjc@google.com, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, vkuznets@redhat.com,
wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org
Subject: Re: [PATCH v2] KVM: x86/MMU: Do not check unsync status for root SP.
Date: Tue, 9 Feb 2021 16:53:03 +0800 [thread overview]
Message-ID: <20210209085303.kamlf4zc47ut6utp@linux.intel.com> (raw)
In-Reply-To: <6ca2d73c-703a-9964-48ae-e3d910bebc48@redhat.com>
On Tue, Feb 09, 2021 at 08:46:42AM +0100, Paolo Bonzini wrote:
> On 09/02/21 04:33, Yu Zhang wrote:
> > On Mon, Feb 08, 2021 at 05:47:22PM +0100, Paolo Bonzini wrote:
> > > On 08/02/21 14:49, Yu Zhang wrote:
> > > > On Mon, Feb 08, 2021 at 12:36:57PM +0100, Paolo Bonzini wrote:
> > > > > On 07/02/21 13:22, Yu Zhang wrote:
> > > > > > In shadow page table, only leaf SPs may be marked as unsync.
> > > > > > And for non-leaf SPs, we use unsync_children to keep the number
> > > > > > of the unsynced children. In kvm_mmu_sync_root(), sp->unsync
> > > > > > shall always be zero for the root SP, , hence no need to check
> > > > > > it. Instead, a warning inside mmu_sync_children() is added, in
> > > > > > case someone incorrectly used it.
> > > > > >
> > > > > > Also, clarify the mmu_need_write_protect(), by moving the warning
> > > > > > into kvm_unsync_page().
> > > > > >
> > > > > > Signed-off-by: Yu Zhang <yu.c.zhang@linux.intel.com>
> > > > > > Signed-off-by: Sean Christopherson <seanjc@google.com>
> > > > >
> > > > > This should really be more of a Co-developed-by, and there are a couple
> > > > > adjustments that could be made in the commit message. I've queued the patch
> > > > > and I'll fix it up later.
> > > >
> > > > Indeed. Thanks for the remind, and I'll pay attention in the future. :)
> > >
> > > Also:
> > >
> > > arch/x86/kvm/mmu/mmu.c: In function ‘mmu_sync_children’:
> > > arch/x86/kvm/mmu/mmu.c:2002:17: error: ‘sp’ is used uninitialized in this
> > > function [-Werror=uninitialized]
> > > WARN_ON_ONCE(sp->unsync);
> >
> > Oops. This is wrong. Should be WARN_ON_ONCE(parent->unsync);
> >
> > >
> > > so how was this tested?
> > >
> >
> > I ran access test in kvm-unit-test for previous version, which hasn't
> > this code(also in my local repo "enable_ept" was explicitly set to
> > 0 in order to test the shadow mode). But I did not test this one. I'm
> > truely sorry for the negligence - even trying to compile should make
> > this happen!
> >
> > Should we submit another version? Any suggestions on the test cases?
>
> Yes, please send v3.
>
> The commit message can be:
>
> In shadow page table, only leaf SPs may be marked as unsync; instead, for
> non-leaf SPs, we store the number of unsynced children in unsync_children.
> Therefore, in kvm_mmu_sync_root(), sp->unsync
> shall always be zero for the root SP and there is no need to check
> it. Remove the check, and add a warning inside mmu_sync_children() to
> assert that the flags are used properly.
>
> While at it, move the warning from mmu_need_write_protect() to
> kvm_unsync_page().
Thanks Paolo. Will send out v3.
BTW, I just realized that mmu_sync_children() was not triggered by
kvm-unit-test(the access.flat case), so I ran another test by running
a regular VM using shadow, in which I witnessed the synchronization.
B.R.
Yu
>
> Paolo
>
prev parent reply other threads:[~2021-02-09 8:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-07 12:22 [PATCH v2] KVM: x86/MMU: Do not check unsync status for root SP Yu Zhang
2021-02-08 11:36 ` Paolo Bonzini
2021-02-08 13:49 ` Yu Zhang
2021-02-08 16:47 ` Paolo Bonzini
2021-02-09 3:33 ` Yu Zhang
2021-02-09 7:46 ` Paolo Bonzini
2021-02-09 8:53 ` Yu Zhang [this message]
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=20210209085303.kamlf4zc47ut6utp@linux.intel.com \
--to=yu.c.zhang@linux.intel.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.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