diff mbox series

[PATCH/master,6/7] package/qemu: add BR2_PACKAGE_HOST_QEMU_USER_MODE_ARGS string

Message ID 20210903162027.1935040-7-aduskett@gmail.com
State Accepted
Headers show
Series Qemu and gobject-introspection fixes | expand

Commit Message

Adam Duskett Sept. 3, 2021, 4:20 p.m. UTC
For specific architectures, running qemu in user mode without any additional
options may fail if the host processor does not have the necessary instructions
to properly run qemu in user mode, which results in the following error:
"qemu: uncaught target signal 4 (Illegal instruction) - core dumped"

CoreI7 is one such architecture that has had consistent auto-build failures.

Add a new string in qemu/Config.in.host: BR2_PACKAGE_HOST_QEMU_USER_MODE_ARGS.
The default for the Corei7 architecture is directly from the OpenEmbedded
project found in meta/conf/machine/include/x86/tune-corei7.inc:
"-cpu Nehalem,check=false." Other architectures may be added to this string at
a later date if other failures occure.

Signed-off-by: Adam Duskett <aduskett@gmail.com>
---
 package/qemu/Config.in.host | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Thomas Petazzoni Sept. 3, 2021, 10:37 p.m. UTC | #1
Hello Adam,

On Fri,  3 Sep 2021 09:20:26 -0700
Adam Duskett <aduskett@gmail.com> wrote:

> For specific architectures, running qemu in user mode without any additional
> options may fail if the host processor does not have the necessary instructions
> to properly run qemu in user mode, which results in the following error:
> "qemu: uncaught target signal 4 (Illegal instruction) - core dumped"
> 
> CoreI7 is one such architecture that has had consistent auto-build failures.
> 
> Add a new string in qemu/Config.in.host: BR2_PACKAGE_HOST_QEMU_USER_MODE_ARGS.
> The default for the Corei7 architecture is directly from the OpenEmbedded
> project found in meta/conf/machine/include/x86/tune-corei7.inc:
> "-cpu Nehalem,check=false." Other architectures may be added to this string at
> a later date if other failures occure.
> 
> Signed-off-by: Adam Duskett <aduskett@gmail.com>

So on the principle, I'm obviously OK as this is something I have
suggested. However, what bothers me here is that we are handling only
the Core i7 case, because it caused some issue in the autobuilder.

What is qemu doing when no -cpu is provided? Does it emulate the host
CPU in this case? If so, then it is going to be wrong in a lot of other
cases than Core i7, no?

Or put differently, shouldn't we essentially have a value for
BR2_PACKAGE_HOST_QEMU_USER_MODE_ARGS for pretty much all CPU
architectures that we want to support for this use-case ?

Thomas
Adam Duskett Sept. 10, 2021, 5:42 p.m. UTC | #2
Hey Thomas;

As briefly discussed on IRC, this is mostly due to x86 discrepancies,
however, as I do not have access to * every * CPU
that buildroot + GOI supports, it's better to commit these changes
now, and if others find issues with their CPU/GOI
builds, they can submit a patch far easier thanks to this patch series!

Adam

On Fri, Sep 3, 2021 at 3:37 PM Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
>
> Hello Adam,
>
> On Fri,  3 Sep 2021 09:20:26 -0700
> Adam Duskett <aduskett@gmail.com> wrote:
>
> > For specific architectures, running qemu in user mode without any additional
> > options may fail if the host processor does not have the necessary instructions
> > to properly run qemu in user mode, which results in the following error:
> > "qemu: uncaught target signal 4 (Illegal instruction) - core dumped"
> >
> > CoreI7 is one such architecture that has had consistent auto-build failures.
> >
> > Add a new string in qemu/Config.in.host: BR2_PACKAGE_HOST_QEMU_USER_MODE_ARGS.
> > The default for the Corei7 architecture is directly from the OpenEmbedded
> > project found in meta/conf/machine/include/x86/tune-corei7.inc:
> > "-cpu Nehalem,check=false." Other architectures may be added to this string at
> > a later date if other failures occure.
> >
> > Signed-off-by: Adam Duskett <aduskett@gmail.com>
>
> So on the principle, I'm obviously OK as this is something I have
> suggested. However, what bothers me here is that we are handling only
> the Core i7 case, because it caused some issue in the autobuilder.
>
> What is qemu doing when no -cpu is provided? Does it emulate the host
> CPU in this case? If so, then it is going to be wrong in a lot of other
> cases than Core i7, no?
>
> Or put differently, shouldn't we essentially have a value for
> BR2_PACKAGE_HOST_QEMU_USER_MODE_ARGS for pretty much all CPU
> architectures that we want to support for this use-case ?
>
> Thomas
> --
> Thomas Petazzoni, co-owner and CEO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
Arnout Vandecappelle Sept. 11, 2021, 7:39 p.m. UTC | #3
On 10/09/2021 19:42, Adam Duskett wrote:
> Hey Thomas;
> 
> As briefly discussed on IRC, this is mostly due to x86 discrepancies,
> however, as I do not have access to * every * CPU
> that buildroot + GOI supports, it's better to commit these changes
> now, and if others find issues with their CPU/GOI
> builds, they can submit a patch far easier thanks to this patch series!

 I still think Thomas is right: we should have a mapping for each architecture
option to the Qemu emulation option that corresponds to it.

 In an ideal world, we would have BR2_ARCH_QEMU_CPU that is set in
arch/Config.in.* for all (sub)architectures.

 However, I doubt that anyone is going to take the time to do that (and test it,
without even knowing how to test it because *most* code will run just fine when
the wrong -cpu option is used).

 So, the pragmatic approach is to use this patch.

 Therefore, applied to master, thanks.

 Regards,
 Arnout

> 
> Adam
> 
> On Fri, Sep 3, 2021 at 3:37 PM Thomas Petazzoni
> <thomas.petazzoni@bootlin.com> wrote:
>>
>> Hello Adam,
>>
>> On Fri,  3 Sep 2021 09:20:26 -0700
>> Adam Duskett <aduskett@gmail.com> wrote:
>>
>>> For specific architectures, running qemu in user mode without any additional
>>> options may fail if the host processor does not have the necessary instructions
>>> to properly run qemu in user mode, which results in the following error:
>>> "qemu: uncaught target signal 4 (Illegal instruction) - core dumped"
>>>
>>> CoreI7 is one such architecture that has had consistent auto-build failures.
>>>
>>> Add a new string in qemu/Config.in.host: BR2_PACKAGE_HOST_QEMU_USER_MODE_ARGS.
>>> The default for the Corei7 architecture is directly from the OpenEmbedded
>>> project found in meta/conf/machine/include/x86/tune-corei7.inc:
>>> "-cpu Nehalem,check=false." Other architectures may be added to this string at
>>> a later date if other failures occure.
>>>
>>> Signed-off-by: Adam Duskett <aduskett@gmail.com>
>>
>> So on the principle, I'm obviously OK as this is something I have
>> suggested. However, what bothers me here is that we are handling only
>> the Core i7 case, because it caused some issue in the autobuilder.
>>
>> What is qemu doing when no -cpu is provided? Does it emulate the host
>> CPU in this case? If so, then it is going to be wrong in a lot of other
>> cases than Core i7, no?
>>
>> Or put differently, shouldn't we essentially have a value for
>> BR2_PACKAGE_HOST_QEMU_USER_MODE_ARGS for pretty much all CPU
>> architectures that we want to support for this use-case ?
>>
>> Thomas
>> --
>> Thomas Petazzoni, co-owner and CEO, Bootlin
>> Embedded Linux and Kernel engineering
>> https://bootlin.com
> _______________________________________________
> buildroot mailing list
> buildroot@lists.buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
>
Arnout Vandecappelle Sept. 11, 2021, 7:42 p.m. UTC | #4
On 11/09/2021 21:39, Arnout Vandecappelle wrote:
> 
> 
> On 10/09/2021 19:42, Adam Duskett wrote:
>> Hey Thomas;
>>
>> As briefly discussed on IRC, this is mostly due to x86 discrepancies,
>> however, as I do not have access to * every * CPU
>> that buildroot + GOI supports, it's better to commit these changes
>> now, and if others find issues with their CPU/GOI
>> builds, they can submit a patch far easier thanks to this patch series!
> 
>  I still think Thomas is right: we should have a mapping for each architecture
> option to the Qemu emulation option that corresponds to it.
> 
>  In an ideal world, we would have BR2_ARCH_QEMU_CPU that is set in
> arch/Config.in.* for all (sub)architectures.

 And even better: a qemu wrapper would make sure that the correct cpu option is
*always* passed to qemu.

 Dream on...

 Regards,
 Arnout

> 
>  However, I doubt that anyone is going to take the time to do that (and test it,
> without even knowing how to test it because *most* code will run just fine when
> the wrong -cpu option is used).
> 
>  So, the pragmatic approach is to use this patch.
> 
>  Therefore, applied to master, thanks.
> 
>  Regards,
>  Arnout
> 
>>
>> Adam
>>
>> On Fri, Sep 3, 2021 at 3:37 PM Thomas Petazzoni
>> <thomas.petazzoni@bootlin.com> wrote:
>>>
>>> Hello Adam,
>>>
>>> On Fri,  3 Sep 2021 09:20:26 -0700
>>> Adam Duskett <aduskett@gmail.com> wrote:
>>>
>>>> For specific architectures, running qemu in user mode without any additional
>>>> options may fail if the host processor does not have the necessary instructions
>>>> to properly run qemu in user mode, which results in the following error:
>>>> "qemu: uncaught target signal 4 (Illegal instruction) - core dumped"
>>>>
>>>> CoreI7 is one such architecture that has had consistent auto-build failures.
>>>>
>>>> Add a new string in qemu/Config.in.host: BR2_PACKAGE_HOST_QEMU_USER_MODE_ARGS.
>>>> The default for the Corei7 architecture is directly from the OpenEmbedded
>>>> project found in meta/conf/machine/include/x86/tune-corei7.inc:
>>>> "-cpu Nehalem,check=false." Other architectures may be added to this string at
>>>> a later date if other failures occure.
>>>>
>>>> Signed-off-by: Adam Duskett <aduskett@gmail.com>
>>>
>>> So on the principle, I'm obviously OK as this is something I have
>>> suggested. However, what bothers me here is that we are handling only
>>> the Core i7 case, because it caused some issue in the autobuilder.
>>>
>>> What is qemu doing when no -cpu is provided? Does it emulate the host
>>> CPU in this case? If so, then it is going to be wrong in a lot of other
>>> cases than Core i7, no?
>>>
>>> Or put differently, shouldn't we essentially have a value for
>>> BR2_PACKAGE_HOST_QEMU_USER_MODE_ARGS for pretty much all CPU
>>> architectures that we want to support for this use-case ?
>>>
>>> Thomas
>>> --
>>> Thomas Petazzoni, co-owner and CEO, Bootlin
>>> Embedded Linux and Kernel engineering
>>> https://bootlin.com
>> _______________________________________________
>> buildroot mailing list
>> buildroot@lists.buildroot.org
>> https://lists.buildroot.org/mailman/listinfo/buildroot
>>
diff mbox series

Patch

diff --git a/package/qemu/Config.in.host b/package/qemu/Config.in.host
index 2dcf5631e5..fedf90d8b7 100644
--- a/package/qemu/Config.in.host
+++ b/package/qemu/Config.in.host
@@ -73,6 +73,10 @@  config BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE
 	  the running host kernel, you may run into invalid system
 	  calls, which may yield surprising effects.
 
+config BR2_PACKAGE_HOST_QEMU_USER_MODE_ARGS
+	string
+	default "-cpu Nehalem,check=false" if BR2_x86_corei7
+
 config BR2_PACKAGE_HOST_QEMU_VDE2
 	bool "VDE2 support"
 	help