aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorWei Yang <richard.weiyang@gmail.com>2018-10-03 22:04:23 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2018-10-16 18:30:12 -0400
commite7912386ede89d2aa1f72ebb74969e48e9d5f56c (patch)
tree6a70d452d025c90e5ab55ae438863b91e223dbb9 /arch/x86/kvm
parent8daf346226b22e565baf27ccaec58fed9e108b42 (diff)
KVM: x86: reintroduce pte_list_remove, but including mmu_spte_clear_track_bits
rmap_remove() removes the sptep after locating the correct rmap_head but, in several cases, the caller has already known the correct rmap_head. This patch introduces a new pte_list_remove(); because it is known that the spte is present (or it would not have an rmap_head), it is safe to remove the tracking bits without any previous check. Signed-off-by: Wei Yang <richard.weiyang@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/mmu.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 175bfb6766db..4cf43ce42959 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1301,6 +1301,12 @@ static void __pte_list_remove(u64 *spte, struct kvm_rmap_head *rmap_head)
1301 } 1301 }
1302} 1302}
1303 1303
1304static void pte_list_remove(struct kvm_rmap_head *rmap_head, u64 *sptep)
1305{
1306 mmu_spte_clear_track_bits(sptep);
1307 __pte_list_remove(sptep, rmap_head);
1308}
1309
1304static struct kvm_rmap_head *__gfn_to_rmap(gfn_t gfn, int level, 1310static struct kvm_rmap_head *__gfn_to_rmap(gfn_t gfn, int level,
1305 struct kvm_memory_slot *slot) 1311 struct kvm_memory_slot *slot)
1306{ 1312{
@@ -1685,7 +1691,7 @@ static bool kvm_zap_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head)
1685 while ((sptep = rmap_get_first(rmap_head, &iter))) { 1691 while ((sptep = rmap_get_first(rmap_head, &iter))) {
1686 rmap_printk("%s: spte %p %llx.\n", __func__, sptep, *sptep); 1692 rmap_printk("%s: spte %p %llx.\n", __func__, sptep, *sptep);
1687 1693
1688 drop_spte(kvm, sptep); 1694 pte_list_remove(rmap_head, sptep);
1689 flush = true; 1695 flush = true;
1690 } 1696 }
1691 1697
@@ -1721,7 +1727,7 @@ restart:
1721 need_flush = 1; 1727 need_flush = 1;
1722 1728
1723 if (pte_write(*ptep)) { 1729 if (pte_write(*ptep)) {
1724 drop_spte(kvm, sptep); 1730 pte_list_remove(rmap_head, sptep);
1725 goto restart; 1731 goto restart;
1726 } else { 1732 } else {
1727 new_spte = *sptep & ~PT64_BASE_ADDR_MASK; 1733 new_spte = *sptep & ~PT64_BASE_ADDR_MASK;
@@ -5682,7 +5688,7 @@ restart:
5682 if (sp->role.direct && 5688 if (sp->role.direct &&
5683 !kvm_is_reserved_pfn(pfn) && 5689 !kvm_is_reserved_pfn(pfn) &&
5684 PageTransCompoundMap(pfn_to_page(pfn))) { 5690 PageTransCompoundMap(pfn_to_page(pfn))) {
5685 drop_spte(kvm, sptep); 5691 pte_list_remove(rmap_head, sptep);
5686 need_tlb_flush = 1; 5692 need_tlb_flush = 1;
5687 goto restart; 5693 goto restart;
5688 } 5694 }