Received: from eggs.gnu.org ([208.118.235.92]:35728) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TF4R3-00052G-FN for qemu-devel@nongnu.org; Fri, 21 Sep 2012 10:42:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TF4Qw-0004KG-Mo for qemu-devel@nongnu.org; Fri, 21 Sep 2012 10:42:29 -0400 Received: from cantor2.suse.de ([195.135.220.15]:35816 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TF4Qw-0004K1-AG for qemu-devel@nongnu.org; Fri, 21 Sep 2012 10:42:22 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Fri, 21 Sep 2012 16:38:32 +0200 Message-Id: <1348238315-29748-9-git-send-email-afaerber@suse.de> In-Reply-To: <1348238315-29748-1-git-send-email-afaerber@suse.de> References: <1348238315-29748-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 08/11] target-i386: Kill cpudef config section support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Eduardo Habkost , anthony@codemonkey.ws, =?UTF-8?q?Andreas=20F=C3=A4rber?= From: Eduardo Habkost It's nice to have a flexible system to maintain CPU models as data, but this is holding us from making improvements in the CPU code because it's not using the common infra-structure, and because the machine-type data is still inside C code. Users who want to configure CPU features directly may simply use the "-cpu" command-line option (and maybe an equivalent -device option in the future) to set CPU features. Signed-off-by: Eduardo Habkost Signed-off-by: Andreas F=C3=A4rber --- target-i386/cpu.c | 101 ++---------------------------------------------= ------ 1 Datei ge=C3=A4ndert, 2 Zeilen hinzugef=C3=BCgt(+), 99 Zeilen entfernt(= -) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index e13e6d5..7c0953f 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -240,7 +240,6 @@ typedef struct x86_def_t { uint32_t xlevel; char model_id[48]; int vendor_override; - uint32_t flags; /* Store the results of Centaur's CPUID instructions */ uint32_t ext4_features; uint32_t xlevel2; @@ -1299,7 +1298,7 @@ void x86_cpu_list(FILE *f, fprintf_function cpu_fpr= intf) char buf[256]; =20 for (def =3D x86_defs; def; def =3D def->next) { - snprintf(buf, sizeof (buf), def->flags ? "[%s]": "%s", def->name= ); + snprintf(buf, sizeof(buf), "%s", def->name); (*cpu_fprintf)(f, "x86 %16s %-48s\n", buf, def->model_id); } if (kvm_enabled()) { @@ -1393,16 +1392,6 @@ int cpu_x86_register(X86CPU *cpu, const char *cpu_= model) } =20 #if !defined(CONFIG_USER_ONLY) -/* copy vendor id string to 32 bit register, nul pad as needed - */ -static void cpyid(const char *s, uint32_t *id) -{ - char *d =3D (char *)id; - char i; - - for (i =3D sizeof (*id); i--; ) - *d++ =3D *s ? *s++ : '\0'; -} =20 /* interpret radix and convert from string to arbitrary scalar, * otherwise flag failure @@ -1416,87 +1405,6 @@ static void cpyid(const char *s, uint32_t *id) *str && !*pend ? (*pval =3D ul) : (*perr =3D 1); \ } =20 -/* map cpuid options to feature bits, otherwise return failure - * (option tags in *str are delimited by whitespace) - */ -static void setfeatures(uint32_t *pval, const char *str, - const char **featureset, int *perr) -{ - const char *p, *q; - - for (q =3D p =3D str; *p || *q; q =3D p) { - while (iswhite(*p)) - q =3D ++p; - while (*p && !iswhite(*p)) - ++p; - if (!*q && !*p) - return; - if (!lookup_feature(pval, q, p, featureset)) { - fprintf(stderr, "error: feature \"%.*s\" not available in se= t\n", - (int)(p - q), q); - *perr =3D 1; - return; - } - } -} - -/* map config file options to x86_def_t form - */ -static int cpudef_setfield(const char *name, const char *str, void *opaq= ue) -{ - x86_def_t *def =3D opaque; - int err =3D 0; - - if (!strcmp(name, "name")) { - g_free((void *)def->name); - def->name =3D g_strdup(str); - } else if (!strcmp(name, "model_id")) { - strncpy(def->model_id, str, sizeof (def->model_id)); - } else if (!strcmp(name, "level")) { - setscalar(&def->level, str, &err) - } else if (!strcmp(name, "vendor")) { - cpyid(&str[0], &def->vendor1); - cpyid(&str[4], &def->vendor2); - cpyid(&str[8], &def->vendor3); - } else if (!strcmp(name, "family")) { - setscalar(&def->family, str, &err) - } else if (!strcmp(name, "model")) { - setscalar(&def->model, str, &err) - } else if (!strcmp(name, "stepping")) { - setscalar(&def->stepping, str, &err) - } else if (!strcmp(name, "feature_edx")) { - setfeatures(&def->features, str, feature_name, &err); - } else if (!strcmp(name, "feature_ecx")) { - setfeatures(&def->ext_features, str, ext_feature_name, &err); - } else if (!strcmp(name, "extfeature_edx")) { - setfeatures(&def->ext2_features, str, ext2_feature_name, &err); - } else if (!strcmp(name, "extfeature_ecx")) { - setfeatures(&def->ext3_features, str, ext3_feature_name, &err); - } else if (!strcmp(name, "xlevel")) { - setscalar(&def->xlevel, str, &err) - } else { - fprintf(stderr, "error: unknown option [%s =3D %s]\n", name, str= ); - return (1); - } - if (err) { - fprintf(stderr, "error: bad option value [%s =3D %s]\n", name, s= tr); - return (1); - } - return (0); -} - -/* register config file entry as x86_def_t - */ -static int cpudef_register(QemuOpts *opts, void *opaque) -{ - x86_def_t *def =3D g_malloc0(sizeof (x86_def_t)); - - qemu_opt_foreach(opts, cpudef_setfield, def, 1); - def->next =3D x86_defs; - x86_defs =3D def; - return (0); -} - void cpu_clear_apic_feature(CPUX86State *env) { env->cpuid_features &=3D ~CPUID_APIC; @@ -1504,8 +1412,7 @@ void cpu_clear_apic_feature(CPUX86State *env) =20 #endif /* !CONFIG_USER_ONLY */ =20 -/* register "cpudef" models defined in configuration file. Here we firs= t - * preload any built-in definitions +/* Initialize list of CPU models, filling some non-static fields if nece= ssary */ void x86_cpudef_setup(void) { @@ -1515,7 +1422,6 @@ void x86_cpudef_setup(void) for (i =3D 0; i < ARRAY_SIZE(builtin_x86_defs); ++i) { x86_def_t *def =3D &builtin_x86_defs[i]; def->next =3D x86_defs; - def->flags =3D 1; =20 /* Look for specific "cpudef" models that */ /* have the QEMU version in .model_id */ @@ -1531,9 +1437,6 @@ void x86_cpudef_setup(void) =20 x86_defs =3D def; } -#if !defined(CONFIG_USER_ONLY) - qemu_opts_foreach(qemu_find_opts("cpudef"), cpudef_register, NULL, 0= ); -#endif } =20 static void get_cpuid_vendor(CPUX86State *env, uint32_t *ebx, --=20 1.7.10.4