Xen queue
[PULL 1/2] xen-hvm: Allow disabling buffer_io_timer
In reply to Anthony PERARD viaFrom: Jason Andryuk <[email protected]>
commit f37f29d31488 "xen: slightly simplify bufioreq handling" hard coded setting req.count = 1 during initial field setup before the main loop. This missed a subtlety that an early exit from the loop when there are no ioreqs to process, would have req.count == 0 for the return value. handle_buffered_io() would then remove state->buffered_io_timer. Instead handle_buffered_iopage() is basically always returning true and handle_buffered_io() always re-setting the timer.
Restore the disabling of the timer by introducing a new handled_ioreq boolean and use as the return value. The named variable will more clearly show the intent of the code.
Message-Id: <[email protected]>
--- hw/i386/xen/xen-hvm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/i386/xen/xen-hvm.c +4 -2
@@ -1087,10 +1087,11 @@ static void handle_ioreq(XenIOState *state, ioreq_t *req) } } -static int handle_buffered_iopage (XenIOState *state) +static bool handle_buffered_iopage (XenIOState *state) {buffered_iopage_t *buf_page = state->buffered_io_page;buf_ioreq_t *buf_req =NULL ; +bool handled_ioreq = false;ioreq_t req;int qw;
@@ -1144,9 +1145,10 @@ static int handle_buffered_iopage(XenIOState *state)assert (!req.data_is_ptr);qatomic_add (&buf_page->read_pointer, qw +1 ); + handled_ioreq = true; } -return req.count; +return handled_ioreq; }static void handle_buffered_io (void *opaque)
Signature · 1 line
Anthony PERARD
The following changes since commit 48302d4eb628ff0bea4d7e92cbf6b726410eb4c3:
Merge remote-tracking branch 'remotes/dgilbert-gitlab/tags/pull-virtiofs-20220126' into staging (2022-01-26 10:59:50 +0000)
are available in the Git repository at:
https://xenbits.xen.org/git-http/people/aperard/qemu-dm.git tags/pull-xen-20220127
for you to fetch changes up to a021a2dd8b790437d27db95774969349632f856a:
xen-mapcache: Avoid entry->lock overflow (2022-01-27 15:14:21 +0000)
----------------------------------------------------------------
Xen patches
- bug fixes for mapcache and ioreq handling
----------------------------------------------------------------
Jason Andryuk (1):
xen-hvm: Allow disabling buffer_io_timer
Ross Lagerwall (1):
xen-mapcache: Avoid entry->lock overflow
hw/i386/xen/xen-hvm.c | 6 ++++-- hw/i386/xen/xen-mapcache.c | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-)
[PULL 2/2] xen-mapcache: Avoid entry->lock overflow
From: Ross Lagerwall <[email protected]>
In some cases, a particular mapcache entry may be mapped 256 times causing the lock field to wrap to 0. For example, this may happen when using emulated NVME and the guest submits a large scatter-gather write. At this point, the entry map be remapped causing QEMU to write the wrong data or crash (since remap is not atomic).
Avoid this overflow by increasing the lock field to a uint32_t and also detect it and abort rather than continuing regardless.
Message-Id: <[email protected]>
--- hw/i386/xen/xen-mapcache.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
hw/i386/xen/xen-mapcache.c +7 -1
@@ -52,7 +52,7 @@ typedef struct MapCacheEntry {hwaddr paddr_index;uint8_t *vaddr_base;unsigned long *valid_mapping; -uint8_t lock; +uint32_t lock;#define XEN_MAPCACHE_ENTRY_DUMMY (1 << 0)uint8_t flags;hwaddr size;
@@ -355,6 +355,12 @@ static uint8_t *xen_map_cache_unlocked(hwaddr phys_addr, hwaddr size,if (lock) {MapCacheRev *reventry =g_malloc0 (sizeof (MapCacheRev)); entry->lock++; +if (entry->lock ==0 ) { +fprintf (stderr, +"mapcache entry lock overflow: " TARGET_FMT_plx" -> %p\n" , + entry->paddr_index, entry->vaddr_base); +abort (); + } reventry->dma = dma; reventry->vaddr_req = mapcache->last_entry->vaddr_base + address_offset; reventry->paddr_index = mapcache->last_entry->paddr_index;
Signature · 1 line
Anthony PERARD
Peter Maydell
AppliedQuoted 9 lines · Anthony PERARD
The following changes since commit
48302d4eb628ff0bea4d7e92cbf6b726410eb4c3:Merge remote-tracking branch 'remotes/dgilbert-gitlab/tags/pull-virtiofs-20220126' into staging (2022-01-26 10:59:50 +0000)
are available in the Git repository at:
https://xenbits.xen.org/git-http/people/aperard/qemu-dm.git tags/pull-xen-20220127
Quoted 9 lines
for you to fetch changes up to
a021a2dd8b790437d27db95774969349632f856a:xen-mapcache: Avoid
entry->lockoverflow (2022-01-27 15:14:21 +0000)----------------------------------------------------------------
Xen patches- bug fixes for mapcache and ioreq handling
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/7.0
for any user-visible changes.
-- PMM