From patchwork Tue Mar 3 19:02:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Bellows X-Patchwork-Id: 45377 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5D9092142B for ; Tue, 3 Mar 2015 19:03:22 +0000 (UTC) Received: by wivz2 with SMTP id z2sf1336750wiv.3 for ; Tue, 03 Mar 2015 11:03:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list; bh=sgt+Lq6QIkJ1bqOrs3JFf5S14+yMFTBmHdNMyMH3aD8=; b=YlmaQojoWgWIZ3oYtLO62NYjDwr48DS6t5xxvceBGYFVwIrViJ3eagxCEvDDP+AjPn P9ydIhh5sSiQ4613uPHPclvDqLN5b07/TxCFYw12/BiIlrWKQzTCt1Cj2OZafJbkz1Ng 70WxmmosZUfvKwViYpAl0CicedBob+GQUQQUdNWQic3xpHLCqeq/4k3AjvA1fH9W04lT f9CCN5iMhZmBW2WcUIcSKTmq1A8w0cBb5gYdAvh5GUrCNvqfMC+s66sa0mT94EHu5r9X OvPjZRzU4CnNSzkgWXXgD+4lCtMnJ6ws1bfFe7kVd3MM2fJAyqRDcp1hQQOeVVwCTBW+ 5JyQ== X-Gm-Message-State: ALoCoQno/YZaXyrZjGU6NoLMqKwjcNo5isIbCLtSN3SgpChci0D9FAuKpaWcmUZYTI+m/7j3r18f X-Received: by 10.152.45.7 with SMTP id i7mr59977lam.9.1425409401575; Tue, 03 Mar 2015 11:03:21 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.228.136 with SMTP id si8ls88874lac.11.gmail; Tue, 03 Mar 2015 11:03:21 -0800 (PST) X-Received: by 10.112.48.67 with SMTP id j3mr267121lbn.25.1425409401429; Tue, 03 Mar 2015 11:03:21 -0800 (PST) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id q1si1072152laj.84.2015.03.03.11.03.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Mar 2015 11:03:21 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by lbiz11 with SMTP id z11so13314977lbi.13 for ; Tue, 03 Mar 2015 11:03:21 -0800 (PST) X-Received: by 10.152.121.33 with SMTP id lh1mr335651lab.86.1425409401281; Tue, 03 Mar 2015 11:03:21 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp759742lbj; Tue, 3 Mar 2015 11:03:20 -0800 (PST) X-Received: by 10.55.31.101 with SMTP id f98mr586596qkf.3.1425409400528; Tue, 03 Mar 2015 11:03:20 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d8si1370904qcr.41.2015.03.03.11.03.19 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 03 Mar 2015 11:03:20 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:40413 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSs6B-0005IP-AY for patch@linaro.org; Tue, 03 Mar 2015 14:03:19 -0500 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) X-Received: by 10.60.23.37 with SMTP id j5mr254414oef.25.1425409357341; Tue, 03 Mar 2015 11:02:37 -0800 (PST) Received: from localhost.localdomain (rrcs-67-52-129-61.west.biz.rr.com. [67.52.129.61]) by mx.google.com with ESMTPSA id z8sm852532obw.23.2015.03.03.11.02.36 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Mar 2015 11:02:36 -0800 (PST) From: Greg Bellows To: qemu-devel@nongnu.org, peter.maydell@linaro.org, alex.bennee@linaro.org, ard.biesheuvel@linaro.org Date: Tue, 3 Mar 2015 13:02:16 -0600 Message-Id: <1425409336-26671-1-git-send-email-greg.bellows@linaro.org> X-Mailer: git-send-email 1.8.3.2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.218.45 Cc: Greg Bellows Subject: [Qemu-devel] [PATCH] target-arm: Fix multi-pass virt CPU feature parsing X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: greg.bellows@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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);