Skip to contentSkip to conversation

virtio, pc: fixes

GIT PULL Applied Michael S. Tsirkin 3 participants 11 messages Mar 22, 2017 – Mar 23, 2017

lore
Share & tools
lore
#0 lore raw

The following changes since commit 55a19ad8b2d0797e3a8fe90ab99a9bb713824059:

Update version for v2.9.0-rc1 release (2017-03-21 17:13:29 +0000)

are available in the git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to 807211b76603b094c46a0cd95a3c785f47f3ab73:

hw/acpi/vmgenid: prevent more than one vmgenid device (2017-03-22 17:56:00 +0200)

----------------------------------------------------------------
virtio, pc: fixes

virtio and misc fixes for 2.9.

----------------------------------------------------------------
Fam Zheng (1):
virtio: Fix error handling in virtio_bus_device_plugged

Laszlo Ersek (2):
hw/acpi/vmgenid: prevent device realization on pre-2.5 machine types hw/acpi/vmgenid: prevent more than one vmgenid device

Paolo Bonzini (1):
virtio: always use handle_aio_output if registered

 include/hw/acpi/vmgenid.h |  2 ++
 include/hw/compat.h       |  4 ++++
 hw/acpi/vmgenid.c         | 22 ++++++++++++++++++++++
 hw/virtio/virtio-bus.c    | 20 +++++++++++++++++---
 hw/virtio/virtio.c        | 13 ++++++++++++-
 5 files changed, 57 insertions(+), 4 deletions(-)
#1 lore raw

[Qemu-devel] [PULL 3/4] hw/acpi/vmgenid: prevent device realization on pre-2.5 machine types

From: Laszlo Ersek <[email protected]>

The WRITE_POINTER linker/loader command that underlies VMGENID depends on commit baf2d5bfbac0 ("fw-cfg: support writeable blobs", 2017-01-12), which in turn depends on fw_cfg DMA.

DMA for fw_cfg is enabled in 2.5+ machine types only (see commit e6915b5f3a87, "fw_cfg: unbreak migration compatibility for 2.4 and earlier machines", 2016-02-18).

---
 include/hw/acpi/vmgenid.h |  1 +
 include/hw/compat.h       |  4 ++++
 hw/acpi/vmgenid.c         | 14 ++++++++++++++
 3 files changed, 19 insertions(+)
include/hw/acpi/vmgenid.h +1 -0
index db7fa0e..8578476 100644
@@ -21,6 +21,7 @@ typedef struct VmGenIdState {
     DeviceClass parent_obj;
     QemuUUID guid;                /* The 128-bit GUID seen by the guest */
     uint8_t vmgenid_addr_le[8];   /* Address of the GUID (little-endian) */
+    bool write_pointer_available;
 } VmGenIdState;
 
 static inline Object *find_vmgenid_dev(void)
include/hw/compat.h +4 -0
index fc8c3e0..5d5be91 100644
@@ -131,6 +131,10 @@
         .driver   = "fw_cfg_io",\
         .property = "dma_enabled",\
         .value    = "off",\
+    },{\
+        .driver   = "vmgenid",\
+        .property = "x-write-pointer-available",\
+        .value    = "off",\
     },
 
 #define HW_COMPAT_2_3 \
hw/acpi/vmgenid.c +14 -0
index 7a3ad17..c3ddcc8 100644
@@ -205,9 +205,22 @@ static void vmgenid_handle_reset(void *opaque)
     memset(vms->vmgenid_addr_le, 0, ARRAY_SIZE(vms->vmgenid_addr_le));
 }
 
+static Property vmgenid_properties[] = {
+    DEFINE_PROP_BOOL("x-write-pointer-available", VmGenIdState,
+                     write_pointer_available, true),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static void vmgenid_realize(DeviceState *dev, Error **errp)
 {
     VmGenIdState *vms = VMGENID(dev);
+
+    if (!vms->write_pointer_available) {
+        error_setg(errp, "%s requires DMA write support in fw_cfg, "
+                   "which this machine type does not provide", VMGENID_DEVICE);
+        return;
+    }
+
     qemu_register_reset(vmgenid_handle_reset, vms);
 }
 
@@ -218,6 +231,7 @@ static void vmgenid_device_class_init(ObjectClass *klass, void *data)
     dc->vmsd = &vmstate_vmgenid;
     dc->realize = vmgenid_realize;
     dc->hotpluggable = false;
+    dc->props = vmgenid_properties;
 
     object_class_property_add_str(klass, VMGENID_GUID, NULL,
                                   vmgenid_set_guid, NULL);
Signature · 1 line
MST
#3 lore raw

[Qemu-devel] [PULL 1/4] virtio: Fix error handling in virtio_bus_device_plugged

In reply to Michael S. Tsirkin

From: Fam Zheng <[email protected]>

For one thing we shouldn't continue if an error happened, for the other two steps failing can cause an abort() in error_setg because we reuse the same errp blindly.

Add error handling checks to fix both issues.

---
 hw/virtio/virtio-bus.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
hw/virtio/virtio-bus.c +17 -3
index a886011..3042232 100644
@@ -25,6 +25,7 @@
 #include "qemu/osdep.h"
 #include "hw/hw.h"
 #include "qemu/error-report.h"
+#include "qapi/error.h"
 #include "hw/qdev.h"
 #include "hw/virtio/virtio-bus.h"
 #include "hw/virtio/virtio.h"
@@ -48,20 +49,33 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp)
     VirtioBusClass *klass = VIRTIO_BUS_GET_CLASS(bus);
     VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
     bool has_iommu = virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
+    Error *local_err = NULL;
 
     DPRINTF("%s: plug device.\n", qbus->name);
 
     if (klass->pre_plugged != NULL) {
-        klass->pre_plugged(qbus->parent, errp);
+        klass->pre_plugged(qbus->parent, &local_err);
+        if (local_err) {
+            error_propagate(errp, local_err);
+            return;
+        }
     }
 
     /* Get the features of the plugged device. */
     assert(vdc->get_features != NULL);
     vdev->host_features = vdc->get_features(vdev, vdev->host_features,
-                                            errp);
+                                            &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
+    }
 
     if (klass->device_plugged != NULL) {
-        klass->device_plugged(qbus->parent, errp);
+        klass->device_plugged(qbus->parent, &local_err);
+    }
+    if (local_err) {
+        error_propagate(errp, local_err);
+        return;
     }
 
     if (klass->get_dma_as != NULL && has_iommu) {
Signature · 1 line
MST
#4 lore raw

[Qemu-devel] [PULL 2/4] virtio: always use handle_aio_output if registered

In reply to Michael S. Tsirkin

From: Paolo Bonzini <[email protected]>

Commit ad07cd6 ("virtio-scsi: always use dataplane path if ioeventfd is active", 2016-10-30) and 9ffe337 ("virtio-blk: always use dataplane path if ioeventfd is active", 2016-10-30) broke the virtio 1.0 indirect access registers.

The indirect access registers bypass the ioeventfd, so that virtio-blk and virtio-scsi now repeatedly try to initialize dataplane instead of triggering the guest->host EventNotifier. Detect the situation by checking vq->handle_aio_output; if it is not NULL, trigger the EventNotifier, which is how the device expects to get notifications and in fact the only thread-safe manner to deliver them.

---
 hw/virtio/virtio.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
hw/virtio/virtio.c +12 -1
index 82b6060..03592c5 100644
@@ -1528,7 +1528,18 @@ static void virtio_queue_notify_vq(VirtQueue *vq)
 
 void virtio_queue_notify(VirtIODevice *vdev, int n)
 {
-    virtio_queue_notify_vq(&vdev->vq[n]);
+    VirtQueue *vq = &vdev->vq[n];
+
+    if (unlikely(!vq->vring.desc || vdev->broken)) {
+        return;
+    }
+
+    trace_virtio_queue_notify(vdev, vq - vdev->vq, vq);
+    if (vq->handle_aio_output) {
+        event_notifier_set(&vq->host_notifier);
+    } else if (vq->handle_output) {
+        vq->handle_output(vdev, vq);
+    }
 }
 
 uint16_t virtio_queue_vector(VirtIODevice *vdev, int n)
Signature · 1 line
MST
#5 lore raw

[Qemu-devel] [PULL 4/4] hw/acpi/vmgenid: prevent more than one vmgenid device

In reply to Michael S. Tsirkin

From: Laszlo Ersek <[email protected]>

A system with multiple VMGENID devices is undefined in the VMGENID spec by omission.

Binary file /tmp/tmp.IaAwzHwwsQ matches

---
 include/hw/acpi/vmgenid.h | 1 +
 hw/acpi/vmgenid.c         | 8 ++++++++
 2 files changed, 9 insertions(+)
include/hw/acpi/vmgenid.h +1 -0
index 8578476..7beb959 100644
@@ -24,6 +24,7 @@ typedef struct VmGenIdState {
     bool write_pointer_available;
 } VmGenIdState;
 
+/* returns NULL unless there is exactly one device */
 static inline Object *find_vmgenid_dev(void)
 {
     return object_resolve_path_type("", VMGENID_DEVICE, NULL);
hw/acpi/vmgenid.c +8 -0
index c3ddcc8..a32b847 100644
@@ -221,6 +221,14 @@ static void vmgenid_realize(DeviceState *dev, Error **errp)
         return;
     }
 
+    /* Given that this function is executing, there is at least one VMGENID
+     * device. Check if there are several.
+     */
+    if (!find_vmgenid_dev()) {
+        error_setg(errp, "at most one %s device is permitted", VMGENID_DEVICE);
+        return;
+    }
+
     qemu_register_reset(vmgenid_handle_reset, vms);
 }
 
Signature · 1 line
MST
#2 lore raw

Re: [Qemu-devel] [PULL 3/4] hw/acpi/vmgenid: prevent device realization on pre-2.5 machine types

In reply to Michael S. Tsirkin
Quoted 10 lines · Michael S. Tsirkin

From: Laszlo Ersek <[email protected]>

The WRITE_POINTER linker/loader command that underlies VMGENID depends on commit baf2d5bfbac0 ("fw-cfg: support writeable blobs", 2017-01-12), which in turn depends on fw_cfg DMA.

DMA for fw_cfg is enabled in 2.5+ machine types only (see commit e6915b5f3a87, "fw_cfg: unbreak migration compatibility for 2.4 and earlier machines", 2016-02-18).

Quoted 7 lines

Can you please add the feedback tags from Ben and Igor?

http://mid.mail-archive.com/[email protected]
http://mid.mail-archive.com/[email protected]

Thanks,
Laszlo

Quoted 69 lines
---
 include/hw/acpi/vmgenid.h |  1 +
 include/hw/compat.h       |  4 ++++
 hw/acpi/vmgenid.c         | 14 ++++++++++++++
 3 files changed, 19 insertions(+)
include/hw/acpi/vmgenid.h +1 -0
index db7fa0e..8578476 100644
@@ -21,6 +21,7 @@ typedef struct VmGenIdState {
     DeviceClass parent_obj;
     QemuUUID guid;                /* The 128-bit GUID seen by the guest */
     uint8_t vmgenid_addr_le[8];   /* Address of the GUID (little-endian) */
+    bool write_pointer_available;
 } VmGenIdState;
 
 static inline Object *find_vmgenid_dev(void)
include/hw/compat.h +4 -0
index fc8c3e0..5d5be91 100644
@@ -131,6 +131,10 @@
         .driver   = "fw_cfg_io",\
         .property = "dma_enabled",\
         .value    = "off",\
+    },{\
+        .driver   = "vmgenid",\
+        .property = "x-write-pointer-available",\
+        .value    = "off",\
     },
 
 #define HW_COMPAT_2_3 \
hw/acpi/vmgenid.c +14 -0
index 7a3ad17..c3ddcc8 100644
@@ -205,9 +205,22 @@ static void vmgenid_handle_reset(void *opaque)
     memset(vms->vmgenid_addr_le, 0, ARRAY_SIZE(vms->vmgenid_addr_le));
 }
 
+static Property vmgenid_properties[] = {
+    DEFINE_PROP_BOOL("x-write-pointer-available", VmGenIdState,
+                     write_pointer_available, true),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static void vmgenid_realize(DeviceState *dev, Error **errp)
 {
     VmGenIdState *vms = VMGENID(dev);
+
+    if (!vms->write_pointer_available) {
+        error_setg(errp, "%s requires DMA write support in fw_cfg, "
+                   "which this machine type does not provide", VMGENID_DEVICE);
+        return;
+    }
+
     qemu_register_reset(vmgenid_handle_reset, vms);
 }
 
@@ -218,6 +231,7 @@ static void vmgenid_device_class_init(ObjectClass *klass, void *data)
     dc->vmsd = &vmstate_vmgenid;
     dc->realize = vmgenid_realize;
     dc->hotpluggable = false;
+    dc->props = vmgenid_properties;
 
     object_class_property_add_str(klass, VMGENID_GUID, NULL,
                                   vmgenid_set_guid, NULL);
#6 lore raw

Re: [Qemu-devel] [PULL 4/4] hw/acpi/vmgenid: prevent more than one vmgenid device

In reply to Michael S. Tsirkin
Quoted 5 lines · Michael S. Tsirkin

From: Laszlo Ersek <[email protected]>

A system with multiple VMGENID devices is undefined in the VMGENID spec by omission.

Quoted 7 lines

Can you please add the feedback tags from Igor and Ben?

http://mid.mail-archive.com/[email protected]
http://mid.mail-archive.com/[email protected]

Quoted 1 line

Binary file /tmp/tmp.IaAwzHwwsQ matches

I'm not sure what this means.

Thanks,
Laszlo

Quoted 37 lines
---
 include/hw/acpi/vmgenid.h | 1 +
 hw/acpi/vmgenid.c         | 8 ++++++++
 2 files changed, 9 insertions(+)
include/hw/acpi/vmgenid.h +1 -0
index 8578476..7beb959 100644
@@ -24,6 +24,7 @@ typedef struct VmGenIdState {
     bool write_pointer_available;
 } VmGenIdState;
 
+/* returns NULL unless there is exactly one device */
 static inline Object *find_vmgenid_dev(void)
 {
     return object_resolve_path_type("", VMGENID_DEVICE, NULL);
hw/acpi/vmgenid.c +8 -0
index c3ddcc8..a32b847 100644
@@ -221,6 +221,14 @@ static void vmgenid_realize(DeviceState *dev, Error **errp)
         return;
     }
 
+    /* Given that this function is executing, there is at least one VMGENID
+     * device. Check if there are several.
+     */
+    if (!find_vmgenid_dev()) {
+        error_setg(errp, "at most one %s device is permitted", VMGENID_DEVICE);
+        return;
+    }
+
     qemu_register_reset(vmgenid_handle_reset, vms);
 }
 
#8 lore raw
In reply to Michael S. Tsirkin
Quoted 11 lines · Michael S. Tsirkin

The following changes since commit 55a19ad8b2d0797e3a8fe90ab99a9bb713824059:

Update version for v2.9.0-rc1 release (2017-03-21 17:13:29 +0000)

are available in the git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to 807211b76603b094c46a0cd95a3c785f47f3ab73:

hw/acpi/vmgenid: prevent more than one vmgenid device (2017-03-22 17:56:00 +0200)

I tweaked commit log on two patches at submitter's request. Pushed 160f57134960e6356257e54408f6bce382aac5f6 - same tree.

Quoted 25 lines

----------------------------------------------------------------
virtio, pc: fixes

virtio and misc fixes for 2.9.

----------------------------------------------------------------
Fam Zheng (1):
virtio: Fix error handling in virtio_bus_device_plugged

Laszlo Ersek (2):
hw/acpi/vmgenid: prevent device realization on pre-2.5 machine types hw/acpi/vmgenid: prevent more than one vmgenid device

Paolo Bonzini (1):
virtio: always use handle_aio_output if registered

 include/hw/acpi/vmgenid.h |  2 ++
 include/hw/compat.h       |  4 ++++
 hw/acpi/vmgenid.c         | 22 ++++++++++++++++++++++
 hw/virtio/virtio-bus.c    | 20 +++++++++++++++++---
 hw/virtio/virtio.c        | 13 ++++++++++++-
 5 files changed, 57 insertions(+), 4 deletions(-)
#9 lore raw
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Michael S. Tsirkin

The following changes since commit 55a19ad8b2d0797e3a8fe90ab99a9bb713824059:

Update version for v2.9.0-rc1 release (2017-03-21 17:13:29 +0000)

are available in the git repository at:

Quoted 8 lines
Quoted 5 lines

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to 807211b76603b094c46a0cd95a3c785f47f3ab73:

hw/acpi/vmgenid: prevent more than one vmgenid device (2017-03-22 17:56:00 +0200)

I tweaked commit log on two patches at submitter's request. Pushed 160f57134960e6356257e54408f6bce382aac5f6 - same tree.

It's really f92063028a0ea9e15d8f962644bce76c0e8aa7d1 sorry about the noise.

Quoted 25 lines
Quoted 25 lines

----------------------------------------------------------------
virtio, pc: fixes

virtio and misc fixes for 2.9.

----------------------------------------------------------------
Fam Zheng (1):
virtio: Fix error handling in virtio_bus_device_plugged

Laszlo Ersek (2):
hw/acpi/vmgenid: prevent device realization on pre-2.5 machine types hw/acpi/vmgenid: prevent more than one vmgenid device

Paolo Bonzini (1):
virtio: always use handle_aio_output if registered

 include/hw/acpi/vmgenid.h |  2 ++
 include/hw/compat.h       |  4 ++++
 hw/acpi/vmgenid.c         | 22 ++++++++++++++++++++++
 hw/virtio/virtio-bus.c    | 20 +++++++++++++++++---
 hw/virtio/virtio.c        | 13 ++++++++++++-
 5 files changed, 57 insertions(+), 4 deletions(-)
#7 lore raw

Re: [Qemu-devel] [PULL 4/4] hw/acpi/vmgenid: prevent more than one vmgenid device

In reply to Laszlo Ersek
Quoted 19 lines · Laszlo Ersek
Quoted 5 lines · Michael S. Tsirkin

From: Laszlo Ersek <[email protected]>

A system with multiple VMGENID devices is undefined in the VMGENID spec by omission.

Quoted 7 lines

Can you please add the feedback tags from Igor and Ben?

http://mid.mail-archive.com/[email protected]
http://mid.mail-archive.com/[email protected]

Quoted 6 lines
Quoted 1 line

Binary file /tmp/tmp.IaAwzHwwsQ matches

I'm not sure what this means.

Thanks,
Laszlo

Fixed, thanks for paying attention.

Quoted 37 lines
Quoted 37 lines
---
 include/hw/acpi/vmgenid.h | 1 +
 hw/acpi/vmgenid.c         | 8 ++++++++
 2 files changed, 9 insertions(+)
include/hw/acpi/vmgenid.h +1 -0
index 8578476..7beb959 100644
@@ -24,6 +24,7 @@ typedef struct VmGenIdState {
     bool write_pointer_available;
 } VmGenIdState;
 
+/* returns NULL unless there is exactly one device */
 static inline Object *find_vmgenid_dev(void)
 {
     return object_resolve_path_type("", VMGENID_DEVICE, NULL);
hw/acpi/vmgenid.c +8 -0
index c3ddcc8..a32b847 100644
@@ -221,6 +221,14 @@ static void vmgenid_realize(DeviceState *dev, Error **errp)
         return;
     }
 
+    /* Given that this function is executing, there is at least one VMGENID
+     * device. Check if there are several.
+     */
+    if (!find_vmgenid_dev()) {
+        error_setg(errp, "at most one %s device is permitted", VMGENID_DEVICE);
+        return;
+    }
+
     qemu_register_reset(vmgenid_handle_reset, vms);
 }
 
#10 lore raw
In reply to Michael S. Tsirkin
Quoted 12 lines · Michael S. Tsirkin

The following changes since commit 55a19ad8b2d0797e3a8fe90ab99a9bb713824059:

Update version for v2.9.0-rc1 release (2017-03-21 17:13:29 +0000)

are available in the git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to 807211b76603b094c46a0cd95a3c785f47f3ab73:

hw/acpi/vmgenid: prevent more than one vmgenid device (2017-03-22 17:56:00 +0200)

Quoted 8 lines

----------------------------------------------------------------
virtio, pc: fixes

virtio and misc fixes for 2.9.

----------------------------------------------------------------

Applied, thanks.

-- PMM