From nobody Tue Feb 10 06:26:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1592896961; cv=none; d=zohomail.com; s=zohoarc; b=bv/Rr8/uzvRK4pkLkOXkHJ1sOxsymDPuzpbiDb3fTNpfmwhBfVkDhN2VKdHW0uFeoctuSByZP7a9LTGzyx2YBUcWj/MfrLpiI5xroFEc26d3qdiXLB1BvQbLZvVVcpStbhgKxb1nD+ak77WR8KGS0cCwHQe6zElC1JsVX/P1JxI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592896961; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RMpBNhc9DgLKSQexvXdiyWq7znNYqzLKh6dEFIwERf0=; b=HmT8eOG1RIFZo+lWL4ru1tXtjoqnbq/ecV2EB+tBH7vUe5yirYkoQNOSgEtdE23x9Mp57FHnr2eAwi8zDvTxiXfpe6D3GYzG++NskUuuEMA1aym3EVJKwN8IuojE4fkPCJXYn9+RsalxsHWeaKjz3C3+sn6lxttUswqqsnBZ+t4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592896961799700.677369121305; Tue, 23 Jun 2020 00:22:41 -0700 (PDT) Received: from localhost ([::1]:53948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jndGS-0001DZ-E8 for importer@patchew.org; Tue, 23 Jun 2020 03:22:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jndFT-0007Xu-9m; Tue, 23 Jun 2020 03:21:39 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:54798) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jndFR-0003E6-OU; Tue, 23 Jun 2020 03:21:39 -0400 Received: by mail-wm1-x342.google.com with SMTP id o8so199764wmh.4; Tue, 23 Jun 2020 00:21:37 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id x13sm21877236wre.83.2020.06.23.00.21.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jun 2020 00:21:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RMpBNhc9DgLKSQexvXdiyWq7znNYqzLKh6dEFIwERf0=; b=ibDcSytHesvRHcej6SkOn0MRHhZjM0DrQHKLAZ0pywqwKj6jUh04vK0uygLi2ZHgpe pZQMphv5aTWUpo2gdYGoURXyJzhg4HJ2ulGDgdFClvoFS/2+BIAgnbb+smkEh04rkqSf 4phyGxd9W914t5X8RBcOr17qdOcsK2OuQC5A/y55U9U8G1odoQZ8WK/k28pd7YiT7jgB kZmmfBDgqXBrPp9INDHOWOnIcZPsGZbKj8/+901ZS+pZKDLf93WJ+pg+PT9/l7oSiEUA iO2m1ubh92MOsfwvG1kfBRieB/0dWbvkLTGQSQBBRQPDf+e2U0y4Ha8tRsyh3BkXVbc9 2JLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=RMpBNhc9DgLKSQexvXdiyWq7znNYqzLKh6dEFIwERf0=; b=QTQnTT1muwcGuv3G4sV2VIMplEyvxCpxQVaBULeswnO+i90WdC3z40AmWVpr39/RYX 3Tpuk5Vs3T1ecfcoqI0kV3chFS31+tmOvALM7pvAbSKKOmLv5HL5molpjdw9KDnKMug4 T77xNb13PNfNyg1Pq/flyfh/ShHPW0p2RlyAfcC9X7WrYzm/xv4tfHNnYMCOMTiinDy4 kT8Q33cGWJOhNHi8/SLQfJ/h7cCXVPE1IM0S7SnZCJloHuDdh+YRIbkvW2vH1lp9vocS uGu636Q0zzJU83EhUNne8t8Tz/G62HD4XWbarfDNUDVcS9WPi2FyVaLrpNKRfLPv8deK ZvCw== X-Gm-Message-State: AOAM532bcrdI0YQZi1vy82knv8nzEpuJl+qrLBBXc2ZqfA0LznM0aBnh vj/mscJp1/m7QqZDN8SfR4pGm5zm X-Google-Smtp-Source: ABdhPJygLfr+DKpBDsMp4dRfA2EDmkaC1b0eKKbFDSpNIFyPPSla5hx1wJUg+NiR9dwXUYIyAtyWog== X-Received: by 2002:a1c:e914:: with SMTP id q20mr21877978wmc.145.1592896895769; Tue, 23 Jun 2020 00:21:35 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 1/3] hw/arm/aspeed: Remove extraneous MemoryRegion object owner Date: Tue, 23 Jun 2020 09:21:30 +0200 Message-Id: <20200623072132.2868-2-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200623072132.2868-1-f4bug@amsat.org> References: <20200623072132.2868-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::342; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x342.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Andrew Jeffery , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Joel Stanley Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) I'm confused by this code, 'bmc' is created as: bmc =3D g_new0(AspeedBoardState, 1); Then we use it as QOM owner for different MemoryRegion objects. But looking at memory_region_init_ram (similarly for ROM): void memory_region_init_ram(MemoryRegion *mr, struct Object *owner, const char *name, uint64_t size, Error **errp) { DeviceState *owner_dev; Error *err =3D NULL; memory_region_init_ram_nomigrate(mr, owner, name, size, &err); if (err) { error_propagate(errp, err); return; } /* This will assert if owner is neither NULL nor a DeviceState. * We only want the owner here for the purposes of defining a * unique name for migration. TODO: Ideally we should implement * a naming scheme for Objects which are not DeviceStates, in * which case we can relax this restriction. */ owner_dev =3D DEVICE(owner); vmstate_register_ram(mr, owner_dev); } The expected assertion is not triggered ('bmc' is not NULL neither a DeviceState). 'bmc' structure is defined as: struct AspeedBoardState { AspeedSoCState soc; MemoryRegion ram_container; MemoryRegion max_ram; }; What happens is when using 'OBJECT(bmc)', the QOM macros cast the memory pointed by bmc, which first member is 'soc', which is initialized ...: object_initialize_child(OBJECT(machine), "soc", &bmc->soc, amc->soc_name); The 'soc' object is indeed a DeviceState, so the assertion passes. Since this is fragile and only happens to work by luck, remove the dangerous OBJECT(bmc) owner argument. Note, this probably breaks migration for this machine. Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/arm/aspeed.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index 0ad08a2b4c..31765792a2 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -329,12 +329,12 @@ static void aspeed_machine_init(MachineState *machine) * needed by the flash modules of the Aspeed machines. */ if (ASPEED_MACHINE(machine)->mmio_exec) { - memory_region_init_alias(boot_rom, OBJECT(bmc), "aspeed.boot_r= om", + memory_region_init_alias(boot_rom, NULL, "aspeed.boot_rom", &fl->mmio, 0, fl->size); memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR, boot_rom); } else { - memory_region_init_rom(boot_rom, OBJECT(bmc), "aspeed.boot_rom= ", + memory_region_init_rom(boot_rom, NULL, "aspeed.boot_rom", fl->size, &error_abort); memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR, boot_rom); @@ -345,7 +345,7 @@ static void aspeed_machine_init(MachineState *machine) if (machine->kernel_filename && sc->num_cpus > 1) { /* With no u-boot we must set up a boot stub for the secondary CPU= */ MemoryRegion *smpboot =3D g_new(MemoryRegion, 1); - memory_region_init_ram(smpboot, OBJECT(bmc), "aspeed.smpboot", + memory_region_init_ram(smpboot, NULL, "aspeed.smpboot", 0x80, &error_abort); memory_region_add_subregion(get_system_memory(), AST_SMP_MAILBOX_BASE, smpboot); --=20 2.21.3