Bug 690683

Summary: CPU flags in guest don't match with qemu-kvm cpu dump info
Product: Red Hat Enterprise Linux 6 Reporter: Chao Yang <chayang>
Component: qemu-kvmAssignee: john cooper <john.cooper>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1CC: bcao, juzhang, michen, mkenneth, nobody, shuang, shu, tburke, virt-maint, yacui
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-04-13 00:17:39 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
what tools see in guest
none
AMD host flag dump info using x86info & cat /proc/cpuinfo none

Description Chao Yang 2011-03-25 02:53:34 UTC
Created attachment 487448 [details]
what tools see in guest

Description of problem:
Boot guest with -cpu Opteron_G3,check it only complains "warning: host cpuid 8000_0001:ecx flag restricted to guest 'svm' [0x00000004]", so I should see all flags except svm, actually in guest, not only svm flags are turned off and some flags are turned on when pass flags from host to guest.

following is what qemu-kvm says when booting guest with different cpu model and will attach flags x86info sees & /proc/cpuinfo sees:

# /usr/libexec/qemu-kvm -M rhel6.1.0 -enable-kvm -m 4096 -smp 2,cores=4,threads=1,socket=2 -cpu Opteron_G1,check -name rhel6.1 -uuid `uuidgen` -rtc base=localtime,clock=vm,driftfix=slew -no-kvm-pit-reinjection -boot c -drive file=/mnt/images/rhel6.1-64.qcow2,if=none,id=drive-virtio-0-0,media=disk,format=qcow2,cache=none -device virtio-blk-pci,drive=drive-virtio-0-0,id=virt0-0-0 -netdev tap,id=hostnet1 -device virtio-net-pci,netdev=hostnet1,id=net1,mac=52:54:40:81:11:53 -usb -device usb-tablet,id=input1 -vnc :0 -monitor stdio -balloon none
Using CPU model "Opteron_G1,check"
Using CPU model "Opteron_G1,check"
QEMU 0.12.1 monitor - type 'help' for more information
(qemu) 

# /usr/libexec/qemu-kvm -M rhel6.1.0 -enable-kvm -m 4096 -smp 2,cores=4,threads=1,socket=2 -cpu Opteron_G2,check -name rhel6.1 -uuid `uuidgen` -rtc base=localtime,clock=vm,driftfix=slew -no-kvm-pit-reinjection -boot c -drive file=/mnt/images/rhel6.1-64.qcow2,if=none,id=drive-virtio-0-0,media=disk,format=qcow2,cache=none -device virtio-blk-pci,drive=drive-virtio-0-0,id=virt0-0-0 -netdev tap,id=hostnet1 -device virtio-net-pci,netdev=hostnet1,id=net1,mac=52:54:40:81:11:53 -usb -device usb-tablet,id=input1 -vnc :0 -monitor stdio -balloon none
Using CPU model "Opteron_G2,check"
warning: host cpuid 8000_0001:ecx flag restricted to guest 'svm' [0x00000004]
Using CPU model "Opteron_G2,check"
warning: host cpuid 8000_0001:ecx flag restricted to guest 'svm' [0x00000004]
QEMU 0.12.1 monitor - type 'help' for more information
(qemu) 

# /usr/libexec/qemu-kvm -M rhel6.1.0 -enable-kvm -m 4096 -smp 2,cores=4,threads=1,socket=2 -cpu Opteron_G3,check -name rhel6.1 -uuid `uuidgen` -rtc base=localtime,clock=vm,driftfix=slew -no-kvm-pit-reinjection -boot c -drive file=/mnt/images/rhel6.1-64.qcow2,if=none,id=drive-virtio-0-0,media=disk,format=qcow2,cache=none -device virtio-blk-pci,drive=drive-virtio-0-0,id=virt0-0-0 -netdev tap,id=hostnet1 -device virtio-net-pci,netdev=hostnet1,id=net1,mac=52:54:40:81:11:53 -usb -device usb-tablet,id=input1 -vnc :0 -monitor stdio -balloon none
Using CPU model "Opteron_G3,check"
warning: host cpuid 8000_0001:ecx flag restricted to guest 'svm' [0x00000004]
Using CPU model "Opteron_G3,check"
warning: host cpuid 8000_0001:ecx flag restricted to guest 'svm' [0x00000004]
QEMU 0.12.1 monitor - type 'help' for more information
(qemu) 

Version-Release number of selected component (if applicable):
qemu-kvm-0.12.1.2-2.151.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:
Same issue happens with -cpu Opteron_G2,check, -cpu Opteron_G1,check

Comment 2 Chao Yang 2011-03-25 02:57:13 UTC
Created attachment 487449 [details]
AMD host flag dump info using x86info & cat /proc/cpuinfo

Comment 3 Chao Yang 2011-03-25 02:58:03 UTC
# /usr/libexec/qemu-kvm -cpu ?dump
x86       Opteron_G3  AMD Opteron 23xx (Gen 3 Class Opteron)          
  family 15 model 6 stepping 1 level 5 xlevel 0x80000008 vendor "AuthenticAMD"
  feature_edx 078bfbfd (sse2 sse fxsr mmx clflush pse36 pat cmov mca pge mtrr sep apic cx8 mce pae msr tsc pse de fpu)
  feature_ecx 00a02009 (popcnt x2apic cx16 monitor pni|sse3)
  extfeature_edx 2993fbfd (lm|i64 rdtscp fxsr mmx nx|xd pse36 pat cmov mca pge mtrr syscall apic cx8 mce pae msr tsc pse de fpu)
  extfeature_ecx 000000e5 (misalignsse sse4a abm svm lahf_lm)

x86       Opteron_G2  AMD Opteron 22xx (Gen 2 Class Opteron)          
  family 15 model 6 stepping 1 level 5 xlevel 0x80000008 vendor "AuthenticAMD"
  feature_edx 078bfbfd (sse2 sse fxsr mmx clflush pse36 pat cmov mca pge mtrr sep apic cx8 mce pae msr tsc pse de fpu)
  feature_ecx 00202001 (x2apic cx16 pni|sse3)
  extfeature_edx 2993fbfd (lm|i64 rdtscp fxsr mmx nx|xd pse36 pat cmov mca pge mtrr syscall apic cx8 mce pae msr tsc pse de fpu)
  extfeature_ecx 00000005 (svm lahf_lm)

x86       Opteron_G1  AMD Opteron 240 (Gen 1 Class Opteron)           
  family 15 model 6 stepping 1 level 5 xlevel 0x80000008 vendor "AuthenticAMD"
  feature_edx 078bfbfd (sse2 sse fxsr mmx clflush pse36 pat cmov mca pge mtrr sep apic cx8 mce pae msr tsc pse de fpu)
  feature_ecx 00200001 (x2apic pni|sse3)
  extfeature_edx 2193fbfd (lm|i64 fxsr mmx nx|xd pse36 pat cmov mca pge mtrr syscall apic cx8 mce pae msr tsc pse de fpu)
  extfeature_ecx 00000000 ()

Comment 4 yacui 2011-03-30 08:34:04 UTC
Tested host Opetron G2 model 

commandline:
------------
qemu-kvm -name 'vm1' -drive file='/root/win2003-32-virtio.qcow2',index=0,if=none,id=drive-virtio-disk1,media=disk,cache=none,format=qcow2,aio=native -device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk1,id=virtio-disk1 -device virtio-net-pci,netdev=id30ex6J,mac=9a:da:dc:13:6c:79,id=ndev00id30ex6J,bus=pci.0,addr=0x3 -netdev tap,id=id30ex6J,vhost=on,ifname='t0-142301-YINn',script='/root/autotest-devel/client/tests/kvm/scripts/qemu-ifup-switch',downscript='no' -m 512 -smp 4,cores=4,threads=1,sockets=1 -cpu Opteron_G1 -vnc :0 -rtc base=utc,clock=host,driftfix=none -M rhel6.1.0 -boot order=cdn,once=c,menu=off -usbdevice tablet -no-kvm-pit-reinjection -enable-kvm

expected result:
(output in qemu-kvm -cpu ?dump)
----------------
x86       Opteron_G1  AMD Opteron 240 (Gen 1 Class Opteron)
  family 15 model 6 stepping 1 level 5 xlevel 0x80000008 vendor "AuthenticAMD"
  feature_edx 078bfbfd (sse2 sse fxsr mmx clflush pse36 pat cmov mca pge mtrr sep apic cx8 mce pae msr tsc pse de fpu)
  feature_ecx 00200001 (x2apic pni|sse3)
  extfeature_edx 2193fbfd (lm|i64 fxsr mmx nx|xd pse36 pat cmov mca pge mtrr syscall apic cx8 mce pae msr tsc pse de fpu)
  extfeature_ecx 00000000 ()

checking rule:
--------------
the following is output truncated from 'x86info -a -f'
in the 'eax in: 0x00000001' line, the ecx and edx value should equal to feature_ecx and feature_edx 
in the 'eax in: 0x80000001' line, the ecx and edx value should equal to extfeature_ecx and extfeature_edx

actual result(tested on rhel6.0.z-32bit,rhel6.1-32bit,win2k3-32bit,win7-32bit)
-------------
eax in: 0x00000001, eax = 00000f61 ebx = 00040800 ecx = 80200001 edx = 178bfbfd
eax in: 0x80000001, eax = 00000f61 ebx = 00000000 ecx = 00000002 edx = 2193fbfd

note:
when i change the -cpu parameter from '-cpu Opteron_G1' to '-cpu Opteron_G1,vendor="GenuineIntel"', the ecx in 'eax in: 0x80000001' line will change from '00000002' to '00000000' while other values stay the same.

Comment 5 john cooper 2011-04-13 00:17:39 UTC
(In reply to comment #4)
> Tested host Opetron G2 model
>
> commandline:
> ------------
> qemu-kvm -name 'vm1' -drive
> file='/root/win2003-32-virtio.qcow2',index=0,if=none,id=drive-virtio-disk1,media=disk,cache=none,format=qcow2,aio=native
    :
> -m 512 -smp 4,cores=4,threads=1,sockets=1 -cpu Opteron_G1 -vnc :0 -rtc
    :
> (output in qemu-kvm -cpu ?dump)
> ----------------
> x86       Opteron_G1  AMD Opteron 240 (Gen 1 Class Opteron)
>   family 15 model 6 stepping 1 level 5 xlevel 0x80000008 vendor "AuthenticAMD"
>   feature_edx 078bfbfd (sse2 sse fxsr mmx clflush pse36 pat cmov mca pge mtrr
> sep apic cx8 mce pae msr tsc pse de fpu)

178bfbfd ^ 078bfbfd -> 10000000  HTT

Always forced true if (1 < #cores * #threads), as is the case above
given "-smp 4,cores=4,threads=1,sockets=1"

>   feature_ecx 00200001 (x2apic pni|sse3)

80200001 ^ 00200001 -> 80000000  RAZ (Reserved for use by hypervisor to indicate guest status)

qemu forces this bit true unconditionally to indicate the guest is
running as a guest vs. natively.

>   extfeature_edx 2193fbfd (lm|i64 fxsr mmx nx|xd pse36 pat cmov mca pge mtrr
> syscall apic cx8 mce pae msr tsc pse de fpu)

2193fbfd ^ 2193fbfd -> 00000000

>   extfeature_ecx 00000000 ()

00000002 ^ 00000000 ->  00000002  CmpLegacy: core multi-processing legacy mode.

always set by qemu unless the cpuid vendor == intel (IOW this bit is cleared
in the case of an intel vendor host, for the benefit of linux boot-time
thread/topology determination)

> checking rule:
> --------------
> the following is output truncated from 'x86info -a -f'
> in the 'eax in: 0x00000001' line, the ecx and edx value should equal to
> feature_ecx and feature_edx
> in the 'eax in: 0x80000001' line, the ecx and edx value should equal to
> extfeature_ecx and extfeature_edx
>
> actual result(tested on rhel6.0.z-32bit,rhel6.1-32bit,win2k3-32bit,win7-32bit)
> -------------
> eax in: 0x00000001, eax = 00000f61 ebx = 00040800 ecx = 80200001 edx = 178bfbfd
> eax in: 0x80000001, eax = 00000f61 ebx = 00000000 ecx = 00000002 edx = 2193fbfd
>
> note:
> when i change the -cpu parameter from '-cpu Opteron_G1' to '-cpu
> Opteron_G1,vendor="GenuineIntel"', the ecx in 'eax in: 0x80000001' line will
> change from '00000002' to '00000000' while other values stay the same.

Yes this is intentional, see "CmpLegacy" above.