From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54438) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNSAu-0000ti-BQ for qemu-devel@nongnu.org; Tue, 11 Mar 2014 15:17:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WNSAn-0005Rb-2M for qemu-devel@nongnu.org; Tue, 11 Mar 2014 15:17:16 -0400 Received: from s6.fused.com ([216.86.156.92]:55329) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNSAm-0005RS-TA for qemu-devel@nongnu.org; Tue, 11 Mar 2014 15:17:08 -0400 Received: from c-98-207-106-20.hsd1.ca.comcast.net ([98.207.106.20]:23904 helo=gateway.ulduzsoft.com) by s6.fused.com with esmtps (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.82) (envelope-from ) id 1WNRW2-0003h8-C5 for qemu-devel@nongnu.org; Tue, 11 Mar 2014 14:34:37 -0400 Received: from [192.168.0.5] (tim.sweethome [192.168.0.5]) by gateway.ulduzsoft.com (Postfix) with ESMTPSA id 5497F120088 for ; Tue, 11 Mar 2014 11:35:01 -0700 (PDT) Message-ID: <531F5763.5030701@ulduzsoft.com> Date: Tue, 11 Mar 2014 11:35:15 -0700 From: George Yunaev MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------050906090800080307010204" Subject: [Qemu-devel] [PATCH] qemu-kvm: use the proper CPU vendor if -cpu is specified with -enable-kvm List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------050906090800080307010204 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hello everyone, This patch fixes the issue when -cpu specification is partially ignored when -enable-kvm is specified. For example, |when running: qemu-system-x86_64 -cpu core2duo on AMD machine, the CPU vendor is properly identified as GenuineIntel. However when running: | |qemu-system-x86_64 -cpu core2duo| |-enable-kvm on the same AMD machine, the CPU vendor is now identified as AuthenticAMD, despite the rest of CPU information (such as name) being Intel-specific. This behavior breaks the attempts to emulate Mac OS X on AMD CPU with kvm enabled. This behavior is caused by the code in cpu_x86_register() which copies the host CPU vendor into the emulated CPU when kvm is enabled. While this makes sense for the qemu-emulated CPU, this makes little sense when the user actually specified the -cpu. Not sure if this behavior The attached patch changes this behavior by only copying the vendor CPU information from the host CPU when either the qemu32 or qemu64 CPU is being used. | Signed-off-by: George Yunaev --- --- qemu.old/target-i386/cpu.c 2014-03-10 23:47:08.000000000 -0700 +++ qemu/target-i386/cpu.c 2014-03-10 23:47:32.433412520 -0700 @@ -1863,7 +1863,7 @@ const char *vendor = def->vendor; char host_vendor[CPUID_VENDOR_SZ + 1]; - if (kvm_enabled()) { + if (kvm_enabled() && def->name[0] == 'q' && def->name[1] == 'e' && def->name[2] == 'm' && def->name[3] == 'u' ) { uint32_t ebx = 0, ecx = 0, edx = 0; host_cpuid(0, 0, NULL, &ebx, &ecx, &edx); x86_cpu_vendor_words2str(host_vendor, ebx, edx, ecx); --- --------------050906090800080307010204 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hello everyone,

This patch fixes the issue when -cpu specification is partially ignored when -enable-kvm is specified. For example, when running:

qemu-system-x86_64 -cpu core2duo

on AMD machine, the CPU vendor is properly identified as GenuineIntel. However when running:

qemu-system-x86_64 -cpu core2duo -enable-kvm

on the same AMD machine, the CPU vendor is now identified as AuthenticAMD, despite the rest of CPU information (such as name) being Intel-specific. This behavior breaks the attempts to emulate Mac OS X on AMD CPU with kvm enabled.

This behavior is caused by the code in cpu_x86_register() which copies the host CPU vendor into the emulated CPU when kvm is enabled. While this makes sense for the qemu-emulated CPU, this makes little sense when the user actually specified the -cpu. Not sure if this behavior

The attached patch changes this behavior by only copying the vendor CPU information from the host CPU when either the qemu32 or qemu64 CPU is being used.

Signed-off-by: George Yunaev <gyunaev@ulduzsoft.com>
---
--- qemu.old/target-i386/cpu.c  2014-03-10 23:47:08.000000000 -0700
+++ qemu/target-i386/cpu.c      2014-03-10 23:47:32.433412520 -0700
@@ -1863,7 +1863,7 @@
     const char *vendor = def->vendor;
     char host_vendor[CPUID_VENDOR_SZ + 1];
 
-    if (kvm_enabled()) {
+    if (kvm_enabled() && def->name[0] == 'q' && def->name[1] == 'e' && def->name[2] == 'm' && def->name[3] == 'u' ) {
         uint32_t  ebx = 0, ecx = 0, edx = 0;
         host_cpuid(0, 0, NULL, &ebx, &ecx, &edx);
         x86_cpu_vendor_words2str(host_vendor, ebx, edx, ecx);
---
--------------050906090800080307010204--