In the loop of kvm_set_pte_rmapp(), both branch of if clause would call mmu_spte_clear_track_bits(). * one indirectly by pte_list_remove in *if* branch * one directly in *else* branch This patch extracts this behavior and call it before if clause. Signed-off-by: Wei Yang <richard.weiyang@xxxxxxxxx> --- arch/x86/kvm/mmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 5b05a8079872..edf3d51b485c 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -1709,9 +1709,10 @@ static int kvm_set_pte_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head, sptep, *sptep, gfn, level); need_flush = 1; + mmu_spte_clear_track_bits(sptep); if (pte_write(*ptep)) { - pte_list_remove(rmap_head, sptep); + __pte_list_remove(sptep, rmap_head); goto restart; } else { new_spte = *sptep & ~PT64_BASE_ADDR_MASK; @@ -1722,7 +1723,6 @@ static int kvm_set_pte_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head, new_spte = mark_spte_for_access_track(new_spte); - mmu_spte_clear_track_bits(sptep); mmu_spte_set(sptep, new_spte); } } -- 2.15.1