Message ID | 20240312142757.34141-3-anthony.perard@citrix.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [PULL,1/3] xen/pt: Emulate multifunction bit in header type | expand |
12.03.2024 17:27, Anthony PERARD wrote: > From: Peng Fan <peng.fan@nxp.com> > > xen_invalidate_map_cache_entry is not expected to run in a > coroutine. Without this, there is crash: Hi! Is this a stable material? (It applies cleanly and builds on 8.2 and 7.2) Thanks, /mjt
13.03.2024 20:21, Michael Tokarev: > 12.03.2024 17:27, Anthony PERARD wrote: >> From: Peng Fan <peng.fan@nxp.com> >> >> xen_invalidate_map_cache_entry is not expected to run in a >> coroutine. Without this, there is crash: > > Hi! Is this a stable material? (It applies cleanly and builds on 8.2 and 7.2) Actually for 7.2 it needed a minor tweak: -void coroutine_mixed_fn xen_invalidate_map_cache_entry(uint8_t *buffer) +void xen_invalidate_map_cache_entry(uint8_t *buffer) but the rest is okay. /mjt
> Subject: Re: [PULL 2/3] xen: Drop out of coroutine context > xen_invalidate_map_cache_entry > > 13.03.2024 20:21, Michael Tokarev: > > 12.03.2024 17:27, Anthony PERARD wrote: > >> From: Peng Fan <peng.fan@nxp.com> > >> > >> xen_invalidate_map_cache_entry is not expected to run in a coroutine. > >> Without this, there is crash: > > > > Hi! Is this a stable material? (It applies cleanly and builds on 8.2 > > and 7.2) > > Actually for 7.2 it needed a minor tweak: > > -void coroutine_mixed_fn xen_invalidate_map_cache_entry(uint8_t *buffer) > +void xen_invalidate_map_cache_entry(uint8_t *buffer) I only tested 8.2 with xen virtio enabled. Not sure whether 7.2 has the issue or not. Thanks, Peng. > > but the rest is okay. > > /mjt
diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c index 4f956d048e..7f59080ba7 100644 --- a/hw/xen/xen-mapcache.c +++ b/hw/xen/xen-mapcache.c @@ -476,11 +476,37 @@ static void xen_invalidate_map_cache_entry_unlocked(uint8_t *buffer) g_free(entry); } -void xen_invalidate_map_cache_entry(uint8_t *buffer) +typedef struct XenMapCacheData { + Coroutine *co; + uint8_t *buffer; +} XenMapCacheData; + +static void xen_invalidate_map_cache_entry_bh(void *opaque) { + XenMapCacheData *data = opaque; + mapcache_lock(); - xen_invalidate_map_cache_entry_unlocked(buffer); + xen_invalidate_map_cache_entry_unlocked(data->buffer); mapcache_unlock(); + + aio_co_wake(data->co); +} + +void coroutine_mixed_fn xen_invalidate_map_cache_entry(uint8_t *buffer) +{ + if (qemu_in_coroutine()) { + XenMapCacheData data = { + .co = qemu_coroutine_self(), + .buffer = buffer, + }; + aio_bh_schedule_oneshot(qemu_get_current_aio_context(), + xen_invalidate_map_cache_entry_bh, &data); + qemu_coroutine_yield(); + } else { + mapcache_lock(); + xen_invalidate_map_cache_entry_unlocked(buffer); + mapcache_unlock(); + } } void xen_invalidate_map_cache(void)