From patchwork Tue Jun 23 12:37:09 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 31966 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 n5NCXtLO011148 for ; Tue, 23 Jun 2009 12:33:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753103AbZFWMdt (ORCPT ); Tue, 23 Jun 2009 08:33:49 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752808AbZFWMdt (ORCPT ); Tue, 23 Jun 2009 08:33:49 -0400 Received: from wa4ehsobe005.messaging.microsoft.com ([216.32.181.15]:25940 "EHLO WA4EHSOBE005.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751419AbZFWMdr (ORCPT ); Tue, 23 Jun 2009 08:33:47 -0400 Received: from mail223-wa4-R.bigfish.com (10.8.14.250) by WA4EHSOBE005.bigfish.com (10.8.40.25) with Microsoft SMTP Server id 8.1.340.0; Tue, 23 Jun 2009 12:33:50 +0000 Received: from mail223-wa4 (localhost.localdomain [127.0.0.1]) by mail223-wa4-R.bigfish.com (Postfix) with ESMTP id 95A1644023F; Tue, 23 Jun 2009 12:33:50 +0000 (UTC) X-SpamScore: 3 X-BigFish: VPS3(zzzz1202hzzz32i17ch43j62h) X-Spam-TCS-SCL: 1:0 X-FB-SS: 5, Received: by mail223-wa4 (MessageSwitch) id 1245760428696057_6007; Tue, 23 Jun 2009 12:33:48 +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 mail223-wa4.bigfish.com (Postfix) with ESMTP id 7536A1098057; Tue, 23 Jun 2009 12:33:48 +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 n5NCXhwu003710; Tue, 23 Jun 2009 07:33:46 -0500 X-WSS-ID: 0KLOYW0-02-21A-01 Received: from sausexbh2.amd.com (SAUSEXBH2.amd.com [163.181.22.102]) by ausb3twp02.amd.com (Tumbleweed MailGate 3.5.1) with ESMTP id 2EE0416A03CB; Tue, 23 Jun 2009 07:33:36 -0500 (CDT) Received: from sausexmb1.amd.com ([163.181.3.156]) by sausexbh2.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 23 Jun 2009 07:33:42 -0500 Received: from SDRSEXMB1.amd.com ([172.20.3.116]) by sausexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 23 Jun 2009 07:33:42 -0500 Received: from localhost.localdomain ([165.204.15.42]) by SDRSEXMB1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 23 Jun 2009 14:33:20 +0200 From: Andre Przywara To: aliguori@us.ibm.com CC: avi@redhat.com, kvm@vger.kernel.org, qemu-devel@nongnu.org, Andre Przywara Subject: [PATCH 1/2 v2] allow hypervisor CPUID bit to be overriden Date: Tue, 23 Jun 2009 14:37:09 +0200 Message-ID: <1245760629-9430-1-git-send-email-andre.przywara@amd.com> X-Mailer: git-send-email 1.6.1.3 In-Reply-To: <1245707244-743-1-git-send-email-andre.przywara@amd.com> References: <1245707244-743-1-git-send-email-andre.przywara@amd.com> X-OriginalArrivalTime: 23 Jun 2009 12:33:20.0096 (UTC) FILETIME=[CA794E00:01C9F3FE] MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org KVM defaults to the hypervisor CPUID bit to be set, whereas pure QEMU clears it. On some occasions one wants to set or clear it the other way round (for instance to get HyperV running inside a guest). Move the bit-set to be done before the command line parsing and enable it by default. One can disable it by using: -cpu qemu64,-hypervisor Fix some whitespace damage on the way. Signed-off-by: Andre Przywara --- target-i386/helper.c | 23 +++++++++++------------ 1 files changed, 11 insertions(+), 12 deletions(-) diff --git a/target-i386/helper.c b/target-i386/helper.c index 8a76abd..cb9113e 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -44,7 +44,7 @@ static const char *ext_feature_name[] = { "pni" /* Intel,AMD sse3 */, NULL, NULL, "monitor", "ds_cpl", "vmx", NULL /* Linux smx */, "est", "tm2", "ssse3", "cid", NULL, NULL, "cx16", "xtpr", NULL, NULL, NULL, "dca", NULL, NULL, NULL, NULL, "popcnt", - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, "hypervisor", }; static const char *ext2_feature_name[] = { "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce", @@ -59,30 +59,30 @@ static const char *ext3_feature_name[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }; -static void add_flagname_to_bitmaps(char *flagname, uint32_t *features, - uint32_t *ext_features, - uint32_t *ext2_features, +static void add_flagname_to_bitmaps(const char *flagname, uint32_t *features, + uint32_t *ext_features, + uint32_t *ext2_features, uint32_t *ext3_features) { int i; int found = 0; - for ( i = 0 ; i < 32 ; i++ ) + for ( i = 0 ; i < 32 ; i++ ) if (feature_name[i] && !strcmp (flagname, feature_name[i])) { *features |= 1 << i; found = 1; } - for ( i = 0 ; i < 32 ; i++ ) + for ( i = 0 ; i < 32 ; i++ ) if (ext_feature_name[i] && !strcmp (flagname, ext_feature_name[i])) { *ext_features |= 1 << i; found = 1; } - for ( i = 0 ; i < 32 ; i++ ) + for ( i = 0 ; i < 32 ; i++ ) if (ext2_feature_name[i] && !strcmp (flagname, ext2_feature_name[i])) { *ext2_features |= 1 << i; found = 1; } - for ( i = 0 ; i < 32 ; i++ ) + for ( i = 0 ; i < 32 ; i++ ) if (ext3_feature_name[i] && !strcmp (flagname, ext3_feature_name[i])) { *ext3_features |= 1 << i; found = 1; @@ -330,6 +330,9 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) goto error; memcpy(x86_cpu_def, def, sizeof(*def)); + add_flagname_to_bitmaps("hypervisor", &plus_features, + &plus_ext_features, &plus_ext2_features, &plus_ext3_features); + featurestr = strtok(NULL, ","); while (featurestr) { @@ -1523,10 +1526,6 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *ebx = (env->cpuid_apic_id << 24) | 8 << 8; /* CLFLUSH size in quad words, Linux wants it. */ *ecx = env->cpuid_ext_features; *edx = env->cpuid_features; - - /* "Hypervisor present" bit required for Microsoft SVVP */ - if (kvm_enabled()) - *ecx |= (1 << 31); break; case 2: /* cache info: needed for Pentium Pro compatibility */