@samitouri / QOSamiQemu / commits / 47b23339a5

system/memory: Constify various AddressSpace arguments (access)

Mark the AddressSpace structure const when it is only accessed read-only. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20260616020359.18627-6-philmd@oss.qualcomm.com>

Philippe Mathieu-Daudé committed Mar 19, 2026 at 13:31 UTC 47b23339a5bba927bca49a08b67e6a7a69e61639
2 files changed +15 -12
include/system/memory.h
+7 -6
@@ -2719,7 +2719,7 @@ void address_space_remove_listeners(const AddressSpace *as);
2719 * @len: the number of bytes to read or write
2720 * @is_write: indicates the transfer direction
2721 */
2722 -MemTxResult address_space_rw(AddressSpace *as, hwaddr addr,
2722 +MemTxResult address_space_rw(const AddressSpace *as, hwaddr addr,
2723 MemTxAttrs attrs, void *buf,
2724 hwaddr len, bool is_write);
2725
@@ -2736,7 +2736,7 @@ MemTxResult address_space_rw(AddressSpace *as, hwaddr addr,
2736 * @buf: buffer with the data transferred
2737 * @len: the number of bytes to write
2738 */
2739 -MemTxResult address_space_write(AddressSpace *as, hwaddr addr,
2739 +MemTxResult address_space_write(const AddressSpace *as, hwaddr addr,
2740 MemTxAttrs attrs,
2741 const void *buf, hwaddr len);
2742
@@ -2799,7 +2799,8 @@ MemTxResult address_space_write_rom(AddressSpace *as, hwaddr addr,
2799 #include "system/memory_ldst_phys.h.inc"
2800 #endif
2801
2802 -void address_space_flush_icache_range(AddressSpace *as, hwaddr addr, hwaddr len);
2802 +void address_space_flush_icache_range(AddressSpace *as,
2803 + hwaddr addr, hwaddr len);
2804
2805 /* address_space_get_iotlb_entry: translate an address into an IOTLB
2806 * entry. Should be called from an RCU critical section.
@@ -2919,7 +2920,7 @@ void address_space_register_map_client(AddressSpace *as, QEMUBH *bh);
2920 void address_space_unregister_map_client(AddressSpace *as, QEMUBH *bh);
2921
2922 /* Internal functions, part of the implementation of address_space_read. */
2922 -MemTxResult address_space_read_full(AddressSpace *as, hwaddr addr,
2923 +MemTxResult address_space_read_full(const AddressSpace *as, hwaddr addr,
2924 MemTxAttrs attrs, void *buf, hwaddr len);
2925 MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr,
2926 MemTxAttrs attrs, void *buf,
@@ -2974,7 +2975,7 @@ static inline bool memory_access_is_direct(const MemoryRegion *mr,
2975 * @len: length of the data transferred
2976 */
2977 static inline __attribute__((__always_inline__))
2977 -MemTxResult address_space_read(AddressSpace *as, hwaddr addr,
2978 +MemTxResult address_space_read(const AddressSpace *as, hwaddr addr,
2979 MemTxAttrs attrs, void *buf,
2980 hwaddr len)
2981 {
@@ -3017,7 +3018,7 @@ MemTxResult address_space_read(AddressSpace *as, hwaddr addr,
3018 * @len: the number of bytes to fill with the constant byte
3019 * @attrs: memory transaction attributes
3020 */
3020 -MemTxResult address_space_set(AddressSpace *as, hwaddr addr,
3021 +MemTxResult address_space_set(const AddressSpace *as, hwaddr addr,
3022 uint8_t c, hwaddr len, MemTxAttrs attrs);
3023
3024 /* Coalesced MMIO regions are areas where write operations can be reordered.
system/physmem.c
+8 -6
@@ -3416,7 +3416,7 @@ static MemTxResult flatview_read(FlatView *fv, hwaddr addr,
3416 mr_addr, l, mr);
3417 }
3418
3419 -MemTxResult address_space_read_full(AddressSpace *as, hwaddr addr,
3419 +MemTxResult address_space_read_full(const AddressSpace *as, hwaddr addr,
3420 MemTxAttrs attrs, void *buf, hwaddr len)
3421 {
3422 MemTxResult result = MEMTX_OK;
@@ -3431,7 +3431,7 @@ MemTxResult address_space_read_full(AddressSpace *as, hwaddr addr,
3431 return result;
3432 }
3433
3434 -MemTxResult address_space_write(AddressSpace *as, hwaddr addr,
3434 +MemTxResult address_space_write(const AddressSpace *as, hwaddr addr,
3435 MemTxAttrs attrs,
3436 const void *buf, hwaddr len)
3437 {
@@ -3447,8 +3447,9 @@ MemTxResult address_space_write(AddressSpace *as, hwaddr addr,
3447 return result;
3448 }
3449
3450 -MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, MemTxAttrs attrs,
3451 - void *buf, hwaddr len, bool is_write)
3450 +MemTxResult address_space_rw(const AddressSpace *as, hwaddr addr,
3451 + MemTxAttrs attrs, void *buf,
3452 + hwaddr len, bool is_write)
3453 {
3454 if (is_write) {
3455 return address_space_write(as, addr, attrs, buf, len);
@@ -3457,7 +3458,7 @@ MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, MemTxAttrs attrs,
3458 }
3459 }
3460
3460 -MemTxResult address_space_set(AddressSpace *as, hwaddr addr,
3461 +MemTxResult address_space_set(const AddressSpace *as, hwaddr addr,
3462 uint8_t c, hwaddr len, MemTxAttrs attrs)
3463 {
3464 #define FILLBUF_SIZE 512
@@ -3514,7 +3515,8 @@ MemTxResult address_space_write_rom(AddressSpace *as, hwaddr addr,
3515 return MEMTX_OK;
3516 }
3517
3517 -void address_space_flush_icache_range(AddressSpace *as, hwaddr addr, hwaddr len)
3518 +void address_space_flush_icache_range(AddressSpace *as,
3519 + hwaddr addr, hwaddr len)
3520 {
3521 /*
3522 * This function should do the same thing as an icache flush that was