From: Sean Christopherson <seanjc@google.com>
To: Yan Zhao <yan.y.zhao@intel.com>
Cc: pbonzini@redhat.com, rick.p.edgecombe@intel.com,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH 2/4] KVM: x86/tdp_mmu: Merge the prefetch into the is_access_allowed() check
Date: Mon, 10 Feb 2025 14:17:05 -0800 [thread overview]
Message-ID: <Z6p64UaZnYg-qfNU@google.com> (raw)
In-Reply-To: <Z6bBoZOynhI3eV+Q@yzhao56-desk.sh.intel.com>
On Sat, Feb 08, 2025, Yan Zhao wrote:
> On Fri, Feb 07, 2025 at 07:03:46AM -0800, Sean Christopherson wrote:
> > On Fri, Feb 07, 2025, Yan Zhao wrote:
> > > Merge the prefetch check into the is_access_allowed() check to determine a
> > > spurious fault.
> > >
> > > In the TDP MMU, a spurious prefetch fault should also pass the
> > > is_access_allowed() check.
> >
> > How so?
> >
> > 1. vCPU takes a write-fault on a swapped out page and queues an async #PF
> > 2. A different task installs a writable SPTE
> > 3. A third task write-protects the SPTE for dirty logging
> > 4. Async #PF handler faults in the SPTE, encounters a read-only SPTE for its
> > write fault.
> >
> > KVM shouldn't mark the gfn as dirty in this case.
> Hmm, but when we prefetch an entry, if a gfn is not write-tracked, it allows to
> mark the gfn as dirty, just like when there's no existing SPTE, a prefetch fault
> also marks a gfn as dirty.
Yeah, but there's a difference between installing a SPTE and overwriting a SPTE.
> If a gfn is write-tracked, make_spte() will not grant write-permission to make
> the gfn dirty.
>
> However, I admit that making the new SPTE as not-accessed again is not desired.
> What about below?
>
> @@ -983,7 +983,7 @@ static int tdp_mmu_map_handle_target_level(struct kvm_vcpu *vcpu,
> return RET_PF_RETRY;
>
> if (is_shadow_present_pte(iter->old_spte) &&
> - is_access_allowed(fault, iter->old_spte) &&
> + (fault->prefetch || is_access_allowed(fault, iter->old_spte)) &&
> is_last_spte(iter->old_spte, iter->level))
> return RET_PF_SPURIOUS;
Works for me.
next prev parent reply other threads:[~2025-02-10 22:17 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-07 3:06 [PATCH 0/4] Small changes related to prefetch and spurious faults Yan Zhao
2025-02-07 3:07 ` [PATCH 1/4] KVM: x86/mmu: Further check old SPTE is leaf for spurious prefetch fault Yan Zhao
2025-02-07 3:08 ` [PATCH 2/4] KVM: x86/tdp_mmu: Merge the prefetch into the is_access_allowed() check Yan Zhao
2025-02-07 15:03 ` Sean Christopherson
2025-02-08 2:29 ` Yan Zhao
2025-02-10 22:17 ` Sean Christopherson [this message]
2025-02-07 3:09 ` [PATCH 3/4] KVM: x86/mmu: Make sure pfn is not changed for spurious fault Yan Zhao
2025-02-07 15:07 ` Sean Christopherson
2025-02-08 2:37 ` Yan Zhao
2025-02-10 22:23 ` Sean Christopherson
2025-02-11 6:48 ` Yan Zhao
2025-02-07 3:09 ` [PATCH 4/4] KVM: x86/mmu: Free obsolete roots when pre-faulting SPTEs Yan Zhao
2025-02-07 15:12 ` Sean Christopherson
2025-02-08 3:01 ` Yan Zhao
2025-02-10 22:41 ` Sean Christopherson
2025-02-11 5:38 ` Yan Zhao
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=Z6p64UaZnYg-qfNU@google.com \
--to=seanjc@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rick.p.edgecombe@intel.com \
--cc=yan.y.zhao@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox