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

Commit 5c609a5e authored by Michael S. Tsirkin's avatar Michael S. Tsirkin
Browse files

virtio: allow finalize_features to fail



This will make it easy for transports to validate features and return
failure.

Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent ce15408f
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@ static void status_notify(struct virtio_device *vdev)
 * sorted out, this routine is called so we can tell the Host which features we
 * understand and accept.
 */
static void lg_finalize_features(struct virtio_device *vdev)
static int lg_finalize_features(struct virtio_device *vdev)
{
	unsigned int i, bits;
	struct lguest_device_desc *desc = to_lgdev(vdev)->desc;
@@ -153,6 +153,8 @@ static void lg_finalize_features(struct virtio_device *vdev)

	/* Tell Host we've finished with this device's feature negotiation */
	status_notify(vdev);

	return 0;
}

/* Once they've found a field, getting a copy of it is easy. */
+3 −1
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ static u64 mic_get_features(struct virtio_device *vdev)
	return features;
}

static void mic_finalize_features(struct virtio_device *vdev)
static int mic_finalize_features(struct virtio_device *vdev)
{
	unsigned int i, bits;
	struct mic_device_desc __iomem *desc = to_micvdev(vdev)->desc;
@@ -107,6 +107,8 @@ static void mic_finalize_features(struct virtio_device *vdev)
			iowrite8(ioread8(&out_features[i / 8]) | (1 << (i % 8)),
				 &out_features[i / 8]);
	}

	return 0;
}

/*
+3 −1
Original line number Diff line number Diff line
@@ -217,7 +217,7 @@ static u64 rproc_virtio_get_features(struct virtio_device *vdev)
	return rsc->dfeatures;
}

static void rproc_virtio_finalize_features(struct virtio_device *vdev)
static int rproc_virtio_finalize_features(struct virtio_device *vdev)
{
	struct rproc_vdev *rvdev = vdev_to_rvdev(vdev);
	struct fw_rsc_vdev *rsc;
@@ -235,6 +235,8 @@ static void rproc_virtio_finalize_features(struct virtio_device *vdev)
	 * to the remote processor once it is powered on.
	 */
	rsc->gfeatures = vdev->features;

	return 0;
}

static void rproc_virtio_get(struct virtio_device *vdev, unsigned offset,
+3 −1
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ static u64 kvm_get_features(struct virtio_device *vdev)
	return features;
}

static void kvm_finalize_features(struct virtio_device *vdev)
static int kvm_finalize_features(struct virtio_device *vdev)
{
	unsigned int i, bits;
	struct kvm_device_desc *desc = to_kvmdev(vdev)->desc;
@@ -112,6 +112,8 @@ static void kvm_finalize_features(struct virtio_device *vdev)
		if (__virtio_test_bit(vdev, i))
			out_features[i / 8] |= (1 << (i % 8));
	}

	return 0;
}

/*
+4 −2
Original line number Diff line number Diff line
@@ -752,7 +752,7 @@ static u64 virtio_ccw_get_features(struct virtio_device *vdev)
	return rc;
}

static void virtio_ccw_finalize_features(struct virtio_device *vdev)
static int virtio_ccw_finalize_features(struct virtio_device *vdev)
{
	struct virtio_ccw_device *vcdev = to_vc_device(vdev);
	struct virtio_feature_desc *features;
@@ -760,7 +760,7 @@ static void virtio_ccw_finalize_features(struct virtio_device *vdev)

	ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL);
	if (!ccw)
		return;
		return 0;

	features = kzalloc(sizeof(*features), GFP_DMA | GFP_KERNEL);
	if (!features)
@@ -793,6 +793,8 @@ static void virtio_ccw_finalize_features(struct virtio_device *vdev)
out_free:
	kfree(features);
	kfree(ccw);

	return 0;
}

static void virtio_ccw_get_config(struct virtio_device *vdev,
Loading