Skip to content

Commit 928c54b

Browse files
committed
KVM: x86/mmu: Always update A/D-disabled SPTEs atomically
In anticipation of aging SPTEs outside of mmu_lock, force A/D-disabled SPTEs to be updated atomically, as aging A/D-disabled SPTEs will mark them for access-tracking outside of mmu_lock. Coupled with restoring access- tracked SPTEs in the fast page fault handler, the end result is that A/D-disable SPTEs will be volatile at all times. Reviewed-by: James Houghton <jthoughton@google.com> Link: https://lore.kernel.org/all/Z60bhK96JnKIgqZQ@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 61d65f2 commit 928c54b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

arch/x86/kvm/mmu/spte.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,11 @@ bool spte_needs_atomic_update(u64 spte)
141141
if (!is_writable_pte(spte) && is_mmu_writable_spte(spte))
142142
return true;
143143

144-
/* Access-tracked SPTEs can be restored by KVM's fast page fault handler. */
145-
if (is_access_track_spte(spte))
144+
/*
145+
* A/D-disabled SPTEs can be access-tracked by aging, and access-tracked
146+
* SPTEs can be restored by KVM's fast page fault handler.
147+
*/
148+
if (!spte_ad_enabled(spte))
146149
return true;
147150

148151
/*
@@ -151,8 +154,7 @@ bool spte_needs_atomic_update(u64 spte)
151154
* invalidate TLBs when aging SPTEs, and so it's safe to clobber the
152155
* Accessed bit (and rare in practice).
153156
*/
154-
return spte_ad_enabled(spte) && is_writable_pte(spte) &&
155-
!(spte & shadow_dirty_mask);
157+
return is_writable_pte(spte) && !(spte & shadow_dirty_mask);
156158
}
157159

158160
bool make_spte(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,

0 commit comments

Comments
 (0)