From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ky514-00012p-Aa for qemu-devel@nongnu.org; Thu, 06 Nov 2008 08:35:18 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ky513-00011f-9N for qemu-devel@nongnu.org; Thu, 06 Nov 2008 08:35:17 -0500 Received: from [199.232.76.173] (port=48408 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ky513-00011O-3X for qemu-devel@nongnu.org; Thu, 06 Nov 2008 08:35:17 -0500 Received: from outbound-va3.frontbridge.com ([216.32.180.16]:46925 helo=VA3EHSOBE005.bigfish.com) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_MD5:16) (Exim 4.60) (envelope-from ) id 1Ky512-0008Vc-Rf for qemu-devel@nongnu.org; Thu, 06 Nov 2008 08:35:16 -0500 Message-ID: <4912F218.2050208@amd.com> Date: Thu, 6 Nov 2008 14:33:12 +0100 From: Andre Przywara MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050503050109080103000006" Subject: [Qemu-devel] [PATCH] x86 CPUID extended family/model Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org --------------050503050109080103000006 Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Hi, (at least) AMD CPUs feature extended family/model bits in CPUID leaf 0000_0001|EAX. Refer to page 10 in: http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/25481.pdf Those bits are necessary to model newer AMD CPUs: -cpu qemu64,family=15,model=65,stepping=3 or -cpu qemu64,family=16,model=4,stepping=2 Attached patch introduces support for specifying those bits on the command line and passing them to the guest. (Patch applies against qemu-svn and kvm-userspace) Signed-off-by: Andre Przywara Regards, Andre. P.S. I heard of a way to propagate the host CPUID bits to the guest, like -cpu=host, but couldn't find any code. Did I miss something? -- Andre Przywara AMD-Operating System Research Center (OSRC), Dresden, Germany Tel: +49 351 277-84917 ----to satisfy European Law for business letters: AMD Saxony Limited Liability Company & Co. KG, Wilschdorfer Landstr. 101, 01109 Dresden, Germany Register Court Dresden: HRA 4896, General Partner authorized to represent: AMD Saxony LLC (Wilmington, Delaware, US) General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy --------------050503050109080103000006 Content-Type: text/x-patch; name="cpuid_ext.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="cpuid_ext.patch" Index: target-i386/helper.c =================================================================== --- target-i386/helper.c (revision 5639) +++ target-i386/helper.c (working copy) @@ -337,7 +337,7 @@ } else if (!strcmp(featurestr, "model")) { char *err; model = strtol(val, &err, 10); - if (!*val || *err || model < 0 || model > 0xf) { + if (!*val || *err || model < 0 || model > 0xff) { fprintf(stderr, "bad numerical value %s\n", val); goto error; } @@ -416,7 +416,12 @@ env->cpuid_vendor3 = CPUID_VENDOR_INTEL_3; } env->cpuid_level = def->level; - env->cpuid_version = (def->family << 8) | (def->model << 4) | def->stepping; + if (def->family > 0x0F) + env->cpuid_version = 0xF00 | (def->family - 0x0F)<<20; + else + env->cpuid_version = def->family << 8; + env->cpuid_version |= (def->model & 0x0F) << 4; + env->cpuid_version |= def->stepping | (def->model>>4)<<16; env->cpuid_features = def->features; env->pat = 0x0007040600070406ULL; env->cpuid_ext_features = def->ext_features; --------------050503050109080103000006--