From nobody Mon Mar 2 08:46:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772143404; cv=none; d=zohomail.com; s=zohoarc; b=lLPgb8QSfgA7rihxe47TqvuxTxSKujqbjF5dkt9y7gUXxzJyaM2JFlxgYD5H10wLxsppTLuiT1Nkjbh0FkBS+jDW6uPJoDJtsPKFolAq6iCgwF/9YedFKXnqm4KL1HjBSRCDOiSV/FqKUe5CkWrRlyXQdqkaJSvRkBcB1ymdoAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772143404; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8BewiopFU6OtMOWx2DJLJCKryyOULKc5wR7PaImslFk=; b=GaywjsnLTu5tjxZbbGcmZGq/as91ten8llCJRei0N7AA5gso7iDWSpnCoE4pjKJw7+PRlnjxkMtLf6S5p96pFqKfBAMRqCRWRRJ5cihrZyWa3r4rPFxoNvKEnCKBleEQii/zc9r13d8zODMwf4j0PjcI5Elz5E4OLysrdK0fGog= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772143404474769.4594157792288; Thu, 26 Feb 2026 14:03:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vvjRX-0002Ux-5z; Thu, 26 Feb 2026 17:02:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vvjRQ-0002UM-4n for qemu-devel@nongnu.org; Thu, 26 Feb 2026 17:02:40 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vvjRO-0001rz-Ht for qemu-devel@nongnu.org; Thu, 26 Feb 2026 17:02:39 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4834826e5a0so14897705e9.2 for ; Thu, 26 Feb 2026 14:02:38 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4399c71b498sm2352668f8f.15.2026.02.26.14.02.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 26 Feb 2026 14:02:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772143357; x=1772748157; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8BewiopFU6OtMOWx2DJLJCKryyOULKc5wR7PaImslFk=; b=lk8OsRtyrOShX666kaXa7dZgiGMihbIyEaSb1kiluEvfBTDnIo6ViXSdLoEmJ4EneQ qOaSENYigfflu01wu/ei7h0fewZNiP1JaWq5AnZ+/zG/tfJH3t80D9PFE7GuWqwhGqMR SAeIKy4n3e/G8FWuJ1RuYSI+4sX1zqRWzD1qiamXh5B004/EKR6enlDLv4Ucz0PrAaTU S48RwOnidnAx7+faOGH125Yk7NWohDCRttIvvswNKsL18ChDCNM76I0QHVs6ktk7Bwlh i6Kx6kFs8ZPUbtOPqPIHUAGZEYoMNvUvLTYcJ47CIwywOyfJw1xsjoRDc1i8C0AEKdk5 K3sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772143357; x=1772748157; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=8BewiopFU6OtMOWx2DJLJCKryyOULKc5wR7PaImslFk=; b=m7XteDaIX5S3xDqZLkKOaxmQQeDk4rJUU3gsj9vpFlVCOrDKrNa/ImLFpASs4yCcOn LYNN/VnH0nyzgzi+hGL76NoTveJ3wEOFA+0oLKMsvYhcIHnSxc20uDwwc5WPfk9P1XHd cd93L5CaYYDCy14KXMrJg8Ivwp+tbaJWE9fHO10Ul5+AUWsoYxL85uIQnIEv287rZkH5 VHj6XdqU1poBkF3clLFObOe3o1RF9EllCSa9VK27z6hooJOvGMbtDfeAafG6qSXh9a4+ rN0gA3BPEOyE2YoC+UaWTyh9kXu7zPsVd+vNC1OEpeM6uQNqoqwzYhAofyGIIaTE3zot wspg== X-Gm-Message-State: AOJu0Yz/VqOIp1c0oUO1GYAgM9ClIXqAWYsnfnOWxt31QyDO7SkIGabB zCH02oE9aPw3uY2e0UUZCX+qQzkNQFBmgXVXHpeoQun+Yu5wv35dvyIguxkhC+id0gIf9qNIfQ6 PSRP3pto= X-Gm-Gg: ATEYQzwHKWqYWPPpwTf9s+L/iUHfD2VLpQQFkSJGQ7fwcb6QLnuuFxnWBBL/CtGnr9e uzY7j0RbBnMO8BDAs4zXWqQ4Yr67cXrdrtX38TxX1Ev26/HSVa31EkFEw6b6zm+ETVTtAHyF+4V Z8z3DqPXQDG+SdAzhgZXryVo6+Trfw6Zq2o6hDj4CC+uRCarK6f2h502xiuJs5jqdvrd6zjhEFJ QVf21QIBDFpQ9QjA3epa7yBMvxJoRnabHdOVLRIUqYgIpM2vk7P2zLbYeUfqw7RAN/VEOnoZ4XO dPr6qvIeObc4gqF1Tej0sU2tXeDrZxM3KYhsnBrH45bbaLSi0KpuZfx2PGnSycSi3DlVAfo8fM4 JoKTTCNfyuAApTZb14Js1d9tjpro35DEXqjkgZymOn/U+UAj+bB84Pu3sGVo4ZeuJLXxbZT4m5P CubCpOT6nj6OhALraXNd7PB2hvcUTwxqXxi+1uuvLTUc8qBKKKZ062zQcoZ1YYIdV7HkAT82BR X-Received: by 2002:a05:600c:c04b:10b0:483:79a6:e7e1 with SMTP id 5b1f17b1804b1-483c9ba7e28mr4360065e9.7.1772143356563; Thu, 26 Feb 2026 14:02:36 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Mark Cave-Ayland , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu , Akihiko Odaki Subject: [PATCH 1/7] stubs: Merge physmem.c within ram-block.c Date: Thu, 26 Feb 2026 23:02:19 +0100 Message-ID: <20260226220226.20164-2-philmd@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260226220226.20164-1-philmd@linaro.org> References: <20260226220226.20164-1-philmd@linaro.org> MIME-Version: 1.0 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::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772143419826158500 physmem.c defines 2 stubs which are related to ram-block: qemu_ram_block_from_host() and qemu_ram_get_fd(). Move them with the other ram-block stubs. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier --- stubs/physmem.c | 13 ------------- stubs/ram-block.c | 11 +++++++++++ stubs/meson.build | 1 - 3 files changed, 11 insertions(+), 14 deletions(-) delete mode 100644 stubs/physmem.c diff --git a/stubs/physmem.c b/stubs/physmem.c deleted file mode 100644 index 14667f2bd8f..00000000000 --- a/stubs/physmem.c +++ /dev/null @@ -1,13 +0,0 @@ -#include "qemu/osdep.h" -#include "system/ramblock.h" - -RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset, - ram_addr_t *offset) -{ - return NULL; -} - -int qemu_ram_get_fd(RAMBlock *rb) -{ - return -1; -} diff --git a/stubs/ram-block.c b/stubs/ram-block.c index 8790a59593e..f0650b19ac6 100644 --- a/stubs/ram-block.c +++ b/stubs/ram-block.c @@ -35,3 +35,14 @@ int ram_block_discard_disable(bool state) { return 0; } + +RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset, + ram_addr_t *offset) +{ + return NULL; +} + +int qemu_ram_get_fd(RAMBlock *rb) +{ + return -1; +} diff --git a/stubs/meson.build b/stubs/meson.build index 8a07059500d..0171f531523 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -20,7 +20,6 @@ if have_block stub_ss.add(files('get-vm-name.c')) stub_ss.add(files('iothread-lock-block.c')) stub_ss.add(files('migr-blocker.c')) - stub_ss.add(files('physmem.c')) stub_ss.add(files('ram-block.c')) stub_ss.add(files('runstate-check.c')) stub_ss.add(files('uuid.c')) --=20 2.52.0 From nobody Mon Mar 2 08:46:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772143405; cv=none; d=zohomail.com; s=zohoarc; b=Rbdsq3ENTMIoCQsCC60v+C4AGmB6DnYRAq7Dx5wl+G8CYNBt2g435TT7iXIE6MHjDtMOyyTEqsjEqDahIMZnd8PwLmShKiKCJ7wYlIU/lmj/W0iAetd2tDcFJyc8YcTizMr7pthSh1BbitRrNzYZuJX+p/kF0i9pMUenO5zG2KM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772143405; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=785oPSJzDG9pvxZyQhvc47hwg0jYWN3ydc6kS0PNkOA=; b=F9ap7feXRpEK3ZmrrVKLVaC2x66YmKL9NoR2nylcgPzTLv0IDbyQPZUcj0EFYrF039x1bFrdUFR1JiUTMwbDKwvsE5OTB40iZ7AAmxiDOPvw5UxadA1ox+E01MaNBR7tq0rYdcGX1X0bZEJ2sJ4wXgoIoz9OxJJPP8T2j8rsLvw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772143405575493.7235588530441; Thu, 26 Feb 2026 14:03:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vvjRe-0002W6-US; Thu, 26 Feb 2026 17:02:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vvjRX-0002Uy-SU for qemu-devel@nongnu.org; Thu, 26 Feb 2026 17:02:49 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vvjRW-0001tD-2K for qemu-devel@nongnu.org; Thu, 26 Feb 2026 17:02:47 -0500 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-4376acce52eso937149f8f.1 for ; Thu, 26 Feb 2026 14:02:45 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4399c71ad07sm2309149f8f.16.2026.02.26.14.02.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 26 Feb 2026 14:02:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772143364; x=1772748164; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=785oPSJzDG9pvxZyQhvc47hwg0jYWN3ydc6kS0PNkOA=; b=IvUnR0hwfxBoOYwWFb6qZum1huQ9MLVuetwTzXSLoLNyqgrUMPp2lZ63C9IWq4rqw/ b/QjvI4K0EtAQNKcWSSjQ6K8N0/L8K6UVFWBe6hmwvk9mcdPEDumAYOx/fpqW4Kcbm3P /ixBb8PA6TN1+GY0D7ntF7LKU6pFT6B5kKgwG9tNArEQ5Zb0rArBnehHswA5mBoigUdR h+0+hZWn9WJdx+red31oAgdg2RJgmZh9wty4HcG89jEs2hwQpeA2CvdsscKBfNZMvsjQ cCuJMs9alGQkp/iJPod5mMivqt5SHIb0VrGFMJ8tcy7v8mBHkQVx9iqIpVIJWV937zmr oXAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772143364; x=1772748164; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=785oPSJzDG9pvxZyQhvc47hwg0jYWN3ydc6kS0PNkOA=; b=Nyv9mIXxNJ94g1GRCK9aXbCq0saHJAczILgrZf3b8Hu9VIT5vIwUS5gIdYt5mINLcV iaaGJZ8DvTO0ez2Hm3IxhwGTBiPYExZ3y/5f/Hxz/bLgua7qtGOmB+gLI7LAPtqDYuC3 2WbmDO6CrDValLTdxNDLeyM4WtEiKcKA7yXDeJwDo+LwLbHqRPDT1jjUrVkZn3fjDVrm I/VOf4XpUSFx1bqgi3DYiLRDc8oM6H1KgtvLzGPDrB+W6okV1ehyodgTeujQWgwzTy3n U8x1kfw0cyNNMFS25v9Sff+V5vGFECS32m0+iTAw+n9ETawyP2mQdhFE5ZkvBLBJn179 z7MA== X-Gm-Message-State: AOJu0YzuF7XPbJc81t+lKneBYhjolnVW9gfgDxt1HurzH2yRewkFD3OF Wfle8G3Dq1Q3hf2iR/QX43+WA4JQIcDHiGsf5AWEsPReywnIiTBG6HWrhKxqrqTqv+yqibcBlXi MFNM97mQ= X-Gm-Gg: ATEYQzy1jD83kn/ddYcvbxCzyGFYhj2OtT8Zq42204SKn/9VK+VzO/MINKuferpc/R4 DQAOnfDM/wsvs7fqiEVRHyNczgTsTd4vaUF341DrYDFJwcLDc0KmIgBUjB2/2K46FLUSkABwgJk bqDsN8QFSDTuWVNVJSCzZ3L9K+6qSIXAGkP/rYMSRNpqvEx2uHq+6ao0LElyN3vUsVGnvXSsasO OF6P/jBsy6z+dYXxRwB4D3TkpFEnSzFFewPm0/AbHVSP/zL6nXU5sy+ioSNZwnmfKh5fNhFFzCz jk6OXgRYjUM3rUW/QHDN8BnhUQPnBG5yHkyTpa4Zcgc3FYmm/UcxCHiOBrVw4PHZFPzSKq14oqI u7EGV0CmZssTrD4GyXleNUUFSLSIW8JiWPkMQvouMu70q/GoZ/bQmDtosgQOdgmuoeGBON1G91/ h7n2TNRSKZBDl4X+bH2ccR8JCPmAOeU52g2NFcRyjb0iCVYlz71l1yeYGB1n9jdKrjNanxe+as X-Received: by 2002:a05:6000:4010:b0:430:fd84:3175 with SMTP id ffacd0b85a97d-4399de206c1mr675632f8f.38.1772143364138; Thu, 26 Feb 2026 14:02:44 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Mark Cave-Ayland , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu , Akihiko Odaki Subject: [PATCH 2/7] system/ramblock: Constify various RAMBlock arguments Date: Thu, 26 Feb 2026 23:02:20 +0100 Message-ID: <20260226220226.20164-3-philmd@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260226220226.20164-1-philmd@linaro.org> References: <20260226220226.20164-1-philmd@linaro.org> MIME-Version: 1.0 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::430; envelope-from=philmd@linaro.org; helo=mail-wr1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772143406998158500 Mark the RAMBlock structure const when is only accessed read-only. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier --- include/system/ramblock.h | 26 +++++++++++++------------- stubs/ram-block.c | 8 ++++---- system/physmem.c | 26 +++++++++++++------------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/include/system/ramblock.h b/include/system/ramblock.h index e9f58ac0457..221e8e5d03e 100644 --- a/include/system/ramblock.h +++ b/include/system/ramblock.h @@ -154,24 +154,24 @@ RAMBlock *qemu_ram_block_by_name(const char *name); */ RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset, ram_addr_t *offset); -ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host); +ram_addr_t qemu_ram_block_host_offset(const RAMBlock *rb, void *host); void qemu_ram_set_idstr(RAMBlock *block, const char *name, DeviceState *de= v); void qemu_ram_unset_idstr(RAMBlock *block); -const char *qemu_ram_get_idstr(RAMBlock *rb); -void *qemu_ram_get_host_addr(RAMBlock *rb); -ram_addr_t qemu_ram_get_offset(RAMBlock *rb); -ram_addr_t qemu_ram_get_fd_offset(RAMBlock *rb); -ram_addr_t qemu_ram_get_used_length(RAMBlock *rb); -ram_addr_t qemu_ram_get_max_length(RAMBlock *rb); -bool qemu_ram_is_shared(RAMBlock *rb); -bool qemu_ram_is_noreserve(RAMBlock *rb); -bool qemu_ram_is_uf_zeroable(RAMBlock *rb); +const char *qemu_ram_get_idstr(const RAMBlock *rb); +void *qemu_ram_get_host_addr(const RAMBlock *rb); +ram_addr_t qemu_ram_get_offset(const RAMBlock *rb); +ram_addr_t qemu_ram_get_fd_offset(const RAMBlock *rb); +ram_addr_t qemu_ram_get_used_length(const RAMBlock *rb); +ram_addr_t qemu_ram_get_max_length(const RAMBlock *rb); +bool qemu_ram_is_shared(const RAMBlock *rb); +bool qemu_ram_is_noreserve(const RAMBlock *rb); +bool qemu_ram_is_uf_zeroable(const RAMBlock *rb); void qemu_ram_set_uf_zeroable(RAMBlock *rb); -bool qemu_ram_is_migratable(RAMBlock *rb); +bool qemu_ram_is_migratable(const RAMBlock *rb); void qemu_ram_set_migratable(RAMBlock *rb); void qemu_ram_unset_migratable(RAMBlock *rb); -bool qemu_ram_is_named_file(RAMBlock *rb); -int qemu_ram_get_fd(RAMBlock *rb); +bool qemu_ram_is_named_file(const RAMBlock *rb); +int qemu_ram_get_fd(const RAMBlock *rb); =20 size_t qemu_ram_pagesize(RAMBlock *block); size_t qemu_ram_pagesize_largest(void); diff --git a/stubs/ram-block.c b/stubs/ram-block.c index f0650b19ac6..3ca47214a0c 100644 --- a/stubs/ram-block.c +++ b/stubs/ram-block.c @@ -3,17 +3,17 @@ #include "system/ramblock.h" #include "system/memory.h" =20 -void *qemu_ram_get_host_addr(RAMBlock *rb) +void *qemu_ram_get_host_addr(const RAMBlock *rb) { return 0; } =20 -ram_addr_t qemu_ram_get_offset(RAMBlock *rb) +ram_addr_t qemu_ram_get_offset(const RAMBlock *rb) { return 0; } =20 -ram_addr_t qemu_ram_get_used_length(RAMBlock *rb) +ram_addr_t qemu_ram_get_used_length(const RAMBlock *rb) { return 0; } @@ -42,7 +42,7 @@ RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_= offset, return NULL; } =20 -int qemu_ram_get_fd(RAMBlock *rb) +int qemu_ram_get_fd(const RAMBlock *rb) { return -1; } diff --git a/system/physmem.c b/system/physmem.c index 2fb0c25c93b..2384c6dbba4 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -1857,48 +1857,48 @@ static void qemu_ram_setup_dump(void *addr, ram_add= r_t size) } } =20 -const char *qemu_ram_get_idstr(RAMBlock *rb) +const char *qemu_ram_get_idstr(const RAMBlock *rb) { return rb->idstr; } =20 -void *qemu_ram_get_host_addr(RAMBlock *rb) +void *qemu_ram_get_host_addr(const RAMBlock *rb) { return rb->host; } =20 -ram_addr_t qemu_ram_get_offset(RAMBlock *rb) +ram_addr_t qemu_ram_get_offset(const RAMBlock *rb) { return rb->offset; } =20 -ram_addr_t qemu_ram_get_fd_offset(RAMBlock *rb) +ram_addr_t qemu_ram_get_fd_offset(const RAMBlock *rb) { return rb->fd_offset; } =20 -ram_addr_t qemu_ram_get_used_length(RAMBlock *rb) +ram_addr_t qemu_ram_get_used_length(const RAMBlock *rb) { return rb->used_length; } =20 -ram_addr_t qemu_ram_get_max_length(RAMBlock *rb) +ram_addr_t qemu_ram_get_max_length(const RAMBlock *rb) { return rb->max_length; } =20 -bool qemu_ram_is_shared(RAMBlock *rb) +bool qemu_ram_is_shared(const RAMBlock *rb) { return rb->flags & RAM_SHARED; } =20 -bool qemu_ram_is_noreserve(RAMBlock *rb) +bool qemu_ram_is_noreserve(const RAMBlock *rb) { return rb->flags & RAM_NORESERVE; } =20 /* Note: Only set at the start of postcopy */ -bool qemu_ram_is_uf_zeroable(RAMBlock *rb) +bool qemu_ram_is_uf_zeroable(const RAMBlock *rb) { return rb->flags & RAM_UF_ZEROPAGE; } @@ -1908,7 +1908,7 @@ void qemu_ram_set_uf_zeroable(RAMBlock *rb) rb->flags |=3D RAM_UF_ZEROPAGE; } =20 -bool qemu_ram_is_migratable(RAMBlock *rb) +bool qemu_ram_is_migratable(const RAMBlock *rb) { return rb->flags & RAM_MIGRATABLE; } @@ -1923,12 +1923,12 @@ void qemu_ram_unset_migratable(RAMBlock *rb) rb->flags &=3D ~RAM_MIGRATABLE; } =20 -bool qemu_ram_is_named_file(RAMBlock *rb) +bool qemu_ram_is_named_file(const RAMBlock *rb) { return rb->flags & RAM_NAMED_FILE; } =20 -int qemu_ram_get_fd(RAMBlock *rb) +int qemu_ram_get_fd(const RAMBlock *rb) { return rb->fd; } @@ -2770,7 +2770,7 @@ void *qemu_map_ram_ptr(RAMBlock *ram_block, ram_addr_= t addr) } =20 /* Return the offset of a hostpointer within a ramblock */ -ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host) +ram_addr_t qemu_ram_block_host_offset(const RAMBlock *rb, void *host) { ram_addr_t res =3D (uint8_t *)host - (uint8_t *)rb->host; assert((uintptr_t)host >=3D (uintptr_t)rb->host); --=20 2.52.0 From nobody Mon Mar 2 08:46:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772143405; cv=none; d=zohomail.com; s=zohoarc; b=YA2BtpEiFuYkK8Vf7Ai4m+S5ZHwQnhM6tYJXsiO6s+SriM3QjoIw/KtkbzMP9d297ZBJE1njLLtHSmvAPWK8jid4L7HGHjgMTB3LJU/imUoMjTvwEmeDQ7oeEKDjdVT/CPESn9JdznRuN5VWnLfrtO6VZ9uVP23d13vs3lis9aM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772143405; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WCZUc1LA8R4v0JRjwSW69cVOsM9EcduzH6g7RYX1cUA=; b=Vkg3g+AeFwkFC00mj4zBswX5HKmiZ+h+pKWztT76agONJBwy32vSqyBraultnvvBxKf2wShyTL08YTqXmKPueQcTQ9s7bKaKl7tkrPKfrbFOxOi2Og+F6Y4CD/TIF/qM5bFqyoVaB4aiS89gaqM0dIfBnoZvRq5EPTNSD4/I+K8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772143405659707.2838961894831; Thu, 26 Feb 2026 14:03:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vvjRp-0002XK-FA; Thu, 26 Feb 2026 17:03:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vvjRf-0002WH-02 for qemu-devel@nongnu.org; Thu, 26 Feb 2026 17:03:02 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vvjRc-0001td-VH for qemu-devel@nongnu.org; Thu, 26 Feb 2026 17:02:54 -0500 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4836f4cbe0bso12382415e9.3 for ; Thu, 26 Feb 2026 14:02:52 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483c3b84023sm68696045e9.12.2026.02.26.14.02.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 26 Feb 2026 14:02:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772143371; x=1772748171; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WCZUc1LA8R4v0JRjwSW69cVOsM9EcduzH6g7RYX1cUA=; b=urH1xcI6Ebn5pm8kgeV9/rDHPjvQeSCUDSTkPw3HzdmACA2YrUqJWX0Gpf18Sh8OLQ rlrEi9tE8QBq+MSYXpKaUvL7qGWWV8yyCSQpGvTcBhhz5oCHhvvnAHuLaJpzp1xJbSOx aAM048gdU8kKOVTG/RQo2krYkb6zpN+2rYweFsRR1xeMoWZIrbC44+SRtGdrkDjlmUTi //c9WQoR8AHwT7g/9GxI5HSsSA58hs0P1436qTTDMyM0vK6wnF1uimrfG3Yk5nOpKIFM sbp2A82zI/m69FmRAUs/wvw0QNK9HfFe0uVLH9FOTBkm86SgWKLCLbHjcJ4c50sf6fcg eNxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772143371; x=1772748171; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=WCZUc1LA8R4v0JRjwSW69cVOsM9EcduzH6g7RYX1cUA=; b=Aa4I5MIk0dVBasgDUlEOlWU0zcapdG0iN5cYN5NflkXoaHgyb6JALyylDMRrt+aNEH 0jLK0fnL27oq1fg6Q0X1apidARssmOiLLaQBijZjJdCEDGVydslN2s1pDGuiLxlAsb7e m9O3S/z+C1DbK8Yfcf45CUPFsUFDCQNscnbA7DsqtwPLKUcepIT5e6eVUolBaUK6xsZm tiVT+tGlKjVi5n50sn9jqbkQq04It+qJPP9XAGFZnFM6mWVAKPEUfen4tEb478n9SiiJ PNpnuM1GzxpjGcpI4Ph/I7pSgxeFZya8nExnREEbWyG1MNZFGPMrzTsAicCjFIlxuIvV SMfA== X-Gm-Message-State: AOJu0YwK9oWFM5V0JPTOcaO+Z6sRoKhxPOfL8O+MlzCVCgG8Z6sHNQzZ Vzpz6LDipbPpEuPt/wLAvczVvSHhiTCh07xgT5+DvqeC2RaPokvbB1QB1Ay5PT7tqS8wmauLHqY e1mZlsRk= X-Gm-Gg: ATEYQzzsIqc6TxuYHXcgfvwJ0F4nZ+XR+7YlNcmO0nIw005GoUikRmZclIUA3czGugR Z5TECh+LZWmhBat2IFg9hx2f+t1qScGkeN+xcdPkUJqpzSvcqZ5Sj42vAwE4/waPqi+f+iAW1Qh zDWNgbt/xFhCs5us1QLnErHnGVmkhmXaDix9kiE21w8n3C2uEhz1kxsimkHkva5Z1BxOsW+CyXc iIEOBt10XKfRjBshpp6uyniTXfm5XxNl/DI7TIV2vHvQs5sHYWEQ1gyUqQe8Fm1x7L5OwIS2ZoO iQiOd3J6scFpd/J4p3fY28su3rVUjrRKVwln2AR52KiAnt3gv+SBUpgXexzTkXB9BxgyebwHUGA 31hK0WFsN0aJPvuGmLHC/VokrjrXKhdurAoKle8nIPgKyH2SqOMPazjU0NrfoUp0TpiBhhN4AMs Ue7aQ6qbjEjnkplsO/Y6u3LdxVJNLibAFPzY+gcb+WvK9r3mmlg4iQyHFNz5dTsPWtLgrI0TpT X-Received: by 2002:a05:600c:4f11:b0:477:7925:f7fb with SMTP id 5b1f17b1804b1-483c9babeaamr6690795e9.10.1772143371096; Thu, 26 Feb 2026 14:02:51 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Mark Cave-Ayland , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu , Akihiko Odaki Subject: [PATCH 3/7] system/memory: Constify various MemoryRegion arguments Date: Thu, 26 Feb 2026 23:02:21 +0100 Message-ID: <20260226220226.20164-4-philmd@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260226220226.20164-1-philmd@linaro.org> References: <20260226220226.20164-1-philmd@linaro.org> MIME-Version: 1.0 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::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772143408002158500 Mark the MemoryRegion structure const when is only accessed read-only. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier --- include/system/memory.h | 28 ++++++++++++++-------------- system/memory.c | 34 ++++++++++++++++++---------------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/include/system/memory.h b/include/system/memory.h index 0562af31361..baa6a840375 100644 --- a/include/system/memory.h +++ b/include/system/memory.h @@ -1749,14 +1749,14 @@ bool memory_region_init_rom_device(MemoryRegion *mr, * * @mr: the memory region being queried. */ -Object *memory_region_owner(MemoryRegion *mr); +Object *memory_region_owner(const MemoryRegion *mr); =20 /** * memory_region_size: get a memory region's size. * * @mr: the memory region being queried. */ -uint64_t memory_region_size(MemoryRegion *mr); +uint64_t memory_region_size(const MemoryRegion *mr); =20 /** * memory_region_is_ram: check whether a memory region is random access @@ -1765,7 +1765,7 @@ uint64_t memory_region_size(MemoryRegion *mr); * * @mr: the memory region being queried */ -static inline bool memory_region_is_ram(MemoryRegion *mr) +static inline bool memory_region_is_ram(const MemoryRegion *mr) { return mr->ram; } @@ -1777,7 +1777,7 @@ static inline bool memory_region_is_ram(MemoryRegion = *mr) * * @mr: the memory region being queried */ -bool memory_region_is_ram_device(MemoryRegion *mr); +bool memory_region_is_ram_device(const MemoryRegion *mr); =20 /** * memory_region_is_romd: check whether a memory region is in ROMD mode @@ -1787,7 +1787,7 @@ bool memory_region_is_ram_device(MemoryRegion *mr); * * @mr: the memory region being queried */ -static inline bool memory_region_is_romd(MemoryRegion *mr) +static inline bool memory_region_is_romd(const MemoryRegion *mr) { return mr->rom_device && mr->romd_mode; } @@ -1800,7 +1800,7 @@ static inline bool memory_region_is_romd(MemoryRegion= *mr) * * @mr: the memory region being queried */ -bool memory_region_is_protected(MemoryRegion *mr); +bool memory_region_is_protected(const MemoryRegion *mr); =20 /** * memory_region_has_guest_memfd: check whether a memory region has guest_= memfd @@ -1810,7 +1810,7 @@ bool memory_region_is_protected(MemoryRegion *mr); * * @mr: the memory region being queried */ -bool memory_region_has_guest_memfd(MemoryRegion *mr); +bool memory_region_has_guest_memfd(const MemoryRegion *mr); =20 /** * memory_region_get_iommu: check whether a memory region is an iommu @@ -1820,7 +1820,7 @@ bool memory_region_has_guest_memfd(MemoryRegion *mr); * * @mr: the memory region being queried */ -static inline IOMMUMemoryRegion *memory_region_get_iommu(MemoryRegion *mr) +static inline IOMMUMemoryRegion *memory_region_get_iommu(const MemoryRegio= n *mr) { if (mr->alias) { return memory_region_get_iommu(mr->alias); @@ -1991,7 +1991,7 @@ const char *memory_region_name(const MemoryRegion *mr= ); * @mr: the memory region being queried * @client: the client being queried */ -bool memory_region_is_logging(MemoryRegion *mr, uint8_t client); +bool memory_region_is_logging(const MemoryRegion *mr, uint8_t client); =20 /** * memory_region_get_dirty_log_mask: return the clients for which a @@ -2002,7 +2002,7 @@ bool memory_region_is_logging(MemoryRegion *mr, uint8= _t client); * * @mr: the memory region being queried */ -uint8_t memory_region_get_dirty_log_mask(MemoryRegion *mr); +uint8_t memory_region_get_dirty_log_mask(const MemoryRegion *mr); =20 /** * memory_region_is_rom: check whether a memory region is ROM @@ -2011,7 +2011,7 @@ uint8_t memory_region_get_dirty_log_mask(MemoryRegion= *mr); * * @mr: the memory region being queried */ -static inline bool memory_region_is_rom(MemoryRegion *mr) +static inline bool memory_region_is_rom(const MemoryRegion *mr) { return mr->ram && mr->readonly; } @@ -2023,7 +2023,7 @@ static inline bool memory_region_is_rom(MemoryRegion = *mr) * * @mr: the memory region being queried */ -static inline bool memory_region_is_nonvolatile(MemoryRegion *mr) +static inline bool memory_region_is_nonvolatile(const MemoryRegion *mr) { return mr->nonvolatile; } @@ -2036,7 +2036,7 @@ static inline bool memory_region_is_nonvolatile(Memor= yRegion *mr) * * @mr: the RAM or alias memory region being queried. */ -int memory_region_get_fd(MemoryRegion *mr); +int memory_region_get_fd(const MemoryRegion *mr); =20 /** * memory_region_from_host: Convert a pointer into a RAM memory region @@ -2521,7 +2521,7 @@ bool memory_region_present(MemoryRegion *container, h= waddr addr); * * @mr: a #MemoryRegion which should be checked if it's mapped */ -bool memory_region_is_mapped(MemoryRegion *mr); +bool memory_region_is_mapped(const MemoryRegion *mr); =20 /** * memory_region_get_ram_discard_manager: get the #RamDiscardManager for a diff --git a/system/memory.c b/system/memory.c index c51d0798a84..eeb0d19484f 100644 --- a/system/memory.c +++ b/system/memory.c @@ -1819,9 +1819,9 @@ static void memory_region_finalize(Object *obj) g_free(mr->ioeventfds); } =20 -Object *memory_region_owner(MemoryRegion *mr) +Object *memory_region_owner(const MemoryRegion *mr) { - Object *obj =3D OBJECT(mr); + const Object *obj =3D OBJECT(mr); return obj->parent; } =20 @@ -1849,7 +1849,7 @@ void memory_region_unref(MemoryRegion *mr) } } =20 -uint64_t memory_region_size(MemoryRegion *mr) +uint64_t memory_region_size(const MemoryRegion *mr) { if (int128_eq(mr->size, int128_2_64())) { return UINT64_MAX; @@ -1866,25 +1866,25 @@ const char *memory_region_name(const MemoryRegion *= mr) return mr->name; } =20 -bool memory_region_is_ram_device(MemoryRegion *mr) +bool memory_region_is_ram_device(const MemoryRegion *mr) { return mr->ram_device; } =20 -bool memory_region_is_protected(MemoryRegion *mr) +bool memory_region_is_protected(const MemoryRegion *mr) { return mr->ram && (mr->ram_block->flags & RAM_PROTECTED); } =20 -bool memory_region_has_guest_memfd(MemoryRegion *mr) +bool memory_region_has_guest_memfd(const MemoryRegion *mr) { return mr->ram_block && mr->ram_block->guest_memfd >=3D 0; } =20 -uint8_t memory_region_get_dirty_log_mask(MemoryRegion *mr) +uint8_t memory_region_get_dirty_log_mask(const MemoryRegion *mr) { uint8_t mask =3D mr->dirty_log_mask; - RAMBlock *rb =3D mr->ram_block; + const RAMBlock *rb =3D mr->ram_block; =20 if (global_dirty_tracking && ((rb && qemu_ram_is_migratable(rb)) || memory_region_is_iommu(mr))) { @@ -1898,7 +1898,7 @@ uint8_t memory_region_get_dirty_log_mask(MemoryRegion= *mr) return mask; } =20 -bool memory_region_is_logging(MemoryRegion *mr, uint8_t client) +bool memory_region_is_logging(const MemoryRegion *mr, uint8_t client) { return memory_region_get_dirty_log_mask(mr) & (1 << client); } @@ -2406,7 +2406,7 @@ void memory_region_reset_dirty(MemoryRegion *mr, hwad= dr addr, memory_region_get_ram_addr(mr) + addr, size, client, NULL); } =20 -int memory_region_get_fd(MemoryRegion *mr) +int memory_region_get_fd(const MemoryRegion *mr) { RCU_READ_LOCK_GUARD(); while (mr->alias) { @@ -2806,7 +2806,7 @@ static FlatRange *flatview_lookup(FlatView *view, Add= rRange addr) sizeof(FlatRange), cmp_flatrange_addr); } =20 -bool memory_region_is_mapped(MemoryRegion *mr) +bool memory_region_is_mapped(const MemoryRegion *mr) { return !!mr->container || mr->mapped_via_alias; } @@ -3290,7 +3290,7 @@ void address_space_destroy_free(AddressSpace *as) call_rcu(as, do_address_space_destroy_free, rcu); } =20 -static const char *memory_region_type(MemoryRegion *mr) +static const char *memory_region_type(const MemoryRegion *mr) { if (mr->alias) { return memory_region_type(mr->alias); @@ -3483,7 +3483,6 @@ static void mtree_print_flatview(gpointer key, gpoint= er value, GArray *fv_address_spaces =3D value; struct FlatViewInfo *fvi =3D user_data; FlatRange *range =3D &view->ranges[0]; - MemoryRegion *mr; int n =3D view->nr; int i; AddressSpace *as; @@ -3510,7 +3509,8 @@ static void mtree_print_flatview(gpointer key, gpoint= er value, } =20 while (n--) { - mr =3D range->mr; + const MemoryRegion *mr =3D range->mr; + if (range->offset_in_region) { qemu_printf(MTREE_INDENT HWADDR_FMT_plx "-" HWADDR_FMT_plx " (prio %d, %s%s): %s @" HWADDR_FMT_plx, @@ -3683,8 +3683,10 @@ static void mtree_info_as(bool dispatch_tree, bool o= wner, bool disabled) =20 /* print aliased regions */ QTAILQ_FOREACH(ml, &ml_head, mrqueue) { - qemu_printf("memory-region: %s\n", memory_region_name(ml->mr)); - mtree_print_mr(ml->mr, 1, 0, &ml_head, owner, disabled); + const MemoryRegion *mr =3D ml->mr; + + qemu_printf("memory-region: %s\n", memory_region_name(mr)); + mtree_print_mr(mr, 1, 0, &ml_head, owner, disabled); qemu_printf("\n"); } =20 --=20 2.52.0 From nobody Mon Mar 2 08:46:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772143426; cv=none; d=zohomail.com; s=zohoarc; b=ILjSbgTOTV5VQKn7mV1SY4kAdAeosu3vB6yH7qs1KPKcZ+SyskQTV98HX5MsYdNYQwXMB4rop3CCsPPoMVTJkjxGlhV6Du1wgND2U7c2rE3UG03DU6oHqzLMiauWLt7G1t7xXmLeUTPMReotnqm3Lo5deN9YLvu+rD07JhMaHRY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772143426; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IJ+Tv4G5h3x1rcHXKQ6649mV1rq/SLP2Dnsze79zphM=; b=mJdfBZ+4LoGyEmPxlZd32ZA+oTnrXRIz4SvLwI23sA0xn8Lj34attNhFWmPVVAJMtiX/jBk2716mmp9IUxjxGSqKE1WSr2yYmoJfTIruJy0wzAi/uwrZM03/54yuxk/CZGl3qb6oi4V6/aSgHKBELnlf1Fl29TXD5KwofGjZMCM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772143426097370.65584879194273; Thu, 26 Feb 2026 14:03:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vvjSG-0002Zf-36; Thu, 26 Feb 2026 17:03:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vvjRl-0002WS-MF for qemu-devel@nongnu.org; Thu, 26 Feb 2026 17:03:02 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vvjRk-0001tx-4y for qemu-devel@nongnu.org; Thu, 26 Feb 2026 17:03:01 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-483703e4b08so11935205e9.1 for ; Thu, 26 Feb 2026 14:02:59 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483bd7507adsm188751385e9.9.2026.02.26.14.02.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 26 Feb 2026 14:02:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772143378; x=1772748178; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IJ+Tv4G5h3x1rcHXKQ6649mV1rq/SLP2Dnsze79zphM=; b=NAkfGDGSVvUjch0nYRBjW58gkkYoFm+rCge0YbLNKTG+O6SJhzU4xxJP0U94xsp5WQ H7dHjpfgZamabpLbDlH7Wmhid4WC/VPBDCy4Ssxe/6xxcCxVEZVxRL0GYCrt18YGSdUx A/ssPCGYQAx8FrKNi4+6TiggMD5idxyEJRoJCl09lEsqShRnSeG+cbnoCKDqbf6oZcXI DTeW5zNVxkCNsbMPzlCkRKNnDt4gjqeK6/lHAlgQ9RuHvQimi8POQAwH/XNVoCubZ2vG W6qR6fFHFO/fxJZiL0AgQYnRowop9b2TBV5qXmrXdxWcud0atBAmJJC3dfczOQCk8RhY o5qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772143378; x=1772748178; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=IJ+Tv4G5h3x1rcHXKQ6649mV1rq/SLP2Dnsze79zphM=; b=HJsbJku6W1DPU++BBiRUlGPMy5y4O4+R2doJ09MjE1Kpvhatn5wvYlm/QSnCm2c0eK 7ncnIjfvQikHBTH+SGTE/ff1vDrXx4P28XdR3cwK5+i98Rppdl8LkwUm4XMicBb+PW1d KLgCgTfp6G87cthcbR9xNH12BCxrIDNLr4Lyjng4ZPChj+8Y5TFaZIm32aV1DJc3iSbJ k1rDmSQvu94FG4tDiui3aMpX/UezygdQwE0zoS+DJvYU0kURbC9Neyjmb1T8QKk/Kncu YnWeS3vju8uQ5yJ8KypKO1/35yP8cz9zUfy1j7EqlGPWTrdDOEJpvOZ6F4cuG6yRKGds lT9Q== X-Gm-Message-State: AOJu0YwKSa+sCgbTbMsacn6rPAyDBN+FNm+VzLs3RD44FhaeN+c90Tjy 0sYb8NzNfw8HbvoZAS1r+ZUlHvQ/rrzH7mOM/ra6Csgr86COh8La2FsCZUsGvG682tn3dtaYw4U cE8Wz8Gg= X-Gm-Gg: ATEYQzxPZ6cv/+5zjkQt+7xAVQAESKgUMuXWwqALmcdlE29znstqjZV5F5OmFZG0g1E 7CVMlakfBgF+dY5zZoD9ZQkPhwTWUuFl8n+a3V/fjUZteUu8sBnhELR9BWY4DuQ3j3tR06USz6/ 2dVGX3FRGrKvPCbyD2knEyuf/d2GGGFDtRlRgc3qd3tPiFTbQCq7oQpEPNcY2ScfG4qqZ5JMXYQ ie1D26Mm1Gb770gE1mRfKukrLWJUE1VFTn4masyHbobY+AOSebZtZXNKLFryAMFoChnyEd6JXYY PIvoHtW4rx4xvQKH/yMsZY9f8NGGExWgSJ2vMtzm/0tFmcwmTe1YvfcO8ijTHw7WmgCNdALzvwX IgbsfK76BkJC7gjA7ynNMZQN9R6sDpnzRW2am3xGe370ZX/HqQNeK1g/Hd5KNsjhsJZrGEkh7U+ /7p5zE494L4LYsb20dMC3jYaGJUIVQP4RJvueagWPGZ7WieXXU7OAKn2tepbO9j53kY3R/Zo4h X-Received: by 2002:a05:600c:4ec7:b0:477:9a61:fd06 with SMTP id 5b1f17b1804b1-483c33cab41mr69979905e9.8.1772143377923; Thu, 26 Feb 2026 14:02:57 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Mark Cave-Ayland , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu , Akihiko Odaki Subject: [PATCH 4/7] system/memory: Have memory_region_type() correctly describe containers Date: Thu, 26 Feb 2026 23:02:22 +0100 Message-ID: <20260226220226.20164-5-philmd@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260226220226.20164-1-philmd@linaro.org> References: <20260226220226.20164-1-philmd@linaro.org> MIME-Version: 1.0 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::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772143428040158500 MemoryRegion containers are not I/O regions, describe them as 'container'. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier --- system/memory.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/system/memory.c b/system/memory.c index eeb0d19484f..d5060774834 100644 --- a/system/memory.c +++ b/system/memory.c @@ -3303,6 +3303,8 @@ static const char *memory_region_type(const MemoryReg= ion *mr) return "rom"; } else if (memory_region_is_ram(mr)) { return "ram"; + } else if (!mr->container) { + return "container"; } else { return "i/o"; } --=20 2.52.0 From nobody Mon Mar 2 08:46:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772143496; cv=none; d=zohomail.com; s=zohoarc; b=QbrdRle7dRTS0uoU1d1Qk1xRJYDXEkjxnj/AkJfvq2nb6g8TAJnheZ9C+QqhydqLJLcWZsx1BmgPcdgEyAqoxKlvMi3qVYl0RxXDH4Id2AQ9XaeB5vJw9coA89AQ/UFtU8jT8vXeiPe5aNzN1eATB08MIwnUyf4h73ElyIN3x18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772143496; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=E3ZvAyTB+J8g8R55NOM7HtC99XIoDKv+zKI4lqiJNnQ=; b=asHn4soK6JTRXqP6acYgIIlenNlxe3xPK3DnDOYEaIYbluYoSVR5BnoMx968Z+inMXxRwn/xTbz98YP8DwYC2/++3mdjjby+Edzu23nwDiCfxpb0Ojv/PL4xyefgBWVbjKKUbEStZ5yrT93sf0nyvfUQpJfbMeeUTZoAbw6Ndpw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772143496159279.22167863151446; Thu, 26 Feb 2026 14:04:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vvjSZ-0002y0-P2; Thu, 26 Feb 2026 17:03:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vvjRt-0002ZD-Cc for qemu-devel@nongnu.org; Thu, 26 Feb 2026 17:03:18 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vvjRr-0001uV-KJ for qemu-devel@nongnu.org; Thu, 26 Feb 2026 17:03:08 -0500 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-43987b97701so933790f8f.3 for ; Thu, 26 Feb 2026 14:03:06 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4399c763e78sm2368017f8f.26.2026.02.26.14.03.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 26 Feb 2026 14:03:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772143385; x=1772748185; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=E3ZvAyTB+J8g8R55NOM7HtC99XIoDKv+zKI4lqiJNnQ=; b=g6wEGga0t66ZERMexP6VSTtTD9NnOImA5NX7n4NVQoIjqYi93wzpZcREmAdmonU6S+ thEVd6fYUk48nTOUjPDxL0q5rPlhrbv/s8tCF1enDALyHVYdvkDHo/HcpNIy5XPUzZoi UoQxZ5jG1MUCXDBGJpFh5OH13s9afn8mSvUj47wfiRfzScYqcq4v6cOjPFJvb3/HFOj1 AyQ5oVNIurcKVuNmahgD7zjVm3W2mLSUasrAT5WNVZdNscq6xFKuB2FRBJYexFq6ZhkQ k7BL/+oSZJPEjMoUTbmf+YBb+KGi/ypk6LezHCpyOOijBx1TvtSAu/j8/+x0olp823MA 2jdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772143385; x=1772748185; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=E3ZvAyTB+J8g8R55NOM7HtC99XIoDKv+zKI4lqiJNnQ=; b=IPh/bdxCTJ5ZEk6ZMGfZo3EcvBfYFH1SK+jEPeyiI8Z5NyY6ztedxsoYyeW8iOlO55 u6AYVqgXz9xjF/5lC/G8v3EriBJacRjv9bJtxo1zBRQq5KnmunFzTAQOW3O+z8IraLRY MuDvDEViY8cXH6EBalBq3GPfrJTSE1gt2yPSawsjWUI1T+k/Ls5z1abMhMwOw/l18NQ8 FLle61llkUF+yTBSNO0ouOTfKgXFoXpGfauxNluvBa6IDc4/b+7nIfhZrdqEtNKFIBmn vPIf8f12UxZyqNT9HnxWeK7QqJ7F79p3F2wddg9XM3mzxYMr9Jed8g0sRfxy/mwUJcil 7Xrg== X-Gm-Message-State: AOJu0YyUaoSLiufTyyFjGyU2ZnKrnGD8eqetdNPE49FoeiPZFm9w8L9x 2cLi6eMb5BBYZBI2YXsFfBoVb+0izrryje39J76Y/4A3r+t7aSuZYXjOzbLpaAxuCDEyI67KHlh Goih7KM8= X-Gm-Gg: ATEYQzzMhMh3HI7kfd1qMJcxVKVET2dwClxzy6C59wZwa4JWegRE0Y3oYNP4BJLXxJD vnhfqFbw/8HEHmFalVaDI5hlk+sHy5+67PTMqJ4UrKEOtWllPPuZkDCqfL/iAC9dS4MOYLcOwOw TLHhrDCtwLYoQDuj8/gVbMCPUdbk3cRcBy7W4Hme2UFX9bRji4QgblOHucvc9YL1p1pAqooyYOw s6lXhQYdOayBJ/ZLBglepR9APTwDYU7O+qy8aMa0Y3UcdQNeJII5Kd/eeJ9uQcnlMSDZkvpSpqP ZGvSM9JOG/L2b4Fa0OZ1snGONtPoqxoUkUPrtIp1Sh0iDMNnABTF02LmHKNEdGnmceHPKCpWRN/ Reesp3eIHjJWbWRUiqJs9rw9TpY5YcrOgL6vjfY5rQHUrQMK0POikG0dNwombIyi7AyyQ5Vcgu8 YqimvZKRSnu34xTiIrfYWvqO/SVG9AVGDINkB2oesDMRSYY0uhWmJ9fgheN4g6w/hIPFYOCvaN X-Received: by 2002:a5d:5d82:0:b0:431:808:2d58 with SMTP id ffacd0b85a97d-4399de3a446mr584432f8f.51.1772143384696; Thu, 26 Feb 2026 14:03:04 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Mark Cave-Ayland , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu , Akihiko Odaki Subject: [PATCH 5/7] system/memory: Display address spaces starting at 0x0000.0000 Date: Thu, 26 Feb 2026 23:02:23 +0100 Message-ID: <20260226220226.20164-6-philmd@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260226220226.20164-1-philmd@linaro.org> References: <20260226220226.20164-1-philmd@linaro.org> MIME-Version: 1.0 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::432; envelope-from=philmd@linaro.org; helo=mail-wr1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772143496695158500 Since AddressSpace root MemoryRegion can be remapped, it is bogus to use the MemoryRegion address as the AddressSpace absolute address. Besides, the AddressSpace APIs take an @addr argument expecting AddressSpaces start at 0x0000.0000. Substract the MemoryRegion address in mtree_print_mr() to display AddressSpaces starting at 0x0000.0000. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier --- system/memory.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/system/memory.c b/system/memory.c index d5060774834..1106f48d0d5 100644 --- a/system/memory.c +++ b/system/memory.c @@ -3360,7 +3360,7 @@ static void mtree_print_mr_owner(const MemoryRegion *= mr) } =20 static void mtree_print_mr(const MemoryRegion *mr, unsigned int level, - hwaddr base, + hwaddr offset, bool detect_overflow, MemoryRegionListHead *alias_print_queue, bool owner, bool display_disabled) { @@ -3374,7 +3374,7 @@ static void mtree_print_mr(const MemoryRegion *mr, un= signed int level, return; } =20 - cur_start =3D base + mr->addr; + cur_start =3D mr->addr + offset; cur_end =3D cur_start + MR_SIZE(mr->size); =20 /* @@ -3382,7 +3382,7 @@ static void mtree_print_mr(const MemoryRegion *mr, un= signed int level, * happen normally. When it happens, we dump something to warn the * user who is observing this. */ - if (cur_start < base || cur_end < cur_start) { + if (detect_overflow && (cur_start < offset || cur_end < cur_start)) { qemu_printf("[DETECTED OVERFLOW!] "); } =20 @@ -3462,7 +3462,7 @@ static void mtree_print_mr(const MemoryRegion *mr, un= signed int level, } =20 QTAILQ_FOREACH(ml, &submr_print_queue, mrqueue) { - mtree_print_mr(ml->mr, level + 1, cur_start, + mtree_print_mr(ml->mr, level + 1, cur_start, true, alias_print_queue, owner, display_disabled); } =20 @@ -3641,7 +3641,8 @@ static void mtree_print_as(gpointer key, gpointer val= ue, gpointer user_data) struct AddressSpaceInfo *asi =3D user_data; =20 g_slist_foreach(as_same_root_mr_list, mtree_print_as_name, NULL); - mtree_print_mr(mr, 1, 0, asi->ml_head, asi->owner, asi->disabled); + mtree_print_mr(mr, 1, -mr->addr, false, + asi->ml_head, asi->owner, asi->disabled); qemu_printf("\n"); } =20 @@ -3688,7 +3689,7 @@ static void mtree_info_as(bool dispatch_tree, bool ow= ner, bool disabled) const MemoryRegion *mr =3D ml->mr; =20 qemu_printf("memory-region: %s\n", memory_region_name(mr)); - mtree_print_mr(mr, 1, 0, &ml_head, owner, disabled); + mtree_print_mr(mr, 1, 0, false, &ml_head, owner, disabled); qemu_printf("\n"); } =20 --=20 2.52.0 From nobody Mon Mar 2 08:46:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772143499; cv=none; d=zohomail.com; s=zohoarc; b=ZCIe0ZEe638Lm/M2ZjLEbJNhwTUYZYF6Ny7o9ceFa1Zf6r/9AqRGkexzsD5HINefGBcIY024ksBSEC62AzlfisDHZQuHh9vFgW/PVsJNiBfnxwmtA1EWFzPRxqbrfV0KjViYYwGUpLuMw74vfkKi3D5TSu0tOhRpOGNxyMYWNNI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772143499; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=t1EnJk3wPeLwBeWTp7ZSpg6ulILpuVB2qbJBtvmV7es=; b=V+G1uvdmZUDPSmNnhGhR1WJodx0dDRcx4gvfjr5gZ5nPwSLpViEs8d+1IETVlZvCwnlVNcbPlNCRyL1fje5qTkSn+qpO6n9ic0Q6mrWrc5dTnszLwZRfqXb2SWtJOd3A5Mewq6Emd911oMOGJXGVGBTEt4OKKgZL3tlOx81EIqI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772143499593461.1974284197803; Thu, 26 Feb 2026 14:04:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vvjSV-0002t0-Mn; Thu, 26 Feb 2026 17:03:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vvjRz-0002ZR-Al for qemu-devel@nongnu.org; Thu, 26 Feb 2026 17:03:24 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vvjRx-0001uw-Ms for qemu-devel@nongnu.org; Thu, 26 Feb 2026 17:03:15 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4836f363d0dso11336755e9.3 for ; Thu, 26 Feb 2026 14:03:12 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483bd75df90sm174167475e9.14.2026.02.26.14.03.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 26 Feb 2026 14:03:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772143391; x=1772748191; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t1EnJk3wPeLwBeWTp7ZSpg6ulILpuVB2qbJBtvmV7es=; b=wnTmp33E3/g4keVi1swvVsZUr3BFJQp/TKqD9Kiogjah1lM5b64ERhfp+5mam+7qY1 6XdQJAgXJg515w0M3mMrTZAJlU1N/dkF/uebiX5yhJ4t4AxA8sItTuRRF5uYCjlZkKVn YCOipFlTXjF/xERBiZC1HokSzyBRjvoBS8h+yAbBJxgpU1KmZqkbzR0/jCJtGA5IUgh5 Z6YuJ9bcwW5p2xvuC9jwNzJS30nIrBNJElJs0uYeNAWwYrRuR6iRjp4kD+yrHHAqinxH HlaBEeMaQrzSg1sE9DRbVz7lEK9ZYqYhA0l5r8jiOUC5Deu4TZ0EzluNuO57HVKRCZpi BT2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772143391; x=1772748191; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=t1EnJk3wPeLwBeWTp7ZSpg6ulILpuVB2qbJBtvmV7es=; b=E4V+TKMFVZEQTRcUV+JpeC+yLCuspWF871jizWys38K/CstycN3tjDZlwpycrDtsw7 RAZVJLJqTgEJwr19ZqygQdmR/A2GUDjcliFZnbask5Xlj+YdwNC1oUh3NGB6bTzr17oO L/Ak3+driO2h8j29qfN1mcsXW6rRyS4GNHh+sVbj/Z0Qwyqnmh9RCl8tv+H8aL6Q+aYq Qh9KFiEiOcu374RNzQIvJ9z7MtnrSHVdQJvNXs+kjP4b95sXq/WpD/w7g0hT1ens2V2K LZsNAozrfjqGH66J6lf7sOKm1aOR24Tb95ly0L1+gYRwlfyxVVNPtlKb6jTF9NGW7U41 pRiA== X-Gm-Message-State: AOJu0YyYnWu1UWoDF3ZNjXuQIGSf1kIWOK18BfCoN2OQRZG+FsZaK9fO fArt9q4GnwU4DMv0EFaXLrYYSLAybTrAD3itKup0SIlso32aP0viYiDq6i21sprqYUjYhkpGfMu KBHBvpHk= X-Gm-Gg: ATEYQzyWKgHNHOZpEJzE4AsS5WZolVzjeKYms9UdE99PaTDwl2NvCpTNADDwn2wab27 lD0BW2Pa+PP66iiVJWq7IdT32qiFjl2TxsA61igDUefRirNoyMEkTIBfijAjzhsWYWEyVo+NVxZ S7qwAU0XNfHCWLW+oaWtDqzvbZ9MBxHWMJJU5I/p3OUCZXTo84pIjqbBfqGKlSKYtPRsBxU0P2G pYeinejMbPSnnJs93g0wFBW+9rnEFEwThrJM4M6N9nqzkN+8R9NS2wi+tgogijnmaNeGkhMpnVl k8CQV+WZn0GciRpBuGRR7dAeJquzi1abTO+A7X+75BS5yvOmYrHQPWLFcA8krEvGzWwk2jMHwS7 2DccwrDdkGR53J5FaC9dwg0jljD8dzse8i2vx8aH1MqsBYApq3UnxJaGmp2pj8919hnkAW6nEPJ L54HAj8bmTXkZqIVeP9F1Ft/h9WNIujfzvpty5xLhGtWaMmoEm06Q1yCVDip8eY8HDNRxdrGlP X-Received: by 2002:a05:600c:1548:b0:480:1c10:5633 with SMTP id 5b1f17b1804b1-483c9c1045cmr5341675e9.26.1772143391422; Thu, 26 Feb 2026 14:03:11 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Mark Cave-Ayland , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu , Akihiko Odaki Subject: [PATCH 6/7] system/memory: Allow mtree_print_mr() to display distinct address width Date: Thu, 26 Feb 2026 23:02:24 +0100 Message-ID: <20260226220226.20164-7-philmd@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260226220226.20164-1-philmd@linaro.org> References: <20260226220226.20164-1-philmd@linaro.org> MIME-Version: 1.0 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::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772143500644158500 mtree_print_mr() display addresses using 16 chars on 64-bit binaries, and 8 chars on 32-bit ones. Some MR / AS don't always benefit of 16 chars, for example the ISA I/O region fits in 16 bits, and displaying 12 extra '0' in 64-bit binaries isn't really a good user experience. Add an extra @width argument to mtree_print_mr(). Next commit will make use of it. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier --- system/memory.c | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/system/memory.c b/system/memory.c index 1106f48d0d5..4d276307da5 100644 --- a/system/memory.c +++ b/system/memory.c @@ -3321,6 +3321,7 @@ typedef QTAILQ_HEAD(, MemoryRegionList) MemoryRegionL= istHead; =20 #define MR_SIZE(size) (int128_nz(size) ? (hwaddr)int128_get64( \ int128_sub((size), int128_one())) : 0) +#define MR_ADDR_WIDTH 16 #define MTREE_INDENT " " =20 static void mtree_expand_owner(const char *label, Object *obj) @@ -3360,6 +3361,7 @@ static void mtree_print_mr_owner(const MemoryRegion *= mr) } =20 static void mtree_print_mr(const MemoryRegion *mr, unsigned int level, + unsigned int width, hwaddr offset, bool detect_overflow, MemoryRegionListHead *alias_print_queue, bool owner, bool display_disabled) @@ -3405,17 +3407,17 @@ static void mtree_print_mr(const MemoryRegion *mr, = unsigned int level, for (i =3D 0; i < level; i++) { qemu_printf(MTREE_INDENT); } - qemu_printf(HWADDR_FMT_plx "-" HWADDR_FMT_plx - " (prio %d, %s%s): alias %s @%s " HWADDR_FMT_plx - "-" HWADDR_FMT_plx "%s", - cur_start, cur_end, + qemu_printf("%0*" PRIx64 "-" "%0*" PRIx64 + " (prio %d, %s%s): alias %s @%s " + "%0*" PRIx64"-" "%0*" PRIx64 "%s", + width, cur_start, width, cur_end, mr->priority, mr->nonvolatile ? "nv-" : "", memory_region_type((MemoryRegion *)mr), memory_region_name(mr), memory_region_name(mr->alias), - mr->alias_offset, - mr->alias_offset + MR_SIZE(mr->size), + width, mr->alias_offset, + width, mr->alias_offset + MR_SIZE(mr->size), mr->enabled ? "" : " [disabled]"); if (owner) { mtree_print_mr_owner(mr); @@ -3427,9 +3429,9 @@ static void mtree_print_mr(const MemoryRegion *mr, un= signed int level, for (i =3D 0; i < level; i++) { qemu_printf(MTREE_INDENT); } - qemu_printf(HWADDR_FMT_plx "-" HWADDR_FMT_plx + qemu_printf("%0*" PRIx64 "-" "%0*" PRIx64 " (prio %d, %s%s): %s%s", - cur_start, cur_end, + width, cur_start, width, cur_end, mr->priority, mr->nonvolatile ? "nv-" : "", memory_region_type((MemoryRegion *)mr), @@ -3462,7 +3464,7 @@ static void mtree_print_mr(const MemoryRegion *mr, un= signed int level, } =20 QTAILQ_FOREACH(ml, &submr_print_queue, mrqueue) { - mtree_print_mr(ml->mr, level + 1, cur_start, true, + mtree_print_mr(ml->mr, level + 1, width, cur_start, true, alias_print_queue, owner, display_disabled); } =20 @@ -3485,6 +3487,7 @@ static void mtree_print_flatview(gpointer key, gpoint= er value, GArray *fv_address_spaces =3D value; struct FlatViewInfo *fvi =3D user_data; FlatRange *range =3D &view->ranges[0]; + unsigned int width; int n =3D view->nr; int i; AddressSpace *as; @@ -3510,26 +3513,27 @@ static void mtree_print_flatview(gpointer key, gpoi= nter value, return; } =20 + width =3D MR_ADDR_WIDTH; while (n--) { const MemoryRegion *mr =3D range->mr; =20 if (range->offset_in_region) { - qemu_printf(MTREE_INDENT HWADDR_FMT_plx "-" HWADDR_FMT_plx - " (prio %d, %s%s): %s @" HWADDR_FMT_plx, - int128_get64(range->addr.start), - int128_get64(range->addr.start) - + MR_SIZE(range->addr.size), + qemu_printf(MTREE_INDENT "%0*" PRIx64 "-" "%0*" PRIx64 + " (prio %d, %s%s): %s @" "%0*" PRIx64, + width, int128_get64(range->addr.start), + width, int128_get64(range->addr.start) + + MR_SIZE(range->addr.size), mr->priority, range->nonvolatile ? "nv-" : "", range->readonly ? "rom" : memory_region_type(mr), memory_region_name(mr), - range->offset_in_region); + width, range->offset_in_region); } else { - qemu_printf(MTREE_INDENT HWADDR_FMT_plx "-" HWADDR_FMT_plx + qemu_printf(MTREE_INDENT "%0*" PRIx64 "-" "%0*" PRIx64 " (prio %d, %s%s): %s", - int128_get64(range->addr.start), - int128_get64(range->addr.start) - + MR_SIZE(range->addr.size), + width, int128_get64(range->addr.start), + width, int128_get64(range->addr.start) + + MR_SIZE(range->addr.size), mr->priority, range->nonvolatile ? "nv-" : "", range->readonly ? "rom" : memory_region_type(mr), @@ -3639,9 +3643,10 @@ static void mtree_print_as(gpointer key, gpointer va= lue, gpointer user_data) MemoryRegion *mr =3D key; GSList *as_same_root_mr_list =3D value; struct AddressSpaceInfo *asi =3D user_data; + const unsigned int width =3D MR_ADDR_WIDTH; =20 g_slist_foreach(as_same_root_mr_list, mtree_print_as_name, NULL); - mtree_print_mr(mr, 1, -mr->addr, false, + mtree_print_mr(mr, 1, width, -mr->addr, false, asi->ml_head, asi->owner, asi->disabled); qemu_printf("\n"); } @@ -3687,9 +3692,10 @@ static void mtree_info_as(bool dispatch_tree, bool o= wner, bool disabled) /* print aliased regions */ QTAILQ_FOREACH(ml, &ml_head, mrqueue) { const MemoryRegion *mr =3D ml->mr; + const unsigned int width =3D MR_ADDR_WIDTH; =20 qemu_printf("memory-region: %s\n", memory_region_name(mr)); - mtree_print_mr(mr, 1, 0, false, &ml_head, owner, disabled); + mtree_print_mr(mr, 1, width, 0, false, &ml_head, owner, disabled); qemu_printf("\n"); } =20 --=20 2.52.0 From nobody Mon Mar 2 08:46:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1772143466; cv=none; d=zohomail.com; s=zohoarc; b=NMQPIAFJdYkOWpuNe69boSKFg16Sgx94wO9ljhPNFlgngNQTPwzwTgaez6WAN1jSQTvTQWbjMW4BwCnqGw59Blnq1JEtpfXNAHjQ7czH+r+t4i5MNBQfVRxKC8Uv8FWShpMItJ8TOT+hRSQtTiOmzlT1SMSPL9WkI2GNqaa+u80= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772143466; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Hbzn5vHgMdXp7p0dhzileZ9MCb8UEIgfWGmULUXbwAo=; b=VPoY5XUSkXN/QC6hqIodcF2kpxH6/n44nBjkfxwzzXV7B30Utk1iLkCQzRfOwR+v667zqQV65K9JACtlrAbFDo9FmOLpZGIg8IGwR3znr7lDrAla23dp5Ftz7NWatoQoxZ6DG32yXshUYFhj9HNtQjlWTKNH5qWiMgHanO9LCcU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772143466703436.1656492348204; Thu, 26 Feb 2026 14:04:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vvjSz-0003hU-JB; Thu, 26 Feb 2026 17:04:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vvjSF-0002gO-Bm for qemu-devel@nongnu.org; Thu, 26 Feb 2026 17:03:32 -0500 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vvjS9-0001vJ-Ka for qemu-devel@nongnu.org; Thu, 26 Feb 2026 17:03:28 -0500 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-437711e9195so991447f8f.1 for ; Thu, 26 Feb 2026 14:03:20 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4399c76b40esm1838119f8f.36.2026.02.26.14.03.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 26 Feb 2026 14:03:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772143399; x=1772748199; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Hbzn5vHgMdXp7p0dhzileZ9MCb8UEIgfWGmULUXbwAo=; b=OlM4xEeNzJsLYitiemx8oGObTEMPV5FERDflDi74fHJON+QxZ5Z2pPjZZnygaGd1t/ 5BJGpaP+p5+2ho6Jr9lnFMHXYWYqGscuBDyFXJGhZAT8Z44GeXAeY8KYRUbExL3C7Vda 5BYVKQO1k4z/Xzyx5fjPn7A+yluIMtUu/0niTT3xP9NsIWX9sukfljVSg3z6fv/mRog7 L0rDIRnxBRnDFV6CuGellV7G6Fsdp//h6e5WfIsIk0K9/xlEnVx5lI6yFkahzu3OB08u MwgXcsPgpONlHI/KR5p9B72tP5g9qVZp41m59C5XFxONl+V3Huq+H+SBuWghjbf2utmz esLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772143399; x=1772748199; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Hbzn5vHgMdXp7p0dhzileZ9MCb8UEIgfWGmULUXbwAo=; b=qp14njOeqWm4zQ8TqWirxFx/zYXWtNsTgPQF1DVr5r0+OB4kFKfWFlXpWwKtQtr/2A 4TnIU4iGYCbO1jwuwd7XMGoG8GSKbL6FiislJzlwrrv7BQ5gll3S6byUj22iNmSQqxHE WvfyiLOxYThWOHBQfM2spZpFlpPIK/K1NVdT3bxzHSlpYu4IRGaAwwBBPeb9zcpbN/4f 6RSZDFj8quV6wkFQdSxIO+tfozKnKsJyzv1S65ENSbXT9/rMOV8x4G3MxRXw/4hLsrHZ F63kYHKb7MvA3fsjOXzZhIvyOTiBy3x50zN2X1fChET0TsCUvVCflMsbLMpWSIY7M8N8 675w== X-Gm-Message-State: AOJu0Yy9Ah/dIyZ3CSAcKiI0VlaxWDB8s8iaKpeEdC3l4ejhT17L7i6x 8hRJtZtN2P/mFON+X/5/vy9etC+EQTfrjsdwSD+wr9PBK7H8a5k1d9eRAukW1Ayh+RSMrgOzLP9 AeJN0Vp0= X-Gm-Gg: ATEYQzy9HohlkKfsNsNsaEGhcbTrJvIZ/KqzdW0RY1balaWhYpUXlpYN4odQKiAjCbM 0BtfG/e4kjOz+GuF6XAhMl8WmQnThLyeBG0Ke05ne/00SR9EMjdZsFXSRCqjoBSfh6a9+R6qh/X n79MCBab1DDDbi7sRRgFH5nYkswtqXUAWS7P3OOAXLW2aYXXz9xzEPS8PVAijK1kMDNJ1ESTX5t qC1elMI/+Y4aehj1EkCOcHmkQR+wIvv3XYkkkFYgYUnfJJxjv7fGZH9jvZoekpyegtdP0nxR0pw eCuEEjQcvdSBIc0WseNP8/ehxeCWYxtR5akNXDNzC2tBz3wGDCez8Eh+UfStTVP5QoBFDVBK3pZ a2E95SSBxir+aPc43uGKv4AXu6Q0IQy7YGdwy7zbZ5cvJfoss6GvAnA9YmcgWDLEbtWo2YnexZP l0Xpota/WrIDa/Ofxacs9RCEFtC7WTLUA1V9mQk6B9LPZ6cR1lM00rpYpCZ9IjdqR51uNHcBTBR hzSJ0PChkY= X-Received: by 2002:a05:6000:2901:b0:439:5c09:4854 with SMTP id ffacd0b85a97d-4399de2fcd2mr690489f8f.41.1772143398974; Thu, 26 Feb 2026 14:03:18 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Mark Cave-Ayland , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Peter Xu , Akihiko Odaki Subject: [PATCH 7/7] system/memory: Have 'info mtree' display addresses nicely Date: Thu, 26 Feb 2026 23:02:25 +0100 Message-ID: <20260226220226.20164-8-philmd@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260226220226.20164-1-philmd@linaro.org> References: <20260226220226.20164-1-philmd@linaro.org> MIME-Version: 1.0 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::42d; envelope-from=philmd@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1772143468318158500 Use the size of a MR / AS to decide how many address chars need to be used. For example, using 'qemu-system-x86_64 -M q35 -S -monitor stdio' to run 'info mtree' displays before: address-space: I/O 0000000000000000-000000000000ffff (prio 0, i/o): io 0000000000000000-0000000000000003 (prio 0, i/o): acpi-evt 0000000000000004-0000000000000005 (prio 0, i/o): acpi-cnt 0000000000000008-000000000000000b (prio 0, i/o): acpi-tmr 0000000000000020-000000000000002f (prio 0, i/o): acpi-gpe0 0000000000000030-0000000000000037 (prio 0, i/o): acpi-smi 0000000000000060-000000000000007f (prio 0, i/o): sm-tco 0000000000000000-0000000000000007 (prio 0, i/o): dma-chan 0000000000000008-000000000000000f (prio 0, i/o): dma-cont 0000000000000020-0000000000000021 (prio 0, i/o): pic 0000000000000040-0000000000000043 (prio 0, i/o): pit ... memory-region: pc.ram 0000000000000000-0000000007ffffff (prio 0, ram): pc.ram memory-region: pc.bios 00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios memory-region: pci 0000000000000000-ffffffffffffffff (prio -1, i/o): pci 00000000000a0000-00000000000bffff (prio 1, i/o): vga-lowmem 00000000000c0000-00000000000dffff (prio 1, rom): pc.rom 00000000000e0000-00000000000fffff (prio 1, rom): alias isa-bios @pc.b= ios 0000000000020000-000000000003ffff 00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios ... and after: address-space: I/O 0000-ffff (prio 0, container): io 0000-0003 (prio 0, i/o): acpi-evt 0004-0005 (prio 0, i/o): acpi-cnt 0008-000b (prio 0, i/o): acpi-tmr 0020-002f (prio 0, i/o): acpi-gpe0 0030-0037 (prio 0, i/o): acpi-smi 0060-007f (prio 0, i/o): sm-tco 0000-0007 (prio 0, i/o): dma-chan 0008-000f (prio 0, i/o): dma-cont 0020-0021 (prio 0, i/o): pic 0040-0043 (prio 0, i/o): pit ... memory-region: pc.ram 00000000-07ffffff (prio 0, ram): pc.ram memory-region: pc.bios fffc0000-ffffffff (prio 0, rom): pc.bios memory-region: pci 0000000000000000-ffffffffffffffff (prio -1, i/o): pci 00000000000a0000-00000000000bffff (prio 1, i/o): vga-lowmem 00000000000c0000-00000000000dffff (prio 1, rom): pc.rom 00000000000e0000-00000000000fffff (prio 1, rom): alias isa-bios @pc.b= ios 0000000000020000-000000000003ffff 00000000fffc0000-00000000ffffffff (prio 0, rom): pc.bios ... Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier --- system/memory.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/system/memory.c b/system/memory.c index 4d276307da5..abcbdaadcd7 100644 --- a/system/memory.c +++ b/system/memory.c @@ -3321,7 +3321,26 @@ typedef QTAILQ_HEAD(, MemoryRegionList) MemoryRegion= ListHead; =20 #define MR_SIZE(size) (int128_nz(size) ? (hwaddr)int128_get64( \ int128_sub((size), int128_one())) : 0) -#define MR_ADDR_WIDTH 16 + +static unsigned mr_addr_fmt_width(const MemoryRegion *mr) +{ + const unsigned int bits =3D 127 - clz128(mr->size); + unsigned int width; + + if (bits <=3D 8) { + width =3D 2; + } else if (bits <=3D 16) { + width =3D 4; + } else if (bits <=3D 32) { + width =3D 8; + } else if (bits <=3D 64) { + width =3D 16; + } else { + width =3D 20; + } + return width; +} + #define MTREE_INDENT " " =20 static void mtree_expand_owner(const char *label, Object *obj) @@ -3513,7 +3532,7 @@ static void mtree_print_flatview(gpointer key, gpoint= er value, return; } =20 - width =3D MR_ADDR_WIDTH; + width =3D mr_addr_fmt_width(view->root); while (n--) { const MemoryRegion *mr =3D range->mr; =20 @@ -3643,7 +3662,7 @@ static void mtree_print_as(gpointer key, gpointer val= ue, gpointer user_data) MemoryRegion *mr =3D key; GSList *as_same_root_mr_list =3D value; struct AddressSpaceInfo *asi =3D user_data; - const unsigned int width =3D MR_ADDR_WIDTH; + const unsigned int width =3D mr_addr_fmt_width(mr); =20 g_slist_foreach(as_same_root_mr_list, mtree_print_as_name, NULL); mtree_print_mr(mr, 1, width, -mr->addr, false, @@ -3692,7 +3711,7 @@ static void mtree_info_as(bool dispatch_tree, bool ow= ner, bool disabled) /* print aliased regions */ QTAILQ_FOREACH(ml, &ml_head, mrqueue) { const MemoryRegion *mr =3D ml->mr; - const unsigned int width =3D MR_ADDR_WIDTH; + const unsigned int width =3D mr_addr_fmt_width(mr); =20 qemu_printf("memory-region: %s\n", memory_region_name(mr)); mtree_print_mr(mr, 1, width, 0, false, &ml_head, owner, disabled); --=20 2.52.0