From: David Matlack <dmatlack@google.com>
To: Sean Christopherson <seanjc@google.com>
Cc: Ben Gardon <bgardon@google.com>,
Vipin Sharma <vipinsh@google.com>,
pbonzini@redhat.com, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [Patch] KVM: x86/mmu: Make optimized __handle_changed_spte() for clear dirty log
Date: Mon, 30 Jan 2023 14:12:21 -0800 [thread overview]
Message-ID: <CALzav=fkmS0U4tb4trDtbCmDxo27EcJeOWbiwb+meagj9+PFiw@mail.gmail.com> (raw)
In-Reply-To: <Y9HcHRBShQgjxsQb@google.com>
On Wed, Jan 25, 2023 at 5:49 PM Sean Christopherson <seanjc@google.com> wrote:
[...]
> ---
> arch/x86/kvm/mmu/tdp_mmu.c | 92 ++++++++++----------------------------
> 1 file changed, 24 insertions(+), 68 deletions(-)
>
> diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c
> index bba33aea0fb0..2f78ca43a276 100644
> --- a/arch/x86/kvm/mmu/tdp_mmu.c
> +++ b/arch/x86/kvm/mmu/tdp_mmu.c
[...]
> @@ -1289,8 +1244,7 @@ static bool age_gfn_range(struct kvm *kvm, struct tdp_iter *iter,
> new_spte = mark_spte_for_access_track(new_spte);
> }
>
> - tdp_mmu_set_spte_no_acc_track(kvm, iter, new_spte);
> -
> + kvm_tdp_mmu_write_spte(iter->sptep, iter->old_spte, new_spte, iter->level);
This can race with fast_page_fault() setting the W-bit and the CPU
setting the D-bit. i.e. This call to kvm_tdp_mmu_write_spte() could
clear the W-bit or D-bit.
> @@ -1703,9 +1657,11 @@ static void clear_dirty_pt_masked(struct kvm *kvm, struct kvm_mmu_page *root,
> new_spte = iter.old_spte & ~shadow_dirty_mask;
> else
> continue;
> +
> + kvm_set_pfn_dirty(spte_to_pfn(iter.old_spte));
> }
>
> - tdp_mmu_set_spte_no_dirty_log(kvm, &iter, new_spte);
> + kvm_tdp_mmu_write_spte(iter.sptep, iter.old_spte, new_spte, iter.level);
Similar issue here. This call to kvm_tdp_mmu_write_spte() could clear
the A-bit or mark the SPTE for access-tracking.
> --
>
next prev parent reply other threads:[~2023-01-30 22:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-25 21:38 [Patch] KVM: x86/mmu: Make optimized __handle_changed_spte() for clear dirty log Vipin Sharma
2023-01-25 22:00 ` David Matlack
2023-01-25 22:25 ` Ben Gardon
2023-01-26 0:40 ` Vipin Sharma
2023-01-26 1:49 ` Sean Christopherson
2023-01-28 17:20 ` Vipin Sharma
2023-01-30 18:09 ` Sean Christopherson
2023-01-30 20:17 ` Vipin Sharma
2023-01-30 22:49 ` Sean Christopherson
2023-01-30 22:12 ` David Matlack [this message]
2023-01-30 23:49 ` Sean Christopherson
2023-01-31 17:41 ` David Matlack
2023-01-31 18:01 ` Vipin Sharma
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='CALzav=fkmS0U4tb4trDtbCmDxo27EcJeOWbiwb+meagj9+PFiw@mail.gmail.com' \
--to=dmatlack@google.com \
--cc=bgardon@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=vipinsh@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;
as well as URLs for NNTP newsgroup(s).