From patchwork Tue Apr 10 12:17:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 133076 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1240358ljb; Tue, 10 Apr 2018 05:23:59 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/VZ2F8UpATJHknjONAJl4xm7r0yJbohw8wYH19ChShMuG0P9xs1iQ0Qt1BUx5qAo4WBsyh X-Received: by 10.55.72.79 with SMTP id v76mr212303qka.193.1523363039239; Tue, 10 Apr 2018 05:23:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523363039; cv=none; d=google.com; s=arc-20160816; b=SVFh+7kgy9kUZXL0NRU8qnbU55zRP+QLEenP5MvDNMJQnXAIesjtKllluCiKseripl dUJ9dyw+kENW/nOs6N5PJggLs4UheAPEW0TuuNzYSt4zwhE+7ul8zNFvO0ZrCY35lHkP 4a0N9QgeAY/OPnGNk/7tawBdyi3tQr97r2qTZ8UPeeiR0KrPiTGjglXXIAB/wYuN7QEU z3fKqhlscYmqrG1vofvJDldIqKsuxXqmWd1BcTVmJOEvJamiTGTCySaJ36Pe/qHV/jQn 8qgm8O2K0aTihp1ZKbmkFG56T1uKggjIfRat4/BCfkqQHtH6Naz4EW+SX8qICrBvrwI0 RZgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=JRW/9XIPhZ40KG07VH2hCFScNu7cEBEGX0h+QNKI5ZQ=; b=Ab8T68ryHYw+1SKb4botqPhr285CsZobzt++BKQaLg++6HAjSBTmxGrzf2qrV+PkGV JL2KQD4NkE3FfI31e3kIWGri022Ql1x47NK1fF9doBAEzor7GVH0tKs/Y6HvRfhYb1bZ QBW1pKMz85bZF3COaGn5mk/FHxH/Cv2TEQoQUxq6YDH8M01h10aofy8D5WijRyhztKqb 2FKADM+O4VP6N5b6ZtBSLJgMB6OxA7YxKPVqBPqalT6/fII9TsgiswfAzXv18dPswes/ FCjTr+MA0Z/FAVVXuWIji7tlFDyh+gfQUUF/5/nX7nGbYZ8hbtFeZmIUsWPDj4w55Ycc hpVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k64si1570926qkc.463.2018.04.10.05.23.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 10 Apr 2018 05:23:59 -0700 (PDT) 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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40601 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5sJa-0003sB-Jj for patch@linaro.org; Tue, 10 Apr 2018 08:23:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5sDX-0007yL-CF for qemu-devel@nongnu.org; Tue, 10 Apr 2018 08:17:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f5sDR-0000jg-Jc for qemu-devel@nongnu.org; Tue, 10 Apr 2018 08:17:43 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:40762) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f5sDR-0000iH-CD for qemu-devel@nongnu.org; Tue, 10 Apr 2018 08:17:37 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1f5sDL-0007cA-N7 for qemu-devel@nongnu.org; Tue, 10 Apr 2018 13:17:31 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 10 Apr 2018 13:17:19 +0100 Message-Id: <20180410121724.8549-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180410121724.8549-1-peter.maydell@linaro.org> References: <20180410121724.8549-1-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 07/12] hw/arm/fsl-imx: Fix introspection problem with fsl-imx6 and fsl-imx7 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" From: Thomas Huth QEMU currently exits unexpectedly when trying to introspect the fsl-imx6 and fsl-imx7 devices on systems with many SMP CPUs: $ echo "{'execute':'qmp_capabilities'}"\ "{'execute':'device-list-properties',"\ " 'arguments':{'typename':'fsl,imx6'}}" \ | arm-softmmu/qemu-system-arm -M virt,accel=qtest -qmp stdio -smp 8 {"QMP": {"version": {"qemu": {"micro": 91, "minor": 11, "major": 2}, "package": "build-all"}, "capabilities": []}} {"return": {}} fsl,imx6: Only 4 CPUs are supported (8 requested) And: $ echo "{'execute':'qmp_capabilities'}"\ "{'execute':'device-list-properties',"\ " 'arguments':{'typename':'fsl,imx7'}}" \ | arm-softmmu/qemu-system-arm -M raspi2,accel=qtest -qmp stdio {"QMP": {"version": {"qemu": {"micro": 91, "minor": 11, "major": 2}, "package": "build-all"}, "capabilities": []}} {"return": {}} fsl,imx7: Only 2 CPUs are supported (4 requested) This happens because these devices are doing an exit() from their instance_init function - which should never be done since instance_init can be called at any time for device introspection! Fix it by moving the deadly check into the realize() function instead. Signed-off-by: Thomas Huth Message-id: 1522908551-14885-1-git-send-email-thuth@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/fsl-imx6.c | 14 +++++++------- hw/arm/fsl-imx7.c | 13 +++++++------ 2 files changed, 14 insertions(+), 13 deletions(-) -- 2.16.2 diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c index b6ac72de27..9dfbc9a8c4 100644 --- a/hw/arm/fsl-imx6.c +++ b/hw/arm/fsl-imx6.c @@ -37,13 +37,7 @@ static void fsl_imx6_init(Object *obj) char name[NAME_SIZE]; int i; - if (smp_cpus > FSL_IMX6_NUM_CPUS) { - error_report("%s: Only %d CPUs are supported (%d requested)", - TYPE_FSL_IMX6, FSL_IMX6_NUM_CPUS, smp_cpus); - exit(1); - } - - for (i = 0; i < smp_cpus; i++) { + for (i = 0; i < MIN(smp_cpus, FSL_IMX6_NUM_CPUS); i++) { object_initialize(&s->cpu[i], sizeof(s->cpu[i]), "cortex-a9-" TYPE_ARM_CPU); snprintf(name, NAME_SIZE, "cpu%d", i); @@ -119,6 +113,12 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) uint16_t i; Error *err = NULL; + if (smp_cpus > FSL_IMX6_NUM_CPUS) { + error_setg(errp, "%s: Only %d CPUs are supported (%d requested)", + TYPE_FSL_IMX6, FSL_IMX6_NUM_CPUS, smp_cpus); + return; + } + for (i = 0; i < smp_cpus; i++) { /* On uniprocessor, the CBAR is set to 0 */ diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c index 26ef36c79a..390b4310e6 100644 --- a/hw/arm/fsl-imx7.c +++ b/hw/arm/fsl-imx7.c @@ -35,13 +35,8 @@ static void fsl_imx7_init(Object *obj) char name[NAME_SIZE]; int i; - if (smp_cpus > FSL_IMX7_NUM_CPUS) { - error_report("%s: Only %d CPUs are supported (%d requested)", - TYPE_FSL_IMX7, FSL_IMX7_NUM_CPUS, smp_cpus); - exit(1); - } - for (i = 0; i < smp_cpus; i++) { + for (i = 0; i < MIN(smp_cpus, FSL_IMX7_NUM_CPUS); i++) { object_initialize(&s->cpu[i], sizeof(s->cpu[i]), ARM_CPU_TYPE_NAME("cortex-a7")); snprintf(name, NAME_SIZE, "cpu%d", i); @@ -197,6 +192,12 @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) qemu_irq irq; char name[NAME_SIZE]; + if (smp_cpus > FSL_IMX7_NUM_CPUS) { + error_setg(errp, "%s: Only %d CPUs are supported (%d requested)", + TYPE_FSL_IMX7, FSL_IMX7_NUM_CPUS, smp_cpus); + return; + } + for (i = 0; i < smp_cpus; i++) { o = OBJECT(&s->cpu[i]);