Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MeD1g-0005Qy-Cu for qemu-devel@nongnu.org; Thu, 20 Aug 2009 15:10:20 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MeD1c-0005QQ-MV for qemu-devel@nongnu.org; Thu, 20 Aug 2009 15:10:20 -0400 Received: from [199.232.76.173] (port=42396 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MeD1c-0005QN-Hh for qemu-devel@nongnu.org; Thu, 20 Aug 2009 15:10:16 -0400 Received: from va3ehsobe001.messaging.microsoft.com ([216.32.180.11]:53354 helo=VA3EHSOBE001.bigfish.com) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_MD5:16) (Exim 4.60) (envelope-from ) id 1MeD1c-0005Ke-6W for qemu-devel@nongnu.org; Thu, 20 Aug 2009 15:10:16 -0400 From: Andre Przywara Date: Thu, 20 Aug 2009 21:03:48 +0200 Message-ID: <1250795028-25995-1-git-send-email-andre.przywara@amd.com> In-Reply-To: <4A8D2E1E.2040608@redhat.com> References: <4A8D2E1E.2040608@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH] allow overriding of CPUID level on command line List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: avi@redhat.com, anthony@codemonkey.ws Cc: qemu-devel@nongnu.org The CPUID level determines how many CPUID leafs are exposed to the guest. Some features (like multi-core) cannot be propagated without the proper level, but guests maybe confused by bogus entries in some leafs. So add level= and xlevel= to the list of -cpu options to allow the user to override the default settings. While at it, merge unnecessary local variables into one and allow hexadecimal arguments. Signed-off-by: Andre Przywara --- target-i386/helper.c | 39 +++++++++++++++++++++++++++++---------- 1 files changed, 29 insertions(+), 10 deletions(-) diff --git a/target-i386/helper.c b/target-i386/helper.c index d4dfcbd..21b268a 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -349,7 +349,7 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) char *featurestr, *name = strtok(s, ","); uint32_t plus_features = 0, plus_ext_features = 0, plus_ext2_features = 0, plus_ext3_features = 0; uint32_t minus_features = 0, minus_ext_features = 0, minus_ext2_features = 0, minus_ext3_features = 0; - int family = -1, model = -1, stepping = -1; + uint32_t numvalue; def = NULL; for (i = 0; i < ARRAY_SIZE(x86_defs); i++) { @@ -381,28 +381,47 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) *val = 0; val++; if (!strcmp(featurestr, "family")) { char *err; - family = strtol(val, &err, 10); - if (!*val || *err || family < 0) { + numvalue = strtoul(val, &err, 0); + if (!*val || *err) { fprintf(stderr, "bad numerical value %s\n", val); goto error; } - x86_cpu_def->family = family; + x86_cpu_def->family = numvalue; } else if (!strcmp(featurestr, "model")) { char *err; - model = strtol(val, &err, 10); - if (!*val || *err || model < 0 || model > 0xff) { + numvalue = strtoul(val, &err, 0); + if (!*val || *err || numvalue > 0xff) { fprintf(stderr, "bad numerical value %s\n", val); goto error; } - x86_cpu_def->model = model; + x86_cpu_def->model = numvalue; } else if (!strcmp(featurestr, "stepping")) { char *err; - stepping = strtol(val, &err, 10); - if (!*val || *err || stepping < 0 || stepping > 0xf) { + numvalue = strtoul(val, &err, 0); + if (!*val || *err || numvalue > 0xf) { fprintf(stderr, "bad numerical value %s\n", val); goto error; } - x86_cpu_def->stepping = stepping; + x86_cpu_def->stepping = numvalue ; + } else if (!strcmp(featurestr, "level")) { + char *err; + numvalue = strtoul(val, &err, 0); + if (!*val || *err) { + fprintf(stderr, "bad numerical value %s\n", val); + goto error; + } + x86_cpu_def->level = numvalue; + } else if (!strcmp(featurestr, "xlevel")) { + char *err; + numvalue = strtoul(val, &err, 0); + if (!*val || *err) { + fprintf(stderr, "bad numerical value %s\n", val); + goto error; + } + if (numvalue < 0x80000000) { + numvalue += 0x80000000; + } + x86_cpu_def->xlevel = numvalue; } else if (!strcmp(featurestr, "vendor")) { if (strlen(val) != 12) { fprintf(stderr, "vendor string must be 12 chars long\n"); -- 1.6.1.3