From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5235DA0542 for ; Thu, 10 Nov 2022 18:31:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4C8A240143; Thu, 10 Nov 2022 18:31:55 +0100 (CET) Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) by mails.dpdk.org (Postfix) with ESMTP id AB33F400EF; Thu, 10 Nov 2022 18:31:53 +0100 (CET) Received: by mail-qt1-f174.google.com with SMTP id hh9so1303240qtb.13; Thu, 10 Nov 2022 09:31:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=D+mqHyTA9FnXTqumn0MfjbVMpnngnpDxk14Kfx1ZjYs=; b=Fy/Yv3GV/tlRO6CEp5oitZpoDEMDKVnEjcW4Ks6uYomQccHnYmmjKyfCr5fQxXkrkt XQUcvhEGjhc9Wg6p2samAk9eoMKXaPFdC3e9o2ib3mdqriCjO2CDTb+8aSW4wPsdaYWZ mP1U/NhTV6XbMA990gq7gzfAbvwAf77km7kyv9aJxIs1Tocn1pQVZOLogwHLRWrjqm7/ oQSlaUZu47chZsxRPtdGSDXaTjUasuAUcmvSpv2j6TI5WYZgTG9uKrXFVpILq2DhQ4CI 8Ka/eRd6eAe9icSCDGI/hdZwvrS/KQz1X1xxvjhDd4zZEi/zKjnlCGBxB95TjCYm5ipb DSmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=D+mqHyTA9FnXTqumn0MfjbVMpnngnpDxk14Kfx1ZjYs=; b=PHrTM9+pI0J4OuLPt2Dfj4ckG927+A2a1EuWOdgTgq20bT2DZfBwnpDUIhjHu0FALJ thOkwpT+5fF1ixFGtfb64rQJ6HDla4ErHxoRps+sFvR4q7sDBH+FgnpUwfnKt1mzFO+m cYIjSBqM2+iER67nPm2wRqbCo3KiDO8HLDr+IquxPL+SW/+9wtwm+K0G+QtZEE9iP5VK 6xD2Kia3pyZgWD+AxeMxEi9OTwCQsaAqpZqUEUoy4un33rQLfi+Yixyk8y9vZ7NwASFk jMAN6P6VeuNgMxThDWP7PBXbXQYEcLZnoiF6xLxd2AEs3kDfgpmqkPFQlqCXUgvv3kjT OMZA== X-Gm-Message-State: ACrzQf1+bjC50ZhGmyQkFrk22IeORBpwak0csX4YCWmQ4bXrfKOE0pcw P2YCSSsnBAWCL4Jm3BEyG88= X-Google-Smtp-Source: AMsMyM5IDJmSW7i76k/flbSQMsnSjggKdVZYaWBHD652vXOFQnDl7UNi/O59i69nbZfF2fd6x0PFgQ== X-Received: by 2002:a05:622a:1aa2:b0:3a5:3046:c150 with SMTP id s34-20020a05622a1aa200b003a53046c150mr42672705qtc.286.1668101512829; Thu, 10 Nov 2022 09:31:52 -0800 (PST) Received: from localhost.localdomain (bras-base-hullpq2034w-grc-21-70-54-168-223.dsl.bell.ca. [70.54.168.223]) by smtp.gmail.com with ESMTPSA id d4-20020a05620a240400b006f87d28ea3asm13379724qkn.54.2022.11.10.09.31.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 09:31:52 -0800 (PST) From: Luc Pelletier To: grive@u256.net Cc: dev@dpdk.org, Luc Pelletier , Konstantin Ananyev , stable@dpdk.org Subject: [PATCH] failsafe: fix segfault on hotplug event Date: Thu, 10 Nov 2022 11:34:12 -0500 Message-Id: <20221110163410.12734-1-lucp.at.work@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org When the failsafe PMD encounters a hotplug event, it switches its rx/tx functions to "safe" ones that validate the sub-device's rx/tx functions before calling them. It switches the rx/tx functions by changing the function pointers in the rte_eth_dev structure. Following commit 7a0935239b, the rx/tx functions of PMDs are no longer called through the function pointers in the rte_eth_dev structure. They are rather called through a flat array named rte_eth_fp_ops. The function pointers in that array are initialized when the devices start and are initialized. When a hotplug event occurs, the function pointers in rte_eth_fp_ops still point to the "unsafe" rx/tx functions in the failsafe PMD since they haven't been updated. This results in a segmentation fault because it ends up using the "unsafe" functions, when the "safe" functions should have been used. To fix the problem, the failsafe PMD code was changed to update the function pointers in the rte_eth_fp_ops array when a hotplug event occurs. Fixes: 7a0935239b ("ethdev: make fast-path functions to use new flat array") Cc: Konstantin Ananyev Cc: stable@dpdk.org Signed-off-by: Luc Pelletier --- drivers/net/failsafe/failsafe_rxtx.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/failsafe/failsafe_rxtx.c b/drivers/net/failsafe/failsafe_rxtx.c index fe67293299..34d59dfbb1 100644 --- a/drivers/net/failsafe/failsafe_rxtx.c +++ b/drivers/net/failsafe/failsafe_rxtx.c @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -44,9 +45,13 @@ failsafe_set_burst_fn(struct rte_eth_dev *dev, int force_safe) DEBUG("Using safe RX bursts%s", (force_safe ? " (forced)" : "")); dev->rx_pkt_burst = &failsafe_rx_burst; + rte_eth_fp_ops[dev->data->port_id].rx_pkt_burst = + &failsafe_rx_burst; } else if (!need_safe && safe_set) { DEBUG("Using fast RX bursts"); dev->rx_pkt_burst = &failsafe_rx_burst_fast; + rte_eth_fp_ops[dev->data->port_id].rx_pkt_burst = + &failsafe_rx_burst_fast; } need_safe = force_safe || fs_tx_unsafe(TX_SUBDEV(dev)); safe_set = (dev->tx_pkt_burst == &failsafe_tx_burst); @@ -54,9 +59,13 @@ failsafe_set_burst_fn(struct rte_eth_dev *dev, int force_safe) DEBUG("Using safe TX bursts%s", (force_safe ? " (forced)" : "")); dev->tx_pkt_burst = &failsafe_tx_burst; + rte_eth_fp_ops[dev->data->port_id].tx_pkt_burst = + &failsafe_tx_burst; } else if (!need_safe && safe_set) { DEBUG("Using fast TX bursts"); dev->tx_pkt_burst = &failsafe_tx_burst_fast; + rte_eth_fp_ops[dev->data->port_id].tx_pkt_burst = + &failsafe_tx_burst_fast; } rte_wmb(); } -- 2.25.1