From patchwork Tue Apr 10 12:17:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 133081 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1242865ljb; Tue, 10 Apr 2018 05:26:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+w9GmDKZTvj7bD2dBOo5FOWXfyMIy4VeDOPmN4QvqCx/7lHlJyCtfWxzDPXMoSi4Gzes55 X-Received: by 10.55.128.67 with SMTP id b64mr297148qkd.78.1523363211266; Tue, 10 Apr 2018 05:26:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523363211; cv=none; d=google.com; s=arc-20160816; b=tWYzJlbJASG9s6Rh6k0L2fnJ+1wiXRlUd5h3x/kIJM3sSRotMrlpYjlprPssrYfNP9 DqtZWWY8hEkmg4mddbrb/H0nH1lvO0EdLddzxdaxnE1FXFGvfuxM+sHQ7XwG0EYo6oDH maC1c+RKcNyUyBn7+jVnLaQab+pVAfP9rVujSobO2tuAxtzg9J65Mo4oelmaP4EUcBj9 +HTAj+/5kztMHcI27zHB0fKltkOKxyiJTh9CUiRP2W4bPi7hfAU8e7te2KUw7Sm7d7P2 OV7T1uSiaVuv3XbREEEdrGgy/8VLzwyQq3O/ykubPzdxx5Y/c8/nt1sjM4UjKuNC/Vyg Va5g== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=lETdiqBRR1tj4hIoCiEBXr2JiK12wAMS9USe0Rx+EB8=; b=gvElI4G3nkLfLnBSOiEY/SD6Is6/WIpxOo6GrggLTHheCbAM6Ttj4XGg48w1Ny9r6r kSJjNxSjNtCeEMPjW8AJ0yia3MoKuhJak/rQ3Mq16LQltygyWoGefZ9f2VWY4vhAEec+ VcIP7BRO7fOAhNkyBNGf+Y8F5gdugTk64O/HKo7WkUge6vhd2i8hgzLsc++Oazs1TcpG /msA6qa97URI5uIyGvMx4WZNYdkocR53Y5GjFudzxRHYZad7eozjh+GQ9toXnuf64KEQ pRc0bRikHAgMxJtwLu94Bd6QkyugjqgQaZ0B/i5rJMPCJI7BEmg+h6nDE8pqPOi47gut JO8w== 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 t14si547253qkj.5.2018.04.10.05.26.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 10 Apr 2018 05:26:51 -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]:40729 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5sMM-00070s-MN for patch@linaro.org; Tue, 10 Apr 2018 08:26:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5sDV-0007w9-2W for qemu-devel@nongnu.org; Tue, 10 Apr 2018 08:17:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f5sDT-0000lI-UL for qemu-devel@nongnu.org; Tue, 10 Apr 2018 08:17:41 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:40760) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f5sDT-0000er-Mh for qemu-devel@nongnu.org; Tue, 10 Apr 2018 08:17:39 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1f5sDH-0007Zr-TM for qemu-devel@nongnu.org; Tue, 10 Apr 2018 13:17:27 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 10 Apr 2018 13:17:14 +0100 Message-Id: <20180410121724.8549-3-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> MIME-Version: 1.0 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 02/12] hw/arm/integratorcp: Don't do things that could be fatal in the instance_init 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 An instance_init function must not fail - and might be called multiple times, e.g. during device introspection with the 'device-list-properties' QMP command. Since the integratorcm device ignores this rule, QEMU currently aborts in this case (though it really should not): echo "{'execute':'qmp_capabilities'}"\ "{'execute':'device-list-properties',"\ "'arguments':{'typename':'integrator_core'}}" \ | arm-softmmu/qemu-system-arm -M integratorcp,accel=qtest -qmp stdio {"QMP": {"version": {"qemu": {"micro": 91, "minor": 11, "major": 2}, "package": "build-all"}, "capabilities": []}} {"return": {}} RAMBlock "integrator.flash" already registered, abort! Aborted (core dumped) Move the problematic code to the realize() function instead to fix this problem. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Thomas Huth Message-id: 1522906473-11252-1-git-send-email-thuth@redhat.com Signed-off-by: Peter Maydell --- hw/arm/integratorcp.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) -- 2.16.2 diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c index e8303b83be..58b40efc19 100644 --- a/hw/arm/integratorcp.c +++ b/hw/arm/integratorcp.c @@ -266,7 +266,6 @@ static const MemoryRegionOps integratorcm_ops = { static void integratorcm_init(Object *obj) { IntegratorCMState *s = INTEGRATOR_CM(obj); - SysBusDevice *dev = SYS_BUS_DEVICE(obj); s->cm_osc = 0x01000048; /* ??? What should the high bits of this value be? */ @@ -276,20 +275,28 @@ static void integratorcm_init(Object *obj) s->cm_init = 0x00000112; s->cm_refcnt_offset = muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), 24, 1000); - memory_region_init_ram(&s->flash, obj, "integrator.flash", 0x100000, - &error_fatal); - memory_region_init_io(&s->iomem, obj, &integratorcm_ops, s, - "integratorcm", 0x00800000); - sysbus_init_mmio(dev, &s->iomem); - - integratorcm_do_remap(s); /* ??? Save/restore. */ } static void integratorcm_realize(DeviceState *d, Error **errp) { IntegratorCMState *s = INTEGRATOR_CM(d); + SysBusDevice *dev = SYS_BUS_DEVICE(d); + Error *local_err = NULL; + + memory_region_init_ram(&s->flash, OBJECT(d), "integrator.flash", 0x100000, + &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + memory_region_init_io(&s->iomem, OBJECT(d), &integratorcm_ops, s, + "integratorcm", 0x00800000); + sysbus_init_mmio(dev, &s->iomem); + + integratorcm_do_remap(s); if (s->memsz >= 256) { integrator_spd[31] = 64;