Skip to content

Commit 8564911

Browse files
committed
KVM: x86/mmu: Set Dirty bit for new SPTEs, even if _hardware_ A/D bits are disabled
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>
1 parent c9b6256 commit 8564911

File tree

2 files changed

+1
-7
lines changed

2 files changed

+1
-7
lines changed

arch/x86/kvm/mmu/spte.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ bool make_spte(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
237237
wrprot = true;
238238
else
239239
spte |= PT_WRITABLE_MASK | shadow_mmu_writable_mask |
240-
spte_shadow_dirty_mask(spte);
240+
shadow_dirty_mask;
241241
}
242242

243243
if (prefetch && !synchronizing)

arch/x86/kvm/mmu/spte.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,6 @@ static inline bool spte_ad_need_write_protect(u64 spte)
316316
return (spte & SPTE_TDP_AD_MASK) != SPTE_TDP_AD_ENABLED;
317317
}
318318

319-
static inline u64 spte_shadow_dirty_mask(u64 spte)
320-
{
321-
KVM_MMU_WARN_ON(!is_shadow_present_pte(spte));
322-
return spte_ad_enabled(spte) ? shadow_dirty_mask : 0;
323-
}
324-
325319
static inline bool is_access_track_spte(u64 spte)
326320
{
327321
return !spte_ad_enabled(spte) && (spte & shadow_acc_track_mask) == 0;

0 commit comments

Comments
 (0)