diff options
| author | Marcelo Tosatti <mtosatti@redhat.com> | 2012-08-24 14:54:57 -0400 |
|---|---|---|
| committer | Avi Kivity <avi@redhat.com> | 2012-09-06 09:37:25 -0400 |
| commit | 2df72e9bc4c505d8357012f2924589f3d16f9d44 (patch) | |
| tree | b5b0e8d63005300dd06fd779658639645d55a67b | |
| parent | 09941fbb712655cde9b350852be7a99a6f61a03f (diff) | |
KVM: split kvm_arch_flush_shadow
Introducing kvm_arch_flush_shadow_memslot, to invalidate the
translations of a single memory slot.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
| -rw-r--r-- | arch/ia64/kvm/kvm-ia64.c | 8 | ||||
| -rw-r--r-- | arch/powerpc/kvm/powerpc.c | 6 | ||||
| -rw-r--r-- | arch/s390/kvm/kvm-s390.c | 7 | ||||
| -rw-r--r-- | arch/x86/kvm/x86.c | 8 | ||||
| -rw-r--r-- | include/linux/kvm_host.h | 6 | ||||
| -rw-r--r-- | virt/kvm/kvm_main.c | 8 |
6 files changed, 34 insertions, 9 deletions
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index eac65380bd20..8b3a9c0e771d 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c | |||
| @@ -1613,11 +1613,17 @@ void kvm_arch_commit_memory_region(struct kvm *kvm, | |||
| 1613 | return; | 1613 | return; |
| 1614 | } | 1614 | } |
| 1615 | 1615 | ||
| 1616 | void kvm_arch_flush_shadow(struct kvm *kvm) | 1616 | void kvm_arch_flush_shadow_all(struct kvm *kvm) |
| 1617 | { | 1617 | { |
| 1618 | kvm_flush_remote_tlbs(kvm); | 1618 | kvm_flush_remote_tlbs(kvm); |
| 1619 | } | 1619 | } |
| 1620 | 1620 | ||
| 1621 | void kvm_arch_flush_shadow_memslot(struct kvm *kvm, | ||
| 1622 | struct kvm_memory_slot *slot) | ||
| 1623 | { | ||
| 1624 | kvm_arch_flush_shadow_all(); | ||
| 1625 | } | ||
| 1626 | |||
| 1621 | long kvm_arch_dev_ioctl(struct file *filp, | 1627 | long kvm_arch_dev_ioctl(struct file *filp, |
| 1622 | unsigned int ioctl, unsigned long arg) | 1628 | unsigned int ioctl, unsigned long arg) |
| 1623 | { | 1629 | { |
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index 879b14a61403..4d213b8b0fb5 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c | |||
| @@ -334,8 +334,12 @@ void kvm_arch_commit_memory_region(struct kvm *kvm, | |||
| 334 | kvmppc_core_commit_memory_region(kvm, mem); | 334 | kvmppc_core_commit_memory_region(kvm, mem); |
| 335 | } | 335 | } |
| 336 | 336 | ||
| 337 | void kvm_arch_flush_shadow_all(struct kvm *kvm) | ||
| 338 | { | ||
| 339 | } | ||
| 337 | 340 | ||
| 338 | void kvm_arch_flush_shadow(struct kvm *kvm) | 341 | void kvm_arch_flush_shadow_memslot(struct kvm *kvm, |
| 342 | struct kvm_memory_slot *slot) | ||
| 339 | { | 343 | { |
| 340 | } | 344 | } |
| 341 | 345 | ||
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index e83df7f0fedd..ecced9d18986 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c | |||
| @@ -969,7 +969,12 @@ void kvm_arch_commit_memory_region(struct kvm *kvm, | |||
| 969 | return; | 969 | return; |
| 970 | } | 970 | } |
| 971 | 971 | ||
| 972 | void kvm_arch_flush_shadow(struct kvm *kvm) | 972 | void kvm_arch_flush_shadow_all(struct kvm *kvm) |
| 973 | { | ||
| 974 | } | ||
| 975 | |||
| 976 | void kvm_arch_flush_shadow_memslot(struct kvm *kvm, | ||
| 977 | struct kvm_memory_slot *slot) | ||
| 973 | { | 978 | { |
| 974 | } | 979 | } |
| 975 | 980 | ||
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 666da13c34fc..37797a090a8f 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
| @@ -6447,12 +6447,18 @@ void kvm_arch_commit_memory_region(struct kvm *kvm, | |||
| 6447 | spin_unlock(&kvm->mmu_lock); | 6447 | spin_unlock(&kvm->mmu_lock); |
| 6448 | } | 6448 | } |
| 6449 | 6449 | ||
| 6450 | void kvm_arch_flush_shadow(struct kvm *kvm) | 6450 | void kvm_arch_flush_shadow_all(struct kvm *kvm) |
| 6451 | { | 6451 | { |
| 6452 | kvm_mmu_zap_all(kvm); | 6452 | kvm_mmu_zap_all(kvm); |
| 6453 | kvm_reload_remote_mmus(kvm); | 6453 | kvm_reload_remote_mmus(kvm); |
| 6454 | } | 6454 | } |
| 6455 | 6455 | ||
| 6456 | void kvm_arch_flush_shadow_memslot(struct kvm *kvm, | ||
| 6457 | struct kvm_memory_slot *slot) | ||
| 6458 | { | ||
| 6459 | kvm_arch_flush_shadow_all(kvm); | ||
| 6460 | } | ||
| 6461 | |||
| 6456 | int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu) | 6462 | int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu) |
| 6457 | { | 6463 | { |
| 6458 | return (vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE && | 6464 | return (vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE && |
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 9c0b3c3ae0a5..40791930bc15 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
| @@ -458,7 +458,11 @@ void kvm_arch_commit_memory_region(struct kvm *kvm, | |||
| 458 | int user_alloc); | 458 | int user_alloc); |
| 459 | bool kvm_largepages_enabled(void); | 459 | bool kvm_largepages_enabled(void); |
| 460 | void kvm_disable_largepages(void); | 460 | void kvm_disable_largepages(void); |
| 461 | void kvm_arch_flush_shadow(struct kvm *kvm); | 461 | /* flush all memory translations */ |
| 462 | void kvm_arch_flush_shadow_all(struct kvm *kvm); | ||
| 463 | /* flush memory translations pointing to 'slot' */ | ||
| 464 | void kvm_arch_flush_shadow_memslot(struct kvm *kvm, | ||
| 465 | struct kvm_memory_slot *slot); | ||
| 462 | 466 | ||
| 463 | int gfn_to_page_many_atomic(struct kvm *kvm, gfn_t gfn, struct page **pages, | 467 | int gfn_to_page_many_atomic(struct kvm *kvm, gfn_t gfn, struct page **pages, |
| 464 | int nr_pages); | 468 | int nr_pages); |
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 6425906d7cec..a4bf05be5fea 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
| @@ -408,7 +408,7 @@ static void kvm_mmu_notifier_release(struct mmu_notifier *mn, | |||
| 408 | int idx; | 408 | int idx; |
| 409 | 409 | ||
| 410 | idx = srcu_read_lock(&kvm->srcu); | 410 | idx = srcu_read_lock(&kvm->srcu); |
| 411 | kvm_arch_flush_shadow(kvm); | 411 | kvm_arch_flush_shadow_all(kvm); |
| 412 | srcu_read_unlock(&kvm->srcu, idx); | 412 | srcu_read_unlock(&kvm->srcu, idx); |
| 413 | } | 413 | } |
| 414 | 414 | ||
| @@ -582,7 +582,7 @@ static void kvm_destroy_vm(struct kvm *kvm) | |||
| 582 | #if defined(CONFIG_MMU_NOTIFIER) && defined(KVM_ARCH_WANT_MMU_NOTIFIER) | 582 | #if defined(CONFIG_MMU_NOTIFIER) && defined(KVM_ARCH_WANT_MMU_NOTIFIER) |
| 583 | mmu_notifier_unregister(&kvm->mmu_notifier, kvm->mm); | 583 | mmu_notifier_unregister(&kvm->mmu_notifier, kvm->mm); |
| 584 | #else | 584 | #else |
| 585 | kvm_arch_flush_shadow(kvm); | 585 | kvm_arch_flush_shadow_all(kvm); |
| 586 | #endif | 586 | #endif |
| 587 | kvm_arch_destroy_vm(kvm); | 587 | kvm_arch_destroy_vm(kvm); |
| 588 | kvm_free_physmem(kvm); | 588 | kvm_free_physmem(kvm); |
| @@ -814,7 +814,7 @@ int __kvm_set_memory_region(struct kvm *kvm, | |||
| 814 | * - gfn_to_hva (kvm_read_guest, gfn_to_pfn) | 814 | * - gfn_to_hva (kvm_read_guest, gfn_to_pfn) |
| 815 | * - kvm_is_visible_gfn (mmu_check_roots) | 815 | * - kvm_is_visible_gfn (mmu_check_roots) |
| 816 | */ | 816 | */ |
| 817 | kvm_arch_flush_shadow(kvm); | 817 | kvm_arch_flush_shadow_memslot(kvm, slot); |
| 818 | kfree(old_memslots); | 818 | kfree(old_memslots); |
| 819 | } | 819 | } |
| 820 | 820 | ||
| @@ -854,7 +854,7 @@ int __kvm_set_memory_region(struct kvm *kvm, | |||
| 854 | * mmio sptes. | 854 | * mmio sptes. |
| 855 | */ | 855 | */ |
| 856 | if (npages && old.base_gfn != mem->guest_phys_addr >> PAGE_SHIFT) | 856 | if (npages && old.base_gfn != mem->guest_phys_addr >> PAGE_SHIFT) |
| 857 | kvm_arch_flush_shadow(kvm); | 857 | kvm_arch_flush_shadow_all(kvm); |
| 858 | 858 | ||
| 859 | kvm_free_physmem_slot(&old, &new); | 859 | kvm_free_physmem_slot(&old, &new); |
| 860 | kfree(old_memslots); | 860 | kfree(old_memslots); |
