Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 93d389f8 authored by Michael S. Tsirkin's avatar Michael S. Tsirkin
Browse files

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: default avatarRusty Russell <rusty@rustcorp.com.au>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Reviewed-by: default avatarDavid Hildenbrand <dahi@linux.vnet.ibm.com>
Reviewed-by: default avatarCornelia Huck <cornelia.huck@de.ibm.com>


parent d0254773
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -136,6 +136,9 @@ static void lg_finalize_features(struct virtio_device *vdev)
	/* Give virtio_ring a chance to accept features. */
	vring_transport_features(vdev);

	/* Make sure we don't have any features > 32 bits! */
	BUG_ON((u32)vdev->features != vdev->features);

	/*
	 * Since lguest is currently x86-only, we're little-endian.  That
	 * means we could just memcpy.  But it's not time critical, and in
+3 −0
Original line number Diff line number Diff line
@@ -96,6 +96,9 @@ static void mic_finalize_features(struct virtio_device *vdev)
	/* Give virtio_ring a chance to accept features. */
	vring_transport_features(vdev);

	/* Make sure we don't have any features > 32 bits! */
	BUG_ON((u32)vdev->features != vdev->features);

	memset_io(out_features, 0, feature_len);
	bits = min_t(unsigned, feature_len,
		sizeof(vdev->features)) * 8;
+3 −0
Original line number Diff line number Diff line
@@ -227,6 +227,9 @@ static void rproc_virtio_finalize_features(struct virtio_device *vdev)
	/* Give virtio_ring a chance to accept features */
	vring_transport_features(vdev);

	/* Make sure we don't have any features > 32 bits! */
	BUG_ON((u32)vdev->features != vdev->features);

	/*
	 * Remember the finalized features of our vdev, and provide it
	 * to the remote processor once it is powered on.
+3 −0
Original line number Diff line number Diff line
@@ -103,6 +103,9 @@ static void kvm_finalize_features(struct virtio_device *vdev)
	/* Give virtio_ring a chance to accept features. */
	vring_transport_features(vdev);

	/* Make sure we don't have any features > 32 bits! */
	BUG_ON((u32)vdev->features != vdev->features);

	memset(out_features, 0, desc->feature_len);
	bits = min_t(unsigned, desc->feature_len, sizeof(vdev->features)) * 8;
	for (i = 0; i < bits; i++) {
+3 −0
Original line number Diff line number Diff line
@@ -714,6 +714,9 @@ static void virtio_ccw_finalize_features(struct virtio_device *vdev)
	/* Give virtio_ring a chance to accept features. */
	vring_transport_features(vdev);

	/* Make sure we don't have any features > 32 bits! */
	BUG_ON((u32)vdev->features != vdev->features);

	features->index = 0;
	features->features = cpu_to_le32(vdev->features);
	/* Write the feature bits to the host. */
Loading