GVE bug fixes
Subsystems (3)
cover GVE bug fixes
This patch series includes fixes to some bugs in the gve driver.
Catherine Sullivan (2):
gve: Check TX QPL was actually assigned
gve: Upgrade memory barrier in poll routine
David Awogbemila (3):
gve: Update mgmt_msix_idx if num_ntfy changes
gve: Add NULL pointer checks when freeing irqs.
gve: Drop skbs with invalid queue index.
drivers/net/ethernet/google/gve/gve_main.c | 21 ++++++++++++--------- drivers/net/ethernet/google/gve/gve_rx.c | 2 -- drivers/net/ethernet/google/gve/gve_tx.c | 10 +++++++--- 3 files changed, 19 insertions(+), 14 deletions(-)
Signature · 1 line
2.31.1.751.gd2f1c929bd-goog
PATCH 1/5 gve: Check TX QPL was actually assigned
From: Catherine Sullivan <[email protected]>
Correctly check the TX QPL was assigned and unassigned if other steps in the allocation fail.
--- drivers/net/ethernet/google/gve/gve_tx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/google/gve/gve_tx.c +6 -2
@@ -212,10 +212,11 @@ static int gve_tx_alloc_ring(struct gve_priv *priv, int idx) tx->dev = &priv->pdev->dev;if (!tx->raw_addressing) { tx->tx_fifo.qpl =gve_assign_tx_qpl (priv); - +if (!tx->tx_fifo.qpl) + goto abort_with_desc;/* map Tx FIFO */ if (gve_tx_fifo_init (priv, &tx->tx_fifo)) - goto abort_with_desc; + goto abort_with_qpl; } tx->q_resources =
@@ -236,6 +237,9 @@ static int gve_tx_alloc_ring(struct gve_priv *priv, int idx) abort_with_fifo:if (!tx->raw_addressing)gve_tx_fifo_release (priv, &tx->tx_fifo); +abort_with_qpl: +if (!tx->raw_addressing) +gve_unassign_qpl (priv, tx->tx_fifo.qpl->id); abort_with_desc:dma_free_coherent (hdev, bytes, tx->desc, tx->bus); tx->desc =NULL ;
Signature · 1 line
2.31.1.751.gd2f1c929bd-goog
PATCH 2/5 gve: Update mgmt_msix_idx if num_ntfy changes
In reply to David AwogbemilaIf we do not get the expected number of vectors from pci_enable_msix_range, we update priv->num_ntfy_blks but not priv->mgmt_msix_idx. This patch fixes this so that priv->mgmt_msix_idx is updated accordingly.
--- drivers/net/ethernet/google/gve/gve_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/google/gve/gve_main.c +1 -0
@@ -220,6 +220,7 @@ static int gve_alloc_notify_blocks(struct gve_priv *priv)int vecs_left = new_num_ntfy_blks %2 ; priv->num_ntfy_blks = new_num_ntfy_blks; + priv->mgmt_msix_idx = priv->num_ntfy_blks; priv->tx_cfg.max_queues =min_t (int, priv->tx_cfg.max_queues, vecs_per_type); priv->rx_cfg.max_queues = min_t(int, priv->rx_cfg.max_queues,
Signature · 1 line
2.31.1.751.gd2f1c929bd-goog
PATCH 3/5 gve: Add NULL pointer checks when freeing irqs.
In reply to David AwogbemilaWhen freeing notification blocks, we index priv->msix_vectors. If we failed to allocate priv->msix_vectors (see abort_with_msix_vectors) this could lead to a NULL pointer dereference if the driver is unloaded.
--- drivers/net/ethernet/google/gve/gve_main.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/net/ethernet/google/gve/gve_main.c +11 -9
@@ -301,20 +301,22 @@ static void gve_free_notify_blocks(struct gve_priv *priv) {int i; -/* Free the irqs */ -for (i =0 ; i < priv->num_ntfy_blks; i++) { -struct gve_notify_block *block = &priv->ntfy_blocks[i]; -int msix_idx = i; - -irq_set_affinity_hint (priv->msix_vectors[msix_idx].vector, -NULL ); -free_irq (priv->msix_vectors[msix_idx].vector, block); +if (priv->msix_vectors) { +/* Free the irqs */ +for (i =0 ; i < priv->num_ntfy_blks; i++) { +struct gve_notify_block *block = &priv->ntfy_blocks[i]; +int msix_idx = i; + +irq_set_affinity_hint (priv->msix_vectors[msix_idx].vector, +NULL ); +free_irq (priv->msix_vectors[msix_idx].vector, block); + } +free_irq (priv->msix_vectors[priv->mgmt_msix_idx].vector, priv); }dma_free_coherent (&priv->pdev->dev, priv->num_ntfy_blks *sizeof (*priv->ntfy_blocks), priv->ntfy_blocks, priv->ntfy_block_bus); priv->ntfy_blocks =NULL ; -free_irq (priv->msix_vectors[priv->mgmt_msix_idx].vector, priv);pci_disable_msix (priv->pdev);kvfree (priv->msix_vectors); priv->msix_vectors =NULL ;
Signature · 1 line
2.31.1.751.gd2f1c929bd-goog
PATCH 4/5 gve: Upgrade memory barrier in poll routine
In reply to David AwogbemilaFrom: Catherine Sullivan <[email protected]>
As currently written, if the driver checks for more work (via gve_tx_poll or gve_rx_poll) before the device posts work and the irq doorbell is not unmasked
(via iowrite32be(GVE_IRQ_ACK | GVE_IRQ_EVENT, ...)) before the device attempts to raise an interrupt, an interrupt is lost and this could potentially lead to the traffic being completely halted. For example, if a tx queue has already been stopped, the driver won't get the chance to complete work and egress will be halted.
We need a full memory barrier in the poll
routine to ensure that the irq doorbell is unmasked before the driver checks for more work.
--- drivers/net/ethernet/google/gve/gve_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/google/gve/gve_main.c +1 -1
@@ -180,7 +180,7 @@ static int gve_napi_poll(struct napi_struct *napi, int budget)/* Double check we have no extra work. * Ensure unmask synchronizes with checking for work. */ -dma_rmb (); +mb ();if (block->tx) reschedule |=gve_tx_poll (block,-1 );if (block->rx)
Signature · 1 line
2.31.1.751.gd2f1c929bd-goog
PATCH 5/5 gve: Correct SKB queue index validation.
In reply to David AwogbemilaSKBs with skb_get_queue_mapping(skb) == tx_cfg.num_queues should also be considered invalid.
--- drivers/net/ethernet/google/gve/gve_tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/google/gve/gve_tx.c +1 -1
@@ -593,7 +593,7 @@ netdev_tx_t gve_tx(struct sk_buff *skb, struct net_device *dev)struct gve_tx_ring *tx;int nsegs; -WARN (skb_get_queue_mapping (skb) > priv->tx_cfg.num_queues, +WARN (skb_get_queue_mapping (skb) >= priv->tx_cfg.num_queues,"skb queue index out of range" ); tx = &priv->tx[skb_get_queue_mapping (skb)];if (unlikely (gve_maybe_stop_tx (tx, skb))) {
Signature · 1 line
2.31.1.751.gd2f1c929bd-goog
This series was applied to netdev/net.git (refs/heads/master):
Hello:
This series was applied to netdev/net.git (refs/heads/master):
Quoted 6 lines · On Mon, 17 May 2021 14:08:10 -0700 you wrote:
This patch series includes fixes to some bugs in the gve driver.
Catherine Sullivan (2):
gve: Check TX QPL was actually assigned
gve: Upgrade memory barrier in poll routine
Quoted 6 lines
David Awogbemila (3):
gve: Updatemgmt_msix_idxifnum_ntfychanges
gve: Add NULL pointer checks when freeing irqs.
gve: Drop skbs with invalid queue index.[...]
Here is the summary with links:
- [net,1/5] gve: Check TX QPL was actually assigned
https://git.kernel.org/netdev/net/c/5aec55b46c62 - [net,2/5] gve: Update mgmt_msix_idx if num_ntfy changes https://git.kernel.org/netdev/net/c/e96b491a0ffa - [net,3/5] gve: Add NULL pointer checks when freeing irqs. https://git.kernel.org/netdev/net/c/5218e919c8d0 - [net,4/5] gve: Upgrade memory barrier in poll routine https://git.kernel.org/netdev/net/c/f81781835f0a - [net,5/5] gve: Correct SKB queue index validation. https://git.kernel.org/netdev/net/c/fbd4a28b4fa6
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html