@@ -334,17 +334,6 @@ static void handle_changed_spte(struct kvm *kvm, int as_id, gfn_t gfn,
334334 u64 old_spte , u64 new_spte , int level ,
335335 bool shared );
336336
337- static void handle_changed_spte_acc_track (u64 old_spte , u64 new_spte , int level )
338- {
339- if (!is_shadow_present_pte (old_spte ) || !is_last_spte (old_spte , level ))
340- return ;
341-
342- if (is_accessed_spte (old_spte ) &&
343- (!is_shadow_present_pte (new_spte ) || !is_accessed_spte (new_spte ) ||
344- spte_to_pfn (old_spte ) != spte_to_pfn (new_spte )))
345- kvm_set_pfn_accessed (spte_to_pfn (old_spte ));
346- }
347-
348337static void tdp_account_mmu_page (struct kvm * kvm , struct kvm_mmu_page * sp )
349338{
350339 kvm_account_pgtable_pages ((void * )sp -> spt , +1 );
@@ -487,7 +476,7 @@ static void handle_removed_pt(struct kvm *kvm, tdp_ptep_t pt, bool shared)
487476}
488477
489478/**
490- * __handle_changed_spte - handle bookkeeping associated with an SPTE change
479+ * handle_changed_spte - handle bookkeeping associated with an SPTE change
491480 * @kvm: kvm instance
492481 * @as_id: the address space of the paging structure the SPTE was a part of
493482 * @gfn: the base GFN that was mapped by the SPTE
@@ -502,9 +491,9 @@ static void handle_removed_pt(struct kvm *kvm, tdp_ptep_t pt, bool shared)
502491 * dirty logging updates are handled in common code, not here (see make_spte()
503492 * and fast_pf_fix_direct_spte()).
504493 */
505- static void __handle_changed_spte (struct kvm * kvm , int as_id , gfn_t gfn ,
506- u64 old_spte , u64 new_spte , int level ,
507- bool shared )
494+ static void handle_changed_spte (struct kvm * kvm , int as_id , gfn_t gfn ,
495+ u64 old_spte , u64 new_spte , int level ,
496+ bool shared )
508497{
509498 bool was_present = is_shadow_present_pte (old_spte );
510499 bool is_present = is_shadow_present_pte (new_spte );
@@ -588,15 +577,10 @@ static void __handle_changed_spte(struct kvm *kvm, int as_id, gfn_t gfn,
588577 if (was_present && !was_leaf &&
589578 (is_leaf || !is_present || WARN_ON_ONCE (pfn_changed )))
590579 handle_removed_pt (kvm , spte_to_child_pt (old_spte , level ), shared );
591- }
592580
593- static void handle_changed_spte (struct kvm * kvm , int as_id , gfn_t gfn ,
594- u64 old_spte , u64 new_spte , int level ,
595- bool shared )
596- {
597- __handle_changed_spte (kvm , as_id , gfn , old_spte , new_spte , level ,
598- shared );
599- handle_changed_spte_acc_track (old_spte , new_spte , level );
581+ if (was_leaf && is_accessed_spte (old_spte ) &&
582+ (!is_present || !is_accessed_spte (new_spte ) || pfn_changed ))
583+ kvm_set_pfn_accessed (spte_to_pfn (old_spte ));
600584}
601585
602586/*
@@ -639,9 +623,8 @@ static inline int tdp_mmu_set_spte_atomic(struct kvm *kvm,
639623 if (!try_cmpxchg64 (sptep , & iter -> old_spte , new_spte ))
640624 return - EBUSY ;
641625
642- __handle_changed_spte (kvm , iter -> as_id , iter -> gfn , iter -> old_spte ,
643- new_spte , iter -> level , true);
644- handle_changed_spte_acc_track (iter -> old_spte , new_spte , iter -> level );
626+ handle_changed_spte (kvm , iter -> as_id , iter -> gfn , iter -> old_spte ,
627+ new_spte , iter -> level , true);
645628
646629 return 0 ;
647630}
@@ -705,8 +688,7 @@ static u64 tdp_mmu_set_spte(struct kvm *kvm, int as_id, tdp_ptep_t sptep,
705688
706689 old_spte = kvm_tdp_mmu_write_spte (sptep , old_spte , new_spte , level );
707690
708- __handle_changed_spte (kvm , as_id , gfn , old_spte , new_spte , level , false);
709- handle_changed_spte_acc_track (old_spte , new_spte , level );
691+ handle_changed_spte (kvm , as_id , gfn , old_spte , new_spte , level , false);
710692 return old_spte ;
711693}
712694
@@ -1275,7 +1257,7 @@ static bool set_spte_gfn(struct kvm *kvm, struct tdp_iter *iter,
12751257 * Note, when changing a read-only SPTE, it's not strictly necessary to
12761258 * zero the SPTE before setting the new PFN, but doing so preserves the
12771259 * invariant that the PFN of a present * leaf SPTE can never change.
1278- * See __handle_changed_spte ().
1260+ * See handle_changed_spte ().
12791261 */
12801262 tdp_mmu_iter_set_spte (kvm , iter , 0 );
12811263
@@ -1300,7 +1282,7 @@ bool kvm_tdp_mmu_set_spte_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
13001282 /*
13011283 * No need to handle the remote TLB flush under RCU protection, the
13021284 * target SPTE _must_ be a leaf SPTE, i.e. cannot result in freeing a
1303- * shadow page. See the WARN on pfn_changed in __handle_changed_spte ().
1285+ * shadow page. See the WARN on pfn_changed in handle_changed_spte ().
13041286 */
13051287 return kvm_tdp_mmu_handle_gfn (kvm , range , set_spte_gfn );
13061288}
0 commit comments