exec: Let address_space_read/write_cached() propagate MemTxResult

Both address_space_read_cached_slow() and
address_space_write_cached_slow() return a MemTxResult type.
Do not discard it, return it to the caller.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Philippe Mathieu-Daudé 2020-05-18 17:53:02 +02:00 committed by Paolo Bonzini
parent c535d68755
commit 38df19fad7
2 changed files with 19 additions and 16 deletions

8
exec.c
View File

@ -3718,7 +3718,7 @@ static inline MemoryRegion *address_space_translate_cached(
/* Called from RCU critical section. address_space_read_cached uses this /* Called from RCU critical section. address_space_read_cached uses this
* out of line function when the target is an MMIO or IOMMU region. * out of line function when the target is an MMIO or IOMMU region.
*/ */
void MemTxResult
address_space_read_cached_slow(MemoryRegionCache *cache, hwaddr addr, address_space_read_cached_slow(MemoryRegionCache *cache, hwaddr addr,
void *buf, hwaddr len) void *buf, hwaddr len)
{ {
@ -3728,7 +3728,7 @@ address_space_read_cached_slow(MemoryRegionCache *cache, hwaddr addr,
l = len; l = len;
mr = address_space_translate_cached(cache, addr, &addr1, &l, false, mr = address_space_translate_cached(cache, addr, &addr1, &l, false,
MEMTXATTRS_UNSPECIFIED); MEMTXATTRS_UNSPECIFIED);
flatview_read_continue(cache->fv, return flatview_read_continue(cache->fv,
addr, MEMTXATTRS_UNSPECIFIED, buf, len, addr, MEMTXATTRS_UNSPECIFIED, buf, len,
addr1, l, mr); addr1, l, mr);
} }
@ -3736,7 +3736,7 @@ address_space_read_cached_slow(MemoryRegionCache *cache, hwaddr addr,
/* Called from RCU critical section. address_space_write_cached uses this /* Called from RCU critical section. address_space_write_cached uses this
* out of line function when the target is an MMIO or IOMMU region. * out of line function when the target is an MMIO or IOMMU region.
*/ */
void MemTxResult
address_space_write_cached_slow(MemoryRegionCache *cache, hwaddr addr, address_space_write_cached_slow(MemoryRegionCache *cache, hwaddr addr,
const void *buf, hwaddr len) const void *buf, hwaddr len)
{ {
@ -3746,7 +3746,7 @@ address_space_write_cached_slow(MemoryRegionCache *cache, hwaddr addr,
l = len; l = len;
mr = address_space_translate_cached(cache, addr, &addr1, &l, true, mr = address_space_translate_cached(cache, addr, &addr1, &l, true,
MEMTXATTRS_UNSPECIFIED); MEMTXATTRS_UNSPECIFIED);
flatview_write_continue(cache->fv, return flatview_write_continue(cache->fv,
addr, MEMTXATTRS_UNSPECIFIED, buf, len, addr, MEMTXATTRS_UNSPECIFIED, buf, len,
addr1, l, mr); addr1, l, mr);
} }

View File

@ -2354,10 +2354,11 @@ void *qemu_map_ram_ptr(RAMBlock *ram_block, ram_addr_t addr);
/* Internal functions, part of the implementation of address_space_read_cached /* Internal functions, part of the implementation of address_space_read_cached
* and address_space_write_cached. */ * and address_space_write_cached. */
void address_space_read_cached_slow(MemoryRegionCache *cache, MemTxResult address_space_read_cached_slow(MemoryRegionCache *cache,
hwaddr addr, void *buf, hwaddr len); hwaddr addr, void *buf, hwaddr len);
void address_space_write_cached_slow(MemoryRegionCache *cache, MemTxResult address_space_write_cached_slow(MemoryRegionCache *cache,
hwaddr addr, const void *buf, hwaddr len); hwaddr addr, const void *buf,
hwaddr len);
static inline bool memory_access_is_direct(MemoryRegion *mr, bool is_write) static inline bool memory_access_is_direct(MemoryRegion *mr, bool is_write)
{ {
@ -2422,15 +2423,16 @@ MemTxResult address_space_read(AddressSpace *as, hwaddr addr,
* @buf: buffer with the data transferred * @buf: buffer with the data transferred
* @len: length of the data transferred * @len: length of the data transferred
*/ */
static inline void static inline MemTxResult
address_space_read_cached(MemoryRegionCache *cache, hwaddr addr, address_space_read_cached(MemoryRegionCache *cache, hwaddr addr,
void *buf, hwaddr len) void *buf, hwaddr len)
{ {
assert(addr < cache->len && len <= cache->len - addr); assert(addr < cache->len && len <= cache->len - addr);
if (likely(cache->ptr)) { if (likely(cache->ptr)) {
memcpy(buf, cache->ptr + addr, len); memcpy(buf, cache->ptr + addr, len);
return MEMTX_OK;
} else { } else {
address_space_read_cached_slow(cache, addr, buf, len); return address_space_read_cached_slow(cache, addr, buf, len);
} }
} }
@ -2442,15 +2444,16 @@ address_space_read_cached(MemoryRegionCache *cache, hwaddr addr,
* @buf: buffer with the data transferred * @buf: buffer with the data transferred
* @len: length of the data transferred * @len: length of the data transferred
*/ */
static inline void static inline MemTxResult
address_space_write_cached(MemoryRegionCache *cache, hwaddr addr, address_space_write_cached(MemoryRegionCache *cache, hwaddr addr,
const void *buf, hwaddr len) const void *buf, hwaddr len)
{ {
assert(addr < cache->len && len <= cache->len - addr); assert(addr < cache->len && len <= cache->len - addr);
if (likely(cache->ptr)) { if (likely(cache->ptr)) {
memcpy(cache->ptr + addr, buf, len); memcpy(cache->ptr + addr, buf, len);
return MEMTX_OK;
} else { } else {
address_space_write_cached_slow(cache, addr, buf, len); return address_space_write_cached_slow(cache, addr, buf, len);
} }
} }