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 02E40A0543 for ; Thu, 10 Nov 2022 18:44:18 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8B8554021D; Thu, 10 Nov 2022 18:44:18 +0100 (CET) Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) by mails.dpdk.org (Postfix) with ESMTP id 3EDFB400EF; Thu, 10 Nov 2022 18:44:16 +0100 (CET) Received: by mail-qk1-f181.google.com with SMTP id p18so1558975qkg.2; Thu, 10 Nov 2022 09:44:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7fwQjv5eZ55+zGu/5YLxKeT3e2xkqxcaYKyBgM5s0cc=; b=YEodOcR4jnq8T++om46FumXSgZ3TczA6qYVBS2f1BHsYGE924KHXLGmTLoluKLnvJF CyQJti4cN0MpK4XruaXJarzUo+qsXpCcDNXQhg5pItE/2yQCE/inQ7S0CGRytypw0UQ3 NvmQ7kLRymIvl7bazEWdVjHq3n8QCrznrIcopoKjUh2wQFsuPp6Gp5MVeRTnB/MJI1kN rMKLrwALwGZ2WJSHyFRvv4DhL0vwz0HzFKeW8DB2uDMIohSOwRtzgW4AC5BNGxW68wmN VZcwD0DO+CU7WvprjHDU7UvS1uzBB9SMKeK0KMuk5kmizAMMHFqiL853sLvlt3+lHvLG x1Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7fwQjv5eZ55+zGu/5YLxKeT3e2xkqxcaYKyBgM5s0cc=; b=NIfbTGC6pd6UbzKQIQPzmJAqDRek5+OWWaAHqjM1UlDVdeZtxsfUgpImqZfqNgwoAe Jm6wu0aZ4790Rq1z7uVmCcKyJn/+e3zYefWInGhl5XL/Fsldev9XrBn2kK8l7SbY6njB v/twyhzSe1gso++0mK09d5mc7zKJOvF1iDGkEBnqcZkAZcY2LdPEOk5kT87KDdmq+qsn VCNmuakMJKP1BvYPa9cbbHGV/lSW//nhG1y/4BxKz3IQeU3GdbEaB4njB/JquxykDauc zyvrstzi4f6Gx9JkdY97ekT4o2SEuGBFuiiclDOANB9AzWG213EE1BDVgjzQSdd5imxn DbXA== X-Gm-Message-State: ACrzQf2kFhNd2Dr+Y/AawVAdqIoASx/Px2hFDaiXmuZDaI4o4wGv6Pxk MNcKRNJFCAZc6/pHCID82ro= X-Google-Smtp-Source: AMsMyM4zkYZchQK1VkhtF/K9ufVINv3tMufwq+6ZPagr35TSKYxO3q1M38id7SjYopDU2LRCt8C9tg== X-Received: by 2002:a37:9ace:0:b0:6ee:e139:596c with SMTP id c197-20020a379ace000000b006eee139596cmr1527853qke.606.1668102255567; Thu, 10 Nov 2022 09:44:15 -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-20020a05620a240400b006f87d28ea3asm13398149qkn.54.2022.11.10.09.44.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 09:44:15 -0800 (PST) From: Luc Pelletier To: grive@u256.net Cc: dev@dpdk.org, Luc Pelletier , Konstantin Ananyev , stable@dpdk.org Subject: [PATCH v2] failsafe: fix segfault on hotplug event Date: Thu, 10 Nov 2022 12:42:43 -0500 Message-Id: <20221110174241.16061-1-lucp.at.work@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221110163410.12734-1-lucp.at.work@gmail.com> References: <20221110163410.12734-1-lucp.at.work@gmail.com> 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 7a0935239b9e, 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: 7a0935239b9e ("ethdev: make fast-path functions to use new flat array") Cc: Konstantin Ananyev Cc: stable@dpdk.org Signed-off-by: Luc Pelletier --- v2: * fixed git commit hashes in commit message 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