All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] ppc/pnv.c: add a friendly warning when accel=kvm is used
@ 2021-11-25 22:42 Daniel Henrique Barboza
  2021-11-26  1:11 ` David Gibson
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Henrique Barboza @ 2021-11-25 22:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Daniel Henrique Barboza, qemu-ppc, clg, david

If one tries to use -machine powernv9,accel=kvm in a Power9 host, a
cryptic error will be shown:

qemu-system-ppc64: Register sync failed... If you're using kvm-hv.ko, only "-cpu host" is possible
qemu-system-ppc64: kvm_init_vcpu: kvm_arch_init_vcpu failed (0): Invalid argument

Appending '-cpu host' will throw another error:

qemu-system-ppc64: invalid chip model 'host' for powernv9 machine

The root cause is that in IBM PowerPC we have different specs for the bare-metal
and the guests. The bare-metal follows OPAL, the guests follow PAPR. The kernel
KVM modules presented in the ppc kernels implements PAPR. This means that we
can't use KVM accel when using the powernv machine, which is the emulation of
the bare-metal host.

All that said, let's give a more informative error in this case.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/ppc/pnv.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 71e45515f1..e5b87e8730 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -742,6 +742,11 @@ static void pnv_init(MachineState *machine)
     DriveInfo *pnor = drive_get(IF_MTD, 0, 0);
     DeviceState *dev;
 
+    if (kvm_enabled()) {
+        error_report("The powernv machine does not work with KVM acceleration");
+        exit(EXIT_FAILURE);
+    }
+
     /* allocate RAM */
     if (machine->ram_size < mc->default_ram_size) {
         char *sz = size_to_str(mc->default_ram_size);
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] ppc/pnv.c: add a friendly warning when accel=kvm is used
  2021-11-25 22:42 [PATCH 1/1] ppc/pnv.c: add a friendly warning when accel=kvm is used Daniel Henrique Barboza
@ 2021-11-26  1:11 ` David Gibson
  2021-11-26 17:51   ` Cédric Le Goater
  0 siblings, 1 reply; 6+ messages in thread
From: David Gibson @ 2021-11-26  1:11 UTC (permalink / raw)
  To: Daniel Henrique Barboza; +Cc: qemu-ppc, qemu-devel, clg

[-- Attachment #1: Type: text/plain, Size: 1986 bytes --]

On Thu, Nov 25, 2021 at 07:42:02PM -0300, Daniel Henrique Barboza wrote:
> If one tries to use -machine powernv9,accel=kvm in a Power9 host, a
> cryptic error will be shown:
> 
> qemu-system-ppc64: Register sync failed... If you're using kvm-hv.ko, only "-cpu host" is possible
> qemu-system-ppc64: kvm_init_vcpu: kvm_arch_init_vcpu failed (0): Invalid argument
> 
> Appending '-cpu host' will throw another error:
> 
> qemu-system-ppc64: invalid chip model 'host' for powernv9 machine
> 
> The root cause is that in IBM PowerPC we have different specs for the bare-metal
> and the guests. The bare-metal follows OPAL, the guests follow PAPR. The kernel
> KVM modules presented in the ppc kernels implements PAPR. This means that we
> can't use KVM accel when using the powernv machine, which is the emulation of
> the bare-metal host.
> 
> All that said, let's give a more informative error in this case.
> 
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> ---
>  hw/ppc/pnv.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
> index 71e45515f1..e5b87e8730 100644
> --- a/hw/ppc/pnv.c
> +++ b/hw/ppc/pnv.c
> @@ -742,6 +742,11 @@ static void pnv_init(MachineState *machine)
>      DriveInfo *pnor = drive_get(IF_MTD, 0, 0);
>      DeviceState *dev;
>  
> +    if (kvm_enabled()) {
> +        error_report("The powernv machine does not work with KVM acceleration");
> +        exit(EXIT_FAILURE);
> +    }


Hmm.. my only concern here is that powernv could, at least
theoretically, work with KVM PR.  I don't think it does right now,
though.

> +
>      /* allocate RAM */
>      if (machine->ram_size < mc->default_ram_size) {
>          char *sz = size_to_str(mc->default_ram_size);

-- 
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: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] ppc/pnv.c: add a friendly warning when accel=kvm is used
  2021-11-26  1:11 ` David Gibson
@ 2021-11-26 17:51   ` Cédric Le Goater
  2021-11-27  5:14     ` David Gibson
  0 siblings, 1 reply; 6+ messages in thread
From: Cédric Le Goater @ 2021-11-26 17:51 UTC (permalink / raw)
  To: David Gibson, Daniel Henrique Barboza; +Cc: qemu-ppc, qemu-devel

On 11/26/21 02:11, David Gibson wrote:
> On Thu, Nov 25, 2021 at 07:42:02PM -0300, Daniel Henrique Barboza wrote:
>> If one tries to use -machine powernv9,accel=kvm in a Power9 host, a
>> cryptic error will be shown:
>>
>> qemu-system-ppc64: Register sync failed... If you're using kvm-hv.ko, only "-cpu host" is possible
>> qemu-system-ppc64: kvm_init_vcpu: kvm_arch_init_vcpu failed (0): Invalid argument
>>
>> Appending '-cpu host' will throw another error:
>>
>> qemu-system-ppc64: invalid chip model 'host' for powernv9 machine
>>
>> The root cause is that in IBM PowerPC we have different specs for the bare-metal
>> and the guests. The bare-metal follows OPAL, the guests follow PAPR. The kernel
>> KVM modules presented in the ppc kernels implements PAPR. This means that we
>> can't use KVM accel when using the powernv machine, which is the emulation of
>> the bare-metal host.
>>
>> All that said, let's give a more informative error in this case.
>>
>> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
>> ---
>>   hw/ppc/pnv.c | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
>> index 71e45515f1..e5b87e8730 100644
>> --- a/hw/ppc/pnv.c
>> +++ b/hw/ppc/pnv.c
>> @@ -742,6 +742,11 @@ static void pnv_init(MachineState *machine)
>>       DriveInfo *pnor = drive_get(IF_MTD, 0, 0);
>>       DeviceState *dev;
>>   
>> +    if (kvm_enabled()) {
>> +        error_report("The powernv machine does not work with KVM acceleration");
>> +        exit(EXIT_FAILURE);
>> +    }
> 
> 
> Hmm.. my only concern here is that powernv could, at least
> theoretically, work with KVM PR.  I don't think it does right now,
> though.

At the same time, it is nice to not let the user think that it could work
in its current state. Don't you think so ?

C.

> 
>> +
>>       /* allocate RAM */
>>       if (machine->ram_size < mc->default_ram_size) {
>>           char *sz = size_to_str(mc->default_ram_size);
> 



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] ppc/pnv.c: add a friendly warning when accel=kvm is used
  2021-11-26 17:51   ` Cédric Le Goater
@ 2021-11-27  5:14     ` David Gibson
  2021-11-29 21:09       ` Daniel Henrique Barboza
  0 siblings, 1 reply; 6+ messages in thread
From: David Gibson @ 2021-11-27  5:14 UTC (permalink / raw)
  To: Cédric Le Goater; +Cc: Daniel Henrique Barboza, qemu-ppc, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 2479 bytes --]

On Fri, Nov 26, 2021 at 06:51:38PM +0100, Cédric le Goater wrote:
> On 11/26/21 02:11, David Gibson wrote:
> > On Thu, Nov 25, 2021 at 07:42:02PM -0300, Daniel Henrique Barboza wrote:
> > > If one tries to use -machine powernv9,accel=kvm in a Power9 host, a
> > > cryptic error will be shown:
> > > 
> > > qemu-system-ppc64: Register sync failed... If you're using kvm-hv.ko, only "-cpu host" is possible
> > > qemu-system-ppc64: kvm_init_vcpu: kvm_arch_init_vcpu failed (0): Invalid argument
> > > 
> > > Appending '-cpu host' will throw another error:
> > > 
> > > qemu-system-ppc64: invalid chip model 'host' for powernv9 machine
> > > 
> > > The root cause is that in IBM PowerPC we have different specs for the bare-metal
> > > and the guests. The bare-metal follows OPAL, the guests follow PAPR. The kernel
> > > KVM modules presented in the ppc kernels implements PAPR. This means that we
> > > can't use KVM accel when using the powernv machine, which is the emulation of
> > > the bare-metal host.
> > > 
> > > All that said, let's give a more informative error in this case.
> > > 
> > > Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> > > ---
> > >   hw/ppc/pnv.c | 5 +++++
> > >   1 file changed, 5 insertions(+)
> > > 
> > > diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
> > > index 71e45515f1..e5b87e8730 100644
> > > --- a/hw/ppc/pnv.c
> > > +++ b/hw/ppc/pnv.c
> > > @@ -742,6 +742,11 @@ static void pnv_init(MachineState *machine)
> > >       DriveInfo *pnor = drive_get(IF_MTD, 0, 0);
> > >       DeviceState *dev;
> > > +    if (kvm_enabled()) {
> > > +        error_report("The powernv machine does not work with KVM acceleration");
> > > +        exit(EXIT_FAILURE);
> > > +    }
> > 
> > 
> > Hmm.. my only concern here is that powernv could, at least
> > theoretically, work with KVM PR.  I don't think it does right now,
> > though.
> 
> At the same time, it is nice to not let the user think that it could work
> in its current state. Don't you think so ?

Right, I'm thinking of the implication if you have an old qemu but a
new KVM which let it work.  Chances of KVM actually implementing this
probably aren't good though, so requiring the qemu update if we ever
do is probably the better deal.

-- 
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: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] ppc/pnv.c: add a friendly warning when accel=kvm is used
  2021-11-27  5:14     ` David Gibson
@ 2021-11-29 21:09       ` Daniel Henrique Barboza
  2021-11-30  0:14         ` David Gibson
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Henrique Barboza @ 2021-11-29 21:09 UTC (permalink / raw)
  To: David Gibson, Cédric Le Goater; +Cc: qemu-ppc, qemu-devel



On 11/27/21 02:14, David Gibson wrote:
> On Fri, Nov 26, 2021 at 06:51:38PM +0100, Cédric le Goater wrote:
>> On 11/26/21 02:11, David Gibson wrote:
>>> On Thu, Nov 25, 2021 at 07:42:02PM -0300, Daniel Henrique Barboza wrote:
>>>> If one tries to use -machine powernv9,accel=kvm in a Power9 host, a
>>>> cryptic error will be shown:
>>>>
>>>> qemu-system-ppc64: Register sync failed... If you're using kvm-hv.ko, only "-cpu host" is possible
>>>> qemu-system-ppc64: kvm_init_vcpu: kvm_arch_init_vcpu failed (0): Invalid argument
>>>>
>>>> Appending '-cpu host' will throw another error:
>>>>
>>>> qemu-system-ppc64: invalid chip model 'host' for powernv9 machine
>>>>
>>>> The root cause is that in IBM PowerPC we have different specs for the bare-metal
>>>> and the guests. The bare-metal follows OPAL, the guests follow PAPR. The kernel
>>>> KVM modules presented in the ppc kernels implements PAPR. This means that we
>>>> can't use KVM accel when using the powernv machine, which is the emulation of
>>>> the bare-metal host.
>>>>
>>>> All that said, let's give a more informative error in this case.
>>>>
>>>> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
>>>> ---
>>>>    hw/ppc/pnv.c | 5 +++++
>>>>    1 file changed, 5 insertions(+)
>>>>
>>>> diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
>>>> index 71e45515f1..e5b87e8730 100644
>>>> --- a/hw/ppc/pnv.c
>>>> +++ b/hw/ppc/pnv.c
>>>> @@ -742,6 +742,11 @@ static void pnv_init(MachineState *machine)
>>>>        DriveInfo *pnor = drive_get(IF_MTD, 0, 0);
>>>>        DeviceState *dev;
>>>> +    if (kvm_enabled()) {
>>>> +        error_report("The powernv machine does not work with KVM acceleration");
>>>> +        exit(EXIT_FAILURE);
>>>> +    }
>>>
>>>
>>> Hmm.. my only concern here is that powernv could, at least
>>> theoretically, work with KVM PR.  I don't think it does right now,
>>> though.
>>
>> At the same time, it is nice to not let the user think that it could work
>> in its current state. Don't you think so ?
> 
> Right, I'm thinking of the implication if you have an old qemu but a
> new KVM which let it work.  Chances of KVM actually implementing this
> probably aren't good though, so requiring the qemu update if we ever
> do is probably the better deal.


If the KVM module implements powernv accel support in the future, I wouldn't
take my the chances with the powernv machine working out of the box with it.

Most likely, if an endeavor of supporting KVM accel for powernv ever takes
place, we'll need QEMU changes to go with it. And when that happens we can
revert this patch and make the other necessary changes/fixes.

All that said, perhaps it's useful to add a note in docs/system/ppc/powernv.rst
explaining the the rationale for what we're doing here.



Thanks,


Daniel



> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] ppc/pnv.c: add a friendly warning when accel=kvm is used
  2021-11-29 21:09       ` Daniel Henrique Barboza
@ 2021-11-30  0:14         ` David Gibson
  0 siblings, 0 replies; 6+ messages in thread
From: David Gibson @ 2021-11-30  0:14 UTC (permalink / raw)
  To: Daniel Henrique Barboza; +Cc: qemu-ppc, Cédric Le Goater, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 3374 bytes --]

On Mon, Nov 29, 2021 at 06:09:41PM -0300, Daniel Henrique Barboza wrote:
> 
> 
> On 11/27/21 02:14, David Gibson wrote:
> > On Fri, Nov 26, 2021 at 06:51:38PM +0100, Cédric le Goater wrote:
> > > On 11/26/21 02:11, David Gibson wrote:
> > > > On Thu, Nov 25, 2021 at 07:42:02PM -0300, Daniel Henrique Barboza wrote:
> > > > > If one tries to use -machine powernv9,accel=kvm in a Power9 host, a
> > > > > cryptic error will be shown:
> > > > > 
> > > > > qemu-system-ppc64: Register sync failed... If you're using kvm-hv.ko, only "-cpu host" is possible
> > > > > qemu-system-ppc64: kvm_init_vcpu: kvm_arch_init_vcpu failed (0): Invalid argument
> > > > > 
> > > > > Appending '-cpu host' will throw another error:
> > > > > 
> > > > > qemu-system-ppc64: invalid chip model 'host' for powernv9 machine
> > > > > 
> > > > > The root cause is that in IBM PowerPC we have different specs for the bare-metal
> > > > > and the guests. The bare-metal follows OPAL, the guests follow PAPR. The kernel
> > > > > KVM modules presented in the ppc kernels implements PAPR. This means that we
> > > > > can't use KVM accel when using the powernv machine, which is the emulation of
> > > > > the bare-metal host.
> > > > > 
> > > > > All that said, let's give a more informative error in this case.
> > > > > 
> > > > > Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
> > > > > ---
> > > > >    hw/ppc/pnv.c | 5 +++++
> > > > >    1 file changed, 5 insertions(+)
> > > > > 
> > > > > diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
> > > > > index 71e45515f1..e5b87e8730 100644
> > > > > --- a/hw/ppc/pnv.c
> > > > > +++ b/hw/ppc/pnv.c
> > > > > @@ -742,6 +742,11 @@ static void pnv_init(MachineState *machine)
> > > > >        DriveInfo *pnor = drive_get(IF_MTD, 0, 0);
> > > > >        DeviceState *dev;
> > > > > +    if (kvm_enabled()) {
> > > > > +        error_report("The powernv machine does not work with KVM acceleration");
> > > > > +        exit(EXIT_FAILURE);
> > > > > +    }
> > > > 
> > > > 
> > > > Hmm.. my only concern here is that powernv could, at least
> > > > theoretically, work with KVM PR.  I don't think it does right now,
> > > > though.
> > > 
> > > At the same time, it is nice to not let the user think that it could work
> > > in its current state. Don't you think so ?
> > 
> > Right, I'm thinking of the implication if you have an old qemu but a
> > new KVM which let it work.  Chances of KVM actually implementing this
> > probably aren't good though, so requiring the qemu update if we ever
> > do is probably the better deal.
> 
> 
> If the KVM module implements powernv accel support in the future, I wouldn't
> take my the chances with the powernv machine working out of the box with it.
> 
> Most likely, if an endeavor of supporting KVM accel for powernv ever takes
> place, we'll need QEMU changes to go with it. And when that happens we can
> revert this patch and make the other necessary changes/fixes.
> 
> All that said, perhaps it's useful to add a note in docs/system/ppc/powernv.rst
> explaining the the rationale for what we're doing here.

Yeah, makes sense to me.

-- 
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: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-11-30  2:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-25 22:42 [PATCH 1/1] ppc/pnv.c: add a friendly warning when accel=kvm is used Daniel Henrique Barboza
2021-11-26  1:11 ` David Gibson
2021-11-26 17:51   ` Cédric Le Goater
2021-11-27  5:14     ` David Gibson
2021-11-29 21:09       ` Daniel Henrique Barboza
2021-11-30  0:14         ` David Gibson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.