From nobody Tue Feb 10 11:56:16 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.47 as permitted sender) client-ip=209.85.221.47; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f47.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.47 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1618655484; cv=none; d=zohomail.com; s=zohoarc; b=RRw8YD71b/scIYuYBwi4u3j4SFGt3u56a/pjhbFx5QuJrKk3RfdN8Xy2NQfXmp9lB/OQrwDQordDtj3XXA9EEj5ynAIOb09Y7r+VdQcAxuI7hfJpP6qE7QbvdxnoSC60z97CitqEqyNfyRDg7L4HbQHorhOc4ERa8tMvmRdJWz0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618655484; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GuQcix62yOxi2GAeMBvDGe0wgnFu8eqZ7dkSeHfqLw0=; b=YIm7iv7U0N2YLpZVp8LEudLWGztX+4ZzCWBasbt+oM+brA2VJlLfZwA/s6DEUoaAQrSnR7DXSzow117etoLMSdUISwnwd9BmO0qI0B7OQhCrXT1J2wzbSzvX+vkgm1HMSXkblwd9J+1EihZ9iGSslPQE3X19vPY0A3k7zQ8tzXc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.47 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by mx.zohomail.com with SMTPS id 16186554843361021.1811158191667; Sat, 17 Apr 2021 03:31:24 -0700 (PDT) Received: by mail-wr1-f47.google.com with SMTP id s7so28926937wru.6 for ; Sat, 17 Apr 2021 03:31:23 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (39.red-81-40-121.staticip.rima-tde.net. [81.40.121.39]) by smtp.gmail.com with ESMTPSA id v7sm14384268wrs.2.2021.04.17.03.31.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Apr 2021 03:31:21 -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=GuQcix62yOxi2GAeMBvDGe0wgnFu8eqZ7dkSeHfqLw0=; b=ntha4+cB1beVYLQnUCS8Wgj495JCB/z4VRNAfEG1eDoLRcn85ncmkg7e9qlkt7UKRq HTRZWPj++lPAy7KvRTWfqn/uQNxwxiAzF3yx5Bu1HiZY1ts2Rkxp74MXAQAlji60sRTo r1Lc4XSBzjouk+7HE7ErQ+qQwOD1a9bSQ7GcwkAohvw+24l25uqDMTxvA6x7ZHRoWLua l5q+BRtzvpxd7VYozqtsOgmjUFK2nZ/gyVs7VV3b8ky/KRXdRgI82gmqzHq8LqTCw53l HOyzjMUoOw1edItCEClP7LpBzrR+uB9//Kzfrydg1Z1TXfhGept51g1lEilnbpsIlqpI JsiA== 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=GuQcix62yOxi2GAeMBvDGe0wgnFu8eqZ7dkSeHfqLw0=; b=A5amU/YeGSsCQ6e3BIoxaII08yJEUFnVrhQPVGzWMaxrfCGgdv1XEH9F+KqXoRTdg3 wW3z3QwKZ6hrbKb5FjZnLlNIQUQHvT4tM4kmw+eiK1jP2isApzrN/7TnsE3/mGAtRzFp Nfn4Ypk/6RIfwyEQVf4DEzwI5n0Fr0wodLmg2Ad3hvsqtImTIby0rvBFKR/j13lRI540 4y7/lmCj8QlYahGOEMcc6pyfroQsfeSHj71/se8T0fmZHP90F22kABK4g7JISMjcLKsK OCQvQzfiHznu8HxtLcLsE8N2OkL0vUu5bKWsjzWiS/E8DyafUAWY+dgeLvR3ASpZ5Of+ ZYKQ== X-Gm-Message-State: AOAM5311P4iKp6V2tbMUzt0NrdV6nbWGGzEIr0A8yyeTEKAW2LFaPnjd tKRFFfgHu5WHa3JU7+8nQJ4= X-Google-Smtp-Source: ABdhPJx4emBAv9xbgtO89BBRVK6AwkJj5KZsCAwn9++TAdcv5u1y0hZ888huEa6wvEnwCd+PrRmryQ== X-Received: by 2002:a5d:4584:: with SMTP id p4mr3591191wrq.383.1618655482669; Sat, 17 Apr 2021 03:31:22 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Peter Maydell , Peter Xu , David Gibson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini Subject: [PATCH v2 10/11] memory: Make sure root MR won't be added as subregion Date: Sat, 17 Apr 2021 12:30:27 +0200 Message-Id: <20210417103028.601124-11-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210417103028.601124-1-f4bug@amsat.org> References: <20210417103028.601124-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Content-Type: text/plain; charset="utf-8" From: Peter Xu Add a bool for MR to mark whether this MR is a root MR of an AS. We bail o= ut asap if this MR is added as a subregion of another MR. Signed-off-by: Peter Xu --- include/exec/memory.h | 1 + softmmu/memory.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index 5728a681b27..83ac86525b2 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -477,6 +477,7 @@ struct MemoryRegion { bool ram_device; bool enabled; bool warning_printed; /* For reservations */ + bool is_root_mr; uint8_t vga_logging_count; MemoryRegion *alias; hwaddr alias_offset; diff --git a/softmmu/memory.c b/softmmu/memory.c index d4493ef9e43..409bcaec7f5 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -2443,6 +2443,7 @@ static void memory_region_add_subregion_common(Memory= Region *mr, MemoryRegion *subregion) { assert(!subregion->container); + assert(!subregion->is_root_mr); subregion->container =3D mr; subregion->addr =3D offset; memory_region_update_container_subregions(subregion); @@ -2820,6 +2821,7 @@ void address_space_init(AddressSpace *as, MemoryRegio= n *root, const char *name) { memory_region_ref(root); as->root =3D root; + root->is_root_mr =3D true; as->current_map =3D NULL; as->ioeventfd_nb =3D 0; as->ioeventfds =3D NULL; --=20 2.26.3