aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/include
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2011-12-12 07:31:41 -0500
committerAvi Kivity <avi@redhat.com>2012-03-05 07:52:37 -0500
commitda9d1d7f2875cc8c1ffbce8f3501d0b33f4e7a4d (patch)
treea811ee19778715766e720646506311c8fc7d7bd0 /arch/powerpc/include
parentc77162dee7aff6ab5f075da9b60f649cbbeb86cc (diff)
KVM: PPC: Allow use of small pages to back Book3S HV guests
This relaxes the requirement that the guest memory be provided as 16MB huge pages, allowing it to be provided as normal memory, i.e. in pages of PAGE_SIZE bytes (4k or 64k). To allow this, we index the kvm->arch.slot_phys[] arrays with a small page index, even if huge pages are being used, and use the low-order 5 bits of each entry to store the order of the enclosing page with respect to normal pages, i.e. log_2(enclosing_page_size / PAGE_SIZE). 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')
-rw-r--r--arch/powerpc/include/asm/kvm_book3s_64.h10
-rw-r--r--arch/powerpc/include/asm/kvm_host.h3
-rw-r--r--arch/powerpc/include/asm/kvm_ppc.h2
-rw-r--r--arch/powerpc/include/asm/reg.h1
4 files changed, 13 insertions, 3 deletions
diff --git a/arch/powerpc/include/asm/kvm_book3s_64.h b/arch/powerpc/include/asm/kvm_book3s_64.h
index 7e6f2ede44ac..10920f7a2b8d 100644
--- a/arch/powerpc/include/asm/kvm_book3s_64.h
+++ b/arch/powerpc/include/asm/kvm_book3s_64.h
@@ -113,4 +113,14 @@ static inline unsigned long hpte_page_size(unsigned long h, unsigned long l)
113 return 0; /* error */ 113 return 0; /* error */
114} 114}
115 115
116static inline bool slot_is_aligned(struct kvm_memory_slot *memslot,
117 unsigned long pagesize)
118{
119 unsigned long mask = (pagesize >> PAGE_SHIFT) - 1;
120
121 if (pagesize <= PAGE_SIZE)
122 return 1;
123 return !(memslot->base_gfn & mask) && !(memslot->npages & mask);
124}
125
116#endif /* __ASM_KVM_BOOK3S_64_H__ */ 126#endif /* __ASM_KVM_BOOK3S_64_H__ */
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index beb22ba71e26..9252d5e3758d 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -177,14 +177,13 @@ struct revmap_entry {
177}; 177};
178 178
179/* Low-order bits in kvm->arch.slot_phys[][] */ 179/* Low-order bits in kvm->arch.slot_phys[][] */
180#define KVMPPC_PAGE_ORDER_MASK 0x1f
180#define KVMPPC_GOT_PAGE 0x80 181#define KVMPPC_GOT_PAGE 0x80
181 182
182struct kvm_arch { 183struct kvm_arch {
183#ifdef CONFIG_KVM_BOOK3S_64_HV 184#ifdef CONFIG_KVM_BOOK3S_64_HV
184 unsigned long hpt_virt; 185 unsigned long hpt_virt;
185 struct revmap_entry *revmap; 186 struct revmap_entry *revmap;
186 unsigned long ram_psize;
187 unsigned long ram_porder;
188 unsigned int lpid; 187 unsigned int lpid;
189 unsigned int host_lpid; 188 unsigned int host_lpid;
190 unsigned long host_lpcr; 189 unsigned long host_lpcr;
diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
index 1458c6740ea3..fb70414db90c 100644
--- a/arch/powerpc/include/asm/kvm_ppc.h
+++ b/arch/powerpc/include/asm/kvm_ppc.h
@@ -122,7 +122,7 @@ extern void kvmppc_free_hpt(struct kvm *kvm);
122extern long kvmppc_prepare_vrma(struct kvm *kvm, 122extern long kvmppc_prepare_vrma(struct kvm *kvm,
123 struct kvm_userspace_memory_region *mem); 123 struct kvm_userspace_memory_region *mem);
124extern void kvmppc_map_vrma(struct kvm_vcpu *vcpu, 124extern void kvmppc_map_vrma(struct kvm_vcpu *vcpu,
125 struct kvm_memory_slot *memslot); 125 struct kvm_memory_slot *memslot, unsigned long porder);
126extern int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu); 126extern int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu);
127extern long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm, 127extern long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
128 struct kvm_create_spapr_tce *args); 128 struct kvm_create_spapr_tce *args);
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index 7fdc2c0b7fa0..64447f6c049a 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -237,6 +237,7 @@
237#define LPCR_ISL (1ul << (63-2)) 237#define LPCR_ISL (1ul << (63-2))
238#define LPCR_VC_SH (63-2) 238#define LPCR_VC_SH (63-2)
239#define LPCR_DPFD_SH (63-11) 239#define LPCR_DPFD_SH (63-11)
240#define LPCR_VRMASD (0x1ful << (63-16))
240#define LPCR_VRMA_L (1ul << (63-12)) 241#define LPCR_VRMA_L (1ul << (63-12))
241#define LPCR_VRMA_LP0 (1ul << (63-15)) 242#define LPCR_VRMA_LP0 (1ul << (63-15))
242#define LPCR_VRMA_LP1 (1ul << (63-16)) 243#define LPCR_VRMA_LP1 (1ul << (63-16))