From patchwork Tue May 26 13:24:05 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 26018 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n4QDM1ic017774 for ; Tue, 26 May 2009 13:22:01 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753090AbZEZNV5 (ORCPT ); Tue, 26 May 2009 09:21:57 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753073AbZEZNV5 (ORCPT ); Tue, 26 May 2009 09:21:57 -0400 Received: from tx2ehsobe002.messaging.microsoft.com ([65.55.88.12]:15528 "EHLO TX2EHSOBE004.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753001AbZEZNV4 (ORCPT ); Tue, 26 May 2009 09:21:56 -0400 Received: from mail4-tx2-R.bigfish.com (10.9.14.245) by TX2EHSOBE004.bigfish.com (10.9.40.24) with Microsoft SMTP Server id 8.1.340.0; Tue, 26 May 2009 13:21:57 +0000 Received: from mail4-tx2 (localhost.localdomain [127.0.0.1]) by mail4-tx2-R.bigfish.com (Postfix) with ESMTP id 759A06581A5; Tue, 26 May 2009 13:21:57 +0000 (UTC) X-BigFish: VPS3(zzzz1202hzzz32i43j) X-FB-SS: 5,13, Received: by mail4-tx2 (MessageSwitch) id 124334410791142_27759; Tue, 26 May 2009 13:21:47 +0000 (UCT) Received: from ausb3extmailp01.amd.com (unknown [163.181.251.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail4-tx2.bigfish.com (Postfix) with ESMTP id 707AC2B8058; Tue, 26 May 2009 13:21:46 +0000 (UTC) Received: from ausb3twp01.amd.com ([163.181.250.37]) by ausb3extmailp01.amd.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id n4QDLdvd011763; Tue, 26 May 2009 08:21:42 -0500 X-WSS-ID: 0KK96FY-01-F0S-01 Received: from sausexbh1.amd.com (sausexbh1.amd.com [163.181.22.101]) by ausb3twp01.amd.com (Tumbleweed MailGate 3.5.1) with ESMTP id 26903194400; Tue, 26 May 2009 08:21:34 -0500 (CDT) Received: from SAUSEXMB3.amd.com ([163.181.22.202]) by sausexbh1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 26 May 2009 08:21:40 -0500 Received: from SDRSEXMB1.amd.com ([172.20.3.116]) by SAUSEXMB3.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 26 May 2009 08:21:40 -0500 Received: from localhost.localdomain ([165.204.15.42]) by SDRSEXMB1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 26 May 2009 15:21:38 +0200 From: Andre Przywara To: avi@redhat.com CC: kvm@vger.kernel.org Subject: [PATCH] allow CPUID vendor override Date: Tue, 26 May 2009 15:24:05 +0200 Message-ID: <1243344245-25427-1-git-send-email-andre.przywara@amd.com> X-Mailer: git-send-email 1.6.1.3 X-OriginalArrivalTime: 26 May 2009 13:21:38.0291 (UTC) FILETIME=[E65DC430:01C9DE04] MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org KVM will always report the vendor ID of the physical CPU it is running on. Allow to override this if explicitly requested on the command line. It will not suffice to name a CPU type (like -cpu phenom), but you have to explicitly set the vendor: -cpu phenom,vendor=AuthenticAMD Signed-off-by: Andre Przywara --- target-i386/cpu.h | 1 + target-i386/helper.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletions(-) diff --git a/target-i386/cpu.h b/target-i386/cpu.h index d7b32d4..133a69d 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -655,6 +655,7 @@ typedef struct CPUX86State { uint32_t cpuid_ext2_features; uint32_t cpuid_ext3_features; uint32_t cpuid_apic_id; + uint32_t cpuid_vendor_override; /* MTRRs */ uint64_t mtrr_fixed[11]; diff --git a/target-i386/helper.c b/target-i386/helper.c index ed2dc41..0fb31c6 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -118,6 +118,7 @@ typedef struct x86_def_t { uint32_t features, ext_features, ext2_features, ext3_features; uint32_t xlevel; char model_id[48]; + int vendor_override; } x86_def_t; #define I486_FEATURES (CPUID_FP87 | CPUID_VME | CPUID_PSE) @@ -378,6 +379,7 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) x86_cpu_def->vendor2 |= ((uint8_t)val[i + 4]) << (8 * i); x86_cpu_def->vendor3 |= ((uint8_t)val[i + 8]) << (8 * i); } + x86_cpu_def->vendor_override = 1; } else if (!strcmp(featurestr, "model_id")) { pstrcpy(x86_cpu_def->model_id, sizeof(x86_cpu_def->model_id), val); @@ -430,6 +432,7 @@ static int cpu_x86_register (CPUX86State *env, const char *cpu_model) env->cpuid_vendor2 = CPUID_VENDOR_INTEL_2; env->cpuid_vendor3 = CPUID_VENDOR_INTEL_3; } + env->cpuid_vendor_override = def->vendor_override; env->cpuid_level = def->level; if (def->family > 0x0f) env->cpuid_version = 0xf00 | ((def->family - 0x0f) << 20); @@ -1508,7 +1511,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, * isn't supported in compatibility mode on Intel. so advertise the * actuall cpu, and say goodbye to migration between different vendors * is you use compatibility mode. */ - if (kvm_enabled()) + if (kvm_enabled() && !env->cpuid_vendor_override) host_cpuid(0, 0, NULL, ebx, ecx, edx); break; case 1: