Bug 1254420

Summary: Add IvyBridge cpu model to libvirt
Product: Red Hat Enterprise Linux 7 Reporter: Pei Zhang <pezhang>
Component: libvirtAssignee: Jiri Denemark <jdenemar>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: chayang, dyuan, fjin, honzhang, jdenemar, juzhang, knoel, lhuang, michen, qzhang, rbalakri, xfu
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.2.17-8.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 06:52:29 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Pei Zhang 2015-08-18 05:28:49 UTC
Description of problem:
Libvirt lost IvyBridge cpu-model.

Version-Release number of selected component (if applicable):
Kernel:3.10.0-304.el7.x86_64
qemu-kvm-rhev:qemu-kvm-rhev-2.3.0-18.el7.x86_64
libvirt:libvirt-1.2.17-3.el7.x86_64


How reproducible:
100%

Steps to Reproduce:
1.
# /usr/libexec/qemu-kvm -cpu ?
x86           qemu64  QEMU Virtual CPU version 2.3.0                  
x86           phenom  AMD Phenom(tm) 9550 Quad-Core Processor         
x86         core2duo  Intel(R) Core(TM)2 Duo CPU     T7700  @ 2.40GHz 
x86            kvm64  Common KVM processor                            
x86           qemu32  QEMU Virtual CPU version 2.3.0                  
x86            kvm32  Common 32-bit KVM processor                     
x86          coreduo  Genuine Intel(R) CPU           T2600  @ 2.16GHz 
x86              486                                                  
x86          pentium                                                  
x86         pentium2                                                  
x86         pentium3                                                  
x86           athlon  QEMU Virtual CPU version 2.3.0                  
x86             n270  Intel(R) Atom(TM) CPU N270   @ 1.60GHz          
x86      cpu64-rhel6  QEMU Virtual CPU version (cpu64-rhel6)          
x86           Conroe  Intel Celeron_4x0 (Conroe/Merom Class Core 2)   
x86           Penryn  Intel Core 2 Duo P9xxx (Penryn Class Core 2)    
x86          Nehalem  Intel Core i7 9xx (Nehalem Class Core i7)       
x86         Westmere  Westmere E56xx/L56xx/X56xx (Nehalem-C)          
x86      SandyBridge  Intel Xeon E312xx (Sandy Bridge)                
*x86        IvyBridge  Intel Xeon E3-12xx v2 (Ivy Bridge)              
x86    Haswell-noTSX  Intel Core Processor (Haswell, no TSX)          
x86          Haswell  Intel Core Processor (Haswell)                  
x86  Broadwell-noTSX  Intel Core Processor (Broadwell, no TSX)        
x86        Broadwell  Intel Core Processor (Broadwell)                
x86       Opteron_G1  AMD Opteron 240 (Gen 1 Class Opteron)           
x86       Opteron_G2  AMD Opteron 22xx (Gen 2 Class Opteron)          
x86       Opteron_G3  AMD Opteron 23xx (Gen 3 Class Opteron)          
x86       Opteron_G4  AMD Opteron 62xx class CPU                      
x86       Opteron_G5  AMD Opteron 63xx class CPU                      
*x86             host  KVM processor with all supported host features (only available in KVM mode)

2.
# virsh cpu-models x86_64
Opteron_G5
Opteron_G4
Opteron_G3
Opteron_G2
Opteron_G1
phenom
athlon
Broadwell
Broadwell-noTSX
Haswell
Haswell-noTSX
SandyBridge
Westmere
Nehalem
Penryn
Conroe
qemu64
kvm64
cpu64-rhel6
*cpu64-rhel5
kvm32
qemu32
core2duo
n270
coreduo
*pentiumpro
pentium3
pentium2
pentium
486


Actual results:
The front with * mean cpu-models differences between qemu and virsh. 
In qemu, host-models include 'IvyBridge' and 'host', but in virsh ,they do not exist. 
In virsh, host-models include 'cpu64-rhel5' and 'pentiumpro', but they can not be found in qemu.


Expected results:
In qemu and in virsh , cpu-models should match exactly.

Additional info:

Comment 2 Jiri Denemark 2015-09-04 13:46:04 UTC
Sent upstream for review: https://www.redhat.com/archives/libvir-list/2015-September/msg00160.html

Comment 3 Jiri Denemark 2015-09-07 10:49:53 UTC
Fixed upstream by v1.2.19-31-g8720551:

commit 87205512565529b8baeb108e3d0fe376fc20c967
Author: Jiri Denemark <jdenemar>
Date:   Fri Sep 4 15:06:40 2015 +0200

    cpu: Introduce IvyBridge CPU model
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1254420

Comment 6 Fangge Jin 2015-09-16 03:12:31 UTC
Hello, Jiri. I'm not sure what the expected results should be. There are four differences between qemu and virsh in the bug description, but the fix only include one. What about the others? 

# /usr/libexec/qemu-kvm -cpu ?
...
*x86        IvyBridge  Intel Xeon E3-12xx v2 (IvyBridge)   
*x86             host  KVM processor with all supported host features (only available in KVM mode)

# virsh cpu-models x86_64
...
*cpu64-rhel5
*pentiumpro

Comment 7 Jiri Denemark 2015-09-16 07:09:34 UTC
You should expect what this bug summary says, that is, libvirt should now know about IvyBridge CPU model and should be able to use it.

Comment 8 Luyao Huang 2015-09-17 07:34:03 UTC
Hi jiri,

I found there is a problem when verify this bug:

When i check the cpu flags, i found IvyBridge has vme flags (CPUID_VME)
but Haswell/Broadwell do not have, but the result in qemu code is different.
Why IvyBridge model has the vme but Haswell/Broadwell not ?

Then i wrote a script to check them one by one (maybe not correct, i was still improving it), and the result is :

cannot find cpu feature named lahf_lm in cpu model qemu64
cannot find cpu feature named vme in cpu model phenom
cannot find cpu feature named cx16 in cpu model phenom
cannot find cpu feature named popcnt in cpu model phenom
cannot find cpu feature named amd_aliases in cpu model phenom
cannot find cpu feature named pdpe1gb in cpu model phenom
cannot find cpu feature named rdtscp in cpu model phenom
cannot find cpu feature named lahf_lm in cpu model phenom
cannot find cpu feature named abm in cpu model phenom
cannot find cpu feature named sse4a in cpu model phenom
cannot find cpu feature named acpi in cpu model core2duo
cannot find cpu feature named ss in cpu model core2duo
cannot find cpu feature named cx16 in cpu model core2duo
cannot find cpu feature named lahf_lm in cpu model core2duo
cannot find cpu feature named vme in cpu model kvm64
cannot find cpu feature named amd_aliases in cpu model kvm64
cannot find cpu feature named popcnt in cpu model qemu32
cannot find cpu feature named vme in cpu model kvm32
cannot find cpu feature named amd_aliases in cpu model kvm32
cannot find cpu feature named acpi in cpu model coreduo
cannot find cpu feature named ss in cpu model coreduo
cannot find cpu feature named apic in cpu model pentium
cannot find cpu feature named apic in cpu model pentium2
cannot find cpu feature named apic in cpu model pentium3
cannot find cpu feature named mca in cpu model athlon
cannot find cpu feature named amd_aliases in cpu model athlon
cannot find cpu feature named acpi in cpu model n270
cannot find cpu feature named ss in cpu model n270
cannot find cpu feature named movbe in cpu model n270
cannot find cpu feature named amd_aliases in cpu model n270
cannot find cpu feature named lahf_lm in cpu model n270
cannot find cpu feature named svm in cpu model cpu64-rhel6
cannot find cpu feature named vme in cpu model Conroe
cannot find cpu feature named vme in cpu model Penryn
cannot find cpu feature named vme in cpu model Nehalem
cannot find cpu feature named vme in cpu model Westmere
cannot find cpu feature named pclmulqdq in cpu model Westmere
cannot find cpu feature named vme in cpu model SandyBridge
cannot find cpu feature named pclmulqdq in cpu model SandyBridge
cannot find cpu feature named pclmulqdq in cpu model IvyBridge
cannot find cpu feature named vme in cpu model Haswell
cannot find cpu feature named pclmulqdq in cpu model Haswell
cannot find cpu feature named f16c in cpu model Haswell
cannot find cpu feature named rdrand in cpu model Haswell
cannot find cpu feature named vme in cpu model Haswell
cannot find cpu feature named pclmulqdq in cpu model Haswell
cannot find cpu feature named f16c in cpu model Haswell
cannot find cpu feature named rdrand in cpu model Haswell
cannot find cpu feature named vme in cpu model Broadwell-noTSX
cannot find cpu feature named pclmulqdq in cpu model Broadwell-noTSX
cannot find cpu feature named f16c in cpu model Broadwell-noTSX
cannot find cpu feature named rdrand in cpu model Broadwell-noTSX
cannot find cpu feature named vme in cpu model Broadwell
cannot find cpu feature named pclmulqdq in cpu model Broadwell
cannot find cpu feature named f16c in cpu model Broadwell
cannot find cpu feature named rdrand in cpu model Broadwell
cannot find cpu feature named vme in cpu model Opteron_G1
cannot find cpu feature named vme in cpu model Opteron_G2
cannot find cpu feature named vme in cpu model Opteron_G3
cannot find cpu feature named vme in cpu model Opteron_G4
cannot find cpu feature named pclmulqdq in cpu model Opteron_G4
cannot find cpu feature named vme in cpu model Opteron_G5
cannot find cpu feature named pclmulqdq in cpu model Opteron_G5

Some of the CPU flags is not in libvirt cpu_map.xml, just like pclmulqdq (CPUID_EXT_PCLMULQDQ), and some of flags are not in some model, just like f16c,vme are not in Broadwell.

Is this excepted ?

Thanks in advance for your reply.

Luyao

Comment 9 Jiri Denemark 2015-09-17 08:57:16 UTC
Some CPU features have different names in libvirt (e.g., pclmulqdq is pclmuldq), you'd have to use CPUID bits to cross check all features without having to worry about different naming. Anyway, even if older CPU models differ, we are not going to change them for backward compatibility (not to mention that their definition may differ depending on a machine type). That said, just focus on verifying IvyBridge.

Comment 10 Luyao Huang 2015-09-17 10:08:00 UTC
(In reply to Jiri Denemark from comment #9)
> Some CPU features have different names in libvirt (e.g., pclmulqdq is
> pclmuldq), you'd have to use CPUID bits to cross check all features without
> having to worry about different naming. Anyway, even if older CPU models
> differ, we are not going to change them for backward compatibility (not to
> mention that their definition may differ depending on a machine type). That
> said, just focus on verifying IvyBridge.

Got it, thanks a lot for your clearly reply.

Verify this bug with libvirt-1.2.17-9.el7.x86_64:

1. prepare a host which is IvyBridge:

# cat /proc/cpuinfo

flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm ida arat epb pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt

2. check virsh capabilities:

#  virsh capabilities 
<capabilities>

  <host>
    <uuid>abc38b34-0bcb-47ad-b28a-b66e0cfc5814</uuid>
    <cpu>
      <arch>x86_64</arch>
      <model>IvyBridge</model>
      <vendor>Intel</vendor>
      <topology sockets='1' cores='10' threads='2'/>
      <feature name='invtsc'/>
      <feature name='pdpe1gb'/>
      <feature name='osxsave'/>
      <feature name='dca'/>
      <feature name='pcid'/>
      <feature name='pdcm'/>
      <feature name='xtpr'/>
      <feature name='tm2'/>
      <feature name='est'/>
      <feature name='smx'/>
      <feature name='vmx'/>
      <feature name='ds_cpl'/>
      <feature name='monitor'/>
      <feature name='dtes64'/>
      <feature name='pbe'/>
      <feature name='tm'/>
      <feature name='ht'/>
      <feature name='ss'/>
      <feature name='acpi'/>
      <feature name='ds'/>
      <pages unit='KiB' size='4'/>
      <pages unit='KiB' size='2048'/>
      <pages unit='KiB' size='1048576'/>
    </cpu>
...

3. check cpu-models:

# virsh cpu-models x86_64
Opteron_G5
Opteron_G4
Opteron_G3
Opteron_G2
Opteron_G1
phenom
athlon
Broadwell
Broadwell-noTSX
Haswell
Haswell-noTSX
IvyBridge
SandyBridge
Westmere
Nehalem
Penryn
Conroe
qemu64
kvm64
cpu64-rhel6
cpu64-rhel5
kvm32
qemu32
core2duo
n270
coreduo
pentiumpro
pentium3
pentium2
pentium
486


4. start a guest which have IvyBridge:

# virsh dumpxml test4
...
  <cpu mode='host-model'>
    <model fallback='allow'/>
    <numa>
      <cell id='0' cpus='0' memory='1024000' unit='KiB'/>
    </numa>
  </cpu>
...

# virsh start test4
Domain test4 started

5. recheck the xml:
# virsh dumpxml test4 --update-cpu
...
  <cpu mode='host-model' match='exact'>
    <model fallback='allow'>IvyBridge</model>
    <vendor>Intel</vendor>
    <feature policy='require' name='pdpe1gb'/>
    <feature policy='require' name='osxsave'/>
    <feature policy='require' name='dca'/>
    <feature policy='require' name='pcid'/>
    <feature policy='require' name='pdcm'/>
    <feature policy='require' name='xtpr'/>
    <feature policy='require' name='tm2'/>
    <feature policy='require' name='est'/>
    <feature policy='require' name='smx'/>
    <feature policy='require' name='vmx'/>
    <feature policy='require' name='ds_cpl'/>
    <feature policy='require' name='monitor'/>
    <feature policy='require' name='dtes64'/>
    <feature policy='require' name='pbe'/>
    <feature policy='require' name='tm'/>
    <feature policy='require' name='ht'/>
    <feature policy='require' name='ss'/>
    <feature policy='require' name='acpi'/>
    <feature policy='require' name='ds'/>
    <numa>
      <cell id='0' cpus='0' memory='1024000' unit='KiB'/>
    </numa>
  </cpu>
...

6. check qemu command line:

# ps aux|grep qemu
qemu      34148 17.7  0.8 1619840 33100 ?       Sl   06:02   0:12 /usr/libexec/qemu-kvm -name test4 -S -machine pc-i440fx-rhel7.0.0,accel=kvm,usb=off -cpu IvyBridge,+pdpe1gb,+osxsave,+dca,+pcid,+pdcm,+xtpr,+tm2,+est,+smx,+vmx,+ds_cpl,+monitor,+dtes64,+pbe,+tm,+ht,+ss,+acpi,+ds...


And use a host is not IvyBridge and start a guest:

1. 

# virsh dumpxml test4
...
  <cpu mode='custom' match='exact'>
    <model fallback='allow'>IvyBridge</model>
    <numa>
      <cell id='0' cpus='0' memory='1024000' unit='KiB'/>
    </numa>
  </cpu>
...

2.

# virsh start test4
error: Failed to start domain test4
error: unsupported configuration: guest and host CPU are not compatible: Host CPU does not provide required features: erms, smep, fsgsbase, rdrand, tsc-deadline, x2apic

Comment 12 errata-xmlrpc 2015-11-19 06:52:29 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-2202.html