Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JOVQH-0003UO-HT for qemu-devel@nongnu.org; Mon, 11 Feb 2008 04:58:01 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JOVQF-0003Sy-Do for qemu-devel@nongnu.org; Mon, 11 Feb 2008 04:58:00 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JOVQF-0003Sd-52 for qemu-devel@nongnu.org; Mon, 11 Feb 2008 04:57:59 -0500 Received: from bzq-179-150-194.static.bezeqint.net ([212.179.150.194] helo=il.qumranet.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JOVQE-0004nP-Et for qemu-devel@nongnu.org; Mon, 11 Feb 2008 04:57:58 -0500 Received: from localhost (karma.qumranet.com [172.16.16.240]) by il.qumranet.com (Postfix) with ESMTP id 8BB9B250DB2 for ; Mon, 11 Feb 2008 11:36:13 +0200 (IST) Date: Mon, 11 Feb 2008 11:36:13 +0200 From: Dan Kenigsberg Message-ID: <20080211093612.GA13201@karma.qumranet.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] (resend) Allow setting the vendor and model_id strings with x86's -cpu option Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Would you consider the following patch, that allows users to set two important x86 cpu options from the command line? (the vendor and model_id strings) Every once in a while I am resending this little patch. It had generated a lot of interest when it included silly bugs, but now it seems to be largely ignored. However, it is important if one would like qemu to impersonate a cpu closely as possible. Regards, Dan. commit 04433bad959a7a4c1b8a0c22bd50eab9bf181b32 Author: Dan Kenigsberg Date: Thu Dec 20 15:43:15 2007 +0200 Change vendor string and model id from the -cpu command line option diff --git a/target-i386/helper2.c b/target-i386/helper2.c index 551a0d8..b59bf92 100644 --- a/target-i386/helper2.c +++ b/target-i386/helper2.c @@ -121,6 +121,7 @@ typedef struct x86_def_t { const char *name; uint32_t level; uint32_t vendor1, vendor2, vendor3; + char model_id[48]; int family; int model; int stepping; @@ -262,7 +263,21 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) goto error; } x86_cpu_def->stepping = stepping; - } else { + } else if (!strcmp(featurestr, "vendor")) { + if (strlen(val) != 12) { + fprintf(stderr, "vendor string must be 12 chars long\n"); + x86_cpu_def = 0; + goto error; + } + x86_cpu_def->vendor1 = x86_cpu_def->vendor2 = x86_cpu_def->vendor3 = 0; + for(i = 0; i < 4; i++) { + x86_cpu_def->vendor1 |= ((unsigned char)val[i ]) << (8 * i); + x86_cpu_def->vendor2 |= ((unsigned char)val[i + 4]) << (8 * i); + x86_cpu_def->vendor3 |= ((unsigned char)val[i + 8]) << (8 * i); + } + } else if (!strcmp(featurestr, "model_id")) + strncpy(x86_cpu_def->model_id, val, 48); + else { fprintf(stderr, "unrecognized feature %s\n", featurestr); x86_cpu_def = 0; goto error; @@ -323,13 +338,14 @@ static int cpu_x86_register (CPUX86State *env, const char *cpu_model) env->cpuid_ext3_features = def->ext3_features; { const char *model_id = "QEMU Virtual CPU version " QEMU_VERSION; - int c, len, i; - len = strlen(model_id); + int c = -1, i; + + if (def->model_id[0] != '\0') + model_id = def->model_id; + for(i = 0; i < 48; i++) { - if (i >= len) - c = '\0'; - else - c = model_id[i]; + if (c != '\0') + c = (unsigned char)model_id[i]; env->cpuid_model[i >> 2] |= c << (8 * (i & 3)); } }