When the snapshot & restore of virtqueues was split between frontend &
backend as part of fcf9a630e9, a subtle
& unintentional change was introduced in how VIRTIO_RING_F_EVENT_IDX
operated. On restore, if interrupts were suppressed for a given
virtqueue, they would not only remain supressed, but the index tracking
when the last interrupt was sent would jump to the current used queue
head. This would stall the device because:
* The device was not sending interrupts.
* The driver, which could tell the device to send interrupts, was asleep
and waiting for an interrupt from the device.
Thus circular waiting is established, and the device stalls.
This CL modifies initialization of split virtqueues to *always* start
with the "last index an interrupt was sent for" aka `last_used` set to
zero. This will generate at most one spurious interrupt per queue when
restoring a snapshot, which is safe and much simpler than plumbing the
actual `last_used` value through the vhost-user protocol.
NOTE: this was a regression which was introduced in
fcf9a630e9.
BUG=b:363280532
TEST=verified that disabling VIRTIO_RING_F_EVENT_IDX fixed the
regression with no code changes. Verified that the regression goes away
once last_used is initialized to zero and VIRTIO_RING_F_EVENT_IDX is
enabled.
Change-Id: If9cacaeed40d7ba1496bd071cc4ffd765f4866de
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/6112791
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
crosvm is a virtual machine monitor (VMM) based on Linux’s KVM hypervisor, with a focus on
simplicity, security, and speed. crosvm is intended to run Linux guests, originally as a security
boundary for running native applications on the ChromeOS platform. Compared to QEMU, crosvm doesn’t
emulate architectures or real hardware, instead concentrating on paravirtualized devices, such as
the virtio standard.
crosvm is currently used to run Linux/Android guests on ChromeOS devices.
For contribution, see the contributor guide. Mirror
repository is available at GitHub for your convenience, but
we don't accept bug reports or pull requests there.