]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: x86/mmu: Set Dirty bit for new SPTEs, even if _hardware_ A/D bits are disabled
authorSean Christopherson <seanjc@google.com>
Fri, 11 Oct 2024 02:10:48 +0000 (19:10 -0700)
committerSean Christopherson <seanjc@google.com>
Wed, 30 Oct 2024 22:25:39 +0000 (15:25 -0700)
When making a SPTE, set the Dirty bit in the SPTE as appropriate, even if
hardware A/D bits are disabled.  Only EPT allows A/D bits to be disabled,
and for EPT, the bits are software-available (ignored by hardware) when
A/D bits are disabled, i.e. it is perfectly legal for KVM to use the Dirty
to track dirty pages in software.

Link: https://lore.kernel.org/r/20241011021051.1557902-17-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/mmu/spte.c
arch/x86/kvm/mmu/spte.h

index 617479efd127a9ba261baa78bc0273b32e3a7a63..fd8c3c92ade071e98835ca10d9e1ae27fa187549 100644 (file)
@@ -237,7 +237,7 @@ bool make_spte(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
                        wrprot = true;
                else
                        spte |= PT_WRITABLE_MASK | shadow_mmu_writable_mask |
-                               spte_shadow_dirty_mask(spte);
+                               shadow_dirty_mask;
        }
 
        if (prefetch && !synchronizing)
index 1d83614baac58f1c03ff8f5e53a9ef8dd2559dc1..ccfd5a091b7a717da43d3b738b5d3d78504a4bfb 100644 (file)
@@ -316,12 +316,6 @@ static inline bool spte_ad_need_write_protect(u64 spte)
        return (spte & SPTE_TDP_AD_MASK) != SPTE_TDP_AD_ENABLED;
 }
 
-static inline u64 spte_shadow_dirty_mask(u64 spte)
-{
-       KVM_MMU_WARN_ON(!is_shadow_present_pte(spte));
-       return spte_ad_enabled(spte) ? shadow_dirty_mask : 0;
-}
-
 static inline bool is_access_track_spte(u64 spte)
 {
        return !spte_ad_enabled(spte) && (spte & shadow_acc_track_mask) == 0;