From: "Edgar E. Iglesias" <[email protected]> Assert that the mapcache was created prior to being used.
Signed-off-by: Edgar E. Iglesias <[email protected]> --- hw/xen/xen-mapcache.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c index 11115f6084..517e5171b7 100644 --- a/hw/xen/xen-mapcache.c +++ b/hw/xen/xen-mapcache.c @@ -464,6 +464,8 @@ uint8_t *xen_map_cache(MemoryRegion *mr, MapCache *mc = mapcache; uint8_t *p; + assert(mapcache); + if (grant) { mc = is_write ? mapcache_grants_rw : mapcache_grants_ro; } @@ -530,6 +532,8 @@ ram_addr_t xen_ram_addr_from_mapcache(void *ptr) { ram_addr_t addr; + assert(mapcache); + addr = xen_ram_addr_from_mapcache_single(mapcache, ptr); if (addr == RAM_ADDR_INVALID) { addr = xen_ram_addr_from_mapcache_single(mapcache_grants_ro, ptr); @@ -652,6 +656,8 @@ static void xen_invalidate_map_cache_entry_bh(void *opaque) void coroutine_mixed_fn xen_invalidate_map_cache_entry(uint8_t *buffer) { + assert(mapcache); + if (qemu_in_coroutine()) { XenMapCacheData data = { .co = qemu_coroutine_self(), @@ -709,6 +715,8 @@ static void xen_invalidate_map_cache_single(MapCache *mc) void xen_invalidate_map_cache(void) { + assert(mapcache); + /* Flush pending AIO before destroying the mapcache */ bdrv_drain_all(); @@ -776,6 +784,8 @@ uint8_t *xen_replace_cache_entry(hwaddr old_phys_addr, { uint8_t *p; + assert(mapcache); + mapcache_lock(mapcache); p = xen_replace_cache_entry_unlocked(mapcache, old_phys_addr, new_phys_addr, size); -- 2.43.0
