<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>12388</bug_id>
          
          <creation_ts>2017-11-29 20:30:27 +0000</creation_ts>
          <short_desc>runqemu: support setting the -cpu &lt;NAME&gt; from the command line</short_desc>
          <delta_ts>2024-01-26 20:44:29 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>Scripts and Tools</component>
          <version>2.4</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>5.99</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="brian avery">brian.avery</reporter>
          <assigned_to name="Simone Weiß">simone.p.weiss</assigned_to>
          <cc>randy.macleod</cc>
    
    <cc>ross.burton</cc>
    
    <cc>simone.p.weiss</cc>
    
    <cc>tim.orling</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Yes (doc changes required)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>78408</commentid>
    <comment_count>0</comment_count>
    <who name="brian avery">brian.avery</who>
    <bug_when>2017-11-29 20:30:27 +0000</bug_when>
    <thetext>One way to do this would be to read QB_CPU from the env if it is set. 

Why would anyone want to do  this?

For x86-64 kvm situations, esp those involving nested qemu&apos;s you may need to set 
  &quot;-cpu host&quot; in order to get certain cpu capabilities into the qemu env (vmx,sse_4_2,...).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79259</commentid>
    <comment_count>1</comment_count>
    <who name="Stephano Cetola">stephano</who>
    <bug_when>2018-01-29 19:41:09 +0000</bug_when>
    <thetext>punting this to 2.6</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87679</commentid>
    <comment_count>2</comment_count>
    <who name="Sakib Sajal">sakib.sajal</who>
    <bug_when>2020-07-03 12:30:04 +0000</bug_when>
    <thetext>Brian, Tim:
While this is an obvious convenience, I wanted to confirm that if this feature is still worth implementing and understand what&apos;s asked for. In runqemu, we see following environment variables are used:
  KERNEL - the kernel image file to use
  BIOS - the bios image file to use
  ROOTFS - the rootfs image file or nfsroot directory to use
  DEVICE_TREE - the device tree blob to use
  MACHINE - the machine name (optional, autodetected from KERNEL filename if unspecified)
This feature asks to add QB_CPU to the list and used by runqemu [qb_cpu], however that option can easily be passed to runqemu by:
$ runqemu [options] qemuparams=&quot;-cpu &lt;model&gt;&quot;

To add to that, to enable -cpu host, one needs kvm on host and pass it as an option to runqemu, otherwise errors out with: 
  runqemu - ERROR - Failed to run qemu: qemu-system-x86_64: CPU model &apos;host&apos; requires KVM

This is fine, as an error, and users need to understand what they are doing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87680</commentid>
    <comment_count>3</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2020-07-03 21:37:59 +0000</bug_when>
    <thetext>Brian is not longer with Intel or connected to the project.

When I had looked into this earlier, I was thinking it was something missing in QEMU. Meaning newer Intel processor instruction sets were somehow not being added. As I dug deeper I realized the deeper reality.

I agree that a knowledgeable user can use qemuparams=&quot;-cpu Skylake&quot; for instance and this only works if they are on a Skylake or better CPU with kvm. Or if they do not use kvm, it will be slower and emulated.

That leads me to two conclusions:
(1) This is more a matter of documentation and good examples
(2) This might be difficult to implement as a feature that will not be brittle 
    and prone to failure

Ultimately, as useful as the &quot;runqemu&quot; wrapper is, it is a crutch. Developers should pay attention to what the command line is that is being generated and modify it to their own needs. Testing more advanced instructions sets, like AVX512, will require a bit more knowledge both at compile time and run time emulation.

It would be great if some magical introspection could make this &quot;just work&quot;, but...that&apos;s not an obvious path. But might be worth some further experimentation.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87681</commentid>
    <comment_count>4</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2020-07-03 21:39:10 +0000</bug_when>
    <thetext>That said, I do think we need to review our settings, because I think we are using deprecated values.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87682</commentid>
    <comment_count>5</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2020-07-03 21:59:03 +0000</bug_when>
    <thetext>https://www.qemu.org/docs/master/system/target-i386.html#recommendations-for-kvm-cpu-model-configuration-on-x86-hosts

Preferred CPU models for Intel x86 hosts
The following CPU models are preferred for use on Intel hosts. Administrators / applications are recommended to use the CPU model that matches the generation of the host CPUs in use. In a deployment with a mixture of host CPU models between machines, if live migration compatibility is required, use the newest CPU model that is compatible across all desired hosts.

Cascadelake-Server, Cascadelake-Server-noTSX
Intel Xeon Processor (Cascade Lake, 2019), with “stepping” levels 6 or 7 only. (The Cascade Lake Xeon processor with stepping 5 is vulnerable to MDS variants.)

Skylake-Server, Skylake-Server-IBRS, Skylake-Server-IBRS-noTSX
Intel Xeon Processor (Skylake, 2016)

Skylake-Client, Skylake-Client-IBRS, Skylake-Client-noTSX-IBRS}
Intel Core Processor (Skylake, 2015)

Broadwell, Broadwell-IBRS, Broadwell-noTSX, Broadwell-noTSX-IBRS
Intel Core Processor (Broadwell, 2014)

Haswell, Haswell-IBRS, Haswell-noTSX, Haswell-noTSX-IBRS
Intel Core Processor (Haswell, 2013)

IvyBridge, IvyBridge-IBR
Intel Xeon E3-12xx v2 (Ivy Bridge, 2012)

SandyBridge, SandyBridge-IBRS
Intel Xeon E312xx (Sandy Bridge, 2011)

Westmere, Westmere-IBRS
Westmere E56xx/L56xx/X56xx (Nehalem-C, 2010)

Nehalem, Nehalem-IBRS
Intel Core i7 9xx (Nehalem Class Core i7, 2008)

Penryn
Intel Core 2 Duo P9xxx (Penryn Class Core 2, 2007)

Conroe
Intel Celeron_4x0 (Conroe/Merom Class Core 2, 2006)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87683</commentid>
    <comment_count>6</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2020-07-03 22:03:33 +0000</bug_when>
    <thetext>Whereas we set:
QEMU_EXTRAOPTIONS_core2-64 = &quot; -cpu core2duo&quot;

http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/conf/machine/include/tune-core2.inc#n31

And even with core-i7 tuning, we are on the now ancient Nehalem architecture (12 years ago!):
QEMU_EXTRAOPTIONS_corei7-64 = &quot; -cpu Nehalem,check=false&quot;

http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/conf/machine/include/tune-corei7.inc#n31</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87684</commentid>
    <comment_count>7</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2020-07-03 22:10:50 +0000</bug_when>
    <thetext>In particular, core2duo is deprecated (equivalent of Penryn, 13 years ago!):

https://www.qemu.org/docs/master/system/qemu-cpu-models.html?highlight=core2#other-non-recommended-x86-cpus

We should at least consider moving that to Nehalem or Westmere.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87742</commentid>
    <comment_count>8</comment_count>
    <who name="Sakib Sajal">sakib.sajal</who>
    <bug_when>2020-07-10 13:13:03 +0000</bug_when>
    <thetext>Tim, looking at all the information provided, I think this is an issue of good documentation/examples. 

I was able to boot Skylake-Server using qemu only (did not try with runqemu and I do not think it will be a problem), with and without kvm, with Intel(R) Core(TM) i7-8665U CPU as the host, but with warnings emitted. This does not seem like an issue and only affects performance in my opinion. 

Also, I was able to run Westmere and Nehalem, with and without kvm and without warnings, delta of one generation. That being said, we can and should update:

QEMU_EXTRAOPTIONS_core2-64 = &quot; -cpu core2duo&quot;

to

QEMU_EXTRAOPTIONS_core2-64 = &quot; -cpu Nehalem,check=false&quot;

which is a delta of one generation, and should be fine.

For those who are trying to test specific cpu instruction sets, one can expect them to be knowledgeable enough to use runqemu (or just qemu itself) to get the desired result they want.

I will work on the update.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>92850</commentid>
    <comment_count>9</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2022-03-24 14:58:12 +0000</bug_when>
    <thetext>A nice idea but not a high priority.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96941</commentid>
    <comment_count>10</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2023-10-24 14:24:47 +0000</bug_when>
    <thetext>Bulk move from 4.99 or 0.00 to 5.99</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98053</commentid>
    <comment_count>11</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2024-01-26 20:44:29 +0000</bug_when>
    <thetext>Thanks Simone, can you provide a link to the commit?</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>