Skip to content

Commit 9b3a35e

Browse files
cohuckmstsirkin
authored andcommitted
virtio: verify that legacy support is not accidentally on
If a virtio device does not have legacy support, make sure that it is actually off, and bail out if not. For virtio-pci, this means that any device without legacy support that has been specified to modern-only (or that has been forced to it) will work. For virtio-ccw, this duplicates the check that is currently done prior to realization for any device that explicitly specified no support for legacy. This catches devices that have not been fenced properly. Signed-off-by: Cornelia Huck <[email protected]> Message-Id: <[email protected]> Cc: [email protected] Acked-by: Halil Pasic <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 7c78bdd commit 9b3a35e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

hw/s390x/virtio-ccw.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,12 @@ static void virtio_ccw_device_plugged(DeviceState *d, Error **errp)
11211121
dev->max_rev = 0;
11221122
}
11231123

1124+
if (!virtio_ccw_rev_max(dev) && !virtio_legacy_allowed(vdev)) {
1125+
error_setg(errp, "Invalid value of property max_rev "
1126+
"(is %d expected >= 1)", virtio_ccw_rev_max(dev));
1127+
return;
1128+
}
1129+
11241130
if (virtio_get_num_queues(vdev) > VIRTIO_QUEUE_MAX) {
11251131
error_setg(errp, "The number of virtqueues %d "
11261132
"exceeds virtio limit %d", n,

hw/virtio/virtio-pci.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,6 +1581,10 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp)
15811581
}
15821582

15831583
if (legacy) {
1584+
if (!virtio_legacy_allowed(vdev)) {
1585+
error_setg(errp, "device is modern-only, use disable-legacy=on");
1586+
return;
1587+
}
15841588
if (virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM)) {
15851589
error_setg(errp, "VIRTIO_F_IOMMU_PLATFORM was supported by"
15861590
" neither legacy nor transitional device");

0 commit comments

Comments
 (0)