Skip to contentSkip to conversation

vdpa/mlx5: Fix umem sizes assignments on VQ create

PATCH In review Eli Cohen 2 participants 7 messages May 30, 2021

Subsystems (2)
lore
Share & tools
lore

Eli Cohen

author
#0 lore raw

PATCH 1/2 vdpa/mlx5: Fix umem sizes assignments on VQ create

Fix copy paste bug assigning umem1 size to umem2 and umem3.

Fixes 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")
---
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +2 -2
index 189e4385df40..53312f0460ad 100644
@@ -828,9 +828,9 @@ static int create_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtque
 	MLX5_SET(virtio_q, vq_ctx, umem_1_id, mvq->umem1.id);
 	MLX5_SET(virtio_q, vq_ctx, umem_1_size, mvq->umem1.size);
 	MLX5_SET(virtio_q, vq_ctx, umem_2_id, mvq->umem2.id);
-	MLX5_SET(virtio_q, vq_ctx, umem_2_size, mvq->umem1.size);
+	MLX5_SET(virtio_q, vq_ctx, umem_2_size, mvq->umem2.size);
 	MLX5_SET(virtio_q, vq_ctx, umem_3_id, mvq->umem3.id);
-	MLX5_SET(virtio_q, vq_ctx, umem_3_size, mvq->umem1.size);
+	MLX5_SET(virtio_q, vq_ctx, umem_3_size, mvq->umem3.size);
 	MLX5_SET(virtio_q, vq_ctx, pd, ndev->mvdev.res.pdn);
 	if (MLX5_CAP_DEV_VDPA_EMULATION(ndev->mvdev.mdev, eth_frame_offload_type))
 		MLX5_SET(virtio_q, vq_ctx, virtio_version_1_0, 1);
Signature · 1 line
2.31.1
#1 lore raw
Quoted 4 lines · Eli Cohen

Fix copy paste bug assigning umem1 size to umem2 and umem3.

Fixes 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")

could you clarify the impact of the bug please?

Quoted 22 lines
---
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +2 -2
index 189e4385df40..53312f0460ad 100644
@@ -828,9 +828,9 @@ static int create_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtque
 	MLX5_SET(virtio_q, vq_ctx, umem_1_id, mvq->umem1.id);
 	MLX5_SET(virtio_q, vq_ctx, umem_1_size, mvq->umem1.size);
 	MLX5_SET(virtio_q, vq_ctx, umem_2_id, mvq->umem2.id);
-	MLX5_SET(virtio_q, vq_ctx, umem_2_size, mvq->umem1.size);
+	MLX5_SET(virtio_q, vq_ctx, umem_2_size, mvq->umem2.size);
 	MLX5_SET(virtio_q, vq_ctx, umem_3_id, mvq->umem3.id);
-	MLX5_SET(virtio_q, vq_ctx, umem_3_size, mvq->umem1.size);
+	MLX5_SET(virtio_q, vq_ctx, umem_3_size, mvq->umem3.size);
 	MLX5_SET(virtio_q, vq_ctx, pd, ndev->mvdev.res.pdn);
 	if (MLX5_CAP_DEV_VDPA_EMULATION(ndev->mvdev.mdev, eth_frame_offload_type))
 		MLX5_SET(virtio_q, vq_ctx, virtio_version_1_0, 1);
Signature · 1 line
2.31.1

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

author
#2 lore raw
Quoted 8 lines · Michael S. Tsirkin
Quoted 4 lines · Eli Cohen

Fix copy paste bug assigning umem1 size to umem2 and umem3.

Fixes 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")

could you clarify the impact of the bug please?

I leads to firmware failure to create the virtqueue resource when you try to use a 1:1 mapping MR. This kind of usage is presented in the virtio_vdpa support I sent earlier.

Quoted 23 lines
Quoted 22 lines
---
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +2 -2
index 189e4385df40..53312f0460ad 100644
@@ -828,9 +828,9 @@ static int create_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtque
 	MLX5_SET(virtio_q, vq_ctx, umem_1_id, mvq->umem1.id);
 	MLX5_SET(virtio_q, vq_ctx, umem_1_size, mvq->umem1.size);
 	MLX5_SET(virtio_q, vq_ctx, umem_2_id, mvq->umem2.id);
-	MLX5_SET(virtio_q, vq_ctx, umem_2_size, mvq->umem1.size);
+	MLX5_SET(virtio_q, vq_ctx, umem_2_size, mvq->umem2.size);
 	MLX5_SET(virtio_q, vq_ctx, umem_3_id, mvq->umem3.id);
-	MLX5_SET(virtio_q, vq_ctx, umem_3_size, mvq->umem1.size);
+	MLX5_SET(virtio_q, vq_ctx, umem_3_size, mvq->umem3.size);
 	MLX5_SET(virtio_q, vq_ctx, pd, ndev->mvdev.res.pdn);
 	if (MLX5_CAP_DEV_VDPA_EMULATION(ndev->mvdev.mdev, eth_frame_offload_type))
 		MLX5_SET(virtio_q, vq_ctx, virtio_version_1_0, 1);
Signature · 1 line
2.31.1
#3 lore raw
Quoted 7 lines · Eli Cohen
Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Eli Cohen

Fix copy paste bug assigning umem1 size to umem2 and umem3.

Fixes 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")
Quoted 6 lines
Quoted 2 lines

could you clarify the impact of the bug please?

I leads to firmware failure to create the virtqueue resource when you try to use a 1:1 mapping MR. This kind of usage is presented in the virtio_vdpa support I sent earlier.

OK pls include this info in the commit log. And is 1:1 the only case where sizes differ? Is it true that in other cases sizes are all the same?

Quoted 23 lines
Quoted 23 lines
Quoted 22 lines
---
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +2 -2
index 189e4385df40..53312f0460ad 100644
@@ -828,9 +828,9 @@ static int create_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtque
 	MLX5_SET(virtio_q, vq_ctx, umem_1_id, mvq->umem1.id);
 	MLX5_SET(virtio_q, vq_ctx, umem_1_size, mvq->umem1.size);
 	MLX5_SET(virtio_q, vq_ctx, umem_2_id, mvq->umem2.id);
-	MLX5_SET(virtio_q, vq_ctx, umem_2_size, mvq->umem1.size);
+	MLX5_SET(virtio_q, vq_ctx, umem_2_size, mvq->umem2.size);
 	MLX5_SET(virtio_q, vq_ctx, umem_3_id, mvq->umem3.id);
-	MLX5_SET(virtio_q, vq_ctx, umem_3_size, mvq->umem1.size);
+	MLX5_SET(virtio_q, vq_ctx, umem_3_size, mvq->umem3.size);
 	MLX5_SET(virtio_q, vq_ctx, pd, ndev->mvdev.res.pdn);
 	if (MLX5_CAP_DEV_VDPA_EMULATION(ndev->mvdev.mdev, eth_frame_offload_type))
 		MLX5_SET(virtio_q, vq_ctx, virtio_version_1_0, 1);
Signature · 1 line
2.31.1
author
#4 lore raw
Quoted 8 lines · Michael S. Tsirkin
Quoted 7 lines · Eli Cohen
Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Eli Cohen

Fix copy paste bug assigning umem1 size to umem2 and umem3.

Fixes 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

could you clarify the impact of the bug please?

I leads to firmware failure to create the virtqueue resource when you try to use a 1:1 mapping MR. This kind of usage is presented in the virtio_vdpa support I sent earlier.

OK pls include this info in the commit log.

OK

Quoted 3 lines

And is 1:1 the only case where
sizes differ? Is it true that in other cases sizes are all the same?

The sizes are calculated based on firmware published paramters and a formula provided by the spec. They do differ but it so happened that size1 was larger than size2 and size3 so we did not see failures till now.

Quoted 24 lines
Quoted 23 lines
Quoted 23 lines
Quoted 22 lines
---
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +2 -2
index 189e4385df40..53312f0460ad 100644
@@ -828,9 +828,9 @@ static int create_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtque
 	MLX5_SET(virtio_q, vq_ctx, umem_1_id, mvq->umem1.id);
 	MLX5_SET(virtio_q, vq_ctx, umem_1_size, mvq->umem1.size);
 	MLX5_SET(virtio_q, vq_ctx, umem_2_id, mvq->umem2.id);
-	MLX5_SET(virtio_q, vq_ctx, umem_2_size, mvq->umem1.size);
+	MLX5_SET(virtio_q, vq_ctx, umem_2_size, mvq->umem2.size);
 	MLX5_SET(virtio_q, vq_ctx, umem_3_id, mvq->umem3.id);
-	MLX5_SET(virtio_q, vq_ctx, umem_3_size, mvq->umem1.size);
+	MLX5_SET(virtio_q, vq_ctx, umem_3_size, mvq->umem3.size);
 	MLX5_SET(virtio_q, vq_ctx, pd, ndev->mvdev.res.pdn);
 	if (MLX5_CAP_DEV_VDPA_EMULATION(ndev->mvdev.mdev, eth_frame_offload_type))
 		MLX5_SET(virtio_q, vq_ctx, virtio_version_1_0, 1);
Signature · 1 line
2.31.1
#5 lore raw
Quoted 19 lines · Eli Cohen
Quoted 8 lines · Michael S. Tsirkin
Quoted 7 lines · Eli Cohen
Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Eli Cohen

Fix copy paste bug assigning umem1 size to umem2 and umem3.

Fixes 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

could you clarify the impact of the bug please?

I leads to firmware failure to create the virtqueue resource when you try to use a 1:1 mapping MR. This kind of usage is presented in the virtio_vdpa support I sent earlier.

OK pls include this info in the commit log.

OK

Quoted 7 lines
Quoted 3 lines

And is 1:1 the only case where
sizes differ? Is it true that in other cases sizes are all the same?

The sizes are calculated based on firmware published paramters and a formula provided by the spec. They do differ but it so happened that size1 was larger than size2 and size3 so we did not see failures till now.

can this have a security impact? e.g. can guest access addresses outside of it's memory with this?

Quoted 24 lines
Quoted 24 lines
Quoted 23 lines
Quoted 23 lines
Quoted 22 lines
---
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +2 -2
index 189e4385df40..53312f0460ad 100644
@@ -828,9 +828,9 @@ static int create_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtque
 	MLX5_SET(virtio_q, vq_ctx, umem_1_id, mvq->umem1.id);
 	MLX5_SET(virtio_q, vq_ctx, umem_1_size, mvq->umem1.size);
 	MLX5_SET(virtio_q, vq_ctx, umem_2_id, mvq->umem2.id);
-	MLX5_SET(virtio_q, vq_ctx, umem_2_size, mvq->umem1.size);
+	MLX5_SET(virtio_q, vq_ctx, umem_2_size, mvq->umem2.size);
 	MLX5_SET(virtio_q, vq_ctx, umem_3_id, mvq->umem3.id);
-	MLX5_SET(virtio_q, vq_ctx, umem_3_size, mvq->umem1.size);
+	MLX5_SET(virtio_q, vq_ctx, umem_3_size, mvq->umem3.size);
 	MLX5_SET(virtio_q, vq_ctx, pd, ndev->mvdev.res.pdn);
 	if (MLX5_CAP_DEV_VDPA_EMULATION(ndev->mvdev.mdev, eth_frame_offload_type))
 		MLX5_SET(virtio_q, vq_ctx, virtio_version_1_0, 1);
Signature · 1 line
2.31.1
author
#6 lore raw
Quoted 23 lines · Michael S. Tsirkin
Quoted 22 lines · Eli Cohen
Quoted 8 lines · Michael S. Tsirkin
Quoted 7 lines · Eli Cohen
Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines · Eli Cohen

Fix copy paste bug assigning umem1 size to umem2 and umem3.

Fixes 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices")
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

could you clarify the impact of the bug please?

I leads to firmware failure to create the virtqueue resource when you try to use a 1:1 mapping MR. This kind of usage is presented in the virtio_vdpa support I sent earlier.

OK pls include this info in the commit log.

OK

Quoted 3 lines

And is 1:1 the only case where
sizes differ? Is it true that in other cases sizes are all the same?

Quoted 8 lines
Quoted 4 lines

The sizes are calculated based on firmware published paramters and a formula provided by the spec. They do differ but it so happened that size1 was larger than size2 and size3 so we did not see failures till now.

can this have a security impact? e.g. can guest access addresses outside of it's memory with this?

No, this memory is accesible only by firmware for its internal use.

Quoted 25 lines
Quoted 24 lines
Quoted 24 lines
Quoted 23 lines
Quoted 23 lines
Quoted 22 lines
---
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +2 -2
index 189e4385df40..53312f0460ad 100644
@@ -828,9 +828,9 @@ static int create_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtque
 	MLX5_SET(virtio_q, vq_ctx, umem_1_id, mvq->umem1.id);
 	MLX5_SET(virtio_q, vq_ctx, umem_1_size, mvq->umem1.size);
 	MLX5_SET(virtio_q, vq_ctx, umem_2_id, mvq->umem2.id);
-	MLX5_SET(virtio_q, vq_ctx, umem_2_size, mvq->umem1.size);
+	MLX5_SET(virtio_q, vq_ctx, umem_2_size, mvq->umem2.size);
 	MLX5_SET(virtio_q, vq_ctx, umem_3_id, mvq->umem3.id);
-	MLX5_SET(virtio_q, vq_ctx, umem_3_size, mvq->umem1.size);
+	MLX5_SET(virtio_q, vq_ctx, umem_3_size, mvq->umem3.size);
 	MLX5_SET(virtio_q, vq_ctx, pd, ndev->mvdev.res.pdn);
 	if (MLX5_CAP_DEV_VDPA_EMULATION(ndev->mvdev.mdev, eth_frame_offload_type))
 		MLX5_SET(virtio_q, vq_ctx, virtio_version_1_0, 1);
Signature · 1 line
2.31.1