diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2014-11-27 06:45:58 -0500 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2014-12-09 05:05:24 -0500 |
commit | 93d389f82078cf7197152fb10d21977da0883420 (patch) | |
tree | c168e5be2acd4e257212006a710af14df2185d80 /drivers/virtio | |
parent | d025477368792b272802146a86e41f81a54d8a19 (diff) |
virtio: assert 32 bit features in transports
At this point, no transports set any of the high 32 feature bits.
Since transports generally can't (yet) cope with such bits, add BUG_ON
checks to make sure they are not set by mistake.
Based on rproc patch by Rusty.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Diffstat (limited to 'drivers/virtio')
-rw-r--r-- | drivers/virtio/virtio_mmio.c | 3 | ||||
-rw-r--r-- | drivers/virtio/virtio_pci.c | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c index c63d0efa947b..aec1daee9ada 100644 --- a/drivers/virtio/virtio_mmio.c +++ b/drivers/virtio/virtio_mmio.c | |||
@@ -159,6 +159,9 @@ static void vm_finalize_features(struct virtio_device *vdev) | |||
159 | /* Give virtio_ring a chance to accept features. */ | 159 | /* Give virtio_ring a chance to accept features. */ |
160 | vring_transport_features(vdev); | 160 | vring_transport_features(vdev); |
161 | 161 | ||
162 | /* Make sure we don't have any features > 32 bits! */ | ||
163 | BUG_ON((u32)vdev->features != vdev->features); | ||
164 | |||
162 | writel(0, vm_dev->base + VIRTIO_MMIO_GUEST_FEATURES_SEL); | 165 | writel(0, vm_dev->base + VIRTIO_MMIO_GUEST_FEATURES_SEL); |
163 | writel(vdev->features, vm_dev->base + VIRTIO_MMIO_GUEST_FEATURES); | 166 | writel(vdev->features, vm_dev->base + VIRTIO_MMIO_GUEST_FEATURES); |
164 | } | 167 | } |
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c index 7e0efa7fc384..dd6df979862b 100644 --- a/drivers/virtio/virtio_pci.c +++ b/drivers/virtio/virtio_pci.c | |||
@@ -119,6 +119,9 @@ static void vp_finalize_features(struct virtio_device *vdev) | |||
119 | /* Give virtio_ring a chance to accept features. */ | 119 | /* Give virtio_ring a chance to accept features. */ |
120 | vring_transport_features(vdev); | 120 | vring_transport_features(vdev); |
121 | 121 | ||
122 | /* Make sure we don't have any features > 32 bits! */ | ||
123 | BUG_ON((u32)vdev->features != vdev->features); | ||
124 | |||
122 | /* We only support 32 feature bits. */ | 125 | /* We only support 32 feature bits. */ |
123 | iowrite32(vdev->features, vp_dev->ioaddr + VIRTIO_PCI_GUEST_FEATURES); | 126 | iowrite32(vdev->features, vp_dev->ioaddr + VIRTIO_PCI_GUEST_FEATURES); |
124 | } | 127 | } |