From patchwork Thu Jan 8 12:57:53 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 1360 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 n08CrPtO030891 for ; Thu, 8 Jan 2009 04:53:26 -0800 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758730AbZAHM4i (ORCPT ); Thu, 8 Jan 2009 07:56:38 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1760040AbZAHM4i (ORCPT ); Thu, 8 Jan 2009 07:56:38 -0500 Received: from outbound-wa4.frontbridge.com ([216.32.181.16]:59718 "EHLO WA4EHSOBE002.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760025AbZAHM4g (ORCPT ); Thu, 8 Jan 2009 07:56:36 -0500 Received: from mail104-wa4-R.bigfish.com (10.8.14.243) by WA4EHSOBE002.bigfish.com (10.8.40.22) with Microsoft SMTP Server id 8.1.291.1; Thu, 8 Jan 2009 12:56:36 +0000 Received: from mail104-wa4 (localhost.localdomain [127.0.0.1]) by mail104-wa4-R.bigfish.com (Postfix) with ESMTP id 0210716C03CD for ; Thu, 8 Jan 2009 12:56:36 +0000 (UTC) X-BigFish: VPS-12(zzaf6W3117K2399kzzzzz32i43j61h) X-Spam-TCS-SCL: 0:0 X-FB-SS: 5, Received: by mail104-wa4 (MessageSwitch) id 1231419394440835_2568; Thu, 8 Jan 2009 12:56:34 +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 mail104-wa4.bigfish.com (Postfix) with ESMTP id 4897FB5005A for ; Thu, 8 Jan 2009 12:56:34 +0000 (UTC) Received: from ausb3twp02.amd.com ([163.181.250.38]) by ausb3extmailp01.amd.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id n08CuQw4017664 for ; Thu, 8 Jan 2009 06:56:29 -0600 X-WSS-ID: 0KD5LA0-02-USY-01 Received: from sausexbh1.amd.com (sausexbh1.amd.com [163.181.22.101]) by ausb3twp02.amd.com (Tumbleweed MailGate 3.5.1) with ESMTP id 25B2316A0424 for ; Thu, 8 Jan 2009 06:56:23 -0600 (CST) Received: from sausexmb5.amd.com ([163.181.49.129]) by sausexbh1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 8 Jan 2009 06:56:29 -0600 Received: from SDRSEXMB1.amd.com ([172.20.3.116]) by sausexmb5.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 8 Jan 2009 06:56:29 -0600 Received: from localhost.localdomain ([165.204.85.38]) by SDRSEXMB1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 8 Jan 2009 13:56:27 +0100 From: Andre Przywara To: kvm@vger.kernel.org CC: Andre Przywara Subject: [PATCH] KVM-userspace: allow CPUID vendor override Date: Thu, 8 Jan 2009 13:57:53 +0100 Message-ID: <1231419473-14844-1-git-send-email-andre.przywara@amd.com> X-Mailer: git-send-email 1.5.5 X-OriginalArrivalTime: 08 Jan 2009 12:56:27.0200 (UTC) FILETIME=[84AE1400:01C97190] MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Hi, currently KVM always propagates the host CPU vendor ID to the guest. This patch allows to override this behavior by explicitly specifying a vendor ID with -cpu qemu64,vendor=KVMKVMKVMKVM. This proved to be useful for cross vendor migration tests. Regards, Andre. Andre Przywara AMD-Operating System Research Center (OSRC), Dresden, Germany Tel: +49 351 277-84917 ****to satisfy European Law for business letters: Advanced Micro Devices GmbH Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Jochen Polster; Thomas M. McCoy; Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632 Signed-off-by: Andre Przywara --- qemu/target-i386/cpu.h | 1 + qemu/target-i386/helper.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletions(-) diff --git a/qemu/target-i386/cpu.h b/qemu/target-i386/cpu.h index 944e386..d83d62b 100644 --- a/qemu/target-i386/cpu.h +++ b/qemu/target-i386/cpu.h @@ -628,6 +628,7 @@ typedef struct CPUX86State { uint32_t cpuid_ext2_features; uint32_t cpuid_ext3_features; uint32_t cpuid_apic_id; + uint32_t cpuid_vendor_override; #ifdef USE_KQEMU int kqemu_enabled; diff --git a/qemu/target-i386/helper.c b/qemu/target-i386/helper.c index cda0390..7dbe36b 100644 --- a/qemu/target-i386/helper.c +++ b/qemu/target-i386/helper.c @@ -103,6 +103,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) @@ -335,6 +336,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); @@ -387,6 +389,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); @@ -1435,7 +1438,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, * 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, NULL, ebx, ecx, edx); break; case 1: