Bug 692374

Summary: -cpu enforce with wrong cpu flags does not cause qemu-kvm process quit
Product: Red Hat Enterprise Linux 6 Reporter: Mike Cao <bcao>
Component: qemu-kvmAssignee: Eduardo Habkost <ehabkost>
Status: CLOSED WONTFIX QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1CC: areis, ehabkost, flang, juzhang, michen, mkenneth, qzhang, sluo, tburke, virt-maint, xfu, xutian
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: upstream qemu-1.4.0 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 822616 (view as bug list) Environment:
Last Closed: 2013-07-03 13:11:56 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 814426    
Bug Blocks: 822613, 833129    

Description Mike Cao 2011-03-31 07:25:16 UTC
Description of problem:


Version-Release number of selected component (if applicable):
# uname -r
2.6.32-128.el6.x86_64
# rpm -q qemu-kvm
qemu-kvm-0.12.1.2-2.153.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1.<commandline> -cpu Penryn,+ace,enforce ( ace is the flag on Westmere cpu model)
2.<commandLine> -cpu Conroe,+smx,enforce ( smx is the flag on Westmere cpu model)
3.<commandLine> -cpu Nehalem,+ace,enforce

Actual results:
QEMU runs in both cases

Expected results:
QEMU does not run

Additional info:
#<commandLine> -cpu host,+ace,enforce
CPU feature ace not found
warning: host cpuid 0000_0001:ecx flag restricted to guest 'vmx' [0x00000020]
Unable to support requested x86 CPU definition

#<commandLine> -cpu cpu64-rhel6,+ace,enforce
CPU feature ace not found
warning: host cpuid 8000_0001:ecx lacks requested flag 'svm' [0x00000004]
warning: host cpuid 8000_0001:ecx lacks requested flag 'abm' [0x00000020]
warning: host cpuid 8000_0001:ecx lacks requested flag 'sse4a' [0x00000040]
Unable to support requested x86 CPU definition

Comment 2 Dor Laor 2011-03-31 10:36:20 UTC
I'm not sure it is worth fixing as long as the regular models w/o additional flags work.

Comment 3 john cooper 2011-04-06 00:40:47 UTC
Yes that is the default "-cpu" flag parsing of qemu, namely it doesn't
bail if unknown flags are present:

# x86_64-softmmu/qemu-system-x86_64 -smp 1 -netic -net user ../../winxp-64.img \
    -m 1024 -cpu Penryn,+popcnt,+ou812,+sse4_2,check 
Using CPU model "Penryn,+popcnt,+ou812,+sse4_2,check"
CPU feature ou812 not found
warning: host cpuid 0000_0001:ecx lacks requested flag 'sse4.2|sse4_2' [0x00100000]
warning: host cpuid 0000_0001:ecx lacks requested flag 'popcnt' [0x00800000]

<guest launches>


But you're right "enforce" semantics should be held (in addition to
complaining) and qemu should error exit.  It's a nit and should be
cleaned up the next time we're in that section of the code.

Comment 7 Eduardo Habkost 2012-03-27 19:56:03 UTC
Not only non-existing flags are not rejected properly, but also flags that exist, are supported by the host, but unsupported by the kernel. e.g.:

-cpu Opteron_G3,+ht,-svm,enforce

HT is not supported by the KVM kernel module and gets disabled, but Qemu continues to run without aborting.

Comment 8 Eduardo Habkost 2012-04-20 20:46:49 UTC
*** Bug 813132 has been marked as a duplicate of this bug. ***

Comment 10 Eduardo Habkost 2012-07-20 13:34:28 UTC
*** Bug 821581 has been marked as a duplicate of this bug. ***

Comment 12 langfang 2012-11-08 09:43:39 UTC
not sure if  hit the same problem on Opteron_G5 host.
version:
# uname -r
2.6.32-339.el6.x86_64
# rpm -q qemu-kvm
qemu-kvm-0.12.1.2-2.334.el6.x86_64

guest:win2008r2

host:
[root@amd-pence-01 src]# cat /proc/cpuinfo
processor	: 0
vendor_id	: AuthenticAMD
cpu family	: 21
model		: 2
model name	: AMD Eng Sample, 1S256146U8K54_35/25/20_2/8     
stepping	: 0
cpu MHz		: 1400.000
cache size	: 2048 KB
physical id	: 0
siblings	: 8
core id		: 0
cpu cores	: 4
apicid		: 16
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nonstop_tsc extd_apicid aperfmperf pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 popcnt aes xsave avx f16c lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs xop skinit wdt lwp fma4 tce nodeid_msr tbm topoext perfctr_core cpb npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold bmi1
bogomips	: 4987.26
TLB size	: 1536 4K pages
clflush size	: 64
cache_alignment	: 64
address sizes	: 48 bits physical, 48 bits virtual
power management: ts ttp tm 100mhzsteps hwpstate cpb eff_freq_ro

steps:
1.boot guest with -cpu Opteron_G1,-nx,+sse4a,enforce..(sse4a is the flag on Opteron_G3 cpu model)

 /usr/libexec/qemu-kvm -M rhel6.4.0 -cpu Opteron_G1,-nx,+sse4a......

2.use x86info to check the cpu flag 


results:QEMU runs and not prompt any error,check in guest ,the flag 'sse4a' expose to guest.

addinfo:
but boot with '-cpu Opteron_G2' :
# /usr/libexec/qemu-kvm -M rhel6.4.0 -cpu Opteron_G2,-nx,+sse4a,check,enforce
warning: host cpuid 8000_0001:ecx flag restricted to guest 'svm' [0x00000004]
Unable to support requested x86 CPU definition