diff mbox series

[v2,3/3] KVM: x86: extract mmu_spte_clear_track_bits in the loop of kvm_set_pte_rmapp

Message ID 20181004014803.94963-4-richard.weiyang@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/3] KVM: x86: rename pte_list_remove to __pte_list_remove | expand

Commit Message

Wei Yang Oct. 4, 2018, 1:48 a.m. UTC
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@gmail.com>
---
 arch/x86/kvm/mmu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 00853b4d6658..26269948bf8c 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1710,9 +1710,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;
@@ -1723,7 +1724,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);
 		}
 	}