Browse Source

xen: mapcache: Assert mapcache existance

Assert that the mapcache was created prior to being used.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
master
Edgar E. Iglesias 8 months ago
parent
commit
3038c84daa
  1. 10
      hw/xen/xen-mapcache.c

10
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);

Loading…
Cancel
Save