|
|
7711c0 |
From 6b1bea7682e1f321225e29cc6ee934a32f7b09d5 Mon Sep 17 00:00:00 2001
|
|
|
7711c0 |
From: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Date: Fri, 25 Jan 2019 22:50:07 +0100
|
|
|
7711c0 |
Subject: [PATCH 07/23] virtio: Return true from virtio_queue_empty if broken
|
|
|
7711c0 |
MIME-Version: 1.0
|
|
|
7711c0 |
Content-Type: text/plain; charset=UTF-8
|
|
|
7711c0 |
Content-Transfer-Encoding: 8bit
|
|
|
7711c0 |
|
|
|
7711c0 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Message-id: <20190125225007.8197-8-jsnow@redhat.com>
|
|
|
7711c0 |
Patchwork-id: 84122
|
|
|
7711c0 |
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH v2 7/7] virtio: Return true from virtio_queue_empty if broken
|
|
|
7711c0 |
Bugzilla: 1597482
|
|
|
7711c0 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Peter Xu <peterx@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
From: Fam Zheng <famz@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
Both virtio-blk and virtio-scsi use virtio_queue_empty() as the
|
|
|
7711c0 |
loop condition in VQ handlers (virtio_blk_handle_vq,
|
|
|
7711c0 |
virtio_scsi_handle_cmd_vq). When a device is marked broken in
|
|
|
7711c0 |
virtqueue_pop, for example if a vIOMMU address translation failed, we
|
|
|
7711c0 |
want to break out of the loop.
|
|
|
7711c0 |
|
|
|
7711c0 |
This fixes a hanging problem when booting a CentOS 3.10.0-862.el7.x86_64
|
|
|
7711c0 |
kernel with ATS enabled:
|
|
|
7711c0 |
|
|
|
7711c0 |
$ qemu-system-x86_64 \
|
|
|
7711c0 |
... \
|
|
|
7711c0 |
-device intel-iommu,intremap=on,caching-mode=on,eim=on,device-iotlb=on \
|
|
|
7711c0 |
-device virtio-scsi-pci,iommu_platform=on,ats=on,id=scsi0,bus=pci.4,addr=0x0
|
|
|
7711c0 |
|
|
|
7711c0 |
The dead loop happens immediately when the kernel boots and initializes
|
|
|
7711c0 |
the device, where virtio_scsi_data_plane_handle_cmd will not return:
|
|
|
7711c0 |
|
|
|
7711c0 |
> ...
|
|
|
7711c0 |
> #13 0x00005586602b7793 in virtio_scsi_handle_cmd_vq
|
|
|
7711c0 |
> #14 0x00005586602b8d66 in virtio_scsi_data_plane_handle_cmd
|
|
|
7711c0 |
> #15 0x00005586602ddab7 in virtio_queue_notify_aio_vq
|
|
|
7711c0 |
> #16 0x00005586602dfc9f in virtio_queue_host_notifier_aio_poll
|
|
|
7711c0 |
> #17 0x00005586607885da in run_poll_handlers_once
|
|
|
7711c0 |
> #18 0x000055866078880e in try_poll_mode
|
|
|
7711c0 |
> #19 0x00005586607888eb in aio_poll
|
|
|
7711c0 |
> #20 0x0000558660784561 in aio_wait_bh_oneshot
|
|
|
7711c0 |
> #21 0x00005586602b9582 in virtio_scsi_dataplane_stop
|
|
|
7711c0 |
> #22 0x00005586605a7110 in virtio_bus_stop_ioeventfd
|
|
|
7711c0 |
> #23 0x00005586605a9426 in virtio_pci_stop_ioeventfd
|
|
|
7711c0 |
> #24 0x00005586605ab808 in virtio_pci_common_write
|
|
|
7711c0 |
> #25 0x0000558660242396 in memory_region_write_accessor
|
|
|
7711c0 |
> #26 0x00005586602425ab in access_with_adjusted_size
|
|
|
7711c0 |
> #27 0x0000558660245281 in memory_region_dispatch_write
|
|
|
7711c0 |
> #28 0x00005586601e008e in flatview_write_continue
|
|
|
7711c0 |
> #29 0x00005586601e01d8 in flatview_write
|
|
|
7711c0 |
> #30 0x00005586601e04de in address_space_write
|
|
|
7711c0 |
> #31 0x00005586601e052f in address_space_rw
|
|
|
7711c0 |
> #32 0x00005586602607f2 in kvm_cpu_exec
|
|
|
7711c0 |
> #33 0x0000558660227148 in qemu_kvm_cpu_thread_fn
|
|
|
7711c0 |
> #34 0x000055866078bde7 in qemu_thread_start
|
|
|
7711c0 |
> #35 0x00007f5784906594 in start_thread
|
|
|
7711c0 |
> #36 0x00007f5784639e6f in clone
|
|
|
7711c0 |
|
|
|
7711c0 |
With this patch, virtio_queue_empty will now return 1 as soon as the
|
|
|
7711c0 |
vdev is marked as broken, after a "virtio: zero sized buffers are not
|
|
|
7711c0 |
allowed" error.
|
|
|
7711c0 |
|
|
|
7711c0 |
To be consistent, update virtio_queue_empty_rcu as well.
|
|
|
7711c0 |
|
|
|
7711c0 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
7711c0 |
Message-Id: <20180910145616.8598-2-famz@redhat.com>
|
|
|
7711c0 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
7711c0 |
(cherry picked from commit 2d1df8591022737b8ef19d681ff74eda389f5198)
|
|
|
7711c0 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
---
|
|
|
7711c0 |
hw/virtio/virtio.c | 8 ++++++++
|
|
|
7711c0 |
1 file changed, 8 insertions(+)
|
|
|
7711c0 |
|
|
|
7711c0 |
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
|
|
|
7711c0 |
index 77eadaa..1c936ad 100644
|
|
|
7711c0 |
--- a/hw/virtio/virtio.c
|
|
|
7711c0 |
+++ b/hw/virtio/virtio.c
|
|
|
7711c0 |
@@ -345,6 +345,10 @@ int virtio_queue_ready(VirtQueue *vq)
|
|
|
7711c0 |
* Called within rcu_read_lock(). */
|
|
|
7711c0 |
static int virtio_queue_empty_rcu(VirtQueue *vq)
|
|
|
7711c0 |
{
|
|
|
7711c0 |
+ if (unlikely(vq->vdev->broken)) {
|
|
|
7711c0 |
+ return 1;
|
|
|
7711c0 |
+ }
|
|
|
7711c0 |
+
|
|
|
7711c0 |
if (unlikely(!vq->vring.avail)) {
|
|
|
7711c0 |
return 1;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
@@ -360,6 +364,10 @@ int virtio_queue_empty(VirtQueue *vq)
|
|
|
7711c0 |
{
|
|
|
7711c0 |
bool empty;
|
|
|
7711c0 |
|
|
|
7711c0 |
+ if (unlikely(vq->vdev->broken)) {
|
|
|
7711c0 |
+ return 1;
|
|
|
7711c0 |
+ }
|
|
|
7711c0 |
+
|
|
|
7711c0 |
if (unlikely(!vq->vring.avail)) {
|
|
|
7711c0 |
return 1;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
--
|
|
|
7711c0 |
1.8.3.1
|
|
|
7711c0 |
|