From 0cd70f19fa99887ddd1dc09ffd73bd61998cd7f7 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Menil Date: Fri, 19 Oct 2018 21:48:27 +0200 Subject: [PATCH] qemu: qemu-3.0.0 fix virtio assertion failure with OpenBSD, see https://github.com/qemu/qemu/commit/db812c4073c77c8a64db8d6663b3416a587c7b4a --- ...irtio-assertion-failure-with-openbsd.patch | 55 +++++++++++++++++++ srcpkgs/qemu/template | 2 +- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 srcpkgs/qemu/patches/0007-fix-virtio-assertion-failure-with-openbsd.patch diff --git a/srcpkgs/qemu/patches/0007-fix-virtio-assertion-failure-with-openbsd.patch b/srcpkgs/qemu/patches/0007-fix-virtio-assertion-failure-with-openbsd.patch new file mode 100644 index 00000000000..e58573a5212 --- /dev/null +++ b/srcpkgs/qemu/patches/0007-fix-virtio-assertion-failure-with-openbsd.patch @@ -0,0 +1,55 @@ +From db812c4073c77c8a64db8d6663b3416a587c7b4a Mon Sep 17 00:00:00 2001 +From: Paolo Bonzini +Date: Thu, 23 Aug 2018 14:21:23 +0200 +Subject: [PATCH] virtio: update MemoryRegionCaches when guest negotiates + features + +Because the cache is sized to include the rings and the event indices, +negotiating the VIRTIO_RING_F_EVENT_IDX feature will result in the size +of the cache changing. And because MemoryRegionCache accesses are +range-checked, if we skip this we end up with an assertion failure. +This happens with OpenBSD 6.3. + +Reported-by: Fam Zheng +Fixes: 97cd965c070152bc626c7507df9fb356bbe1cd81 +Cc: qemu-stable@nongnu.org +Signed-off-by: Paolo Bonzini +Tested-by: Fam Zheng +Reviewed-by: Michael S. Tsirkin +Signed-off-by: Michael S. Tsirkin +--- + hw/virtio/virtio.c | 15 +++++++++++++-- + 1 file changed, 13 insertions(+), 2 deletions(-) + +diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c +index d4e4d98b595..f6a588ab57e 100644 +--- hw/virtio/virtio.c ++++ hw/virtio/virtio.c +@@ -2006,14 +2006,25 @@ static int virtio_set_features_nocheck(VirtIODevice *vdev, uint64_t val) + + int virtio_set_features(VirtIODevice *vdev, uint64_t val) + { +- /* ++ int ret; ++ /* + * The driver must not attempt to set features after feature negotiation + * has finished. + */ + if (vdev->status & VIRTIO_CONFIG_S_FEATURES_OK) { + return -EINVAL; + } +- return virtio_set_features_nocheck(vdev, val); ++ ret = virtio_set_features_nocheck(vdev, val); ++ if (!ret && virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { ++ /* VIRTIO_RING_F_EVENT_IDX changes the size of the caches. */ ++ int i; ++ for (i = 0; i < VIRTIO_QUEUE_MAX; i++) { ++ if (vdev->vq[i].vring.num != 0) { ++ virtio_init_region_cache(vdev, i); ++ } ++ } ++ } ++ return ret; + } + + int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id) diff --git a/srcpkgs/qemu/template b/srcpkgs/qemu/template index 7ea0fcc1443..6d2d3517c55 100644 --- a/srcpkgs/qemu/template +++ b/srcpkgs/qemu/template @@ -1,7 +1,7 @@ # Template file for 'qemu' pkgname=qemu version=3.0.0 -revision=1 +revision=2 short_desc="Open Source Processor Emulator" maintainer="Juan RP " homepage="http://qemu.org"