All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH resend] qemuboot.conf: make cpus match built artifacts
@ 2017-05-02 19:20 Martin Kelly
  2017-05-22 17:29 ` Martin Kelly
  2017-06-15 11:45 ` Burton, Ross
  0 siblings, 2 replies; 12+ messages in thread
From: Martin Kelly @ 2017-05-02 19:20 UTC (permalink / raw)
  To: openembedded-core; +Cc: Joshua G Lock

Currently, the qemu CPUs for are specified as generic, but the built
artifacts are not. For example, we build x86-64 artifacts targeting
core2duo but run them in qemu with generic qemu/kvm CPUs. This causes
some packages that take advantage of the host architecture to crash
because they try to use CPU features not advertised by qemu. As an
example, Qt uses ssse3. When artifacts linked against Qt and built
targeting core2duo attempt to run on a generic qemu/kvm CPU, we get
the following crash:

Incompatible processor. This Qt build requires the following features:
     ssse3

We could fix this by making packages like Qt not take advantage of CPU
features. However, we will probably keep facing similar issues over
time, so it's better to resolve them in a more enduring way.

Fix this by making the qemu -cpu arguments match the built artifacts.

Signed-off-by: Martin Kelly <mkelly@xevo.com>
---

I sent this to poky@yoctoproject.org but it should have gone to OE-core,
so I'm resending it now to restart the discussion on the right mailing
list. There were some comments about it in a previous mail thread on the
poky mailing list:

https://lists.yoctoproject.org/pipermail/poky/2017-April/010956.html

 meta/conf/machine/include/qemuboot-x86.inc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/meta/conf/machine/include/qemuboot-x86.inc b/meta/conf/machine/include/qemuboot-x86.inc
index 06ac983..acd03a1 100644
--- a/meta/conf/machine/include/qemuboot-x86.inc
+++ b/meta/conf/machine/include/qemuboot-x86.inc
@@ -1,12 +1,12 @@
 # For runqemu
 IMAGE_CLASSES += "qemuboot"
 QB_SYSTEM_NAME_x86 = "qemu-system-i386"
-QB_CPU_x86 = "-cpu qemu32"
-QB_CPU_KVM_x86 = "-cpu kvm32"
+QB_CPU_x86 = "-cpu pentium2"
+QB_CPU_KVM_x86 = "-cpu pentium2"
 
 QB_SYSTEM_NAME_x86-64 = "qemu-system-x86_64"
 QB_CPU_x86-64 = "-cpu core2duo"
-QB_CPU_KVM_x86-64 = "-cpu kvm64"
+QB_CPU_KVM_x86-64 = "-cpu core2duo"
 
 QB_AUDIO_DRV = "alsa"
 QB_AUDIO_OPT = "-soundhw ac97,es1370"
-- 
2.7.4



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

* Re: [PATCH resend] qemuboot.conf: make cpus match built artifacts
  2017-05-02 19:20 [PATCH resend] qemuboot.conf: make cpus match built artifacts Martin Kelly
@ 2017-05-22 17:29 ` Martin Kelly
  2017-05-22 17:53   ` Randy Witt
  2017-06-15 11:45 ` Burton, Ross
  1 sibling, 1 reply; 12+ messages in thread
From: Martin Kelly @ 2017-05-22 17:29 UTC (permalink / raw)
  To: openembedded-core; +Cc: Joshua G Lock

(friendly ping)

On 05/02/2017 12:20 PM, Martin Kelly wrote:
> Currently, the qemu CPUs for are specified as generic, but the built
> artifacts are not. For example, we build x86-64 artifacts targeting
> core2duo but run them in qemu with generic qemu/kvm CPUs. This causes
> some packages that take advantage of the host architecture to crash
> because they try to use CPU features not advertised by qemu. As an
> example, Qt uses ssse3. When artifacts linked against Qt and built
> targeting core2duo attempt to run on a generic qemu/kvm CPU, we get
> the following crash:
>
> Incompatible processor. This Qt build requires the following features:
>      ssse3
>
> We could fix this by making packages like Qt not take advantage of CPU
> features. However, we will probably keep facing similar issues over
> time, so it's better to resolve them in a more enduring way.
>
> Fix this by making the qemu -cpu arguments match the built artifacts.
>
> Signed-off-by: Martin Kelly <mkelly@xevo.com>
> ---
>
> I sent this to poky@yoctoproject.org but it should have gone to OE-core,
> so I'm resending it now to restart the discussion on the right mailing
> list. There were some comments about it in a previous mail thread on the
> poky mailing list:
>
> https://lists.yoctoproject.org/pipermail/poky/2017-April/010956.html
>
>  meta/conf/machine/include/qemuboot-x86.inc | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/meta/conf/machine/include/qemuboot-x86.inc b/meta/conf/machine/include/qemuboot-x86.inc
> index 06ac983..acd03a1 100644
> --- a/meta/conf/machine/include/qemuboot-x86.inc
> +++ b/meta/conf/machine/include/qemuboot-x86.inc
> @@ -1,12 +1,12 @@
>  # For runqemu
>  IMAGE_CLASSES += "qemuboot"
>  QB_SYSTEM_NAME_x86 = "qemu-system-i386"
> -QB_CPU_x86 = "-cpu qemu32"
> -QB_CPU_KVM_x86 = "-cpu kvm32"
> +QB_CPU_x86 = "-cpu pentium2"
> +QB_CPU_KVM_x86 = "-cpu pentium2"
>
>  QB_SYSTEM_NAME_x86-64 = "qemu-system-x86_64"
>  QB_CPU_x86-64 = "-cpu core2duo"
> -QB_CPU_KVM_x86-64 = "-cpu kvm64"
> +QB_CPU_KVM_x86-64 = "-cpu core2duo"
>
>  QB_AUDIO_DRV = "alsa"
>  QB_AUDIO_OPT = "-soundhw ac97,es1370"
>


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

* Re: [PATCH resend] qemuboot.conf: make cpus match built artifacts
  2017-05-22 17:29 ` Martin Kelly
@ 2017-05-22 17:53   ` Randy Witt
  2017-05-22 18:09     ` Martin Kelly
  0 siblings, 1 reply; 12+ messages in thread
From: Randy Witt @ 2017-05-22 17:53 UTC (permalink / raw)
  To: Martin Kelly, openembedded-core; +Cc: Joshua G Lock

On 05/22/2017 10:29 AM, Martin Kelly wrote:
> (friendly ping)
> 
> On 05/02/2017 12:20 PM, Martin Kelly wrote:
>> Currently, the qemu CPUs for are specified as generic, but the built
>> artifacts are not. For example, we build x86-64 artifacts targeting
>> core2duo but run them in qemu with generic qemu/kvm CPUs. This causes
>> some packages that take advantage of the host architecture to crash
>> because they try to use CPU features not advertised by qemu. As an
>> example, Qt uses ssse3. When artifacts linked against Qt and built
>> targeting core2duo attempt to run on a generic qemu/kvm CPU, we get
>> the following crash:
>>
>> Incompatible processor. This Qt build requires the following features:
>>      ssse3
>>
>> We could fix this by making packages like Qt not take advantage of CPU
>> features. However, we will probably keep facing similar issues over
>> time, so it's better to resolve them in a more enduring way.

If the MACHINE is a generic qemu, it seems more correct to build without the 
extensions. For instance, what happens when core2duo doesn't have all the 
necessary instructions that some package decided to use?

I like the idea of being able to exercise the code, but I only see this fix as 
pushing the maintenance until the problem appears again later.

>>
>> Fix this by making the qemu -cpu arguments match the built artifacts.
>>
>> Signed-off-by: Martin Kelly <mkelly@xevo.com>
>> ---
>>
>> I sent this to poky@yoctoproject.org but it should have gone to OE-core,
>> so I'm resending it now to restart the discussion on the right mailing
>> list. There were some comments about it in a previous mail thread on the
>> poky mailing list:
>>
>> https://lists.yoctoproject.org/pipermail/poky/2017-April/010956.html
>>
>>  meta/conf/machine/include/qemuboot-x86.inc | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/meta/conf/machine/include/qemuboot-x86.inc 
>> b/meta/conf/machine/include/qemuboot-x86.inc
>> index 06ac983..acd03a1 100644
>> --- a/meta/conf/machine/include/qemuboot-x86.inc
>> +++ b/meta/conf/machine/include/qemuboot-x86.inc
>> @@ -1,12 +1,12 @@
>>  # For runqemu
>>  IMAGE_CLASSES += "qemuboot"
>>  QB_SYSTEM_NAME_x86 = "qemu-system-i386"
>> -QB_CPU_x86 = "-cpu qemu32"
>> -QB_CPU_KVM_x86 = "-cpu kvm32"
>> +QB_CPU_x86 = "-cpu pentium2"
>> +QB_CPU_KVM_x86 = "-cpu pentium2"
>>
>>  QB_SYSTEM_NAME_x86-64 = "qemu-system-x86_64"
>>  QB_CPU_x86-64 = "-cpu core2duo"
>> -QB_CPU_KVM_x86-64 = "-cpu kvm64"
>> +QB_CPU_KVM_x86-64 = "-cpu core2duo"
>>
>>  QB_AUDIO_DRV = "alsa"
>>  QB_AUDIO_OPT = "-soundhw ac97,es1370"
>>



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

* Re: [PATCH resend] qemuboot.conf: make cpus match built artifacts
  2017-05-22 17:53   ` Randy Witt
@ 2017-05-22 18:09     ` Martin Kelly
  2017-06-13 16:44       ` Martin Kelly
  0 siblings, 1 reply; 12+ messages in thread
From: Martin Kelly @ 2017-05-22 18:09 UTC (permalink / raw)
  To: Randy Witt, openembedded-core; +Cc: Joshua G Lock

On 05/22/2017 10:53 AM, Randy Witt wrote:
> On 05/22/2017 10:29 AM, Martin Kelly wrote:
>> (friendly ping)
>>
>> On 05/02/2017 12:20 PM, Martin Kelly wrote:
>>> Currently, the qemu CPUs for are specified as generic, but the built
>>> artifacts are not. For example, we build x86-64 artifacts targeting
>>> core2duo but run them in qemu with generic qemu/kvm CPUs. This causes
>>> some packages that take advantage of the host architecture to crash
>>> because they try to use CPU features not advertised by qemu. As an
>>> example, Qt uses ssse3. When artifacts linked against Qt and built
>>> targeting core2duo attempt to run on a generic qemu/kvm CPU, we get
>>> the following crash:
>>>
>>> Incompatible processor. This Qt build requires the following features:
>>>      ssse3
>>>
>>> We could fix this by making packages like Qt not take advantage of CPU
>>> features. However, we will probably keep facing similar issues over
>>> time, so it's better to resolve them in a more enduring way.
>
> If the MACHINE is a generic qemu, it seems more correct to build without
> the extensions. For instance, what happens when core2duo doesn't have
> all the necessary instructions that some package decided to use?
>
> I like the idea of being able to exercise the code, but I only see this
> fix as pushing the maintenance until the problem appears again later.
>

Currently, I believe we're passing in all the right flags (e.g. -march) 
to specify a core2duo build, so GCC should not issue any instructions 
that a core2duo wouldn't support. By passing in these flags, we're 
allowing recipes to issue core2duo instructions and then creating a 
runtime environment that doesn't support those same instructions (bug).

I don't think we're deferring any maintenance; unless we change the 
-march and similar flags to be something other than core2duo, I think 
the problems should go away. If we make that change, we should update 
the qemu CPUs at the same time.

We can solve the problem in one of two ways:

- Make qemu run as core2duo
- Make recipes build as something even more basic

The second change is much more involved than the first. I don't which 
-march (and similar) flags are the closest match to the generic qemu 
32/qemu64 CPUs. However, I suspect there may not be a perfect match. 
And, core2duo is already quite old and basic by today's standards 
anyway, so I think bringing the qemu CPUs up to match is the simplest 
and best way to fix the issue.

>>>
>>> Fix this by making the qemu -cpu arguments match the built artifacts.
>>>
>>> Signed-off-by: Martin Kelly <mkelly@xevo.com>
>>> ---
>>>
>>> I sent this to poky@yoctoproject.org but it should have gone to OE-core,
>>> so I'm resending it now to restart the discussion on the right mailing
>>> list. There were some comments about it in a previous mail thread on the
>>> poky mailing list:
>>>
>>> https://lists.yoctoproject.org/pipermail/poky/2017-April/010956.html
>>>
>>>  meta/conf/machine/include/qemuboot-x86.inc | 6 +++---
>>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/meta/conf/machine/include/qemuboot-x86.inc
>>> b/meta/conf/machine/include/qemuboot-x86.inc
>>> index 06ac983..acd03a1 100644
>>> --- a/meta/conf/machine/include/qemuboot-x86.inc
>>> +++ b/meta/conf/machine/include/qemuboot-x86.inc
>>> @@ -1,12 +1,12 @@
>>>  # For runqemu
>>>  IMAGE_CLASSES += "qemuboot"
>>>  QB_SYSTEM_NAME_x86 = "qemu-system-i386"
>>> -QB_CPU_x86 = "-cpu qemu32"
>>> -QB_CPU_KVM_x86 = "-cpu kvm32"
>>> +QB_CPU_x86 = "-cpu pentium2"
>>> +QB_CPU_KVM_x86 = "-cpu pentium2"
>>>
>>>  QB_SYSTEM_NAME_x86-64 = "qemu-system-x86_64"
>>>  QB_CPU_x86-64 = "-cpu core2duo"
>>> -QB_CPU_KVM_x86-64 = "-cpu kvm64"
>>> +QB_CPU_KVM_x86-64 = "-cpu core2duo"
>>>
>>>  QB_AUDIO_DRV = "alsa"
>>>  QB_AUDIO_OPT = "-soundhw ac97,es1370"
>>>
>


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

* Re: [PATCH resend] qemuboot.conf: make cpus match built artifacts
  2017-05-22 18:09     ` Martin Kelly
@ 2017-06-13 16:44       ` Martin Kelly
  0 siblings, 0 replies; 12+ messages in thread
From: Martin Kelly @ 2017-06-13 16:44 UTC (permalink / raw)
  To: Randy Witt, openembedded-core; +Cc: Joshua G Lock

On 05/22/2017 11:09 AM, Martin Kelly wrote:
> On 05/22/2017 10:53 AM, Randy Witt wrote:
>> On 05/22/2017 10:29 AM, Martin Kelly wrote:
>>> (friendly ping)
>>>
>>> On 05/02/2017 12:20 PM, Martin Kelly wrote:
>>>> Currently, the qemu CPUs for are specified as generic, but the built
>>>> artifacts are not. For example, we build x86-64 artifacts targeting
>>>> core2duo but run them in qemu with generic qemu/kvm CPUs. This causes
>>>> some packages that take advantage of the host architecture to crash
>>>> because they try to use CPU features not advertised by qemu. As an
>>>> example, Qt uses ssse3. When artifacts linked against Qt and built
>>>> targeting core2duo attempt to run on a generic qemu/kvm CPU, we get
>>>> the following crash:
>>>>
>>>> Incompatible processor. This Qt build requires the following features:
>>>>      ssse3
>>>>
>>>> We could fix this by making packages like Qt not take advantage of CPU
>>>> features. However, we will probably keep facing similar issues over
>>>> time, so it's better to resolve them in a more enduring way.
>>
>> If the MACHINE is a generic qemu, it seems more correct to build without
>> the extensions. For instance, what happens when core2duo doesn't have
>> all the necessary instructions that some package decided to use?
>>
>> I like the idea of being able to exercise the code, but I only see this
>> fix as pushing the maintenance until the problem appears again later.
>>
>
> Currently, I believe we're passing in all the right flags (e.g. -march)
> to specify a core2duo build, so GCC should not issue any instructions
> that a core2duo wouldn't support. By passing in these flags, we're
> allowing recipes to issue core2duo instructions and then creating a
> runtime environment that doesn't support those same instructions (bug).
>
> I don't think we're deferring any maintenance; unless we change the
> -march and similar flags to be something other than core2duo, I think
> the problems should go away. If we make that change, we should update
> the qemu CPUs at the same time.
>
> We can solve the problem in one of two ways:
>
> - Make qemu run as core2duo
> - Make recipes build as something even more basic
>
> The second change is much more involved than the first. I don't which
> -march (and similar) flags are the closest match to the generic qemu
> 32/qemu64 CPUs. However, I suspect there may not be a perfect match.
> And, core2duo is already quite old and basic by today's standards
> anyway, so I think bringing the qemu CPUs up to match is the simplest
> and best way to fix the issue.
>

(ping)

>>>>
>>>> Fix this by making the qemu -cpu arguments match the built artifacts.
>>>>
>>>> Signed-off-by: Martin Kelly <mkelly@xevo.com>
>>>> ---
>>>>
>>>> I sent this to poky@yoctoproject.org but it should have gone to
>>>> OE-core,
>>>> so I'm resending it now to restart the discussion on the right mailing
>>>> list. There were some comments about it in a previous mail thread on
>>>> the
>>>> poky mailing list:
>>>>
>>>> https://lists.yoctoproject.org/pipermail/poky/2017-April/010956.html
>>>>
>>>>  meta/conf/machine/include/qemuboot-x86.inc | 6 +++---
>>>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/meta/conf/machine/include/qemuboot-x86.inc
>>>> b/meta/conf/machine/include/qemuboot-x86.inc
>>>> index 06ac983..acd03a1 100644
>>>> --- a/meta/conf/machine/include/qemuboot-x86.inc
>>>> +++ b/meta/conf/machine/include/qemuboot-x86.inc
>>>> @@ -1,12 +1,12 @@
>>>>  # For runqemu
>>>>  IMAGE_CLASSES += "qemuboot"
>>>>  QB_SYSTEM_NAME_x86 = "qemu-system-i386"
>>>> -QB_CPU_x86 = "-cpu qemu32"
>>>> -QB_CPU_KVM_x86 = "-cpu kvm32"
>>>> +QB_CPU_x86 = "-cpu pentium2"
>>>> +QB_CPU_KVM_x86 = "-cpu pentium2"
>>>>
>>>>  QB_SYSTEM_NAME_x86-64 = "qemu-system-x86_64"
>>>>  QB_CPU_x86-64 = "-cpu core2duo"
>>>> -QB_CPU_KVM_x86-64 = "-cpu kvm64"
>>>> +QB_CPU_KVM_x86-64 = "-cpu core2duo"
>>>>
>>>>  QB_AUDIO_DRV = "alsa"
>>>>  QB_AUDIO_OPT = "-soundhw ac97,es1370"
>>>>
>>


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

* Re: [PATCH resend] qemuboot.conf: make cpus match built artifacts
  2017-05-02 19:20 [PATCH resend] qemuboot.conf: make cpus match built artifacts Martin Kelly
  2017-05-22 17:29 ` Martin Kelly
@ 2017-06-15 11:45 ` Burton, Ross
  2017-06-15 16:17   ` Martin Kelly
  1 sibling, 1 reply; 12+ messages in thread
From: Burton, Ross @ 2017-06-15 11:45 UTC (permalink / raw)
  To: Martin Kelly; +Cc: Joshua G Lock, OE-core

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

On 2 May 2017 at 20:20, Martin Kelly <mkelly@xevo.com> wrote:

> -QB_CPU_KVM_x86-64 = "-cpu kvm64"
> +QB_CPU_KVM_x86-64 = "-cpu core2duo"
>

What's the actual meaning of the "kvm64" and "kvm32" CPUs?  Is there a
performance hit?  Should we be instead changing the qemu machine to target
a different instruction set?

Ross

[-- Attachment #2: Type: text/html, Size: 780 bytes --]

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

* Re: [PATCH resend] qemuboot.conf: make cpus match built artifacts
  2017-06-15 11:45 ` Burton, Ross
@ 2017-06-15 16:17   ` Martin Kelly
  2017-06-15 16:37     ` Burton, Ross
  0 siblings, 1 reply; 12+ messages in thread
From: Martin Kelly @ 2017-06-15 16:17 UTC (permalink / raw)
  To: Burton, Ross; +Cc: Joshua G Lock, OE-core

On 06/15/2017 04:45 AM, Burton, Ross wrote:
>
> On 2 May 2017 at 20:20, Martin Kelly <mkelly@xevo.com
> <mailto:mkelly@xevo.com>> wrote:
>
>     -QB_CPU_KVM_x86-64 = "-cpu kvm64"
>     +QB_CPU_KVM_x86-64 = "-cpu core2duo"
>
>
> What's the actual meaning of the "kvm64" and "kvm32" CPUs?  Is there a
> performance hit?  Should we be instead changing the qemu machine to
> target a different instruction set?
>

I am no expert, but running qemu -cpu help just says:

kvm32 - "Common 32-bit KVM processor"
kvm64 - "Common 64-bit KVM processor"

My best guess is that, running on qemu without kvm, both cases will be 
slow (since it's all software emulation). But, using qemu -kvm, it 
should be fast as long as you run on a native CPU that is core2duo or 
better, as the native instructions can just be exposed and passed 
through to the host. Since core2duo is very old by now, it should be 
fast for virtually everyone building on x86.

Regardless, the core issue here is not performance but merely making 
sure that binaries run without crashing in the emulated environment. We 
need to upgrade the emulation to match the binaries or downgrade the 
binaries to match the emulation (aka building against something even 
more ancient than core2duo). Further downgrading the CPU seems wrong to 
me because core2duo is already quite old.


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

* Re: [PATCH resend] qemuboot.conf: make cpus match built artifacts
  2017-06-15 16:17   ` Martin Kelly
@ 2017-06-15 16:37     ` Burton, Ross
  2018-04-25 19:54       ` Martin Jansa
  0 siblings, 1 reply; 12+ messages in thread
From: Burton, Ross @ 2017-06-15 16:37 UTC (permalink / raw)
  To: Martin Kelly; +Cc: Joshua G Lock, OE-core

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

On 15 June 2017 at 17:17, Martin Kelly <mkelly@xevo.com> wrote:

> I am no expert, but running qemu -cpu help just says:
>
> kvm32 - "Common 32-bit KVM processor"
> kvm64 - "Common 64-bit KVM processor"
>
> My best guess is that, running on qemu without kvm, both cases will be
> slow (since it's all software emulation). But, using qemu -kvm, it should
> be fast as long as you run on a native CPU that is core2duo or better, as
> the native instructions can just be exposed and passed through to the host.
> Since core2duo is very old by now, it should be fast for virtually everyone
> building on x86.
>

Right, I did some digging.  Assuming you have KVM enabled then in the
general case the -cpu option is irrelevant as the instructions are handled
natively.  -cpu just changes what CPUID flags the userspace sees, and so
this is the Right Thing To Do.

Ross

[-- Attachment #2: Type: text/html, Size: 1301 bytes --]

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

* Re: [PATCH resend] qemuboot.conf: make cpus match built artifacts
  2017-06-15 16:37     ` Burton, Ross
@ 2018-04-25 19:54       ` Martin Jansa
  2018-04-25 23:02         ` Martin Kelly
  0 siblings, 1 reply; 12+ messages in thread
From: Martin Jansa @ 2018-04-25 19:54 UTC (permalink / raw)
  To: Burton, Ross; +Cc: Joshua G Lock, OE-core

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

On Thu, Jun 15, 2017 at 05:37:50PM +0100, Burton, Ross wrote:
> On 15 June 2017 at 17:17, Martin Kelly <mkelly@xevo.com> wrote:
> 
> > I am no expert, but running qemu -cpu help just says:
> >
> > kvm32 - "Common 32-bit KVM processor"
> > kvm64 - "Common 64-bit KVM processor"
> >
> > My best guess is that, running on qemu without kvm, both cases will be
> > slow (since it's all software emulation). But, using qemu -kvm, it should
> > be fast as long as you run on a native CPU that is core2duo or better, as
> > the native instructions can just be exposed and passed through to the host.
> > Since core2duo is very old by now, it should be fast for virtually everyone
> > building on x86.
> >
> 
> Right, I did some digging.  Assuming you have KVM enabled then in the
> general case the -cpu option is irrelevant as the instructions are handled
> natively.  -cpu just changes what CPUID flags the userspace sees, and so
> this is the Right Thing To Do.

Sorry for replying to such old thread, but today I've noticed interesting side-effect of this change.

Today I was checking why starting qtbase examples in qemu fails with
message about missing ssse3 support which which qtbase as compiled.

The DEFAULT_TUNE in qemux86-64 is indeed set to core2-64 which supports
ssse3, so qtbase is right to expect it in runtime.

But then I was starting qemu manually (not with runqemu) with:
qemu-system-x86_64 -M q35 -smp 4 -m 4G -net nic,model=virtio -net user,hostfwd=tcp::2222-:22 -vga virtio -display sdl,gl=on -hda luneui-example-image-qemux86-64-20180425152329-jama.rootfs.wic.vmdk -enable-kvm

which defaults to using this kvm64 generic CPU which doesn't support ssse3

Changing it to
qemu-system-x86_64 -M q35 -cpu core2duo -smp 4 -m 4G -net nic,model=virtio -net user,hostfwd=tcp::2222-:22 -vga virtio -display sdl,gl=on -hda luneui-example-image-qemux86-64-20180425152329-jama.rootfs.wic.vmdk -enable-kvm

gets rid of the message from qtbase, because core2duo supports ssse3 and matches with qemux86-64,
but my host CPU (AMD Bulldozer FX(tm)-8120), doesn't support the same cpu flags like core2due and qemu shows following
message when starting:
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:EDX.ss [bit 27]

EDX.ss is Self Snoop feature which is enabled in core2duo and few other QEmu emulated CPUs, so I was looking
on some other cpu I can emulate which has ssse3 while having the same flags as my host's AMD cpu

e.g. -cpu phenom is relatively close, but Bulldozer CPUs don't support 3dnow, 3dnowext, so similar warning is shown.

In the end I've switched to using -cpu Nehalem, which has ssse3, but doesn't enable CPUID_SS flag, now it starts without any warnings:
qemu-system-x86_64 -M q35 -cpu Nehalem -smp 4 -m 4G -net nic,model=virtio -net user,hostfwd=tcp::2222-:22 -vga virtio -display sdl,gl=on -hda luneui-example-image-qemux86-64-20180425152329-jama.rootfs.wic.vmdk -enable-kvm

Regards,

-- 
Martin 'JaMa' Jansa     jabber: Martin.Jansa@gmail.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 201 bytes --]

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

* Re: [PATCH resend] qemuboot.conf: make cpus match built artifacts
  2018-04-25 19:54       ` Martin Jansa
@ 2018-04-25 23:02         ` Martin Kelly
  2018-04-25 23:11           ` Martin Jansa
  0 siblings, 1 reply; 12+ messages in thread
From: Martin Kelly @ 2018-04-25 23:02 UTC (permalink / raw)
  To: Martin Jansa, Burton, Ross; +Cc: Joshua G Lock, OE-core

On 04/25/2018 12:54 PM, Martin Jansa wrote:
> On Thu, Jun 15, 2017 at 05:37:50PM +0100, Burton, Ross wrote:
>> On 15 June 2017 at 17:17, Martin Kelly <mkelly@xevo.com> wrote:
>>
>>> I am no expert, but running qemu -cpu help just says:
>>>
>>> kvm32 - "Common 32-bit KVM processor"
>>> kvm64 - "Common 64-bit KVM processor"
>>>
>>> My best guess is that, running on qemu without kvm, both cases will be
>>> slow (since it's all software emulation). But, using qemu -kvm, it should
>>> be fast as long as you run on a native CPU that is core2duo or better, as
>>> the native instructions can just be exposed and passed through to the host.
>>> Since core2duo is very old by now, it should be fast for virtually everyone
>>> building on x86.
>>>
>>
>> Right, I did some digging.  Assuming you have KVM enabled then in the
>> general case the -cpu option is irrelevant as the instructions are handled
>> natively.  -cpu just changes what CPUID flags the userspace sees, and so
>> this is the Right Thing To Do.
> 
> Sorry for replying to such old thread, but today I've noticed interesting side-effect of this change.
> 
> Today I was checking why starting qtbase examples in qemu fails with
> message about missing ssse3 support which which qtbase as compiled.
> 
> The DEFAULT_TUNE in qemux86-64 is indeed set to core2-64 which supports
> ssse3, so qtbase is right to expect it in runtime.
> 
> But then I was starting qemu manually (not with runqemu) with:
> qemu-system-x86_64 -M q35 -smp 4 -m 4G -net nic,model=virtio -net user,hostfwd=tcp::2222-:22 -vga virtio -display sdl,gl=on -hda luneui-example-image-qemux86-64-20180425152329-jama.rootfs.wic.vmdk -enable-kvm
> 
> which defaults to using this kvm64 generic CPU which doesn't support ssse3
> 
> Changing it to
> qemu-system-x86_64 -M q35 -cpu core2duo -smp 4 -m 4G -net nic,model=virtio -net user,hostfwd=tcp::2222-:22 -vga virtio -display sdl,gl=on -hda luneui-example-image-qemux86-64-20180425152329-jama.rootfs.wic.vmdk -enable-kvm
> 
> gets rid of the message from qtbase, because core2duo supports ssse3 and matches with qemux86-64,
> but my host CPU (AMD Bulldozer FX(tm)-8120), doesn't support the same cpu flags like core2due and qemu shows following
> message when starting:
> qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:EDX.ss [bit 27]
> 
> EDX.ss is Self Snoop feature which is enabled in core2duo and few other QEmu emulated CPUs, so I was looking
> on some other cpu I can emulate which has ssse3 while having the same flags as my host's AMD cpu
> 
> e.g. -cpu phenom is relatively close, but Bulldozer CPUs don't support 3dnow, 3dnowext, so similar warning is shown.
> 
> In the end I've switched to using -cpu Nehalem, which has ssse3, but doesn't enable CPUID_SS flag, now it starts without any warnings:
> qemu-system-x86_64 -M q35 -cpu Nehalem -smp 4 -m 4G -net nic,model=virtio -net user,hostfwd=tcp::2222-:22 -vga virtio -display sdl,gl=on -hda luneui-example-image-qemux86-64-20180425152329-jama.rootfs.wic.vmdk -enable-kvm
> 
> Regards,
> 

Heh, this is bringing back memories of when I wrote the patch. It's 
tricky to say what CPU we should pick here; we want whatever is the 
closest to a lowest common denominator. I don't know enough to say what 
the right choice is, though it is important that the CPU we build for 
and the one we run for are the same.

Prior to this patch, we built for core2duo and then ran with kvm64, 
causing issues. Good follow-up work would be to see if core2duo is 
really the best CPU to be targeting for a lowest common denominator. If 
Nehalem is a better match, we might as well switch to that, as long as 
we switch in both build and runtime consistently.


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

* Re: [PATCH resend] qemuboot.conf: make cpus match built artifacts
  2018-04-25 23:02         ` Martin Kelly
@ 2018-04-25 23:11           ` Martin Jansa
  2018-04-27 17:47             ` Martin Kelly
  0 siblings, 1 reply; 12+ messages in thread
From: Martin Jansa @ 2018-04-25 23:11 UTC (permalink / raw)
  To: Martin Kelly; +Cc: Joshua G Lock, OE-core

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

There are actually 3 we need to consider for lowest common denominator.

The one we build for, the one we build on and the one where we will run the
qemu in the end.

I mean the core2duo is probably best match for core2-64 DEFAULT used by
qemux86-64 MACHINE. But it's not good match to emulate with QEmu and KVM
enabled on the host like my.

It's easy to work around this, we probably don't need to change the default
values, but it would be good to document this case and how to override
QB_CPU_KVM
if your host doesn't match the features of core2duo.

On Thu, Apr 26, 2018 at 1:02 AM, Martin Kelly <mkelly@xevo.com> wrote:

> On 04/25/2018 12:54 PM, Martin Jansa wrote:
>
>> On Thu, Jun 15, 2017 at 05:37:50PM +0100, Burton, Ross wrote:
>>
>>> On 15 June 2017 at 17:17, Martin Kelly <mkelly@xevo.com> wrote:
>>>
>>> I am no expert, but running qemu -cpu help just says:
>>>>
>>>> kvm32 - "Common 32-bit KVM processor"
>>>> kvm64 - "Common 64-bit KVM processor"
>>>>
>>>> My best guess is that, running on qemu without kvm, both cases will be
>>>> slow (since it's all software emulation). But, using qemu -kvm, it
>>>> should
>>>> be fast as long as you run on a native CPU that is core2duo or better,
>>>> as
>>>> the native instructions can just be exposed and passed through to the
>>>> host.
>>>> Since core2duo is very old by now, it should be fast for virtually
>>>> everyone
>>>> building on x86.
>>>>
>>>>
>>> Right, I did some digging.  Assuming you have KVM enabled then in the
>>> general case the -cpu option is irrelevant as the instructions are
>>> handled
>>> natively.  -cpu just changes what CPUID flags the userspace sees, and so
>>> this is the Right Thing To Do.
>>>
>>
>> Sorry for replying to such old thread, but today I've noticed interesting
>> side-effect of this change.
>>
>> Today I was checking why starting qtbase examples in qemu fails with
>> message about missing ssse3 support which which qtbase as compiled.
>>
>> The DEFAULT_TUNE in qemux86-64 is indeed set to core2-64 which supports
>> ssse3, so qtbase is right to expect it in runtime.
>>
>> But then I was starting qemu manually (not with runqemu) with:
>> qemu-system-x86_64 -M q35 -smp 4 -m 4G -net nic,model=virtio -net
>> user,hostfwd=tcp::2222-:22 -vga virtio -display sdl,gl=on -hda
>> luneui-example-image-qemux86-64-20180425152329-jama.rootfs.wic.vmdk
>> -enable-kvm
>>
>> which defaults to using this kvm64 generic CPU which doesn't support ssse3
>>
>> Changing it to
>> qemu-system-x86_64 -M q35 -cpu core2duo -smp 4 -m 4G -net
>> nic,model=virtio -net user,hostfwd=tcp::2222-:22 -vga virtio -display
>> sdl,gl=on -hda luneui-example-image-qemux86-6
>> 4-20180425152329-jama.rootfs.wic.vmdk -enable-kvm
>>
>> gets rid of the message from qtbase, because core2duo supports ssse3 and
>> matches with qemux86-64,
>> but my host CPU (AMD Bulldozer FX(tm)-8120), doesn't support the same cpu
>> flags like core2due and qemu shows following
>> message when starting:
>> qemu-system-x86_64: warning: host doesn't support requested feature:
>> CPUID.01H:EDX.ss [bit 27]
>>
>> EDX.ss is Self Snoop feature which is enabled in core2duo and few other
>> QEmu emulated CPUs, so I was looking
>> on some other cpu I can emulate which has ssse3 while having the same
>> flags as my host's AMD cpu
>>
>> e.g. -cpu phenom is relatively close, but Bulldozer CPUs don't support
>> 3dnow, 3dnowext, so similar warning is shown.
>>
>> In the end I've switched to using -cpu Nehalem, which has ssse3, but
>> doesn't enable CPUID_SS flag, now it starts without any warnings:
>> qemu-system-x86_64 -M q35 -cpu Nehalem -smp 4 -m 4G -net nic,model=virtio
>> -net user,hostfwd=tcp::2222-:22 -vga virtio -display sdl,gl=on -hda
>> luneui-example-image-qemux86-64-20180425152329-jama.rootfs.wic.vmdk
>> -enable-kvm
>>
>> Regards,
>>
>>
> Heh, this is bringing back memories of when I wrote the patch. It's tricky
> to say what CPU we should pick here; we want whatever is the closest to a
> lowest common denominator. I don't know enough to say what the right choice
> is, though it is important that the CPU we build for and the one we run for
> are the same.
>
> Prior to this patch, we built for core2duo and then ran with kvm64,
> causing issues. Good follow-up work would be to see if core2duo is really
> the best CPU to be targeting for a lowest common denominator. If Nehalem is
> a better match, we might as well switch to that, as long as we switch in
> both build and runtime consistently.
>

[-- Attachment #2: Type: text/html, Size: 5827 bytes --]

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

* Re: [PATCH resend] qemuboot.conf: make cpus match built artifacts
  2018-04-25 23:11           ` Martin Jansa
@ 2018-04-27 17:47             ` Martin Kelly
  0 siblings, 0 replies; 12+ messages in thread
From: Martin Kelly @ 2018-04-27 17:47 UTC (permalink / raw)
  To: Martin Jansa; +Cc: Joshua G Lock, OE-core

On 04/25/2018 04:11 PM, Martin Jansa wrote:
> There are actually 3 we need to consider for lowest common denominator.
> 
> The one we build for, the one we build on and the one where we will run 
> the qemu in the end.
> 
> I mean the core2duo is probably best match for core2-64 DEFAULT used by 
> qemux86-64 MACHINE. But it's not good match to emulate with QEmu and KVM 
> enabled on the host like my.
> 
> It's easy to work around this, we probably don't need to change the 
> default values, but it would be good to document this case and how to 
> override QB_CPU_KVM if your host doesn't match the features of core2duo.
> 

Agreed. I just sent a patch to yocto-docs to add some documentation for 
this.


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

end of thread, other threads:[~2018-04-27 18:19 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-02 19:20 [PATCH resend] qemuboot.conf: make cpus match built artifacts Martin Kelly
2017-05-22 17:29 ` Martin Kelly
2017-05-22 17:53   ` Randy Witt
2017-05-22 18:09     ` Martin Kelly
2017-06-13 16:44       ` Martin Kelly
2017-06-15 11:45 ` Burton, Ross
2017-06-15 16:17   ` Martin Kelly
2017-06-15 16:37     ` Burton, Ross
2018-04-25 19:54       ` Martin Jansa
2018-04-25 23:02         ` Martin Kelly
2018-04-25 23:11           ` Martin Jansa
2018-04-27 17:47             ` Martin Kelly

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.