Skip to contentSkip to conversation

virtio_net: CTRL_GUEST_OFFLOADS depends on CTRL_VQ

PATCH In review Michael S. Tsirkin 3 participants 13 messages Jan 5, 2020 – Jan 10, 2020

Subsystems (4)
lore
Share & tools
lore

Michael S. Tsirkin

author maintainer
#0 lore raw

PATCH v2 1/1 virtio_net: CTRL_GUEST_OFFLOADS depends on CTRL_VQ

The only way for guest to control offloads (as enabled by VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) is by sending commands through CTRL_VQ. So it does not make sense to acknowledge VIRTIO_NET_F_CTRL_GUEST_OFFLOADS without VIRTIO_NET_F_CTRL_VQ.

The spec does not outlaw devices with such a configuration, so we have to support it. Simply clear VIRTIO_NET_F_CTRL_GUEST_OFFLOADS. Note that Linux is still crashing if it tries to
change the offloads when there's no control vq.
That needs to be fixed by another patch.

Fixes 3f93522ffab2 ("virtio-net: switch off offloads on demand if possible on XDP set")

---

Same patch as v1 but update documentation so it's clear it's not enough to fix the crash.

 drivers/net/virtio_net.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/net/virtio_net.c +9 -0
index 4d7d5434cc5d..7b8805b47f0d 100644
@@ -2971,6 +2971,15 @@ static int virtnet_validate(struct virtio_device *vdev)
 	if (!virtnet_validate_features(vdev))
 		return -EINVAL;
 
+	/* VIRTIO_NET_F_CTRL_GUEST_OFFLOADS does not work without
+	 * VIRTIO_NET_F_CTRL_VQ. Unfortunately spec forgot to
+	 * specify that VIRTIO_NET_F_CTRL_GUEST_OFFLOADS depends
+	 * on VIRTIO_NET_F_CTRL_VQ so devices can set the later but
+	 * not the former.
+	 */
+	if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ))
+			__virtio_clear_bit(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS);
+
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_MTU)) {
 		int mtu = virtio_cread16(vdev,
 					 offsetof(struct virtio_net_config,
Signature · 1 line
MST
#1 lore raw
Quoted 30 lines · Michael S. Tsirkin

The only way for guest to control offloads (as enabled by VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) is by sending commands through CTRL_VQ. So it does not make sense to acknowledge VIRTIO_NET_F_CTRL_GUEST_OFFLOADS without VIRTIO_NET_F_CTRL_VQ.

The spec does not outlaw devices with such a configuration, so we have to support it. Simply clear VIRTIO_NET_F_CTRL_GUEST_OFFLOADS. Note that Linux is still crashing if it tries to
change the offloads when there's no control vq.
That needs to be fixed by another patch.

Fixes 3f93522ffab2 ("virtio-net: switch off offloads on demand if possible on XDP set")

---

Same patch as v1 but update documentation so it's clear it's not enough to fix the crash.

  drivers/net/virtio_net.c | 9 +++++++++
  1 file changed, 9 insertions(+)
drivers/net/virtio_net.c +0 -0
index 4d7d5434cc5d..7b8805b47f0d 100644
@@ -2971,6 +2971,15 @@ static int virtnet_validate(struct virtio_device *vdev)
  	if (!virtnet_validate_features(vdev))

drivers/net/virtio_net.c static int virtnet_validate(struct virtio_device *vdev) · line 2981

Quoted 10 lines
drivers/net/virtio_net.c +8 -0
  		return -EINVAL;
 
+	/* VIRTIO_NET_F_CTRL_GUEST_OFFLOADS does not work without
+	 * VIRTIO_NET_F_CTRL_VQ. Unfortunately spec forgot to
+	 * specify that VIRTIO_NET_F_CTRL_GUEST_OFFLOADS depends
+	 * on VIRTIO_NET_F_CTRL_VQ so devices can set the later but
+	 * not the former.
+	 */
+	if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ))
+			__virtio_clear_bit(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS);

If it's just because a bug of spec, should we simply fix the bug and fail the negotiation in virtnet_validate_feature()?

Otherwise there would be inconsistency in handling feature dependencies for ctrl vq.

Thanks

drivers/net/virtio_net.c static int virtnet_validate(struct virtio_device *vdev) · line 2985

Quoted 4 lines
drivers/net/virtio_net.c +1 -0
+
  	if (virtio_has_feature(vdev, VIRTIO_NET_F_MTU)) {
  		int mtu = virtio_cread16(vdev,
  					 offsetof(struct virtio_net_config,

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#2 lore raw
In reply to Michael S. Tsirkin
Quoted 30 lines · Michael S. Tsirkin

The only way for guest to control offloads (as enabled by VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) is by sending commands through CTRL_VQ. So it does not make sense to acknowledge VIRTIO_NET_F_CTRL_GUEST_OFFLOADS without VIRTIO_NET_F_CTRL_VQ.

The spec does not outlaw devices with such a configuration, so we have to support it. Simply clear VIRTIO_NET_F_CTRL_GUEST_OFFLOADS. Note that Linux is still crashing if it tries to
change the offloads when there's no control vq.
That needs to be fixed by another patch.

Fixes 3f93522ffab2 ("virtio-net: switch off offloads on demand if possible on XDP set")

---

Same patch as v1 but update documentation so it's clear it's not enough to fix the crash.

  drivers/net/virtio_net.c | 9 +++++++++
  1 file changed, 9 insertions(+)
drivers/net/virtio_net.c +0 -0
index 4d7d5434cc5d..7b8805b47f0d 100644
@@ -2971,6 +2971,15 @@ static int virtnet_validate(struct virtio_device *vdev)
  	if (!virtnet_validate_features(vdev))

drivers/net/virtio_net.c static int virtnet_validate(struct virtio_device *vdev) · line 2981

Quoted 10 lines
drivers/net/virtio_net.c +8 -0
  		return -EINVAL;
 
+	/* VIRTIO_NET_F_CTRL_GUEST_OFFLOADS does not work without
+	 * VIRTIO_NET_F_CTRL_VQ. Unfortunately spec forgot to
+	 * specify that VIRTIO_NET_F_CTRL_GUEST_OFFLOADS depends
+	 * on VIRTIO_NET_F_CTRL_VQ so devices can set the later but
+	 * not the former.
+	 */
+	if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ))
+			__virtio_clear_bit(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS);

If it's just because a bug of spec, should we simply fix the bug and fail the negotiation in virtnet_validate_feature()?

Otherwise there would be inconsistency in handling feature dependencies for ctrl vq.

Thanks

Quoted 4 lines
drivers/net/virtio_net.c +1 -0
+
  	if (virtio_has_feature(vdev, VIRTIO_NET_F_MTU)) {
  		int mtu = virtio_cread16(vdev,
  					 offsetof(struct virtio_net_config,
author maintainer
#3 lore raw
Quoted 37 lines · Jason Wang
Quoted 35 lines · Michael S. Tsirkin

The only way for guest to control offloads (as enabled by VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) is by sending commands through CTRL_VQ. So it does not make sense to acknowledge VIRTIO_NET_F_CTRL_GUEST_OFFLOADS without VIRTIO_NET_F_CTRL_VQ.

The spec does not outlaw devices with such a configuration, so we have to support it. Simply clear VIRTIO_NET_F_CTRL_GUEST_OFFLOADS. Note that Linux is still crashing if it tries to
change the offloads when there's no control vq.
That needs to be fixed by another patch.

Fixes 3f93522ffab2 ("virtio-net: switch off offloads on demand if possible on XDP set")

---

Same patch as v1 but update documentation so it's clear it's not enough to fix the crash.

  drivers/net/virtio_net.c | 9 +++++++++
  1 file changed, 9 insertions(+)
drivers/net/virtio_net.c +4 -0
index 4d7d5434cc5d..7b8805b47f0d 100644
@@ -2971,6 +2971,15 @@ static int virtnet_validate(struct virtio_device *vdev)
  	if (!virtnet_validate_features(vdev))
  		return -EINVAL;
+	/* VIRTIO_NET_F_CTRL_GUEST_OFFLOADS does not work without
+	 * VIRTIO_NET_F_CTRL_VQ. Unfortunately spec forgot to
+	 * specify that VIRTIO_NET_F_CTRL_GUEST_OFFLOADS depends
+	 * on VIRTIO_NET_F_CTRL_VQ so devices can set the later but
Quoted 8 lines

drivers/net/virtio_net.c static int virtnet_validate(struct virtio_device *vdev) · line 2981

Quoted 4 lines
drivers/net/virtio_net.c +4 -0
+	 * not the former.
+	 */
+	if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ))
+			__virtio_clear_bit(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS);

If it's just because a bug of spec, should we simply fix the bug and fail the negotiation in virtnet_validate_feature()?

One man's bug is another man's feature: arguably leaving the features independent in the spec might allow reuse of the feature bit without breaking guests.

And even if we say it's a bug we can't simply fix the bug in the
spec: changing the text for a future version does not change the fact that devices behaving according to the spec exist.

Quoted 4 lines

Otherwise there would be inconsistency in handling feature dependencies for ctrl vq.

Thanks

That's a cosmetic problem ATM. It might be a good idea to generally change our handling of dependencies, and clear feature bits instead of failing probe on a mismatch. It's worth thinking - at the spec level - how we can best make the configuration extensible.
But that's not something spec should worry about.

Quoted 5 lines

drivers/net/virtio_net.c static int virtnet_validate(struct virtio_device *vdev) · line 2985

Quoted 5 lines
drivers/net/virtio_net.c +1 -0
+
  	if (virtio_has_feature(vdev, VIRTIO_NET_F_MTU)) {
  		int mtu = virtio_cread16(vdev,
  					 offsetof(struct virtio_net_config,

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

author maintainer
#4 lore raw
In reply to Jason Wang
Quoted 37 lines · Jason Wang
Quoted 35 lines · Michael S. Tsirkin

The only way for guest to control offloads (as enabled by VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) is by sending commands through CTRL_VQ. So it does not make sense to acknowledge VIRTIO_NET_F_CTRL_GUEST_OFFLOADS without VIRTIO_NET_F_CTRL_VQ.

The spec does not outlaw devices with such a configuration, so we have to support it. Simply clear VIRTIO_NET_F_CTRL_GUEST_OFFLOADS. Note that Linux is still crashing if it tries to
change the offloads when there's no control vq.
That needs to be fixed by another patch.

Fixes 3f93522ffab2 ("virtio-net: switch off offloads on demand if possible on XDP set")

---

Same patch as v1 but update documentation so it's clear it's not enough to fix the crash.

  drivers/net/virtio_net.c | 9 +++++++++
  1 file changed, 9 insertions(+)
drivers/net/virtio_net.c +4 -0
index 4d7d5434cc5d..7b8805b47f0d 100644
@@ -2971,6 +2971,15 @@ static int virtnet_validate(struct virtio_device *vdev)
  	if (!virtnet_validate_features(vdev))
  		return -EINVAL;
+	/* VIRTIO_NET_F_CTRL_GUEST_OFFLOADS does not work without
+	 * VIRTIO_NET_F_CTRL_VQ. Unfortunately spec forgot to
+	 * specify that VIRTIO_NET_F_CTRL_GUEST_OFFLOADS depends
+	 * on VIRTIO_NET_F_CTRL_VQ so devices can set the later but
Quoted 8 lines

drivers/net/virtio_net.c static int virtnet_validate(struct virtio_device *vdev) · line 2981

Quoted 4 lines
drivers/net/virtio_net.c +4 -0
+	 * not the former.
+	 */
+	if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ))
+			__virtio_clear_bit(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS);

If it's just because a bug of spec, should we simply fix the bug and fail the negotiation in virtnet_validate_feature()?

One man's bug is another man's feature: arguably leaving the features independent in the spec might allow reuse of the feature bit without breaking guests.

And even if we say it's a bug we can't simply fix the bug in the
spec: changing the text for a future version does not change the fact that devices behaving according to the spec exist.

Quoted 4 lines

Otherwise there would be inconsistency in handling feature dependencies for ctrl vq.

Thanks

That's a cosmetic problem ATM. It might be a good idea to generally change our handling of dependencies, and clear feature bits instead of failing probe on a mismatch. It's worth thinking - at the spec level - how we can best make the configuration extensible.
But that's not something spec should worry about.

Quoted 5 lines
Quoted 5 lines
drivers/net/virtio_net.c +1 -0
+
  	if (virtio_has_feature(vdev, VIRTIO_NET_F_MTU)) {
  		int mtu = virtio_cread16(vdev,
  					 offsetof(struct virtio_net_config,
#5 lore raw
Quoted 52 lines · Michael S. Tsirkin
Quoted 35 lines · Jason Wang
Quoted 34 lines · Michael S. Tsirkin

The only way for guest to control offloads (as enabled by VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) is by sending commands through CTRL_VQ. So it does not make sense to acknowledge VIRTIO_NET_F_CTRL_GUEST_OFFLOADS without VIRTIO_NET_F_CTRL_VQ.

The spec does not outlaw devices with such a configuration, so we have to support it. Simply clear VIRTIO_NET_F_CTRL_GUEST_OFFLOADS. Note that Linux is still crashing if it tries to
change the offloads when there's no control vq.
That needs to be fixed by another patch.

Fixes 3f93522ffab2 ("virtio-net: switch off offloads on demand if possible on XDP set")

---

Same patch as v1 but update documentation so it's clear it's not enough to fix the crash.

   drivers/net/virtio_net.c | 9 +++++++++
   1 file changed, 9 insertions(+)
drivers/net/virtio_net.c +3 -0
index 4d7d5434cc5d..7b8805b47f0d 100644
@@ -2971,6 +2971,15 @@ static int virtnet_validate(struct virtio_device *vdev)
   	if (!virtnet_validate_features(vdev))
   		return -EINVAL;
+	/* VIRTIO_NET_F_CTRL_GUEST_OFFLOADS does not work without
+	 * VIRTIO_NET_F_CTRL_VQ. Unfortunately spec forgot to
+	 * specify that VIRTIO_NET_F_CTRL_GUEST_OFFLOADS depends
Quoted 8 lines

drivers/net/virtio_net.c static int virtnet_validate(struct virtio_device *vdev) · line 2981

Quoted 5 lines
drivers/net/virtio_net.c +5 -0
+	 * on VIRTIO_NET_F_CTRL_VQ so devices can set the later but
+	 * not the former.
+	 */
+	if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ))
+			__virtio_clear_bit(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS);

If it's just because a bug of spec, should we simply fix the bug and fail the negotiation in virtnet_validate_feature()?

One man's bug is another man's feature: arguably leaving the features independent in the spec might allow reuse of the feature bit without breaking guests.

And even if we say it's a bug we can't simply fix the bug in the
spec: changing the text for a future version does not change the fact that devices behaving according to the spec exist.

Quoted 7 lines
Quoted 4 lines

Otherwise there would be inconsistency in handling feature dependencies for ctrl vq.

Thanks

That's a cosmetic problem ATM. It might be a good idea to generally change our handling of dependencies, and clear feature bits instead of failing probe on a mismatch.

Something like I proposed in the past ? [1]

[1] https://lore.kernel.org/patchwork/patch/519074/

Quoted 9 lines

It's worth thinking - at the spec level -
how we can best make the configuration extensible. But that's not something spec should worry about.

Quoted 4 lines
Quoted 4 lines
drivers/net/virtio_net.c +1 -0
+
   	if (virtio_has_feature(vdev, VIRTIO_NET_F_MTU)) {
   		int mtu = virtio_cread16(vdev,
   					 offsetof(struct virtio_net_config,

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#6 lore raw
In reply to Michael S. Tsirkin
Quoted 52 lines · Michael S. Tsirkin
Quoted 35 lines · Jason Wang
Quoted 34 lines · Michael S. Tsirkin

The only way for guest to control offloads (as enabled by VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) is by sending commands through CTRL_VQ. So it does not make sense to acknowledge VIRTIO_NET_F_CTRL_GUEST_OFFLOADS without VIRTIO_NET_F_CTRL_VQ.

The spec does not outlaw devices with such a configuration, so we have to support it. Simply clear VIRTIO_NET_F_CTRL_GUEST_OFFLOADS. Note that Linux is still crashing if it tries to
change the offloads when there's no control vq.
That needs to be fixed by another patch.

Fixes 3f93522ffab2 ("virtio-net: switch off offloads on demand if possible on XDP set")

---

Same patch as v1 but update documentation so it's clear it's not enough to fix the crash.

   drivers/net/virtio_net.c | 9 +++++++++
   1 file changed, 9 insertions(+)
drivers/net/virtio_net.c +3 -0
index 4d7d5434cc5d..7b8805b47f0d 100644
@@ -2971,6 +2971,15 @@ static int virtnet_validate(struct virtio_device *vdev)
   	if (!virtnet_validate_features(vdev))
   		return -EINVAL;
+	/* VIRTIO_NET_F_CTRL_GUEST_OFFLOADS does not work without
+	 * VIRTIO_NET_F_CTRL_VQ. Unfortunately spec forgot to
+	 * specify that VIRTIO_NET_F_CTRL_GUEST_OFFLOADS depends
Quoted 8 lines

drivers/net/virtio_net.c static int virtnet_validate(struct virtio_device *vdev) · line 2981

Quoted 5 lines
drivers/net/virtio_net.c +5 -0
+	 * on VIRTIO_NET_F_CTRL_VQ so devices can set the later but
+	 * not the former.
+	 */
+	if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ))
+			__virtio_clear_bit(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS);

If it's just because a bug of spec, should we simply fix the bug and fail the negotiation in virtnet_validate_feature()?

One man's bug is another man's feature: arguably leaving the features independent in the spec might allow reuse of the feature bit without breaking guests.

And even if we say it's a bug we can't simply fix the bug in the
spec: changing the text for a future version does not change the fact that devices behaving according to the spec exist.

Quoted 7 lines
Quoted 4 lines

Otherwise there would be inconsistency in handling feature dependencies for ctrl vq.

Thanks

That's a cosmetic problem ATM. It might be a good idea to generally change our handling of dependencies, and clear feature bits instead of failing probe on a mismatch.

Something like I proposed in the past ? [1]

[1] https://lore.kernel.org/patchwork/patch/519074/

Quoted 9 lines

It's worth thinking - at the spec level -
how we can best make the configuration extensible. But that's not something spec should worry about.

Quoted 4 lines
Quoted 4 lines
drivers/net/virtio_net.c +1 -0
+
   	if (virtio_has_feature(vdev, VIRTIO_NET_F_MTU)) {
   		int mtu = virtio_cread16(vdev,
   					 offsetof(struct virtio_net_config,
author maintainer
#7 lore raw
Quoted 58 lines · Jason Wang
Quoted 56 lines · Michael S. Tsirkin
Quoted 35 lines · Jason Wang
Quoted 34 lines · Michael S. Tsirkin

The only way for guest to control offloads (as enabled by VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) is by sending commands through CTRL_VQ. So it does not make sense to acknowledge VIRTIO_NET_F_CTRL_GUEST_OFFLOADS without VIRTIO_NET_F_CTRL_VQ.

The spec does not outlaw devices with such a configuration, so we have to support it. Simply clear VIRTIO_NET_F_CTRL_GUEST_OFFLOADS. Note that Linux is still crashing if it tries to
change the offloads when there's no control vq.
That needs to be fixed by another patch.

Fixes 3f93522ffab2 ("virtio-net: switch off offloads on demand if possible on XDP set")

---

Same patch as v1 but update documentation so it's clear it's not enough to fix the crash.

   drivers/net/virtio_net.c | 9 +++++++++
   1 file changed, 9 insertions(+)
drivers/net/virtio_net.c +3 -0
index 4d7d5434cc5d..7b8805b47f0d 100644
@@ -2971,6 +2971,15 @@ static int virtnet_validate(struct virtio_device *vdev)
   	if (!virtnet_validate_features(vdev))
   		return -EINVAL;
+	/* VIRTIO_NET_F_CTRL_GUEST_OFFLOADS does not work without
+	 * VIRTIO_NET_F_CTRL_VQ. Unfortunately spec forgot to
+	 * specify that VIRTIO_NET_F_CTRL_GUEST_OFFLOADS depends
Quoted 8 lines

drivers/net/virtio_net.c static int virtnet_validate(struct virtio_device *vdev) · line 2981

Quoted 5 lines
drivers/net/virtio_net.c +5 -0
+	 * on VIRTIO_NET_F_CTRL_VQ so devices can set the later but
+	 * not the former.
+	 */
+	if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ))
+			__virtio_clear_bit(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS);

If it's just because a bug of spec, should we simply fix the bug and fail the negotiation in virtnet_validate_feature()?

One man's bug is another man's feature: arguably leaving the features independent in the spec might allow reuse of the feature bit without breaking guests.

And even if we say it's a bug we can't simply fix the bug in the
spec: changing the text for a future version does not change the fact that devices behaving according to the spec exist.

Quoted 4 lines

Otherwise there would be inconsistency in handling feature dependencies for ctrl vq.

Thanks

Quoted 8 lines
Quoted 3 lines

That's a cosmetic problem ATM. It might be a good idea to generally change our handling of dependencies, and clear feature bits instead of failing probe on a mismatch.

Something like I proposed in the past ? [1]

[1] https://lore.kernel.org/patchwork/patch/519074/

No that still fails probe.

I am asking whether it's more future proof to fail probe on feature combinations disallowed by spec, or to clear bits to get to an expected combination.

In any case, we should probably document in the spec how drivers behave on such combinations.

Quoted 10 lines
Quoted 10 lines

It's worth thinking - at the spec level -
how we can best make the configuration extensible. But that's not something spec should worry about.

Quoted 4 lines
Quoted 4 lines
drivers/net/virtio_net.c +1 -0
+
   	if (virtio_has_feature(vdev, VIRTIO_NET_F_MTU)) {
   		int mtu = virtio_cread16(vdev,
   					 offsetof(struct virtio_net_config,

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#8 lore raw
Quoted 63 lines · Michael S. Tsirkin
Quoted 62 lines · Jason Wang
Quoted 51 lines · Michael S. Tsirkin
Quoted 34 lines · Jason Wang
Quoted 33 lines · Michael S. Tsirkin

The only way for guest to control offloads (as enabled by VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) is by sending commands through CTRL_VQ. So it does not make sense to acknowledge VIRTIO_NET_F_CTRL_GUEST_OFFLOADS without VIRTIO_NET_F_CTRL_VQ.

The spec does not outlaw devices with such a configuration, so we have to support it. Simply clear VIRTIO_NET_F_CTRL_GUEST_OFFLOADS. Note that Linux is still crashing if it tries to
change the offloads when there's no control vq.
That needs to be fixed by another patch.

Fixes 3f93522ffab2 ("virtio-net: switch off offloads on demand if possible on XDP set")

---

Same patch as v1 but update documentation so it's clear it's not enough to fix the crash.

    drivers/net/virtio_net.c | 9 +++++++++
    1 file changed, 9 insertions(+)
drivers/net/virtio_net.c +2 -0
index 4d7d5434cc5d..7b8805b47f0d 100644
@@ -2971,6 +2971,15 @@ static int virtnet_validate(struct virtio_device *vdev)
    	if (!virtnet_validate_features(vdev))
    		return -EINVAL;
+	/* VIRTIO_NET_F_CTRL_GUEST_OFFLOADS does not work without
+	 * VIRTIO_NET_F_CTRL_VQ. Unfortunately spec forgot to
Quoted 8 lines

drivers/net/virtio_net.c static int virtnet_validate(struct virtio_device *vdev) · line 2981

Quoted 6 lines
drivers/net/virtio_net.c +6 -0
+	 * specify that VIRTIO_NET_F_CTRL_GUEST_OFFLOADS depends
+	 * on VIRTIO_NET_F_CTRL_VQ so devices can set the later but
+	 * not the former.
+	 */
+	if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ))
+			__virtio_clear_bit(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS);

If it's just because a bug of spec, should we simply fix the bug and fail the negotiation in virtnet_validate_feature()?

One man's bug is another man's feature: arguably leaving the features independent in the spec might allow reuse of the feature bit without breaking guests.

And even if we say it's a bug we can't simply fix the bug in the
spec: changing the text for a future version does not change the fact that devices behaving according to the spec exist.

Quoted 7 lines
Quoted 4 lines

Otherwise there would be inconsistency in handling feature dependencies for ctrl vq.

Thanks

That's a cosmetic problem ATM. It might be a good idea to generally change our handling of dependencies, and clear feature bits instead of failing probe on a mismatch.

Something like I proposed in the past ? [1]

Quoted 7 lines
Quoted 1 line

[1] https://lore.kernel.org/patchwork/patch/519074/

No that still fails probe.

I am asking whether it's more future proof to fail probe on feature combinations disallowed by spec, or to clear bits to get to an expected combination.

Sorry wrong link.

It should be: https://lkml.org/lkml/2014/11/17/82

Quoted 3 lines

In any case, we should probably document in the spec how drivers behave on such combinations.

Yes.

Thanks

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

It's worth thinking - at the spec level -
how we can best make the configuration extensible. But that's not something spec should worry about.

Quoted 4 lines
Quoted 4 lines
drivers/net/virtio_net.c +1 -0
+
    	if (virtio_has_feature(vdev, VIRTIO_NET_F_MTU)) {
    		int mtu = virtio_cread16(vdev,
    					 offsetof(struct virtio_net_config,

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

maintainer
#9 lore raw
In reply to Michael S. Tsirkin

From: "Michael S. Tsirkin" <[email protected]>
Date: Sun, 5 Jan 2020 08:22:07 -0500

Quoted 12 lines

The only way for guest to control offloads (as enabled by VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) is by sending commands through CTRL_VQ. So it does not make sense to acknowledge VIRTIO_NET_F_CTRL_GUEST_OFFLOADS without VIRTIO_NET_F_CTRL_VQ.

The spec does not outlaw devices with such a configuration, so we have to support it. Simply clear VIRTIO_NET_F_CTRL_GUEST_OFFLOADS. Note that Linux is still crashing if it tries to
change the offloads when there's no control vq.
That needs to be fixed by another patch.

Quoted 8 lines
Fixes 3f93522ffab2 ("virtio-net: switch off offloads on demand if possible on XDP set")

---

Same patch as v1 but update documentation so it's clear it's not enough to fix the crash.

Where are we with this patch? There seems to still be some unresolved discussion about how we should actually handle this case.

Thanks.

maintainer
#10 lore raw
In reply to Michael S. Tsirkin

From: "Michael S. Tsirkin" <[email protected]>
Date: Sun, 5 Jan 2020 08:22:07 -0500

Quoted 12 lines

The only way for guest to control offloads (as enabled by VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) is by sending commands through CTRL_VQ. So it does not make sense to acknowledge VIRTIO_NET_F_CTRL_GUEST_OFFLOADS without VIRTIO_NET_F_CTRL_VQ.

The spec does not outlaw devices with such a configuration, so we have to support it. Simply clear VIRTIO_NET_F_CTRL_GUEST_OFFLOADS. Note that Linux is still crashing if it tries to
change the offloads when there's no control vq.
That needs to be fixed by another patch.

Quoted 8 lines
Fixes 3f93522ffab2 ("virtio-net: switch off offloads on demand if possible on XDP set")

---

Same patch as v1 but update documentation so it's clear it's not enough to fix the crash.

Where are we with this patch? There seems to still be some unresolved discussion about how we should actually handle this case.

Thanks.

author maintainer
#11 lore raw
Quoted 21 lines · David Miller

From: "Michael S. Tsirkin" <[email protected]>
Date: Sun, 5 Jan 2020 08:22:07 -0500

Quoted 18 lines

The only way for guest to control offloads (as enabled by VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) is by sending commands through CTRL_VQ. So it does not make sense to acknowledge VIRTIO_NET_F_CTRL_GUEST_OFFLOADS without VIRTIO_NET_F_CTRL_VQ.

The spec does not outlaw devices with such a configuration, so we have to support it. Simply clear VIRTIO_NET_F_CTRL_GUEST_OFFLOADS. Note that Linux is still crashing if it tries to
change the offloads when there's no control vq.
That needs to be fixed by another patch.

Fixes 3f93522ffab2 ("virtio-net: switch off offloads on demand if possible on XDP set")

---

Quoted 7 lines
Quoted 2 lines

Same patch as v1 but update documentation so it's clear it's not enough to fix the crash.

Where are we with this patch? There seems to still be some unresolved discussion about how we should actually handle this case.

Thanks.

Once discussion is resolved I'll post v3 with updated commit log.

author maintainer
#12 lore raw
In reply to David Miller
Quoted 21 lines · David Miller

From: "Michael S. Tsirkin" <[email protected]>
Date: Sun, 5 Jan 2020 08:22:07 -0500

Quoted 18 lines

The only way for guest to control offloads (as enabled by VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) is by sending commands through CTRL_VQ. So it does not make sense to acknowledge VIRTIO_NET_F_CTRL_GUEST_OFFLOADS without VIRTIO_NET_F_CTRL_VQ.

The spec does not outlaw devices with such a configuration, so we have to support it. Simply clear VIRTIO_NET_F_CTRL_GUEST_OFFLOADS. Note that Linux is still crashing if it tries to
change the offloads when there's no control vq.
That needs to be fixed by another patch.

Fixes 3f93522ffab2 ("virtio-net: switch off offloads on demand if possible on XDP set")

---

Quoted 7 lines
Quoted 2 lines

Same patch as v1 but update documentation so it's clear it's not enough to fix the crash.

Where are we with this patch? There seems to still be some unresolved discussion about how we should actually handle this case.

Thanks.

Once discussion is resolved I'll post v3 with updated commit log.