From nobody Sat Apr 11 21:30:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1773081363; cv=none; d=zohomail.com; s=zohoarc; b=Pzbl6SbnU4WdFGR5IOMutofaM0C36JSsS0CZRSueqOUgBc/3dB1xUGDVJBN2JMvN6cL3jy8dFf+bH+NJFUlEBpS17e9T4tNuLwfrkiCl1NRYuiW2svCXA2hznu37HOUnrmjUHYH9CzKy6cj5/SMtdPkhtQyl+o0X/HGnWBwb+Vk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773081363; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xA3KiBRZDEy+tGK0VBSBg6K/vS9OJsxKrmQTjGkh/tM=; b=Sx9lrqAADX5MEp0dIjGgjXjJ1/OAh3QDv4vekpPT3PwMXRH5Ezkb0Or4LDbjDwrLoDIcQLVPb6r8dtyGlZwBs1gCS91GdmyJppz7Kg6W5g/D7NY7K1RVM0Yx/y1ROb4aYX/Qto41YNHSRbctRKAL2GOp/SX3uU84TWFko7/1R6k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1773081363796445.0404147515202; Mon, 9 Mar 2026 11:36:03 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1249619.1547081 (Exim 4.92) (envelope-from ) id 1vzfSH-0007Yj-80; Mon, 09 Mar 2026 18:35:49 +0000 Received: by outflank-mailman (output) from mailman id 1249619.1547081; Mon, 09 Mar 2026 18:35:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vzfSH-0007Ya-46; Mon, 09 Mar 2026 18:35:49 +0000 Received: by outflank-mailman (input) for mailman id 1249619; Mon, 09 Mar 2026 18:35:47 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vzfSF-0007JG-Hn for xen-devel@lists.xenproject.org; Mon, 09 Mar 2026 18:35:47 +0000 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [2a00:1450:4864:20::329]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c9a96f7e-1be6-11f1-b164-2bf370ae4941; Mon, 09 Mar 2026 19:35:46 +0100 (CET) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4853e1ce427so12503795e9.3 for ; Mon, 09 Mar 2026 11:35:46 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48541a6bb86sm9367755e9.1.2026.03.09.11.35.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 09 Mar 2026 11:35:45 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: c9a96f7e-1be6-11f1-b164-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1773081346; x=1773686146; darn=lists.xenproject.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=xA3KiBRZDEy+tGK0VBSBg6K/vS9OJsxKrmQTjGkh/tM=; b=vHxbDQhCv7R2l0m7nn8ppI10Jd/khXsW9VNS7owUnYjELJP8p9FXXUZFAJO8qzhfi8 Ss5YV05uGA/L7PlV4CUAB2psoUGlK9x2IhRzPuxagzIVfrC67UQgsUDlC+8iew/GnQNE bw05RPSVofq6tmTCegQw+vUq1Fg+GvrGYadn5Xam/SPwklpS+ymL5iVmxC7U8bJjQkys TylXDZijOTjF7bcu7+J/fMnS/ftHFsO4sVtjMgvSJx6AvyupRW+ssDM++jXK+rBJYnfg P3myScAacVjpluoKtrkzghoiDrfHUp91ZQzwvpwH6BcFhF414pso0Wu9Wq4KT0roPcxA WULg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773081346; x=1773686146; 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=xA3KiBRZDEy+tGK0VBSBg6K/vS9OJsxKrmQTjGkh/tM=; b=fc5+B01u0CIn1N7KIQmwd3puovGFjfOBUuG5YJYTkfnAD6X8PufBq8Msud8MoFSwm7 qLpkfWVRYrVrqEqSvJEjhRmhv5S/9kjQOOxN6hhXzrekVInFxwd2zAVKTnPOUuHrMIO0 TsGqkqmfDDppk7QimdUF2YGckvwi51Z83vPkGJS3j2frPf98O9p693cDnaA4kwHeFNpe jyARv3jmujUziYOb8LBk3bfNm+SnK8ZEt+BtDzyQVeAikM29IPH4AFdcKfGSQnCjUJ2S PMtYhYI4p+JXaF5fQOCdeJziAApCzTZTECiOmoJiW3mvnLZGu727n717wjicXs7c7xWL V+4Q== X-Forwarded-Encrypted: i=1; AJvYcCVJSHVdT5pGyK1v4+rWLQ2n3o39JqCGP+XQtU/SoC8xVscYxGxO14rZU0KoEaLvCY6w8npw3AwwAbs=@lists.xenproject.org X-Gm-Message-State: AOJu0YyH3eJiNbf7xywiJhRY80DwjRlEHNs/feEPrU/9ZTo6R5eqE1Iw DzyMkF94SpE5WTjZO9q3ClBDX05a5QDycXVrnGNnrcTq0NJVICjcZtkYVnLtUO8/lKPRxpzSURs MaUV6wOI= X-Gm-Gg: ATEYQzw7oDthjzhXcXUX5xR263W9mMENckvqHJg69G/a1IfYs/JsesJiZbujWVYb597 O78NbSSAa7NNsJdHji9zNtUa5NEo5fEPvTijGN5vosPG3H/Gl3F4z/Bz3TayXfTkmqpjY4hr8yU eOKAOAGksfnn4COHSQkVPlCfcvyN6BKU6wUn6JmJjFiPn/YAdjeK9JXgDY//LWJh5PSB8NQTFuc mRaLN4dGOor9DC2syZ6+5pDhGFMasMke3Q8o82iIwY+QV9yAY/EUscaSlfA6wV6rzuaJeAX2OfI aw6QBqIMBqBHYm/LN8ngs3GDVDl971r8u0wr+Zh147ZyvHvKwWoIzvNdtEuVmaOUNLK1ha+SunB kYV61aHopIH69RbtBwpPv3lQ4OWfwuZCMAqX+XeWDkNFSutcv2vibdiUYhETD1bJSdvKPKGMXLj tULYJO5CVwr/KLC+sAEwvMTAFrBcdMezivCkEurt4iZdeC+6wllBgVYVdGXVCnNmbEwmcum0j/ X-Received: by 2002:a05:600c:3b8e:b0:485:35a4:939c with SMTP id 5b1f17b1804b1-48535a4a188mr113829175e9.29.1773081346102; Mon, 09 Mar 2026 11:35:46 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , Anthony PERARD , xen-devel@lists.xenproject.org, Mark Cave-Ayland , Peter Xu , Richard Henderson , Pierrick Bouvier , Paolo Bonzini , "Edgar E. Iglesias" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefano Stabellini , Akihiko Odaki Subject: [PATCH v2 1/4] system/ramblock: Constify various RAMBlock arguments Date: Mon, 9 Mar 2026 19:35:32 +0100 Message-ID: <20260309183536.88976-2-philmd@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260309183536.88976-1-philmd@linaro.org> References: <20260309183536.88976-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1773081365372154100 Mark the RAMBlock structure const when is only accessed read-only. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Reviewed-by: Peter Xu --- include/system/ramblock.h | 28 ++++++++++++++-------------- stubs/physmem.c | 2 +- stubs/ram-block.c | 6 +++--- system/physmem.c | 28 ++++++++++++++-------------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/include/system/ramblock.h b/include/system/ramblock.h index e9f58ac0457..4435f8d55fe 100644 --- a/include/system/ramblock.h +++ b/include/system/ramblock.h @@ -154,26 +154,26 @@ 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(const RAMBlock *block); size_t qemu_ram_pagesize_largest(void); #include "exec/target_page.h" #include "exec/hwaddr.h" diff --git a/stubs/physmem.c b/stubs/physmem.c index 14667f2bd8f..2eca06ab6d6 100644 --- a/stubs/physmem.c +++ b/stubs/physmem.c @@ -7,7 +7,7 @@ RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_of= fset, return NULL; } =20 -int qemu_ram_get_fd(RAMBlock *rb) +int qemu_ram_get_fd(const RAMBlock *rb) { return -1; } diff --git a/stubs/ram-block.c b/stubs/ram-block.c index 8790a59593e..1c79e447ff0 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; } diff --git a/system/physmem.c b/system/physmem.c index 7eecd818770..e5390d09bef 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -1859,48 +1859,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; } @@ -1910,7 +1910,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; } @@ -1925,12 +1925,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; } @@ -1987,7 +1987,7 @@ static char *cpr_name(MemoryRegion *mr) } } =20 -size_t qemu_ram_pagesize(RAMBlock *rb) +size_t qemu_ram_pagesize(const RAMBlock *rb) { return rb->page_size; } @@ -2772,7 +2772,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.53.0 From nobody Sat Apr 11 21:30:46 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=1773081382; cv=none; d=zohomail.com; s=zohoarc; b=NiR+mBfvmSHoscgYFVsX50AtRvETAX4dV3Xp5u0lLDwpAc9VgFFgeM4F3eKVQeskCBI9/1FHr0U508edLR06iEeqLqLSuRKo6v0V6B6MCpsRQbotNWP0g3clm4lFusYjnmtUbKlI9uu3X6YNADUYAIUZHiwwwz11LyL/FbRANtI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773081382; 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=UNqLEUifsz1cpFVFbx5viMkbYuuKYfbDoeHlGj5zHNY=; b=lK9J1NQKwrGvfrOSPd4aKmY45lLhhVe6ilVwTU5U0f3w3i1S0/rvsl1lKk7MOxaPAA8/H7wXPBWHOQesU/eguOlIoT4DCFwPfvoaxGvHdHzYeaKtzYzc/lAAl1S+LCqiBs2vmsJ08td/q0s23m0x5judygqrxCUkWqaXnS4Fjh4= 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 1773081382522443.9493626096569; Mon, 9 Mar 2026 11:36:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vzfSS-0007Hy-7Z; Mon, 09 Mar 2026 14:36:00 -0400 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 1vzfSP-0007Fr-Kg for qemu-devel@nongnu.org; Mon, 09 Mar 2026 14:35:57 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vzfSN-0003Vw-AJ for qemu-devel@nongnu.org; Mon, 09 Mar 2026 14:35:57 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-439b73f4ab4so8569116f8f.1 for ; Mon, 09 Mar 2026 11:35:54 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439dae3a20fsm28028805f8f.28.2026.03.09.11.35.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 09 Mar 2026 11:35:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1773081353; x=1773686153; 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=UNqLEUifsz1cpFVFbx5viMkbYuuKYfbDoeHlGj5zHNY=; b=nEvfLWKzgJkvdBMX+CRYWuyQBM6kLYFsxT3bWIvimpTykpiB0Mc3qKmxYI+U2gOT4k 80kP/kmc62jSmQNPiglMNfxczXO0L0lYGH6ESH7mVgFoh8E9VQlfLalDqBepPiPwRTHj 2JY3q3Neb+HsqaSYm3XnoutPCJpXIlx5paXJvCCm4EFkHB3oDeLzvpthQa5mmD8kBPPo eeyzQIU2Cmd0rANmgMcc4GQoGU6AGbxvC5wGprvFvQWfPlMu7PjptBWZDsiAOuTTkBkz gJ/+rZ8CxRdDq7lSGqdzMOuYNISA8wrm+QaGOztfuIZndAsL6ZSOM3rZKUpAdPXhcV2Y AhXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773081353; x=1773686153; 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=UNqLEUifsz1cpFVFbx5viMkbYuuKYfbDoeHlGj5zHNY=; b=u4NVd5bw6CbEXTOY4JntbmUYcvMmNvHMbgrXDEwz2XzX3JABAAdfNQHrZ57UT54w7J xOPY0GuMiknAXpKQoAsBsMAOLynaMbIiuxEVAvYo2ZmMWtj7yA7d7KhBxXzgP9XGAYG0 j5LY5MpFW38v2dYRG16GcuOhVUm9EoicCb+8Tq48ahWpced3Yp+zDtGxV8gri9nYKTr3 sKE5LIPHZ4QUIeb+9Ka7VtJR+IgTCSn9mY+RmyRZoW/qrND1KWukmv8Sag7jrMWdkPZX cyX0BXBXZ6qV02walZqB2PBhlgNvlx3ynpfosfC5jzxY60mASVoPxNpigs2RyfmCLePx Kyig== X-Gm-Message-State: AOJu0Yz9QYGEICfRx1ac/Au39DJlowL+iZrG6R5nD1vLLcimFyK3o7Fu se6FZCKhAFtCszWUb2BaTLMohzXVz2iMD6LvR8NwvlKUAiV0JJLIjguxWcjm2O3g39rG+lAcZsz VJpFx97s= X-Gm-Gg: ATEYQzyfxjJ8LX8l51m/fzr2zM89SucPhu3HNjqUVueCjhEK62K4AbalzvC1JfeEcom x7Dg9FSZ6uJ7NFhENPTpn/Kwe75A+HG1RMGfUmZigm7Ad5vPGsCs+pi/Yhbf/Xt/etFQddPPeh9 FAD7CqAM4uSpzEeypd+8/fvAD3j51XcCgoHUGY5FGG9zabQ+E36kI1PNTFpito0UhTMQ4emQGGU 3gwvq96dywSguqSK/2ZlF9x2LK8KYUfP1E//fVwemFm7Jm/+ZbBw0LXOulKwtB07D1S2kDe7z7t LHUmkcuJ8Y/5St7w76OoxjXM1KUo2fKKoavKmZfxgqfx4QMv1unBYLcO+Pv/zPCRAVahHQ04r78 MNqzzCilUHbTBzPj067UV89E6MdvoXw+T50soQ6kJg5Sv6cctT62CzyBqkHF8On9uKFWaQ3aMIu 4wP3ZaAgtHdJ/e/Wz/zxoPr87UWA/XlnUvmJQJSaZqmwzeYQJi2fSa0+FQjcjc314ufFbnQbAR X-Received: by 2002:a05:6000:704:b0:439:df5f:4220 with SMTP id ffacd0b85a97d-439df5f42f8mr17289075f8f.18.1773081353315; Mon, 09 Mar 2026 11:35:53 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , Anthony PERARD , xen-devel@lists.xenproject.org, Mark Cave-Ayland , Peter Xu , Richard Henderson , Pierrick Bouvier , Paolo Bonzini , "Edgar E. Iglesias" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefano Stabellini , Akihiko Odaki Subject: [PATCH v2 2/4] system/memory: Constify various MemoryRegion arguments Date: Mon, 9 Mar 2026 19:35:33 +0100 Message-ID: <20260309183536.88976-3-philmd@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260309183536.88976-1-philmd@linaro.org> References: <20260309183536.88976-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::42f; envelope-from=philmd@linaro.org; helo=mail-wr1-x42f.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: 1773081385650154100 Mark the MemoryRegion structure const when is only accessed read-only. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Reviewed-by: Peter Xu --- include/system/memory.h | 38 +++++++++++++++++++------------------- system/memory.c | 38 ++++++++++++++++++++------------------ system/physmem.c | 2 +- 3 files changed, 40 insertions(+), 38 deletions(-) diff --git a/include/system/memory.h b/include/system/memory.h index 0562af31361..6a04c46db37 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 @@ -2071,7 +2071,7 @@ MemoryRegion *memory_region_from_host(void *ptr, ram_= addr_t *offset); * * @mr: the memory region being queried. */ -void *memory_region_get_ram_ptr(MemoryRegion *mr); +void *memory_region_get_ram_ptr(const MemoryRegion *mr); =20 /* memory_region_ram_resize: Resize a RAM region. * @@ -2421,7 +2421,7 @@ void memory_region_add_subregion_overlap(MemoryRegion= *mr, * * @mr: the region to be queried */ -ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr); +ram_addr_t memory_region_get_ram_addr(const MemoryRegion *mr); =20 uint64_t memory_region_get_alignment(const MemoryRegion *mr); /** @@ -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 @@ -2967,7 +2967,7 @@ void *qemu_map_ram_ptr(RAMBlock *ram_block, ram_addr_= t addr); int memory_access_size(MemoryRegion *mr, unsigned l, hwaddr addr); bool prepare_mmio_access(MemoryRegion *mr); =20 -static inline bool memory_region_supports_direct_access(MemoryRegion *mr) +static inline bool memory_region_supports_direct_access(const MemoryRegion= *mr) { /* ROM DEVICE regions only allow direct access if in ROMD mode. */ if (memory_region_is_romd(mr)) { @@ -2984,8 +2984,8 @@ static inline bool memory_region_supports_direct_acce= ss(MemoryRegion *mr) return !memory_region_is_ram_device(mr); } =20 -static inline bool memory_access_is_direct(MemoryRegion *mr, bool is_write, - MemTxAttrs attrs) +static inline bool memory_access_is_direct(const MemoryRegion *mr, + bool is_write, MemTxAttrs attrs) { if (!memory_region_supports_direct_access(mr)) { return false; diff --git a/system/memory.c b/system/memory.c index c51d0798a84..b130d956d4e 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) { @@ -2415,7 +2415,7 @@ int memory_region_get_fd(MemoryRegion *mr) return mr->ram_block->fd; } =20 -void *memory_region_get_ram_ptr(MemoryRegion *mr) +void *memory_region_get_ram_ptr(const MemoryRegion *mr) { uint64_t offset =3D 0; =20 @@ -2440,7 +2440,7 @@ MemoryRegion *memory_region_from_host(void *ptr, ram_= addr_t *offset) return block->mr; } =20 -ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr) +ram_addr_t memory_region_get_ram_addr(const MemoryRegion *mr) { return mr->ram_block ? mr->ram_block->offset : RAM_ADDR_INVALID; } @@ -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 diff --git a/system/physmem.c b/system/physmem.c index e5390d09bef..4a9e0760045 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -1975,7 +1975,7 @@ void qemu_ram_unset_idstr(RAMBlock *block) } } =20 -static char *cpr_name(MemoryRegion *mr) +static char *cpr_name(const MemoryRegion *mr) { const char *mr_name =3D memory_region_name(mr); g_autofree char *id =3D mr->dev ? qdev_get_dev_path(mr->dev) : NULL; --=20 2.53.0 From nobody Sat Apr 11 21:30:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1773081373; cv=none; d=zohomail.com; s=zohoarc; b=hyB//ak7CF3eKVPvPAQxcmCMct/p8XER2yZZ4o/hANLGmeq3bqqziuKwPnhU57vwB8QBXOls439DbyF04KPg7fgQhADZT7qgWcG5eeYe/d1gFsNN5Fwe+x0MpHXCB2arhzkXhEKfB0boCc3Qx9vi3a6VVUmktSwJaubNQ75VlFA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773081373; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=frENE9FJEJIJp1aKXCLyQE1na5fHvR5E0RLXQsidK/I=; b=LPVeQAjF1Hu9P51ihZXgXAQ4C9SfvdlMsEsuVZVTRveOiIAnHOtNPxnHzc/RvOZKhXSWr+K6cxdfj6IYpEM8S3hgqa9HE/8raK3bdM/jFny+2P3lFeL3PuLitYfkhtOHACBlyKUMKtkUiwaHlhx4ueuPfRf4hYBrfgELYzfU5ag= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1773081373580532.0774875769308; Mon, 9 Mar 2026 11:36:13 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1249626.1547098 (Exim 4.92) (envelope-from ) id 1vzfSU-0008BU-Jz; Mon, 09 Mar 2026 18:36:02 +0000 Received: by outflank-mailman (output) from mailman id 1249626.1547098; Mon, 09 Mar 2026 18:36:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vzfSU-0008BK-H2; Mon, 09 Mar 2026 18:36:02 +0000 Received: by outflank-mailman (input) for mailman id 1249626; Mon, 09 Mar 2026 18:36:01 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vzfST-0007JG-SA for xen-devel@lists.xenproject.org; Mon, 09 Mar 2026 18:36:01 +0000 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [2a00:1450:4864:20::332]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d23a8f3a-1be6-11f1-b164-2bf370ae4941; Mon, 09 Mar 2026 19:36:01 +0100 (CET) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4852afd42ceso28017405e9.2 for ; Mon, 09 Mar 2026 11:36:01 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439dad977f8sm28487057f8f.9.2026.03.09.11.35.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 09 Mar 2026 11:35:59 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d23a8f3a-1be6-11f1-b164-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1773081360; x=1773686160; darn=lists.xenproject.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=frENE9FJEJIJp1aKXCLyQE1na5fHvR5E0RLXQsidK/I=; b=os2dCYM2iWuRmBmvtuR6wM13CdxyRW3KIePfht+f1sk+yiLI56doQBPzj4ypfiDw64 WPcYrFF6zb8b8aGH3dvw17K0Acu/JV0oBdhiWpDkslu9FS7NmyD40wdhme3M1Y3qgq3j 2g08aNgFkuW5W/47CiDKxSwaHy9gCSQSmH6W3xbJpPaovvFLzlX4MxsuZf6d9cgefu3f QcL9pzdOVxHTZdN3wvdUBBHbNZ14kolnEzDsPSkjwWdGkBN2/oTmZJdv7YOkxtZHIFL8 fVYQ3tEcYxhRrwxlg+UsD7N4frQ1KtFPv9pj3IciXXkz/yseuNulVNnpXBQPwko1PAQF Rf2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773081360; x=1773686160; 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=frENE9FJEJIJp1aKXCLyQE1na5fHvR5E0RLXQsidK/I=; b=hDgi6V2WqLex5z+mCq2HIC4UqaoMEbBTSQGPgFqirdQ2iL06r+yDpsmhwVJlPXSsxD nldTNBxYQKzNZWjtryd99PjYA7rd/JBnD85rkfDHoomnGygHjw88mm4NSv0NNp8ACM4T J+axL2A1IodAj2roe8CnoCUYNWUyuq/O22COsPxInvDaF8qo3/7iFfl3p25/iiyYHY+8 tb4CaiAr/1A1N7z6JLR8r6wQM4doYSYKd41EoorzVKT8lv1oMXF5UoTerWJkI+oh2nWa AQ9vcc+9Zs/W5bREA7/xDDE38IgQ/dM24lkR8n/yt9IG+sQAg+C6hhNu+GJVtK8Llxet zBHQ== X-Forwarded-Encrypted: i=1; AJvYcCWPZ1CdnEN7/jcPMY71qqDgwjQfEpRLJ2t3AZgIuHOzQboRLT292qHLbKn3//3ezjLnOJFxomkxcsk=@lists.xenproject.org X-Gm-Message-State: AOJu0YxIqN84mLl532odponTioOswoDGM9dpz1D/gdFBcUC6wa9Mlxpr +w9iBFf73L4RHjSfDqIBIuxwty3NZ9CzkBTlRMtAy34WyMKA0IuqhxY1UeWC4qgBJZ8= X-Gm-Gg: ATEYQzxrVAS7jPaNI7KyP8iKbxfbxXY8ckqudVHh4HU/grU28WaXHeuJGpDDMImrNGy Pez1PHz4TRGrg4ZF0EIwGDXqrWlybew1ykjKOabgvWg16NjyhoSQmq0M6tp98RU26PPosMLbp5s Zl8uvJRRTilXuHMilQOgCUzyZTQEBpu3dYX9zcHvuJ01HP092MxvYcs6QwCvTNnaUwCG54uLLja DFO99wAuc1s9xYAjkUwE5OkwcghagyRk/LFfF1mqksvIZUTiFk0iRNMgG65sghDByx/+iaX6tfY vUIQ5xGiY8Q/zOmpHWz1kq6aEtE79HZeZtivyd9VHLpzWeoYYUS/UBW3GJOLMpzW1QvagvAgoU2 GrCcMbWpdP35G4EhqySPIsGiDeM4jk+LWzAbYCzXYC1+7kdrUQHR0H2T7PQQPX6lg0j4znAPn0W fRE046Zk0Q6qhsgumo8TnBk87PenROxv/rHdLMwP4z/oIBr2lLjY5oyHouLVloSROI9OU/eMbE X-Received: by 2002:a05:6000:2681:b0:439:be4e:6e58 with SMTP id ffacd0b85a97d-439da891d17mr20945001f8f.47.1773081360467; Mon, 09 Mar 2026 11:36:00 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , Anthony PERARD , xen-devel@lists.xenproject.org, Mark Cave-Ayland , Peter Xu , Richard Henderson , Pierrick Bouvier , Paolo Bonzini , "Edgar E. Iglesias" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefano Stabellini , Akihiko Odaki Subject: [PATCH v2 3/4] system/xen: Constify various MemoryRegion arguments Date: Mon, 9 Mar 2026 19:35:34 +0100 Message-ID: <20260309183536.88976-4-philmd@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260309183536.88976-1-philmd@linaro.org> References: <20260309183536.88976-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1773081386412158500 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/xen-mapcache.h | 2 +- include/system/xen.h | 6 +++--- hw/xen/xen-hvm-common.c | 8 ++++---- hw/xen/xen-mapcache.c | 2 +- hw/xen/xen_stubs.c | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/system/xen-mapcache.h b/include/system/xen-mapcache.h index c46190dd0ce..114d1929c80 100644 --- a/include/system/xen-mapcache.h +++ b/include/system/xen-mapcache.h @@ -16,7 +16,7 @@ typedef hwaddr (*phys_offset_to_gaddr_t)(hwaddr phys_offs= et, bool xen_map_cache_enabled(void); void xen_map_cache_init(phys_offset_to_gaddr_t f, void *opaque); -uint8_t *xen_map_cache(MemoryRegion *mr, hwaddr phys_addr, hwaddr size, +uint8_t *xen_map_cache(const MemoryRegion *mr, hwaddr phys_addr, hwaddr si= ze, ram_addr_t ram_addr_offset, uint8_t lock, bool dma, bool is_write); diff --git a/include/system/xen.h b/include/system/xen.h index 9a7c53f2838..43b857e4d15 100644 --- a/include/system/xen.h +++ b/include/system/xen.h @@ -30,7 +30,7 @@ extern bool xen_allowed; =20 void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length); void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, - struct MemoryRegion *mr, Error **errp); -bool xen_mr_is_memory(MemoryRegion *mr); -bool xen_mr_is_grants(MemoryRegion *mr); + const MemoryRegion *mr, Error **errp); +bool xen_mr_is_memory(const MemoryRegion *mr); +bool xen_mr_is_grants(const MemoryRegion *mr); #endif diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c index eb7f6270a0d..62d88804c43 100644 --- a/hw/xen/xen-hvm-common.c +++ b/hw/xen/xen-hvm-common.c @@ -23,19 +23,19 @@ MemoryRegion xen_memory, xen_grants; =20 /* Check for any kind of xen memory, foreign mappings or grants. */ -bool xen_mr_is_memory(MemoryRegion *mr) +bool xen_mr_is_memory(const MemoryRegion *mr) { return mr =3D=3D &xen_memory || mr =3D=3D &xen_grants; } =20 /* Check specifically for grants. */ -bool xen_mr_is_grants(MemoryRegion *mr) +bool xen_mr_is_grants(const MemoryRegion *mr) { return mr =3D=3D &xen_grants; } =20 -void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr, - Error **errp) +void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, + const MemoryRegion *mr, Error **errp) { unsigned target_page_bits =3D qemu_target_page_bits(); unsigned long nr_pfn; diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c index a3c162cd4c6..85cf0cf359c 100644 --- a/hw/xen/xen-mapcache.c +++ b/hw/xen/xen-mapcache.c @@ -460,7 +460,7 @@ tryagain: return mc->last_entry->vaddr_base + address_offset; } =20 -uint8_t *xen_map_cache(MemoryRegion *mr, +uint8_t *xen_map_cache(const MemoryRegion *mr, hwaddr phys_addr, hwaddr size, ram_addr_t ram_addr_offset, uint8_t lock, bool dma, diff --git a/hw/xen/xen_stubs.c b/hw/xen/xen_stubs.c index a39efb5062d..f830768d998 100644 --- a/hw/xen/xen_stubs.c +++ b/hw/xen/xen_stubs.c @@ -19,12 +19,12 @@ void xen_hvm_modified_memory(ram_addr_t start, ram_addr= _t length) } =20 void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, - struct MemoryRegion *mr, Error **errp) + const MemoryRegion *mr, Error **errp) { g_assert_not_reached(); } =20 -bool xen_mr_is_memory(MemoryRegion *mr) +bool xen_mr_is_memory(const MemoryRegion *mr) { g_assert_not_reached(); } @@ -44,7 +44,7 @@ ram_addr_t xen_ram_addr_from_mapcache(void *ptr) g_assert_not_reached(); } =20 -uint8_t *xen_map_cache(MemoryRegion *mr, +uint8_t *xen_map_cache(const MemoryRegion *mr, hwaddr phys_addr, hwaddr size, ram_addr_t ram_addr_offset, --=20 2.53.0 From nobody Sat Apr 11 21:30:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1773081383; cv=none; d=zohomail.com; s=zohoarc; b=YgRftW7+YxUw3yGbMwKIR4UfIacOXb1mcaYskrY1LLjn24zxCeFfTLd1jhSK78/63rX9DTaXH1eqoTTp57OO2z7tVWwVPHO+D2Bg8sH/eQj1SFGhXwBDZhqw/Qk3Wc9sbzXO6mL2MoLTvCjExjk74VeJ6NrDr80zN+2IptQZYj8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773081383; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bIEbHx6YI4gBPOp+3pEqRYyaYkjjh/Mj9wYvLwhU6C8=; b=GpoX4whuo8E1EXBKfpqjNQPeTsyiRdAUy1CwI8SQL5M6Hxsxtf9cz29PKoUqpgkP/7TIWK9MK+vJCfPTz7SILwvGTknsNRlbJmiAB+JlS7qzISOZNq1xn8cQB6EQwMPJQ2LLWVMSw1u5cC2B0AaqIiXxd5X9PkiQNZWu6qY/dXM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1773081383542729.3971226064492; Mon, 9 Mar 2026 11:36:23 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1249634.1547108 (Exim 4.92) (envelope-from ) id 1vzfSc-0000FY-Uk; Mon, 09 Mar 2026 18:36:10 +0000 Received: by outflank-mailman (output) from mailman id 1249634.1547108; Mon, 09 Mar 2026 18:36:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vzfSc-0000FL-RM; Mon, 09 Mar 2026 18:36:10 +0000 Received: by outflank-mailman (input) for mailman id 1249634; Mon, 09 Mar 2026 18:36:10 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vzfSc-0007ml-09 for xen-devel@lists.xenproject.org; Mon, 09 Mar 2026 18:36:10 +0000 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [2a00:1450:4864:20::32f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d6836500-1be6-11f1-9ccf-f158ae23cfc8; Mon, 09 Mar 2026 19:36:08 +0100 (CET) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-48534b59cf3so13527755e9.2 for ; Mon, 09 Mar 2026 11:36:08 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439dad8dbb3sm25412105f8f.4.2026.03.09.11.36.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 09 Mar 2026 11:36:07 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d6836500-1be6-11f1-9ccf-f158ae23cfc8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1773081368; x=1773686168; darn=lists.xenproject.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=bIEbHx6YI4gBPOp+3pEqRYyaYkjjh/Mj9wYvLwhU6C8=; b=aPaJeDnuDxPPuL19l9GAwpuXdgxNkYHXJtb3gKMJ3RWbVJCmv4aRLhvJ+UBKwvLowv N3LaBNI7o5TDhpQiIog8ZQAPzkiWZLLIiVEUf1fwJMNHEP+16Hu8M9SchebZto+DV7KI f1m8b7m45Pg3eDpxdR2ZhqzPGYo1QOWo5SaGf+w7h2EXMRswKarQK3wSbT0swMzEbAuY 1ark1aw1B0Wh/nPw6yGAuvnCNdkuK38spmbEeaSKvza+mN+sKDN3T4WymUvLsiQ8AOGJ jdv8SP8NAz1vZ6wftmJfWyJXDLA8J71/5SVVzFRkmjxfrxrnVXzsvWTmaKOvWR9DtwPa N0eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773081368; x=1773686168; 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=bIEbHx6YI4gBPOp+3pEqRYyaYkjjh/Mj9wYvLwhU6C8=; b=gWioS4uBy8bCZaZW1FjQxH2iay7OWwS57pmUJ2jGAK4NhWon+q7VeI8Ti0xXBX7BPD 8bmMSOZ+FpivwoddLqC3palPxrsOAwY1QFEX02dSXqBN5+oJBq5H/KS/Ux9RUcOmw5Nu v6pPTKeMXyb29CVCQL8lMtV3hLP13Z/9D1tcHe6Basl0cmhcVn6CFbUfXS8c5f0kcaYF rlsVYpedvxV2wX/hQx2wlD3o0XAVE+qv8vdPOLqd/38AA6MpXU/PSuixv6p21hdKYzQx PwARTmtTgORj7PLLw+5P2mkT508Ke9xY1fmpCRaa5Ya0BAMSQ9sTiE/g4aep7rzBmyef QwNA== X-Forwarded-Encrypted: i=1; AJvYcCXXzAdKu2zvWqNjPjrcrt4Vwso+2TxueXSbPfKNqfYRoPfXM1keKIVSWyV4ek74UG68sNwM/ffMHRY=@lists.xenproject.org X-Gm-Message-State: AOJu0Yx9EwmoAPFaDy/5XOhB2yf/WrABGerxWzuVn06PSxXM6zNbdpQ/ hK0iNfrcOJz6qvXSW5VONCNMDH3zpnGkB1npVJoRI3OEVKhn/IEF0/KLtYVNNO4Ewxk8X6LTmdt jxU4o8jE= X-Gm-Gg: ATEYQzwAFYQRIyd+QE4WNKdc31vohrKlWRspmrOLQUIzYwy/lWxH5Rz331kLKlx7yUf Ig1uzFbZMyzStuXkonSEg2qriqJppteI91nabeIl/kxvrU6F+DLJNX0nzpD5ezGUhSuUhb6dyGS ZXsWjwqlUag2qbKNJNn2wDjkDojcSBedQEaUbJSDJ9qLOJpw+xt4WuzKL0KTeiHz+Ype4+iI9Ed /iHUdQTJ2kLAvIbavZa6mWiXyugQNnK5YXPLymZ++QGc1wrtaA06VZUMYusU8lOMn7pf4UlKNN0 FYv3e+f1ckkVO44o1LArWpBgbrqihJhzpmG/WYDjes3RM0e54Po3F1kBd91EgnMNphk7k23FC2n h1xoyAoxOYyh/h2SDFdaksY7T3czKR3njK5JWvgXwzb24aK+G1XmKDXALjWKRXllkrCjIcjGNLg CAY8PzFVCTFsIzPfYBpeNkGl5Qlk6SD17Hks7V0e7VgjT2b7sxHp3p5sH8IBlS8v1HIaDocWM3 X-Received: by 2002:a05:6000:604:b0:439:b715:6f4b with SMTP id ffacd0b85a97d-439da8a78d1mr22493963f8f.57.1773081367549; Mon, 09 Mar 2026 11:36:07 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , Anthony PERARD , xen-devel@lists.xenproject.org, Mark Cave-Ayland , Peter Xu , Richard Henderson , Pierrick Bouvier , Paolo Bonzini , "Edgar E. Iglesias" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefano Stabellini , Akihiko Odaki Subject: [PATCH v2 4/4] system/memory: Have memory_region_type() correctly describe containers Date: Mon, 9 Mar 2026 19:35:35 +0100 Message-ID: <20260309183536.88976-5-philmd@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260309183536.88976-1-philmd@linaro.org> References: <20260309183536.88976-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1773081386355158500 MemoryRegion containers are not I/O regions, describe them as 'container'. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Reviewed-by: Peter Xu --- system/memory.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/system/memory.c b/system/memory.c index b130d956d4e..2f2f96ab046 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.53.0