Skip to content

Commit 468808b

Browse files
paulusmackmpe
authored andcommitted
KVM: PPC: Book3S HV: Set process table for HPT guests on POWER9
This adds the implementation of the KVM_PPC_CONFIGURE_V3_MMU ioctl for HPT guests on POWER9. With this, we can return 1 for the KVM_CAP_PPC_MMU_HASH_V3 capability. Signed-off-by: Paul Mackerras <paulus@ozlabs.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent c927013 commit 468808b

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

arch/powerpc/include/asm/kvm_host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ struct kvm_arch {
264264
atomic_t hpte_mod_interest;
265265
cpumask_t need_tlb_flush;
266266
int hpt_cma_alloc;
267+
u64 process_table;
267268
struct dentry *debugfs_dir;
268269
struct dentry *htab_dentry;
269270
#endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */

arch/powerpc/kvm/book3s_hv.c

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3091,8 +3091,8 @@ static void kvmppc_setup_partition_table(struct kvm *kvm)
30913091
/* HTABSIZE and HTABORG fields */
30923092
dw0 |= kvm->arch.sdr1;
30933093

3094-
/* Second dword has GR=0; other fields are unused since UPRT=0 */
3095-
dw1 = 0;
3094+
/* Second dword as set by userspace */
3095+
dw1 = kvm->arch.process_table;
30963096

30973097
mmu_partition_table_set_entry(kvm->arch.lpid, dw0, dw1);
30983098
}
@@ -3657,10 +3657,37 @@ static void init_default_hcalls(void)
36573657
}
36583658
}
36593659

3660-
/* dummy implementations for now */
36613660
static int kvmhv_configure_mmu(struct kvm *kvm, struct kvm_ppc_mmuv3_cfg *cfg)
36623661
{
3663-
return -EINVAL;
3662+
unsigned long lpcr;
3663+
3664+
/* If not on a POWER9, reject it */
3665+
if (!cpu_has_feature(CPU_FTR_ARCH_300))
3666+
return -ENODEV;
3667+
3668+
/* If any unknown flags set, reject it */
3669+
if (cfg->flags & ~(KVM_PPC_MMUV3_RADIX | KVM_PPC_MMUV3_GTSE))
3670+
return -EINVAL;
3671+
3672+
/* We can't do radix yet */
3673+
if (cfg->flags & KVM_PPC_MMUV3_RADIX)
3674+
return -EINVAL;
3675+
3676+
/* GR (guest radix) bit in process_table field must match */
3677+
if (cfg->process_table & PATB_GR)
3678+
return -EINVAL;
3679+
3680+
/* Process table size field must be reasonable, i.e. <= 24 */
3681+
if ((cfg->process_table & PRTS_MASK) > 24)
3682+
return -EINVAL;
3683+
3684+
kvm->arch.process_table = cfg->process_table;
3685+
kvmppc_setup_partition_table(kvm);
3686+
3687+
lpcr = (cfg->flags & KVM_PPC_MMUV3_GTSE) ? LPCR_GTSE : 0;
3688+
kvmppc_update_lpcr(kvm, lpcr, LPCR_GTSE);
3689+
3690+
return 0;
36643691
}
36653692

36663693
static int kvmhv_get_rmmu_info(struct kvm *kvm, struct kvm_ppc_rmmu_info *info)

arch/powerpc/kvm/powerpc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
569569
r = !!(0 && hv_enabled && radix_enabled());
570570
break;
571571
case KVM_CAP_PPC_MMU_HASH_V3:
572-
r = !!(0 && hv_enabled && !radix_enabled() &&
572+
r = !!(hv_enabled && !radix_enabled() &&
573573
cpu_has_feature(CPU_FTR_ARCH_300));
574574
break;
575575
#endif

0 commit comments

Comments
 (0)