Received: from eggs.gnu.org ([2001:4830:134:3::10]:34891) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSs5a-0004bN-M5 for qemu-devel@nongnu.org; Tue, 03 Mar 2015 14:02:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YSs5W-0002AC-A4 for qemu-devel@nongnu.org; Tue, 03 Mar 2015 14:02:42 -0500 Received: from mail-oi0-f45.google.com ([209.85.218.45]:37005) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSs5W-00028s-6m for qemu-devel@nongnu.org; Tue, 03 Mar 2015 14:02:38 -0500 Received: by oigi138 with SMTP id i138so1306547oig.4 for ; Tue, 03 Mar 2015 11:02:37 -0800 (PST) From: Greg Bellows Date: Tue, 3 Mar 2015 13:02:16 -0600 Message-Id: <1425409336-26671-1-git-send-email-greg.bellows@linaro.org> Subject: [Qemu-devel] [PATCH] target-arm: Fix multi-pass virt CPU feature parsing List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, peter.maydell@linaro.org, alex.bennee@linaro.org, ard.biesheuvel@linaro.org Cc: Greg Bellows Fixes issue when combining CPU features and smp. The issue is caused by parse_feature's use of strtok which modifies the input feature string that is needed for each smp CPU pass. This patch restores the feature string for each pass. Signed-off-by: Greg Bellows --- hw/arm/virt.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 69f51ac..a64eedd 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -728,7 +728,7 @@ static void machvirt_init(MachineState *machine) const char *cpu_model = machine->cpu_model; VirtBoardInfo *vbi; uint32_t gic_phandle; - char **cpustr; + char **cpustr, *featurestr; if (!cpu_model) { cpu_model = "cortex-a15"; @@ -753,6 +753,12 @@ static void machvirt_init(MachineState *machine) create_fdt(vbi); + /* Parsing modifies the feature string and we need it for each CPU pass, so + * make a copy to refresh from. Duplicate is used to allocate the + * appropriate storage size. + */ + featurestr = g_strdup(cpustr[1]); + for (n = 0; n < smp_cpus; n++) { ObjectClass *oc = cpu_class_by_name(TYPE_ARM_CPU, cpustr[0]); CPUClass *cc = CPU_CLASS(oc); @@ -766,11 +772,14 @@ static void machvirt_init(MachineState *machine) cpuobj = object_new(object_class_get_name(oc)); /* Handle any CPU options specified by the user */ - cc->parse_features(CPU(cpuobj), cpustr[1], &err); + cc->parse_features(CPU(cpuobj), featurestr, &err); if (err) { error_report("%s", error_get_pretty(err)); exit(1); } + /* Refresh the feature string as parse modified the pointer. */ + g_stpcpy(featurestr, cpustr[1]); + if (!vms->secure) { object_property_set_bool(cpuobj, false, "has_el3", NULL); @@ -791,6 +800,7 @@ static void machvirt_init(MachineState *machine) object_property_set_bool(cpuobj, true, "realized", NULL); } + g_free(featurestr); g_strfreev(cpustr); fdt_add_timer_nodes(vbi); fdt_add_cpu_nodes(vbi); -- 1.8.3.2