[PATCH v4 30/32] KVM: PPC: Book3S HV: Allow HV module to load without hypervisor mode

David Gibson david at gibson.dropbear.id.au
Fri Oct 5 13:05:46 AEST 2018


On Thu, Oct 04, 2018 at 09:56:07PM +1000, Paul Mackerras wrote:
> With this, the KVM-HV module can be loaded in a guest running under
> KVM-HV, and if the hypervisor supports nested virtualization, this
> guest can now act as a nested hypervisor and run nested guests.
> 
> This also adds some checks to inform userspace that HPT guests are not
> supported by nested hypervisors, and to prevent userspace from
> configuring a guest to use HPT mode.
> 
> Signed-off-by: Paul Mackerras <paulus at ozlabs.org>

Reviewed-by: David Gibson <david at gibson.dropbear.id.au>

> ---
>  arch/powerpc/kvm/book3s_hv.c | 20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index 7561c99..7f89b22 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -4214,6 +4214,10 @@ static int kvm_vm_ioctl_get_smmu_info_hv(struct kvm *kvm,
>  {
>  	struct kvm_ppc_one_seg_page_size *sps;
>  
> +	/* If we're a nested hypervisor, we only support radix guests */
> +	if (kvmhv_on_pseries())
> +		return -EINVAL;
> +
>  	/*
>  	 * POWER7, POWER8 and POWER9 all support 32 storage keys for data.
>  	 * POWER7 doesn't support keys for instruction accesses,
> @@ -4799,11 +4803,15 @@ static int kvmppc_core_emulate_mfspr_hv(struct kvm_vcpu *vcpu, int sprn,
>  
>  static int kvmppc_core_check_processor_compat_hv(void)
>  {
> -	if (!cpu_has_feature(CPU_FTR_HVMODE) ||
> -	    !cpu_has_feature(CPU_FTR_ARCH_206))
> -		return -EIO;
> +	if (cpu_has_feature(CPU_FTR_HVMODE) &&
> +	    cpu_has_feature(CPU_FTR_ARCH_206))
> +		return 0;
>  
> -	return 0;
> +	/* POWER9 in radix mode is capable of being a nested hypervisor. */
> +	if (cpu_has_feature(CPU_FTR_ARCH_300) && radix_enabled())
> +		return 0;
> +
> +	return -EIO;
>  }
>  
>  #ifdef CONFIG_KVM_XICS
> @@ -5121,6 +5129,10 @@ static int kvmhv_configure_mmu(struct kvm *kvm, struct kvm_ppc_mmuv3_cfg *cfg)
>  	if (radix && !radix_enabled())
>  		return -EINVAL;
>  
> +	/* If we're a nested hypervisor, we currently only support radix */
> +	if (kvmhv_on_pseries() && !radix)
> +		return -EINVAL;
> +
>  	mutex_lock(&kvm->lock);
>  	if (radix != kvm_is_radix(kvm)) {
>  		if (kvm->arch.mmu_ready) {

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20181005/87320ca0/attachment-0001.sig>


More information about the Linuxppc-dev mailing list