Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9e04ba69 authored by Paul Mackerras's avatar Paul Mackerras Committed by Michael Ellerman
Browse files

KVM: PPC: Book3S HV: Add basic infrastructure for radix guests



This adds a field in struct kvm_arch and an inline helper to
indicate whether a guest is a radix guest or not, plus a new file
to contain the radix MMU code, which currently contains just a
translate function which knows how to traverse the guest page
tables to translate an address.

Signed-off-by: default avatarPaul Mackerras <paulus@ozlabs.org>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent ef8c640c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -182,6 +182,9 @@ extern void kvmppc_mmu_hpte_sysexit(void);
extern int kvmppc_mmu_hv_init(void);
extern int kvmppc_book3s_hcall_implemented(struct kvm *kvm, unsigned long hc);

extern int kvmppc_mmu_radix_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
			struct kvmppc_pte *gpte, bool data, bool iswrite);

/* XXX remove this export when load_last_inst() is generic */
extern int kvmppc_ld(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr, bool data);
extern void kvmppc_book3s_queue_irqprio(struct kvm_vcpu *vcpu, unsigned int vec);
+6 −0
Original line number Diff line number Diff line
@@ -36,6 +36,12 @@ static inline void svcpu_put(struct kvmppc_book3s_shadow_vcpu *svcpu)
#endif

#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE

static inline bool kvm_is_radix(struct kvm *kvm)
{
	return kvm->arch.radix;
}

#define KVM_DEFAULT_HPT_ORDER	24	/* 16MB HPT by default */
#endif

+2 −0
Original line number Diff line number Diff line
@@ -264,6 +264,8 @@ struct kvm_arch {
	atomic_t hpte_mod_interest;
	cpumask_t need_tlb_flush;
	int hpt_cma_alloc;
	u8 radix;
	pgd_t *pgtable;
	u64 process_table;
	struct dentry *debugfs_dir;
	struct dentry *htab_dentry;
+2 −1
Original line number Diff line number Diff line
@@ -70,7 +70,8 @@ endif
kvm-hv-y += \
	book3s_hv.o \
	book3s_hv_interrupts.o \
	book3s_64_mmu_hv.o
	book3s_64_mmu_hv.o \
	book3s_64_mmu_radix.o

kvm-book3s_64-builtin-xics-objs-$(CONFIG_KVM_XICS) := \
	book3s_hv_rm_xics.o
+8 −2
Original line number Diff line number Diff line
@@ -119,6 +119,9 @@ long kvmppc_alloc_reset_hpt(struct kvm *kvm, u32 *htab_orderp)
	long err = -EBUSY;
	long order;

	if (kvm_is_radix(kvm))
		return -EINVAL;

	mutex_lock(&kvm->lock);
	if (kvm->arch.hpte_setup_done) {
		kvm->arch.hpte_setup_done = 0;
@@ -157,7 +160,7 @@ void kvmppc_free_hpt(struct kvm *kvm)
	if (kvm->arch.hpt_cma_alloc)
		kvm_release_hpt(virt_to_page(kvm->arch.hpt_virt),
				1 << (kvm->arch.hpt_order - PAGE_SHIFT));
	else
	else if (kvm->arch.hpt_virt)
		free_pages(kvm->arch.hpt_virt,
			   kvm->arch.hpt_order - PAGE_SHIFT);
}
@@ -1675,6 +1678,9 @@ void kvmppc_mmu_book3s_hv_init(struct kvm_vcpu *vcpu)

	vcpu->arch.slb_nr = 32;		/* POWER7/POWER8 */

	if (kvm_is_radix(vcpu->kvm))
		mmu->xlate = kvmppc_mmu_radix_xlate;
	else
		mmu->xlate = kvmppc_mmu_book3s_64_hv_xlate;
	mmu->reset_msr = kvmppc_mmu_book3s_64_hv_reset_msr;

Loading