On Tue, Feb 04, 2025, James Houghton wrote: > spte_has_volatile_bits() is now a misnomer, as the an SPTE can have its > Accessed bit set or cleared without the mmu_lock held, but the state of > the Accessed bit is not checked in spte_has_volatile_bits(). > Even if a caller uses spte_needs_atomic_write(), Accessed bit > information may still be lost, but that is already tolerated, as the TLB > is not invalidated after the Accessed bit is cleared. > > Signed-off-by: James Houghton <jthoughton@xxxxxxxxxx> > --- ... > diff --git a/arch/x86/kvm/mmu/spte.h b/arch/x86/kvm/mmu/spte.h > index 59746854c0af..4c290ae9a02a 100644 > --- a/arch/x86/kvm/mmu/spte.h > +++ b/arch/x86/kvm/mmu/spte.h > @@ -519,7 +519,7 @@ static inline u64 get_mmio_spte_generation(u64 spte) > return gen; > } > > -bool spte_has_volatile_bits(u64 spte); > +bool spte_needs_atomic_write(u64 spte); > > bool make_spte(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp, > const struct kvm_memory_slot *slot, > diff --git a/arch/x86/kvm/mmu/tdp_iter.h b/arch/x86/kvm/mmu/tdp_iter.h > index 05e9d678aac9..b54123163efc 100644 > --- a/arch/x86/kvm/mmu/tdp_iter.h > +++ b/arch/x86/kvm/mmu/tdp_iter.h > @@ -55,7 +55,7 @@ static inline bool kvm_tdp_mmu_spte_need_atomic_write(u64 old_spte, int level) > { > return is_shadow_present_pte(old_spte) && > is_last_spte(old_spte, level) && > - spte_has_volatile_bits(old_spte); > + spte_needs_atomic_write(old_spte); Unless you object, I'll change this to spte_needs_atomic_update(), and tweak kvm_tdp_mmu_spte_need_atomic_write() accordingly. "write" was a bad choice by me. It's not just the store/write that needs to be atomic, it's the entire read-modify-write. E.g. KVM needs to preserve the existing value, but for many flows, it's even more important that KVM's snapshot of the old SPTE is accurate. > } > > static inline u64 kvm_tdp_mmu_write_spte(tdp_ptep_t sptep, u64 old_spte, > -- > 2.48.1.362.g079036d154-goog >