Re: [RFC PATCH 0/4] KVM: x86/mmu: Rework marking folios dirty/accessed

From: Paolo Bonzini
Date: Fri Apr 05 2024 - 10:07:23 EST


On 4/5/24 15:59, Sean Christopherson wrote:
Ya, from commit c13fda237f08 ("KVM: Assert that notifier count is elevated in
.change_pte()"):

x86 and MIPS are clearcut nops if the old SPTE is not-present, and that
is guaranteed due to the prior invalidation. PPC simply unmaps the SPTE,
which again should be a nop due to the invalidation. arm64 is a bit
murky, but it's also likely a nop because kvm_pgtable_stage2_map() is
called without a cache pointer, which means it will map an entry if and
only if an existing PTE was found.

I'm 100% in favor of removing .change_pte(). As I've said multiple times, the
only reason I haven't sent a patch is because I didn't want it to prompt someone
into resurrecting the original behavior. 🙂

Ah, this indeed reminded me of discussions we had in the past. Patches sent now:

https://lore.kernel.org/kvm/20240405115815.3226315-1-pbonzini@xxxxxxxxxx/

and I don't think anyone would try to resurrect the original behavior. It made some sense when there was an .invalidate_page() callback as well, but the whole thing started to crumble when .invalidate_page() was made sleepable, plus as David noticed it's very poorly documented where to use set_pte_at_notify() vs. set_pte_at().

As I wrote in the cover letter above, the only reason why it has never caused a bug is because it was doing nothing...

Paolo