Skip to contentSkip to conversation

net/virtio: fix Tx queue 0 override by queue 128

PATCH Applied Xueming Li 3 participants 3 messages Dec 2, 2021 – Jan 27, 2022 Network drivers

lore
Share & tools
lore

Xueming Li

author
#0 lore raw

PATCH 1/1 net/virtio: fix Tx queue 0 override by queue 128

Both Rx queue and Tx queue are VirtQ in virtio, VQ index is 256 for Tx queue 128. Uint8 type of TxQ VQ index overflows and overrides Tx queue 0 data.

This patch fixes VQ index type with uint16 type.

Fixes c1f86306a026 ("virtio: add new driver")
---
 drivers/net/virtio/virtio_rxtx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_rxtx.c +2 -2
index 2e115ded023..f0eafd29dc1 100644
@@ -814,7 +814,7 @@ virtio_dev_tx_queue_setup(struct rte_eth_dev *dev,
 			unsigned int socket_id __rte_unused,
 			const struct rte_eth_txconf *tx_conf)
 {
-	uint8_t vq_idx = 2 * queue_idx + VTNET_SQ_TQ_QUEUE_IDX;
+	uint16_t vq_idx = 2 * queue_idx + VTNET_SQ_TQ_QUEUE_IDX;
 	struct virtio_hw *hw = dev->data->dev_private;
 	struct virtqueue *vq = hw->vqs[vq_idx];
 	struct virtnet_tx *txvq;
@@ -858,7 +858,7 @@ int
 virtio_dev_tx_queue_setup_finish(struct rte_eth_dev *dev,
 				uint16_t queue_idx)
 {
-	uint8_t vq_idx = 2 * queue_idx + VTNET_SQ_TQ_QUEUE_IDX;
+	uint16_t vq_idx = 2 * queue_idx + VTNET_SQ_TQ_QUEUE_IDX;
 	struct virtio_hw *hw = dev->data->dev_private;
 	struct virtqueue *vq = hw->vqs[vq_idx];
 
Signature · 1 line
2.34.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 28 lines · Xueming Li

Both Rx queue and Tx queue are VirtQ in virtio, VQ index is 256 for Tx queue 128. Uint8 type of TxQ VQ index overflows and overrides Tx queue 0 data.

This patch fixes VQ index type with uint16 type.

Fixes c1f86306a026 ("virtio: add new driver")
---
  drivers/net/virtio/virtio_rxtx.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_rxtx.c +1 -1
index 2e115ded023..f0eafd29dc1 100644
@@ -814,7 +814,7 @@ virtio_dev_tx_queue_setup(struct rte_eth_dev *dev,
  			unsigned int socket_id __rte_unused,
  			const struct rte_eth_txconf *tx_conf)
  {
-	uint8_t vq_idx = 2 * queue_idx + VTNET_SQ_TQ_QUEUE_IDX;
+	uint16_t vq_idx = 2 * queue_idx + VTNET_SQ_TQ_QUEUE_IDX;
  	struct virtio_hw *hw = dev->data->dev_private;
  	struct virtqueue *vq = hw->vqs[vq_idx];
  	struct virtnet_tx *txvq;

drivers/net/virtio/virtio_rxtx.c int · line 864

Quoted 8 lines
drivers/net/virtio/virtio_rxtx.c +1 -1
@@ -858,7 +858,7 @@ int
  virtio_dev_tx_queue_setup_finish(struct rte_eth_dev *dev,
  				uint16_t queue_idx)
  {
-	uint8_t vq_idx = 2 * queue_idx + VTNET_SQ_TQ_QUEUE_IDX;
+	uint16_t vq_idx = 2 * queue_idx + VTNET_SQ_TQ_QUEUE_IDX;
  	struct virtio_hw *hw = dev->data->dev_private;
  	struct virtqueue *vq = hw->vqs[vq_idx];
 

Thanks for the fix!
Maxime

Applied
#2 lore raw
In reply to Xueming Li
Quoted 14 lines

-----Original Message-----
From: Xueming Li <[email protected]>
Sent: Thursday, December 2, 2021 9:51 PM
To: [email protected]
Cc: [email protected]; [email protected]; Maxime Coquelin <[email protected]>; Xia, Chenbo <[email protected]>
Subject: [PATCH] net/virtio: fix Tx queue 0 override by queue 128

Both Rx queue and Tx queue are VirtQ in virtio, VQ index is 256 for Tx queue 128. Uint8 type of TxQ VQ index overflows and overrides Tx queue 0 data.

This patch fixes VQ index type with uint16 type.

Quoted 7 lines
Fixes c1f86306a026 ("virtio: add new driver")

---
--
2.34.0

Applied to next-virtio/main, thanks