Skip to contentSkip to conversation

vdpa/mlx5: Fix is_index_valid() to refer to features

PATCH Si-Wei Liu 3 participants 6 messages Jan 11, 2022 – Jan 12, 2022 3 messages not in the archive virtio core

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Si-Wei Liu

author Reviewed-by
#1 lore raw
Quoted 4 lines · Eli Cohen

Make sure the decision whether an index received trough a callback is valid or not consults the negotiated features.

Is there more for this series? Subject says there're 4 patches in total?

Quoted 16 lines
---
  drivers/vdpa/mlx5/net/mlx5_vnet.c | 10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +2 -2
index d1ff65065fb1..9eacfdb48434 100644
@@ -133,10 +133,14 @@ struct mlx5_vdpa_virtqueue {
 
  static bool is_index_valid(struct mlx5_vdpa_dev *mvdev, u16 idx)
  {
-	if (unlikely(idx > mvdev->max_idx))
-		return false;
+	if (!(mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_MQ))) {
+		if (!(mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ)))

drivers/vdpa/mlx5/net/mlx5_vnet.c struct mlx5_vdpa_virtqueue { · line 146

Quoted 10 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +5 -1
+			return idx < 2;
+		else
+			return idx < 3;
+	}
 
-	return true;
+	return idx <= mvdev->max_idx;
  }
 
  struct mlx5_vdpa_net {

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 8 lines · Eli Cohen
Quoted 7 lines · Si-Wei Liu
Quoted 4 lines · Eli Cohen

Make sure the decision whether an index received trough a callback is valid or not consults the negotiated features.

Quoted 8 lines
Quoted 3 lines

Is there more for this series? Subject says there're 4 patches in total?

No,there were unrelated patches in my tree that went out.

Let me see if there are more patches for me to send and if I do, I will resend this in the previous one again.

Yea the series is malformed. Not a single thread, etc.

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
---
  drivers/vdpa/mlx5/net/mlx5_vnet.c | 10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +3 -2
index d1ff65065fb1..9eacfdb48434 100644
@@ -133,10 +133,14 @@ struct mlx5_vdpa_virtqueue {
  static bool is_index_valid(struct mlx5_vdpa_dev *mvdev, u16 idx)
  {
-	if (unlikely(idx > mvdev->max_idx))
-		return false;
+	if (!(mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_MQ))) {
+		if (!(mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ)))
+			return idx < 2;
Quoted 8 lines
Quoted 8 lines

drivers/vdpa/mlx5/net/mlx5_vnet.c struct mlx5_vdpa_virtqueue { · line 143

Quoted 7 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +4 -1
+		else
+			return idx < 3;
+	}
-	return true;
+	return idx <= mvdev->max_idx;
  }
  struct mlx5_vdpa_net {

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

#4 lore raw
In reply to Si-Wei Liu
Quoted 10 lines · Si-Wei Liu
Quoted 4 lines · Eli Cohen

Make sure the decision whether an index received trough a callback is valid or not consults the negotiated features.

Is there more for this series? Subject says there're 4 patches in total?

OK so with this + 1/4 are we OK with v7 of the big patchset now? I'm kind of beginning to worry it's rushed ...
Jason?

Quoted 15 lines
Quoted 15 lines
---
  drivers/vdpa/mlx5/net/mlx5_vnet.c | 10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +2 -2
index d1ff65065fb1..9eacfdb48434 100644
@@ -133,10 +133,14 @@ struct mlx5_vdpa_virtqueue {
  static bool is_index_valid(struct mlx5_vdpa_dev *mvdev, u16 idx)
  {
-	if (unlikely(idx > mvdev->max_idx))
-		return false;
+	if (!(mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_MQ))) {
+		if (!(mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ)))
Quoted 8 lines

drivers/vdpa/mlx5/net/mlx5_vnet.c struct mlx5_vdpa_virtqueue { · line 143

Quoted 8 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +5 -1
+			return idx < 2;
+		else
+			return idx < 3;
+	}
-	return true;
+	return idx <= mvdev->max_idx;
  }
  struct mlx5_vdpa_net {

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

#5 lore raw
Quoted 8 lines · Michael S. Tsirkin
Quoted 6 lines · Si-Wei Liu
Quoted 3 lines · Eli Cohen

Make sure the decision whether an index received trough a callback is valid or not consults the negotiated features.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Is there more for this series? Subject says there're 4 patches in total?

OK so with this + 1/4 are we OK with v7 of the big patchset now? I'm kind of beginning to worry it's rushed ...
Jason?

With Eli's new series [PATCH 0/4] Fixes to confing max virtqueues series

We are almost fine, Siwei promise to post other minor issues if necessary.

Thanks

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

---
  drivers/vdpa/mlx5/net/mlx5_vnet.c | 10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +2 -2
index d1ff65065fb1..9eacfdb48434 100644
@@ -133,10 +133,14 @@ struct mlx5_vdpa_virtqueue {
  static bool is_index_valid(struct mlx5_vdpa_dev *mvdev, u16 idx)
  {
-   if (unlikely(idx > mvdev->max_idx))
-           return false;
+   if (!(mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_MQ))) {
+           if (!(mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ)))
Quoted 9 lines
Quoted 8 lines

drivers/vdpa/mlx5/net/mlx5_vnet.c struct mlx5_vdpa_virtqueue { · line 143

Quoted 8 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +5 -1
+                   return idx < 2;
+           else
+                   return idx < 3;
+   }
-   return true;
+   return idx <= mvdev->max_idx;
  }
  struct mlx5_vdpa_net {

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

#6 lore raw
In reply to a message not in the archive
Quoted 1 line · Eli Cohen

Make sure the decision whether an index received trough a callback is

through

Quoted 3 lines

valid or not consults the negotiated features.

Which commit does this fix?

Quoted 28 lines
---
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +7 -3
index d1ff65065fb1..9eacfdb48434 100644
@@ -133,10 +133,14 @@ struct mlx5_vdpa_virtqueue {
 
 static bool is_index_valid(struct mlx5_vdpa_dev *mvdev, u16 idx)
 {
-	if (unlikely(idx > mvdev->max_idx))
-		return false;
+	if (!(mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_MQ))) {
+		if (!(mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ)))
+			return idx < 2;
+		else
+			return idx < 3;
+	}
 
-	return true;
+	return idx <= mvdev->max_idx;
 }
 
 struct mlx5_vdpa_net {
Signature · 1 line
2.34.1

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw
Quoted 11 lines · Eli Cohen
Quoted 4 lines · Michael S. Tsirkin
Quoted 1 line · Eli Cohen

Make sure the decision whether an index received trough a callback is

through

Wil fix.

Quoted 3 lines
Quoted 3 lines

valid or not consults the negotiated features.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Which commit does this fix?

No specific commit. It's just that I get called for VQ rellated callbacks (e.g. get_vq_state), after the device has been reset. So this patch provides protection against such cases. I hit this issue while testing locally.

To include in the commit log then.
The point of providing the fixes tag with the commit is that it's then easier to figure out how do changes interact with each other.

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
---
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +6 -2
index d1ff65065fb1..9eacfdb48434 100644
@@ -133,10 +133,14 @@ struct mlx5_vdpa_virtqueue {
 
 static bool is_index_valid(struct mlx5_vdpa_dev *mvdev, u16 idx)
 {
-	if (unlikely(idx > mvdev->max_idx))
-		return false;
+	if (!(mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_MQ))) {
+		if (!(mvdev->actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VQ)))
+			return idx < 2;
+		else
+			return idx < 3;
+	}
 
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
drivers/vdpa/mlx5/net/mlx5_vnet.c +1 -1
-	return true;
+	return idx <= mvdev->max_idx;
 }
 
 struct mlx5_vdpa_net {
Signature · 1 line
2.34.1

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