aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/include/asm/kvm_host.h
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2011-12-12 07:38:05 -0500
committerAvi Kivity <avi@redhat.com>2012-03-05 07:52:38 -0500
commit342d3db763f2621ed4546ebf8f6c61cb29d7fbdb (patch)
treebc806911dd085905a5a97419fbc4f9fc1eeb142d /arch/powerpc/include/asm/kvm_host.h
parent697d3899dcb4bcd918d060a92db57b794e56b077 (diff)
KVM: PPC: Implement MMU notifiers for Book3S HV guests
This adds the infrastructure to enable us to page out pages underneath a Book3S HV guest, on processors that support virtualized partition memory, that is, POWER7. Instead of pinning all the guest's pages, we now look in the host userspace Linux page tables to find the mapping for a given guest page. Then, if the userspace Linux PTE gets invalidated, kvm_unmap_hva() gets called for that address, and we replace all the guest HPTEs that refer to that page with absent HPTEs, i.e. ones with the valid bit clear and the HPTE_V_ABSENT bit set, which will cause an HDSI when the guest tries to access them. Finally, the page fault handler is extended to reinstantiate the guest HPTE when the guest tries to access a page which has been paged out. Since we can't intercept the guest DSI and ISI interrupts on PPC970, we still have to pin all the guest pages on PPC970. We have a new flag, kvm->arch.using_mmu_notifiers, that indicates whether we can page guest pages out. If it is not set, the MMU notifier callbacks do nothing and everything operates as before. Signed-off-by: Paul Mackerras <paulus@samba.org> Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/powerpc/include/asm/kvm_host.h')
-rw-r--r--arch/powerpc/include/asm/kvm_host.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index 937cacaaf236..968f3aa61cd1 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -32,6 +32,7 @@
32#include <linux/atomic.h> 32#include <linux/atomic.h>
33#include <asm/kvm_asm.h> 33#include <asm/kvm_asm.h>
34#include <asm/processor.h> 34#include <asm/processor.h>
35#include <asm/page.h>
35 36
36#define KVM_MAX_VCPUS NR_CPUS 37#define KVM_MAX_VCPUS NR_CPUS
37#define KVM_MAX_VCORES NR_CPUS 38#define KVM_MAX_VCORES NR_CPUS
@@ -44,6 +45,19 @@
44#define KVM_COALESCED_MMIO_PAGE_OFFSET 1 45#define KVM_COALESCED_MMIO_PAGE_OFFSET 1
45#endif 46#endif
46 47
48#ifdef CONFIG_KVM_BOOK3S_64_HV
49#include <linux/mmu_notifier.h>
50
51#define KVM_ARCH_WANT_MMU_NOTIFIER
52
53struct kvm;
54extern int kvm_unmap_hva(struct kvm *kvm, unsigned long hva);
55extern int kvm_age_hva(struct kvm *kvm, unsigned long hva);
56extern int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);
57extern void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
58
59#endif
60
47/* We don't currently support large pages. */ 61/* We don't currently support large pages. */
48#define KVM_HPAGE_GFN_SHIFT(x) 0 62#define KVM_HPAGE_GFN_SHIFT(x) 0
49#define KVM_NR_PAGE_SIZES 1 63#define KVM_NR_PAGE_SIZES 1
@@ -212,6 +226,7 @@ struct kvm_arch {
212 struct kvmppc_rma_info *rma; 226 struct kvmppc_rma_info *rma;
213 unsigned long vrma_slb_v; 227 unsigned long vrma_slb_v;
214 int rma_setup_done; 228 int rma_setup_done;
229 int using_mmu_notifiers;
215 struct list_head spapr_tce_tables; 230 struct list_head spapr_tce_tables;
216 spinlock_t slot_phys_lock; 231 spinlock_t slot_phys_lock;
217 unsigned long *slot_phys[KVM_MEM_SLOTS_NUM]; 232 unsigned long *slot_phys[KVM_MEM_SLOTS_NUM];
@@ -460,6 +475,7 @@ struct kvm_vcpu_arch {
460 struct list_head run_list; 475 struct list_head run_list;
461 struct task_struct *run_task; 476 struct task_struct *run_task;
462 struct kvm_run *kvm_run; 477 struct kvm_run *kvm_run;
478 pgd_t *pgdir;
463#endif 479#endif
464}; 480};
465 481