All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Mohamed Mediouni" <mohamed@unpredictable.fr>,
	"Anthony PERARD" <anthony@xenproject.org>,
	xen-devel@lists.xenproject.org,
	"Mark Cave-Ayland" <mark.caveayland@nutanix.com>,
	"Peter Xu" <peterx@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Akihiko Odaki" <odaki@rsg.ci.i.u-tokyo.ac.jp>
Subject: [PATCH v2 3/4] system/xen: Constify various MemoryRegion arguments
Date: Mon,  9 Mar 2026 19:35:34 +0100	[thread overview]
Message-ID: <20260309183536.88976-4-philmd@linaro.org> (raw)
In-Reply-To: <20260309183536.88976-1-philmd@linaro.org>

Mark the MemoryRegion structure const when is only accessed read-only.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 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_offset,
 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 size,
                        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;
 
 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;
 
 /* 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 == &xen_memory || mr == &xen_grants;
 }
 
 /* Check specifically for grants.  */
-bool xen_mr_is_grants(MemoryRegion *mr)
+bool xen_mr_is_grants(const MemoryRegion *mr)
 {
     return mr == &xen_grants;
 }
 
-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 = 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;
 }
 
-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)
 }
 
 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();
 }
 
-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();
 }
 
-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,
-- 
2.53.0



  parent reply	other threads:[~2026-03-09 18:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-09 18:35 [PATCH v2 0/4] system/memory: Constify various RAMBlock/MemoryRegion arguments Philippe Mathieu-Daudé
2026-03-09 18:35 ` [PATCH v2 1/4] system/ramblock: Constify various RAMBlock arguments Philippe Mathieu-Daudé
2026-03-09 18:35 ` [PATCH v2 2/4] system/memory: Constify various MemoryRegion arguments Philippe Mathieu-Daudé
2026-03-09 18:35 ` Philippe Mathieu-Daudé [this message]
2026-03-09 18:37   ` [PATCH v2 3/4] system/xen: " Pierrick Bouvier
2026-03-09 18:35 ` [PATCH v2 4/4] system/memory: Have memory_region_type() correctly describe containers Philippe Mathieu-Daudé
2026-03-09 19:28 ` [PATCH v2 0/4] system/memory: Constify various RAMBlock/MemoryRegion arguments Peter Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260309183536.88976-4-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=anthony@xenproject.org \
    --cc=edgar.iglesias@gmail.com \
    --cc=mark.caveayland@nutanix.com \
    --cc=mohamed@unpredictable.fr \
    --cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.