[lkml]   [2020]   [Oct]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH 15/22] kvm: mmu: Support changed pte notifier in tdp MMU
On Mon, Sep 28, 2020 at 8:11 AM Paolo Bonzini <> wrote:
> On 25/09/20 23:22, Ben Gardon wrote:
> > + *iter.sptep = 0;
> > + handle_changed_spte(kvm, as_id, iter.gfn, iter.old_spte,
> > + new_spte, iter.level);
> > +
> Can you explain why new_spte is passed here instead of 0?

That's just a bug. Thank you for catching it.

> All calls to handle_changed_spte are preceded by "*something =
> new_spte" except this one, so I'm thinking of having a change_spte
> function like
> static void change_spte(struct kvm *kvm, int as_id, gfn_t gfn,
> u64 *sptep, u64 new_spte, int level)
> {
> u64 old_spte = *sptep;
> *sptep = new_spte;
> __handle_changed_spte(kvm, as_id, gfn, old_spte, new_spte, level);
> handle_changed_spte_acc_track(old_spte, new_spte, level);
> handle_changed_spte_dirty_log(kvm, as_id, gfn, old_spte, new_spte, level);
> }
> in addition to the previously-mentioned cleanup of always calling
> handle_changed_spte instead of special-casing calls to two of the
> three functions. It would be a nice place to add the
> trace_kvm_mmu_set_spte tracepoint, too.

I'm not sure we can avoid special casing calls to the access tracking
and dirty logging handler functions. At least in the past that's
created bugs with things being marked dirty or accessed when they
shouldn't be. I'll revisit those assumptions. It would certainly be
nice to get rid of that complexity.

I agree that putting the SPTE assignment and handler functions in a
helper function would clean up the code. I'll do that. I got some
feedback on the RFC I sent last year which led me to open-code a lot
more, but I think this is still a good cleanup.

Re tracepoints, I was planning to just insert them all once this code
is stabilized, if that's alright.

> Paolo

 \ /
  Last update: 2020-10-07 18:54    [W:0.132 / U:0.476 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site