mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 07:13:54 -06:00
unify len and addr type for memory/address APIs
Some address/memory APIs have different type between 'hwaddr/target_ulong addr' and 'int len'. It is very unsafe, especially some APIs will be passed a non-int len by caller which might cause overflow quietly. Below is an potential overflow case: dma_memory_read(uint32_t len) -> dma_memory_rw(uint32_t len) -> dma_memory_rw_relaxed(uint32_t len) -> address_space_rw(int len) # len overflow CC: Paolo Bonzini <pbonzini@redhat.com> CC: Peter Crosthwaite <crosthwaite.peter@gmail.com> CC: Richard Henderson <rth@twiddle.net> CC: Peter Maydell <peter.maydell@linaro.org> CC: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
b86d01ba47
commit
0c249ff71c
4 changed files with 39 additions and 40 deletions
|
@ -83,14 +83,14 @@ size_t qemu_ram_pagesize(RAMBlock *block);
|
|||
size_t qemu_ram_pagesize_largest(void);
|
||||
|
||||
void cpu_physical_memory_rw(hwaddr addr, uint8_t *buf,
|
||||
int len, int is_write);
|
||||
hwaddr len, int is_write);
|
||||
static inline void cpu_physical_memory_read(hwaddr addr,
|
||||
void *buf, int len)
|
||||
void *buf, hwaddr len)
|
||||
{
|
||||
cpu_physical_memory_rw(addr, buf, len, 0);
|
||||
}
|
||||
static inline void cpu_physical_memory_write(hwaddr addr,
|
||||
const void *buf, int len)
|
||||
const void *buf, hwaddr len)
|
||||
{
|
||||
cpu_physical_memory_rw(addr, (void *)buf, len, 1);
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ bool cpu_physical_memory_is_io(hwaddr phys_addr);
|
|||
*/
|
||||
void qemu_flush_coalesced_mmio_buffer(void);
|
||||
|
||||
void cpu_flush_icache_range(hwaddr start, int len);
|
||||
void cpu_flush_icache_range(hwaddr start, hwaddr len);
|
||||
|
||||
extern struct MemoryRegion io_mem_rom;
|
||||
extern struct MemoryRegion io_mem_notdirty;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue