76daa3
From cc60fde1ea12ad942713d0c78f8b7c94df64229b Mon Sep 17 00:00:00 2001
76daa3
From: Laurent Vivier <lvivier@redhat.com>
76daa3
Date: Wed, 12 Jul 2017 07:45:34 +0200
76daa3
Subject: [PATCH 1/6] ppc/kvm: have the "family" CPU alias to point to
76daa3
 TYPE_HOST_POWERPC_CPU
76daa3
76daa3
RH-Author: Laurent Vivier <lvivier@redhat.com>
76daa3
Message-id: <20170712074534.19224-1-lvivier@redhat.com>
76daa3
Patchwork-id: 75735
76daa3
O-Subject: [RHEL-ALT-7.4 qemu-kvm PATCH] ppc/kvm: have the "family" CPU alias to point to TYPE_HOST_POWERPC_CPU
76daa3
Bugzilla: 1460908
76daa3
RH-Acked-by: Thomas Huth <thuth@redhat.com>
76daa3
RH-Acked-by: David Gibson <dgibson@redhat.com>
76daa3
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
76daa3
76daa3
From: Greg Kurz <groug@kaod.org>
76daa3
76daa3
When running KVM on POWER, we allow the user to pass "-cpu POWERx" instead
76daa3
of "-cpu host". This is achieved by patching the ppc_cpu_aliases[] array
76daa3
so that "POWERx" points to the CPU class with the same PVR as the host CPU.
76daa3
This causes CPUs to be instantiated from this CPU class instead of the
76daa3
TYPE_HOST_POWERPC_CPU class which is used with "-cpu host". These CPUs thus
76daa3
miss all the KVM specific tuning from kvmppc_host_cpu_class_init().
76daa3
76daa3
This currently causes QEMU with "-cpu POWER9" to fail when running KVM on a
76daa3
POWER9 DD1 host:
76daa3
76daa3
qemu-system-ppc64: Register sync failed... If you're using kvm-hv.ko, only
76daa3
 "-cpu host" is possible
76daa3
kvm_init_vcpu failed: Invalid argument
76daa3
76daa3
Let's have the "POWERx" alias to point to TYPE_HOST_POWERPC_CPU directly,
76daa3
so that "-cpu POWERx" instantiates CPUs from the same class as "-cpu host".
76daa3
76daa3
Signed-off-by: Greg Kurz <groug@kaod.org>
76daa3
Tested-by: Laurent Vivier <lvivier@redhat.com>
76daa3
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
76daa3
Reviewed-by: Thomas Huth <thuth@redhat.com>
76daa3
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
76daa3
(cherry picked from commit 92e926e1e37aea7e1632535b6611ed4f62414af1)
76daa3
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
76daa3
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
76daa3
---
76daa3
 target/ppc/kvm.c | 5 ++++-
76daa3
 1 file changed, 4 insertions(+), 1 deletion(-)
76daa3
76daa3
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
76daa3
index 1765204..9eb85ae 100644
76daa3
--- a/target/ppc/kvm.c
76daa3
+++ b/target/ppc/kvm.c
76daa3
@@ -2448,6 +2448,7 @@ static int kvm_ppc_register_host_cpu_type(void)
76daa3
         .class_init = kvmppc_host_cpu_class_init,
76daa3
     };
76daa3
     PowerPCCPUClass *pvr_pcc;
76daa3
+    ObjectClass *oc;
76daa3
     DeviceClass *dc;
76daa3
     int i;
76daa3
 
76daa3
@@ -2458,6 +2459,9 @@ static int kvm_ppc_register_host_cpu_type(void)
76daa3
     type_info.parent = object_class_get_name(OBJECT_CLASS(pvr_pcc));
76daa3
     type_register(&type_info);
76daa3
 
76daa3
+    oc = object_class_by_name(type_info.name);
76daa3
+    g_assert(oc);
76daa3
+
76daa3
 #if defined(TARGET_PPC64)
76daa3
     type_info.name = g_strdup_printf("%s-"TYPE_SPAPR_CPU_CORE, "host");
76daa3
     type_info.parent = TYPE_SPAPR_CPU_CORE,
76daa3
@@ -2477,7 +2481,6 @@ static int kvm_ppc_register_host_cpu_type(void)
76daa3
     dc = DEVICE_CLASS(ppc_cpu_get_family_class(pvr_pcc));
76daa3
     for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) {
76daa3
         if (strcmp(ppc_cpu_aliases[i].alias, dc->desc) == 0) {
76daa3
-            ObjectClass *oc = OBJECT_CLASS(pvr_pcc);
76daa3
             char *suffix;
76daa3
 
76daa3
             ppc_cpu_aliases[i].model = g_strdup(object_class_get_name(oc));
76daa3
-- 
76daa3
1.8.3.1
76daa3