From ea2e9a5aa3cc8123d5316c8a04d953f6bf013d6b Mon Sep 17 00:00:00 2001 From: Eduardo Habkost <ehabkost@redhat.com> Date: Fri, 2 Oct 2009 14:15:29 -0300 Subject: [PATCH 07/10] allow overriding of CPUID level on command line RH-Author: Gleb Natapov <gleb@redhat.com> Message-id: <1253608839-4319-8-git-send-email-gleb@redhat.com> Patchwork-id: 3486 O-Subject: [PATCH 7/7] allow overriding of CPUID level on command line Bugzilla: 508040 RH-Acked-by: Mark McLoughlin <markmc@redhat.com> RH-Acked-by: Markus Armbruster <armbru@redhat.com> RH-Acked-by: Juan Quintela <quintela@redhat.com> 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 <andre.przywara@amd.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Gleb Natapov <gleb@redhat.com> --- qemu/target-i386/helper.c | 39 +++++++++++++++++++++++++++++---------- 1 files changed, 29 insertions(+), 10 deletions(-) Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- qemu/target-i386/helper.c | 39 +++++++++++++++++++++++++++++---------- 1 files changed, 29 insertions(+), 10 deletions(-) diff --git a/qemu/target-i386/helper.c b/qemu/target-i386/helper.c index 64b5642..cc11124 100644 --- a/qemu/target-i386/helper.c +++ b/qemu/target-i386/helper.c @@ -284,7 +284,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++) { @@ -309,28 +309,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.3.rc4.29.g8146