Commit 8234b22e authored by Avi Kivity's avatar Avi Kivity Committed by Marcelo Tosatti

KVM: MMU: Don't flush shadow when enabling dirty tracking

Instead, drop large mappings, which were the reason we dropped shadow.
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
parent 054cfaac
...@@ -3538,14 +3538,18 @@ void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot) ...@@ -3538,14 +3538,18 @@ void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot)
if (!test_bit(slot, sp->slot_bitmap)) if (!test_bit(slot, sp->slot_bitmap))
continue; continue;
if (sp->role.level != PT_PAGE_TABLE_LEVEL)
continue;
pt = sp->spt; pt = sp->spt;
for (i = 0; i < PT64_ENT_PER_PAGE; ++i) for (i = 0; i < PT64_ENT_PER_PAGE; ++i) {
if (sp->role.level != PT_PAGE_TABLE_LEVEL
&& is_large_pte(pt[i])) {
drop_spte(kvm, &pt[i],
shadow_trap_nonpresent_pte);
--kvm->stat.lpages;
}
/* avoid RMW */ /* avoid RMW */
if (is_writable_pte(pt[i])) if (is_writable_pte(pt[i]))
update_spte(&pt[i], pt[i] & ~PT_WRITABLE_MASK); update_spte(&pt[i], pt[i] & ~PT_WRITABLE_MASK);
}
} }
kvm_flush_remote_tlbs(kvm); kvm_flush_remote_tlbs(kvm);
} }
......
...@@ -621,7 +621,7 @@ int __kvm_set_memory_region(struct kvm *kvm, ...@@ -621,7 +621,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
struct kvm_userspace_memory_region *mem, struct kvm_userspace_memory_region *mem,
int user_alloc) int user_alloc)
{ {
int r, flush_shadow = 0; int r;
gfn_t base_gfn; gfn_t base_gfn;
unsigned long npages; unsigned long npages;
unsigned long i; unsigned long i;
...@@ -741,8 +741,6 @@ int __kvm_set_memory_region(struct kvm *kvm, ...@@ -741,8 +741,6 @@ int __kvm_set_memory_region(struct kvm *kvm,
if (kvm_create_dirty_bitmap(&new) < 0) if (kvm_create_dirty_bitmap(&new) < 0)
goto out_free; goto out_free;
/* destroy any largepage mappings for dirty tracking */ /* destroy any largepage mappings for dirty tracking */
if (old.npages)
flush_shadow = 1;
} }
#else /* not defined CONFIG_S390 */ #else /* not defined CONFIG_S390 */
new.user_alloc = user_alloc; new.user_alloc = user_alloc;
...@@ -813,9 +811,6 @@ int __kvm_set_memory_region(struct kvm *kvm, ...@@ -813,9 +811,6 @@ int __kvm_set_memory_region(struct kvm *kvm,
kvm_free_physmem_slot(&old, &new); kvm_free_physmem_slot(&old, &new);
kfree(old_memslots); kfree(old_memslots);
if (flush_shadow)
kvm_arch_flush_shadow(kvm);
return 0; return 0;
out_free: out_free:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment