KVM: PPC: Don't always report hash MMU capability for P9 < DD2.2
authorFabiano Rosas <farosas@linux.ibm.com>
Fri, 5 Feb 2021 16:41:54 +0000 (13:41 -0300)
committerPaul Mackerras <paulus@ozlabs.org>
Wed, 10 Feb 2021 05:19:36 +0000 (16:19 +1100)
These machines don't support running both MMU types at the same time,
so remove the KVM_CAP_PPC_MMU_HASH_V3 capability when the host is
using Radix MMU.

[paulus@ozlabs.org - added defensive check on
 kvmppc_hv_ops->hash_v3_possible]

Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
arch/powerpc/include/asm/kvm_ppc.h
arch/powerpc/kvm/book3s_hv.c
arch/powerpc/kvm/powerpc.c

index 13c39d2..df4bda8 100644 (file)
@@ -315,6 +315,7 @@ struct kvmppc_ops {
        int (*enable_svm)(struct kvm *kvm);
        int (*svm_off)(struct kvm *kvm);
        int (*enable_dawr1)(struct kvm *kvm);
+       bool (*hash_v3_possible)(void);
 };
 
 extern struct kvmppc_ops *kvmppc_hv_ops;
index f6d4701..f09708d 100644 (file)
@@ -5625,6 +5625,15 @@ static int kvmhv_enable_dawr1(struct kvm *kvm)
        return 0;
 }
 
+static bool kvmppc_hash_v3_possible(void)
+{
+       if (radix_enabled() && no_mixing_hpt_and_radix)
+               return false;
+
+       return cpu_has_feature(CPU_FTR_ARCH_300) &&
+               cpu_has_feature(CPU_FTR_HVMODE);
+}
+
 static struct kvmppc_ops kvm_ops_hv = {
        .get_sregs = kvm_arch_vcpu_ioctl_get_sregs_hv,
        .set_sregs = kvm_arch_vcpu_ioctl_set_sregs_hv,
@@ -5669,6 +5678,7 @@ static struct kvmppc_ops kvm_ops_hv = {
        .enable_svm = kvmhv_enable_svm,
        .svm_off = kvmhv_svm_off,
        .enable_dawr1 = kvmhv_enable_dawr1,
+       .hash_v3_possible = kvmppc_hash_v3_possible,
 };
 
 static int kvm_init_subcore_bitmap(void)
index 5914c32..6c083a9 100644 (file)
@@ -611,8 +611,8 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
                r = !!(hv_enabled && radix_enabled());
                break;
        case KVM_CAP_PPC_MMU_HASH_V3:
-               r = !!(hv_enabled && cpu_has_feature(CPU_FTR_ARCH_300) &&
-                      cpu_has_feature(CPU_FTR_HVMODE));
+               r = !!(hv_enabled && kvmppc_hv_ops->hash_v3_possible &&
+                      kvmppc_hv_ops->hash_v3_possible());
                break;
        case KVM_CAP_PPC_NESTED_HV:
                r = !!(hv_enabled && kvmppc_hv_ops->enable_nested &&