* [Qemu-devel] [PATCH] ppc/kvm: have the "family" CPU alias to point to TYPE_HOST_POWERPC_CPU
@ 2017-07-05 8:49 Greg Kurz
2017-07-05 9:41 ` Laurent Vivier
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Greg Kurz @ 2017-07-05 8:49 UTC (permalink / raw)
To: qemu-devel; +Cc: Laurent Vivier, Thomas Huth, qemu-ppc, David Gibson
When running KVM on POWER, we allow the user to pass "-cpu POWERx" instead
of "-cpu host". This is achieved by patching the ppc_cpu_aliases[] array
so that "POWERx" points to the CPU class with the same PVR as the host CPU.
This causes CPUs to be instantiated from this CPU class instead of the
TYPE_HOST_POWERPC_CPU class which is used with "-cpu host". These CPUs thus
miss all the KVM specific tuning from kvmppc_host_cpu_class_init().
This currently causes QEMU with "-cpu POWER9" to fail when running KVM on a
POWER9 DD1 host:
qemu-system-ppc64: Register sync failed... If you're using kvm-hv.ko, only
"-cpu host" is possible
kvm_init_vcpu failed: Invalid argument
Let's have the "POWERx" alias to point to TYPE_HOST_POWERPC_CPU directly,
so that "-cpu POWERx" instantiates CPUs from the same class as "-cpu host".
Signed-off-by: Greg Kurz <groug@kaod.org>
---
target/ppc/kvm.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index f2f7c531bc7b..f7a7ea5858a3 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -2445,6 +2445,7 @@ static int kvm_ppc_register_host_cpu_type(void)
.class_init = kvmppc_host_cpu_class_init,
};
PowerPCCPUClass *pvr_pcc;
+ ObjectClass *oc;
DeviceClass *dc;
int i;
@@ -2455,6 +2456,9 @@ static int kvm_ppc_register_host_cpu_type(void)
type_info.parent = object_class_get_name(OBJECT_CLASS(pvr_pcc));
type_register(&type_info);
+ oc = object_class_by_name(type_info.name);
+ g_assert(oc);
+
#if defined(TARGET_PPC64)
type_info.name = g_strdup_printf("%s-"TYPE_SPAPR_CPU_CORE, "host");
type_info.parent = TYPE_SPAPR_CPU_CORE,
@@ -2474,7 +2478,6 @@ static int kvm_ppc_register_host_cpu_type(void)
dc = DEVICE_CLASS(ppc_cpu_get_family_class(pvr_pcc));
for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) {
if (strcmp(ppc_cpu_aliases[i].alias, dc->desc) == 0) {
- ObjectClass *oc = OBJECT_CLASS(pvr_pcc);
char *suffix;
ppc_cpu_aliases[i].model = g_strdup(object_class_get_name(oc));
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] ppc/kvm: have the "family" CPU alias to point to TYPE_HOST_POWERPC_CPU
2017-07-05 8:49 [Qemu-devel] [PATCH] ppc/kvm: have the "family" CPU alias to point to TYPE_HOST_POWERPC_CPU Greg Kurz
@ 2017-07-05 9:41 ` Laurent Vivier
2017-07-05 9:46 ` Thomas Huth
2017-07-06 7:32 ` David Gibson
2 siblings, 0 replies; 5+ messages in thread
From: Laurent Vivier @ 2017-07-05 9:41 UTC (permalink / raw)
To: Greg Kurz, qemu-devel; +Cc: Thomas Huth, qemu-ppc, David Gibson
On 05/07/2017 10:49, Greg Kurz wrote:
> diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
> index f2f7c531bc7b..f7a7ea5858a3 100644
> --- a/target/ppc/kvm.c
> +++ b/target/ppc/kvm.c
> @@ -2445,6 +2445,7 @@ static int kvm_ppc_register_host_cpu_type(void)
> .class_init = kvmppc_host_cpu_class_init,
> };
> PowerPCCPUClass *pvr_pcc;
> + ObjectClass *oc;
> DeviceClass *dc;
> int i;
>
> @@ -2455,6 +2456,9 @@ static int kvm_ppc_register_host_cpu_type(void)
> type_info.parent = object_class_get_name(OBJECT_CLASS(pvr_pcc));
> type_register(&type_info);
>
> + oc = object_class_by_name(type_info.name);
> + g_assert(oc);
> +
> #if defined(TARGET_PPC64)
> type_info.name = g_strdup_printf("%s-"TYPE_SPAPR_CPU_CORE, "host");
> type_info.parent = TYPE_SPAPR_CPU_CORE,
> @@ -2474,7 +2478,6 @@ static int kvm_ppc_register_host_cpu_type(void)
> dc = DEVICE_CLASS(ppc_cpu_get_family_class(pvr_pcc));
> for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) {
> if (strcmp(ppc_cpu_aliases[i].alias, dc->desc) == 0) {
> - ObjectClass *oc = OBJECT_CLASS(pvr_pcc);
> char *suffix;
>
> ppc_cpu_aliases[i].model = g_strdup(object_class_get_name(oc));
>
A far better solution :)
Tested-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] ppc/kvm: have the "family" CPU alias to point to TYPE_HOST_POWERPC_CPU
2017-07-05 8:49 [Qemu-devel] [PATCH] ppc/kvm: have the "family" CPU alias to point to TYPE_HOST_POWERPC_CPU Greg Kurz
2017-07-05 9:41 ` Laurent Vivier
@ 2017-07-05 9:46 ` Thomas Huth
2017-07-06 7:32 ` David Gibson
2 siblings, 0 replies; 5+ messages in thread
From: Thomas Huth @ 2017-07-05 9:46 UTC (permalink / raw)
To: Greg Kurz, qemu-devel; +Cc: Laurent Vivier, qemu-ppc, David Gibson
On 05.07.2017 10:49, Greg Kurz wrote:
> When running KVM on POWER, we allow the user to pass "-cpu POWERx" instead
> of "-cpu host". This is achieved by patching the ppc_cpu_aliases[] array
> so that "POWERx" points to the CPU class with the same PVR as the host CPU.
> This causes CPUs to be instantiated from this CPU class instead of the
> TYPE_HOST_POWERPC_CPU class which is used with "-cpu host". These CPUs thus
> miss all the KVM specific tuning from kvmppc_host_cpu_class_init().
>
> This currently causes QEMU with "-cpu POWER9" to fail when running KVM on a
> POWER9 DD1 host:
>
> qemu-system-ppc64: Register sync failed... If you're using kvm-hv.ko, only
> "-cpu host" is possible
> kvm_init_vcpu failed: Invalid argument
>
> Let's have the "POWERx" alias to point to TYPE_HOST_POWERPC_CPU directly,
> so that "-cpu POWERx" instantiates CPUs from the same class as "-cpu host".
>
> Signed-off-by: Greg Kurz <groug@kaod.org>
> ---
> target/ppc/kvm.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
> index f2f7c531bc7b..f7a7ea5858a3 100644
> --- a/target/ppc/kvm.c
> +++ b/target/ppc/kvm.c
> @@ -2445,6 +2445,7 @@ static int kvm_ppc_register_host_cpu_type(void)
> .class_init = kvmppc_host_cpu_class_init,
> };
> PowerPCCPUClass *pvr_pcc;
> + ObjectClass *oc;
> DeviceClass *dc;
> int i;
>
> @@ -2455,6 +2456,9 @@ static int kvm_ppc_register_host_cpu_type(void)
> type_info.parent = object_class_get_name(OBJECT_CLASS(pvr_pcc));
> type_register(&type_info);
>
> + oc = object_class_by_name(type_info.name);
> + g_assert(oc);
> +
> #if defined(TARGET_PPC64)
> type_info.name = g_strdup_printf("%s-"TYPE_SPAPR_CPU_CORE, "host");
> type_info.parent = TYPE_SPAPR_CPU_CORE,
> @@ -2474,7 +2478,6 @@ static int kvm_ppc_register_host_cpu_type(void)
> dc = DEVICE_CLASS(ppc_cpu_get_family_class(pvr_pcc));
> for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) {
> if (strcmp(ppc_cpu_aliases[i].alias, dc->desc) == 0) {
> - ObjectClass *oc = OBJECT_CLASS(pvr_pcc);
> char *suffix;
>
> ppc_cpu_aliases[i].model = g_strdup(object_class_get_name(oc));
>
Yes, I think that should be fine, too.
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] ppc/kvm: have the "family" CPU alias to point to TYPE_HOST_POWERPC_CPU
2017-07-05 8:49 [Qemu-devel] [PATCH] ppc/kvm: have the "family" CPU alias to point to TYPE_HOST_POWERPC_CPU Greg Kurz
2017-07-05 9:41 ` Laurent Vivier
2017-07-05 9:46 ` Thomas Huth
@ 2017-07-06 7:32 ` David Gibson
2017-07-06 7:55 ` Greg Kurz
2 siblings, 1 reply; 5+ messages in thread
From: David Gibson @ 2017-07-06 7:32 UTC (permalink / raw)
To: Greg Kurz; +Cc: qemu-devel, Laurent Vivier, Thomas Huth, qemu-ppc
[-- Attachment #1: Type: text/plain, Size: 1386 bytes --]
On Wed, Jul 05, 2017 at 10:49:52AM +0200, Greg Kurz wrote:
> When running KVM on POWER, we allow the user to pass "-cpu POWERx" instead
> of "-cpu host". This is achieved by patching the ppc_cpu_aliases[] array
> so that "POWERx" points to the CPU class with the same PVR as the host CPU.
> This causes CPUs to be instantiated from this CPU class instead of the
> TYPE_HOST_POWERPC_CPU class which is used with "-cpu host". These CPUs thus
> miss all the KVM specific tuning from kvmppc_host_cpu_class_init().
>
> This currently causes QEMU with "-cpu POWER9" to fail when running KVM on a
> POWER9 DD1 host:
>
> qemu-system-ppc64: Register sync failed... If you're using kvm-hv.ko, only
> "-cpu host" is possible
> kvm_init_vcpu failed: Invalid argument
>
> Let's have the "POWERx" alias to point to TYPE_HOST_POWERPC_CPU directly,
> so that "-cpu POWERx" instantiates CPUs from the same class as "-cpu host".
>
> Signed-off-by: Greg Kurz <groug@kaod.org>
Nice. I had mistakenly thought it already did that.
I've applied this to ppc-for-2.10.
Just to make sure I've understood, this obsoletes Laurent's earlier
patches moving DD1 workarounds about, yes?
--
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] ppc/kvm: have the "family" CPU alias to point to TYPE_HOST_POWERPC_CPU
2017-07-06 7:32 ` David Gibson
@ 2017-07-06 7:55 ` Greg Kurz
0 siblings, 0 replies; 5+ messages in thread
From: Greg Kurz @ 2017-07-06 7:55 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-devel, Laurent Vivier, Thomas Huth, qemu-ppc
[-- Attachment #1: Type: text/plain, Size: 1375 bytes --]
On Thu, 6 Jul 2017 17:32:33 +1000
David Gibson <david@gibson.dropbear.id.au> wrote:
> On Wed, Jul 05, 2017 at 10:49:52AM +0200, Greg Kurz wrote:
> > When running KVM on POWER, we allow the user to pass "-cpu POWERx" instead
> > of "-cpu host". This is achieved by patching the ppc_cpu_aliases[] array
> > so that "POWERx" points to the CPU class with the same PVR as the host CPU.
> > This causes CPUs to be instantiated from this CPU class instead of the
> > TYPE_HOST_POWERPC_CPU class which is used with "-cpu host". These CPUs thus
> > miss all the KVM specific tuning from kvmppc_host_cpu_class_init().
> >
> > This currently causes QEMU with "-cpu POWER9" to fail when running KVM on a
> > POWER9 DD1 host:
> >
> > qemu-system-ppc64: Register sync failed... If you're using kvm-hv.ko, only
> > "-cpu host" is possible
> > kvm_init_vcpu failed: Invalid argument
> >
> > Let's have the "POWERx" alias to point to TYPE_HOST_POWERPC_CPU directly,
> > so that "-cpu POWERx" instantiates CPUs from the same class as "-cpu host".
> >
> > Signed-off-by: Greg Kurz <groug@kaod.org>
>
> Nice. I had mistakenly thought it already did that.
>
> I've applied this to ppc-for-2.10.
>
> Just to make sure I've understood, this obsoletes Laurent's earlier
> patches moving DD1 workarounds about, yes?
>
Yes it does.
Cheers,
--
Greg
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-07-06 7:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-05 8:49 [Qemu-devel] [PATCH] ppc/kvm: have the "family" CPU alias to point to TYPE_HOST_POWERPC_CPU Greg Kurz
2017-07-05 9:41 ` Laurent Vivier
2017-07-05 9:46 ` Thomas Huth
2017-07-06 7:32 ` David Gibson
2017-07-06 7:55 ` Greg Kurz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).