Bug 814426

Summary: "rdtscp" flag defined on SandyBridge and Opteron models, but not supported by the kernel
Product: Red Hat Enterprise Linux 6 Reporter: Eduardo Habkost <ehabkost>
Component: qemu-kvmAssignee: Eduardo Habkost <ehabkost>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.3CC: acathrow, areis, bsarathy, chayang, dyasny, flang, juzhang, michen, minovotn, mkenneth, qzhang, shu, sluo, virt-maint, xfu
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-0.12.1.2-2.310.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 813132
: 1004299 (view as bug list) Environment:
Last Closed: 2013-02-21 07:34:06 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:
Bug Depends On: 833152    
Bug Blocks: 692374, 833129, 841379, 1004299    

Description Eduardo Habkost 2012-04-19 20:36:16 UTC
Cloning the bug specifically for the "rdtscp" flag. The flag is defined on the SandyBridge and Opteron CPU models, but not supported by the kernel. "-cpu <model>,check" and "-cpu <model>,enforce" should have detected it, but it didn't.

So, we have to:
1) Either remove the flag from the model definitions, or add rdtscp support to the KVM module
2) Make "-cpu <model>,check" actually detect the missing flag (bug 692374)

+++ This bug was initially created as a clone of Bug #813132 +++

Description of problem:
can find "sep" flag in /usr/libexec/qemu-kvm -cpu ?dump and cann't find it /proc/cpuinof on host. but haven't any warning message when booting guest.
BTW, "sep" isn't exposted to guest.

"rdtscp" flag is defined in dump and /proc/cpuinfo on host but it isn't exposted to guest. 

Version-Release number of selected component (if applicable):
# uname -r
2.6.32-259.el6.x86_64
#rpm -qa|grep qemu
qemu-kvm-0.12.1.2-2.270.el6.x86_64

How reproducible:
always

Steps to Reproduce:
1./usr/libexec/qemu-kvm -M rhel6.3.0 -cpu SandyBridge --enable-kvm -m 4G -smp
40,sockets=2,cores=10,threads=2,maxcpus=41 -name rhel6.3 -uuid
ddcbfb49-3411-1701-3c36-6bdbc00bedbb -rtc base=utc,clock=host,driftfix=slew
-boot c  -drive
file=/mnt/rhel6.3.raw,format=raw,if=none,id=disk0,cache=none,werror=stop,rerror=stop
-device virtio-scsi-pci,id=disk0 -device
scsi-hd,drive=disk0,scsi-id=0,lun=0,bootindex=1 -netdev tap,id=hostnet1 -device
virtio-net-pci,netdev=hostnet1,id=net1,mac=86:12:50:a4:32:72 -spice
port=5911,disable-ticketing -vga qxl -device sga -chardev
socket,id=serial0,path=/var/test1,server,nowait -device
isa-serial,chardev=serial0 -balloon virtio -monitor
unix:/tmp/monitor1,server,nowait -monitor stdio

2. find "sep" flag from dump 
   
3. find "rdtscp" flag from dump and cpuinfo on host

4. check above two flags in guest
  
Actual results:
1. can find "sep" from dump, no any warning message when booting guest.
2. can find "rdtscp" from dump and cpuinfo on host,but cann't find it from guest

Expected results:
qemu should have warning message because "sep" flag isn't defined in host.
rdtscp should expose to guest.

Additional info:

Comment 2 FuXiangChun 2012-10-24 03:45:20 UTC
verify this issue with qemu-kvm-0.12.1.2-2.329.el6.x86_64 and kernel 2.6.32-335.el6.x86_64(host and guest)
rdtscp flag is located 0x80000001 EDX[27]

Testing result via x86info tool
1.Haswell host:
Boot guest with -M rhel6.4.0 -cpu Haswell
guest:
eax in: 0x80000001, eax = 000306c1 ebx = 00000000 ecx = 00000001 edx = 20100800

host:
eax in: 0x80000001, eax = 00000000 ebx = 00000000 ecx = 00000021 edx = 2c100800


2.SandyBridge host
Boot guest with -M rhel6.4.0 -cpu SandyBridge
guest:
eax in: 0x80000001, eax = 000206a1 ebx = 00000000 ecx = 00000001 edx = 20100800

host:
eax in: 0x80000001, eax = 00000000 ebx = 00000000 ecx = 00000001 edx = 28100800

Base on testing result above, I think this bug is not fixed.

Comment 3 Eduardo Habkost 2012-10-24 03:54:21 UTC
This is the expected result. We have followed the first approach mentioned on comment #0 -- the rdtscp flag was removed from all CPU models to reflect reality because it is not supported by the RHEL-6 kernel.

Comment 4 FuXiangChun 2012-10-24 09:09:07 UTC
(In reply to comment #3)
> This is the expected result. We have followed the first approach mentioned
> on comment #0 -- the rdtscp flag was removed from all CPU models to reflect
> reality because it is not supported by the RHEL-6 kernel.

I had a little confused. 

1. expected result "rdtscp should expose to guest" in comment #0
2. can find "rdtscp" from cpuinfo on host, indicate rhel6 kernel support this flag(this is my understand). 
3. If remove this flag from all CPU models, It should be removed from dump,right?

Comment 5 Eduardo Habkost 2012-10-24 14:18:46 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > This is the expected result. We have followed the first approach mentioned
> > on comment #0 -- the rdtscp flag was removed from all CPU models to reflect
> > reality because it is not supported by the RHEL-6 kernel.
> 
> I had a little confused. 
> 
> 1. expected result "rdtscp should expose to guest" in comment #0

It should be exposed if it's set on the CPU models. There were two possible solutions: add rdtscp support to the kernel, or remove the flag from the CPU models to reflect what's actually being exposed to guests when using RHEL-6.3 qemu-kvm. We chose the second approach.


> 2. can find "rdtscp" from cpuinfo on host, indicate rhel6 kernel support
> this flag(this is my understand). 

No, the KVM kernel code has to support it too, and the RHEL-6 KVM kernel code doesn't support exposing rdtscp to guests. That's what makes the rdtscp flag not appear to the guest (as the flags are filtered according to the host CPU + host kernel capabilities[1]).


[1] The filtering should be reported by -cpu check/enforce, and the existing bug on -cpu check/enforce is being tracked at bug 692374.


> 3. If remove this flag from all CPU models, It should be removed from
> dump,right?

It should have been removed from the CPU model dump ("-cpu ?dump"), but -cpu ?dump doesn't exist anymore. The flag removal is only visible by looking at the CPU model definitions in the C code at qemu-kvm/target-i386/cpuid.c.

Comment 6 FuXiangChun 2012-11-06 03:30:59 UTC
according to testing result in comment 2 and comment 5, this bug is fixed.

Comment 9 errata-xmlrpc 2013-02-21 07:34:06 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.

http://rhn.redhat.com/errata/RHBA-2013-0527.html