Commit c857ebba authored by Marcelo Tosatti's avatar Marcelo Tosatti Committed by Greg Kroah-Hartman

KVM: MMU: nuke shadowed pgtable pages and ptes on memslot destruction

Original-Commit-Hash: 3cc312f03e06a8fa39ecb4cc0189efc2bd888899

Flush the shadow mmu before removing regions to avoid stale entries.
Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: default avatarAvi Kivity <avi@qumranet.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 205cb934
......@@ -1460,6 +1460,9 @@ int kvm_arch_set_memory_region(struct kvm *kvm,
return 0;
}
void kvm_arch_flush_shadow(struct kvm *kvm)
{
}
long kvm_arch_dev_ioctl(struct file *filp,
unsigned int ioctl, unsigned long arg)
......
......@@ -167,6 +167,10 @@ int kvm_arch_set_memory_region(struct kvm *kvm,
return 0;
}
void kvm_arch_flush_shadow(struct kvm *kvm)
{
}
struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id)
{
struct kvm_vcpu *vcpu;
......
......@@ -672,6 +672,10 @@ int kvm_arch_set_memory_region(struct kvm *kvm,
return 0;
}
void kvm_arch_flush_shadow(struct kvm *kvm)
{
}
gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn)
{
return gfn;
......
......@@ -4016,6 +4016,11 @@ int kvm_arch_set_memory_region(struct kvm *kvm,
return 0;
}
void kvm_arch_flush_shadow(struct kvm *kvm)
{
kvm_mmu_zap_all(kvm);
}
int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
{
return vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE
......
......@@ -166,6 +166,7 @@ int kvm_arch_set_memory_region(struct kvm *kvm,
struct kvm_userspace_memory_region *mem,
struct kvm_memory_slot old,
int user_alloc);
void kvm_arch_flush_shadow(struct kvm *kvm);
gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn);
struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn);
unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn);
......
......@@ -377,6 +377,9 @@ int __kvm_set_memory_region(struct kvm *kvm,
if (mem->slot >= kvm->nmemslots)
kvm->nmemslots = mem->slot + 1;
if (!npages)
kvm_arch_flush_shadow(kvm);
*memslot = new;
r = kvm_arch_set_memory_region(kvm, mem, old, user_alloc);
......
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