xen-hvm: Avoid livelock while handling buffered ioreqs
authorRoss Lagerwall <ross.lagerwall@citrix.com>
Thu, 4 Apr 2024 14:08:33 +0000 (15:08 +0100)
committerAnthony PERARD <anthony@xenproject.org>
Mon, 1 Jul 2024 12:57:18 +0000 (14:57 +0200)
commit410b4d560dfa3b38a11ad19cf00180238651d9b7
tree5b908629f3aec605d90d1924ec9e910e00e382cb
parent196fb962baeff16342279111cc927a153415f85f
xen-hvm: Avoid livelock while handling buffered ioreqs

A malicious or buggy guest may generated buffered ioreqs faster than
QEMU can process them in handle_buffered_iopage(). The result is a
livelock - QEMU continuously processes ioreqs on the main thread without
iterating through the main loop which prevents handling other events,
processing timers, etc. Without QEMU handling other events, it often
results in the guest becoming unsable and makes it difficult to stop the
source of buffered ioreqs.

To avoid this, if we process a full page of buffered ioreqs, stop and
reschedule an immediate timer to continue processing them. This lets
QEMU go back to the main loop and catch up.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Reviewed-by: Paul Durrant <paul@xen.org>
Message-Id: <20240404140833.1557953-1-ross.lagerwall@citrix.com>
Signed-off-by: Anthony PERARD <anthony@xenproject.org>
hw/xen/xen-hvm-common.c