Re: [PATCH 15/22] kvm: mmu: Support changed pte notifier in tdp MMU

From: Paolo Bonzini
Date: Mon Sep 28 2020 - 11:11:33 EST


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?

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.

Paolo