diff options
author | Marcelo Tosatti <mtosatti@redhat.com> | 2008-07-10 19:49:31 -0400 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-07-20 05:42:40 -0400 |
commit | 34d4cb8fca1f2a31be152b74797e6cd160ec9de6 (patch) | |
tree | 1e8f2c3c4feb54763fd0d8b27ef83ba546215069 | |
parent | d6e88aec07aa8f6c7e4024f5734ec659fd7c5a40 (diff) |
KVM: MMU: nuke shadowed pgtable pages and ptes on memslot destruction
Flush the shadow mmu before removing regions to avoid stale entries.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
-rw-r--r-- | arch/ia64/kvm/kvm-ia64.c | 3 | ||||
-rw-r--r-- | arch/powerpc/kvm/powerpc.c | 4 | ||||
-rw-r--r-- | arch/s390/kvm/kvm-s390.c | 4 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 5 | ||||
-rw-r--r-- | include/linux/kvm_host.h | 1 | ||||
-rw-r--r-- | virt/kvm/kvm_main.c | 3 |
6 files changed, 20 insertions, 0 deletions
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index 9408b30576d6..2672f4d278ac 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c | |||
@@ -1455,6 +1455,9 @@ int kvm_arch_set_memory_region(struct kvm *kvm, | |||
1455 | return 0; | 1455 | return 0; |
1456 | } | 1456 | } |
1457 | 1457 | ||
1458 | void kvm_arch_flush_shadow(struct kvm *kvm) | ||
1459 | { | ||
1460 | } | ||
1458 | 1461 | ||
1459 | long kvm_arch_dev_ioctl(struct file *filp, | 1462 | long kvm_arch_dev_ioctl(struct file *filp, |
1460 | unsigned int ioctl, unsigned long arg) | 1463 | unsigned int ioctl, unsigned long arg) |
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index b850d2497027..53826a5f6c06 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c | |||
@@ -170,6 +170,10 @@ int kvm_arch_set_memory_region(struct kvm *kvm, | |||
170 | return 0; | 170 | return 0; |
171 | } | 171 | } |
172 | 172 | ||
173 | void kvm_arch_flush_shadow(struct kvm *kvm) | ||
174 | { | ||
175 | } | ||
176 | |||
173 | struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id) | 177 | struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id) |
174 | { | 178 | { |
175 | struct kvm_vcpu *vcpu; | 179 | struct kvm_vcpu *vcpu; |
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 399acf3f64dd..1782cbcd2829 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c | |||
@@ -675,6 +675,10 @@ int kvm_arch_set_memory_region(struct kvm *kvm, | |||
675 | return 0; | 675 | return 0; |
676 | } | 676 | } |
677 | 677 | ||
678 | void kvm_arch_flush_shadow(struct kvm *kvm) | ||
679 | { | ||
680 | } | ||
681 | |||
678 | gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn) | 682 | gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn) |
679 | { | 683 | { |
680 | return gfn; | 684 | return gfn; |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index b131f3c0cf64..9f1cdb011cff 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -4032,6 +4032,11 @@ int kvm_arch_set_memory_region(struct kvm *kvm, | |||
4032 | return 0; | 4032 | return 0; |
4033 | } | 4033 | } |
4034 | 4034 | ||
4035 | void kvm_arch_flush_shadow(struct kvm *kvm) | ||
4036 | { | ||
4037 | kvm_mmu_zap_all(kvm); | ||
4038 | } | ||
4039 | |||
4035 | int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu) | 4040 | int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu) |
4036 | { | 4041 | { |
4037 | return vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE | 4042 | return vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE |
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index d220b4926c4a..07d68a8ae8e9 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
@@ -168,6 +168,7 @@ int kvm_arch_set_memory_region(struct kvm *kvm, | |||
168 | struct kvm_userspace_memory_region *mem, | 168 | struct kvm_userspace_memory_region *mem, |
169 | struct kvm_memory_slot old, | 169 | struct kvm_memory_slot old, |
170 | int user_alloc); | 170 | int user_alloc); |
171 | void kvm_arch_flush_shadow(struct kvm *kvm); | ||
171 | gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn); | 172 | gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn); |
172 | struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn); | 173 | struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn); |
173 | unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn); | 174 | unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn); |
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 9ccaf8f5402e..30b36368fcdf 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -405,6 +405,9 @@ int __kvm_set_memory_region(struct kvm *kvm, | |||
405 | if (mem->slot >= kvm->nmemslots) | 405 | if (mem->slot >= kvm->nmemslots) |
406 | kvm->nmemslots = mem->slot + 1; | 406 | kvm->nmemslots = mem->slot + 1; |
407 | 407 | ||
408 | if (!npages) | ||
409 | kvm_arch_flush_shadow(kvm); | ||
410 | |||
408 | *memslot = new; | 411 | *memslot = new; |
409 | 412 | ||
410 | r = kvm_arch_set_memory_region(kvm, mem, old, user_alloc); | 413 | r = kvm_arch_set_memory_region(kvm, mem, old, user_alloc); |