Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MJaaW-000167-0L for qemu-devel@nongnu.org; Wed, 24 Jun 2009 18:05:04 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MJaaR-00011T-HZ for qemu-devel@nongnu.org; Wed, 24 Jun 2009 18:05:03 -0400 Received: from [199.232.76.173] (port=34214 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MJaaR-00011H-C2 for qemu-devel@nongnu.org; Wed, 24 Jun 2009 18:04:59 -0400 Received: from wa4ehsobe002.messaging.microsoft.com ([216.32.181.12]:6754 helo=WA4EHSOBE002.bigfish.com) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_MD5:16) (Exim 4.60) (envelope-from ) id 1MJaaQ-0001yi-PS for qemu-devel@nongnu.org; Wed, 24 Jun 2009 18:04:59 -0400 From: Andre Przywara Date: Thu, 25 Jun 2009 00:07:59 +0200 Message-ID: <1245881284-3656-2-git-send-email-andre.przywara@amd.com> In-Reply-To: <1245881284-3656-1-git-send-email-andre.przywara@amd.com> References: <1245881284-3656-1-git-send-email-andre.przywara@amd.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH 1/6] allow hypervisor CPUID bit to be overriden List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: avi@redhat.com, aliguori@us.ibm.com Cc: Andre Przywara , qemu-devel@nongnu.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 */ -- 1.6.1.3