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 71CC8A034F for ; Wed, 10 Nov 2021 07:40:26 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 61EE140142; Wed, 10 Nov 2021 07:40:26 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2059.outbound.protection.outlook.com [40.107.243.59]) by mails.dpdk.org (Postfix) with ESMTP id 6ACA040142 for ; Wed, 10 Nov 2021 07:40:25 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=higed5XA4RqoYXgAr8xLmdQbbEX2ZVklK0RPgWu9l4pcrvRqigB/fIce2w/i4C5QjXiWQy7zMzkaWC6orbuAQkW1ZVq+ULixDaeSNg4HN4BRBtYGMPd38fWgMNSdmDvm3nuQ5FGxHCWpeWDEo+ygHvlUhrEvSCUZIDuiF1X/kH4SThHhvZXvGu0EGMFPzKAAvvU5Y1BcjKEfH8K+Qk9wX0/zweLuyREHwzaclPa+nCJ+VOH7WKCOswJKu6MTzY9u4sORDpRp2+7MK5Ydr8E+bxUf1pLHXCZnvO9a6ZK1a4Db5yPGmpPc8Wt2Yo6K4HupgfWhLA50TgKzUZOXpl7FNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EAZ4H3T+dLbOphRgANandB0eTrqqar3FDvWCXlVnCgw=; b=ZpeF+Hzk756lULx0YbbYXUcUmsDZyOWuDWNQDGz52qRuKTO15rbjhj5NAjo/nqWxW+D/mqd8+7l6MAc4SaNAMtyLh+mdJDy19h0Ejvo4qNIux6Jw/JtPS4bbx+I5rRpq5ixtF4VI2RkE+1eoLZXvEd6MBGWfyK6FlAaU9j189lXKpp2VMiy0tYUByU1zZynudK6tEY6iAmhX8CB80NhbbVWb2Uf/NQ3+o95cK0jVg3ArMfGDEQCdDcKNP8cAmkKhrPPYwNUd8tN7v2Y+ehV1Rz9W6xNNLzSh28YgGCBviEdCjHzN6eS0VyKGZxX5VHA6aceTkcccF/gJaWvbCcCrSQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=marvell.com smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EAZ4H3T+dLbOphRgANandB0eTrqqar3FDvWCXlVnCgw=; b=ZzXj2SAiX3WhPn4zMKB84jw+mKAI8iNjPP0PX72RpBC5gJ3dZIllINuHdaOHz9zE/unnji0ID3tL357xlmOLGAuX+MMbmHYpUGH3R1EieFSYW+s++K+RvSRFv35//ee1CAVzg8slw4pXFS9ZviFjbjYOyQ3ZV4B0sN0lxWmV/aUliu9slvYG5qqIGQaqfxS1QFs1SbFhbwzxU+14c92JbUOnhH1jvu8bdrJ61qheIoMuvh+rJ8jYgEjQ4VExpRByABxBLiv3gzFqoQQdeV6705PPPlpxueRlYejyD2Y8nnivkk8rKNtehRK2y5P3Gm4rKgIJsYqVP8VmU+yOt9ux/w== Received: from DM6PR06CA0036.namprd06.prod.outlook.com (2603:10b6:5:120::49) by CH2PR12MB3749.namprd12.prod.outlook.com (2603:10b6:610:2a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10; Wed, 10 Nov 2021 06:40:20 +0000 Received: from DM6NAM11FT060.eop-nam11.prod.protection.outlook.com (2603:10b6:5:120:cafe::30) by DM6PR06CA0036.outlook.office365.com (2603:10b6:5:120::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.15 via Frontend Transport; Wed, 10 Nov 2021 06:40:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; marvell.com; dkim=none (message not signed) header.d=none;marvell.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by DM6NAM11FT060.mail.protection.outlook.com (10.13.173.63) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4690.15 via Frontend Transport; Wed, 10 Nov 2021 06:40:20 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 10 Nov 2021 06:40:17 +0000 From: Xueming Li To: Harman Kalra CC: Luca Boccassi , David George , Jerin Jacob , dpdk stable Date: Wed, 10 Nov 2021 14:29:18 +0800 Message-ID: <20211110063216.2744012-75-xuemingl@nvidia.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211110063216.2744012-1-xuemingl@nvidia.com> References: <20211110063216.2744012-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 74831330-6584-4eb7-23cb-08d9a414f717 X-MS-TrafficTypeDiagnostic: CH2PR12MB3749: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uii2E5ZY4cm6rWTl4SPO4K95ErK7QZ/Q5t6EA0qgSqFv7aK1vsgEVR8VeBZnLRmfafLqeQ5+qx8SM3P1f+iiWBTvAkxljuXZPdDCdzKq6QNXLWk7opp4CYk83V/mikyrVf6BowYFIrrxy7tBVrDgOyEQ7OdJ3VpIWECPkB9oOvswrFv+aZAbEr1ivYwkIn0YYt8bCqb2xwpe5u3PW1E5uk6JtUdqFbekViAh+rGOpkqX4G96dPsuPqP0hOmcQtZsGEFRWRZu3IbI5IW00KSKywjxLBiZkwlPyB5faCLD8ePDN2lZafgM6eig661WR4S+OT9c0cifwGehStLkAsupk7OigcRm+MLU8CLK+k15rCjGYRiZj2Co3H4MJmJMR+3oJO0qifU9x81NcRqkt6Z8bcdEarBjp3Q729abwbeoO8XdEfaVm6rES/SabMoSFaV9Gy/fVU1QlCXmWMmyAvUqut7bjuD38+9kDz40qtcOysTRfNt04MGT6K0hVC2YNRrGyNP8NHA6NoRQL+9Lrslue7bTgwSX2wL5CptnNIM7zifHzk2PjwA+ZEFVx75kNl44G9RzHT1zlwrHCCoCtH2LEQfvTZmQ1nAPDwTwyfSsAJlkQhVvWFS5rK6j51GLpD0xzyXHYHtfSDKVZ3Jsn37STcYq/S7sPciL29PrnlwPcCBqGaOy9L2Z9G6d7uGlY/O2Tnz7eBkJ91inZKcsqlnER6GGUlWGYPwqPrtC+B2KPy3cl7iZc2+6mASuhVwJuwC/+mB/6vwrJ958X937D+EDkz7Ub7Z/3yPoXK6veqkYK5L/TLvWoKIe9zPxSq7PmOKxKinZX0753PKJuYEDoUWrKA== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(53546011)(6286002)(82310400003)(7696005)(83380400001)(70206006)(5660300002)(2906002)(70586007)(8936002)(8676002)(316002)(36860700001)(186003)(4326008)(508600001)(2616005)(4001150100001)(47076005)(54906003)(1076003)(966005)(6916009)(356005)(36756003)(426003)(55016002)(16526019)(336012)(26005)(7636003)(86362001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2021 06:40:20.0276 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 74831330-6584-4eb7-23cb-08d9a414f717 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT060.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB3749 Subject: [dpdk-stable] patch 'net/octeontx: fix access to indirect buffers' has been queued to stable release 20.11.4 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 Sender: "stable" Hi, FYI, your patch has been queued to stable release 20.11.4 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/12/21. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/steevenlee/dpdk This queued commit can be viewed at: https://github.com/steevenlee/dpdk/commit/4649ead943c2a16ced41cde27e9354eae57ded79 Thanks. Xueming Li --- >From 4649ead943c2a16ced41cde27e9354eae57ded79 Mon Sep 17 00:00:00 2001 From: Harman Kalra Date: Mon, 20 Sep 2021 20:19:25 +0530 Subject: [PATCH] net/octeontx: fix access to indirect buffers Cc: Xueming Li [ upstream commit 9eb5cb3b11cc97e8e0c61ee216bd586b4793335f ] Issue has been observed where fields of indirect buffers are accessed after being set free by the diver. Also fixing freeing of direct buffers to correct aura. Fixes: 5cbe184802aa ("net/octeontx: support fast mbuf free") Signed-off-by: David George Signed-off-by: Harman Kalra Acked-by: Jerin Jacob --- drivers/net/octeontx/octeontx_rxtx.h | 69 ++++++++++++++++++---------- 1 file changed, 46 insertions(+), 23 deletions(-) diff --git a/drivers/net/octeontx/octeontx_rxtx.h b/drivers/net/octeontx/octeontx_rxtx.h index 7c24d8b4fd..dde0d6277b 100644 --- a/drivers/net/octeontx/octeontx_rxtx.h +++ b/drivers/net/octeontx/octeontx_rxtx.h @@ -161,7 +161,7 @@ ptype_table[PTYPE_SIZE][PTYPE_SIZE][PTYPE_SIZE] = { static __rte_always_inline uint64_t -octeontx_pktmbuf_detach(struct rte_mbuf *m) +octeontx_pktmbuf_detach(struct rte_mbuf *m, struct rte_mbuf **m_tofree) { struct rte_mempool *mp = m->pool; uint32_t mbuf_size, buf_len; @@ -171,6 +171,8 @@ octeontx_pktmbuf_detach(struct rte_mbuf *m) /* Update refcount of direct mbuf */ md = rte_mbuf_from_indirect(m); + /* The real data will be in the direct buffer, inform callers this */ + *m_tofree = md; refcount = rte_mbuf_refcnt_update(md, -1); priv_size = rte_pktmbuf_priv_size(mp); @@ -203,18 +205,18 @@ octeontx_pktmbuf_detach(struct rte_mbuf *m) } static __rte_always_inline uint64_t -octeontx_prefree_seg(struct rte_mbuf *m) +octeontx_prefree_seg(struct rte_mbuf *m, struct rte_mbuf **m_tofree) { if (likely(rte_mbuf_refcnt_read(m) == 1)) { if (!RTE_MBUF_DIRECT(m)) - return octeontx_pktmbuf_detach(m); + return octeontx_pktmbuf_detach(m, m_tofree); m->next = NULL; m->nb_segs = 1; return 0; } else if (rte_mbuf_refcnt_update(m, -1) == 0) { if (!RTE_MBUF_DIRECT(m)) - return octeontx_pktmbuf_detach(m); + return octeontx_pktmbuf_detach(m, m_tofree); rte_mbuf_refcnt_set(m, 1); m->next = NULL; @@ -315,6 +317,14 @@ __octeontx_xmit_prepare(struct rte_mbuf *tx_pkt, uint64_t *cmd_buf, const uint16_t flag) { uint16_t gaura_id, nb_desc = 0; + struct rte_mbuf *m_tofree; + rte_iova_t iova; + uint16_t data_len; + + m_tofree = tx_pkt; + + data_len = tx_pkt->data_len; + iova = rte_mbuf_data_iova(tx_pkt); /* Setup PKO_SEND_HDR_S */ cmd_buf[nb_desc++] = tx_pkt->data_len & 0xffff; @@ -329,22 +339,23 @@ __octeontx_xmit_prepare(struct rte_mbuf *tx_pkt, uint64_t *cmd_buf, * not, as SG_DESC[I] and SEND_HDR[II] are clear. */ if (flag & OCCTX_TX_OFFLOAD_MBUF_NOFF_F) - cmd_buf[0] |= (octeontx_prefree_seg(tx_pkt) << + cmd_buf[0] |= (octeontx_prefree_seg(tx_pkt, &m_tofree) << 58); /* Mark mempool object as "put" since it is freed by PKO */ if (!(cmd_buf[0] & (1ULL << 58))) - __mempool_check_cookies(tx_pkt->pool, (void **)&tx_pkt, + __mempool_check_cookies(m_tofree->pool, (void **)&m_tofree, 1, 0); /* Get the gaura Id */ - gaura_id = octeontx_fpa_bufpool_gaura((uintptr_t)tx_pkt->pool->pool_id); + gaura_id = + octeontx_fpa_bufpool_gaura((uintptr_t)m_tofree->pool->pool_id); /* Setup PKO_SEND_BUFLINK_S */ cmd_buf[nb_desc++] = PKO_SEND_BUFLINK_SUBDC | PKO_SEND_BUFLINK_LDTYPE(0x1ull) | PKO_SEND_BUFLINK_GAUAR((long)gaura_id) | - tx_pkt->data_len; - cmd_buf[nb_desc++] = rte_mbuf_data_iova(tx_pkt); + data_len; + cmd_buf[nb_desc++] = iova; return nb_desc; } @@ -355,7 +366,9 @@ __octeontx_xmit_mseg_prepare(struct rte_mbuf *tx_pkt, uint64_t *cmd_buf, { uint16_t nb_segs, nb_desc = 0; uint16_t gaura_id, len = 0; - struct rte_mbuf *m_next = NULL; + struct rte_mbuf *m_next = NULL, *m_tofree; + rte_iova_t iova; + uint16_t data_len; nb_segs = tx_pkt->nb_segs; /* Setup PKO_SEND_HDR_S */ @@ -369,40 +382,50 @@ __octeontx_xmit_mseg_prepare(struct rte_mbuf *tx_pkt, uint64_t *cmd_buf, do { m_next = tx_pkt->next; - /* To handle case where mbufs belong to diff pools, like - * fragmentation + /* Get TX parameters up front, octeontx_prefree_seg might change + * them */ - gaura_id = octeontx_fpa_bufpool_gaura((uintptr_t) - tx_pkt->pool->pool_id); + m_tofree = tx_pkt; + data_len = tx_pkt->data_len; + iova = rte_mbuf_data_iova(tx_pkt); /* Setup PKO_SEND_GATHER_S */ - cmd_buf[nb_desc] = PKO_SEND_GATHER_SUBDC | - PKO_SEND_GATHER_LDTYPE(0x1ull) | - PKO_SEND_GATHER_GAUAR((long)gaura_id) | - tx_pkt->data_len; + cmd_buf[nb_desc] = 0; /* SG_DESC[I] bit controls if buffer is to be freed or * not, as SEND_HDR[DF] and SEND_HDR[II] are clear. */ if (flag & OCCTX_TX_OFFLOAD_MBUF_NOFF_F) { cmd_buf[nb_desc] |= - (octeontx_prefree_seg(tx_pkt) << 57); + (octeontx_prefree_seg(tx_pkt, &m_tofree) << 57); } + /* To handle case where mbufs belong to diff pools, like + * fragmentation + */ + gaura_id = octeontx_fpa_bufpool_gaura((uintptr_t) + m_tofree->pool->pool_id); + + /* Setup PKO_SEND_GATHER_S */ + cmd_buf[nb_desc] |= PKO_SEND_GATHER_SUBDC | + PKO_SEND_GATHER_LDTYPE(0x1ull) | + PKO_SEND_GATHER_GAUAR((long)gaura_id) | + data_len; + /* Mark mempool object as "put" since it is freed by * PKO. */ if (!(cmd_buf[nb_desc] & (1ULL << 57))) { tx_pkt->next = NULL; - __mempool_check_cookies(tx_pkt->pool, - (void **)&tx_pkt, 1, 0); + __mempool_check_cookies(m_tofree->pool, + (void **)&m_tofree, 1, 0); } nb_desc++; - cmd_buf[nb_desc++] = rte_mbuf_data_iova(tx_pkt); + cmd_buf[nb_desc++] = iova; nb_segs--; - len += tx_pkt->data_len; + len += data_len; tx_pkt = m_next; } while (nb_segs); -- 2.33.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-11-10 14:17:05.365018094 +0800 +++ 0074-net-octeontx-fix-access-to-indirect-buffers.patch 2021-11-10 14:17:01.837413030 +0800 @@ -1 +1 @@ -From 9eb5cb3b11cc97e8e0c61ee216bd586b4793335f Mon Sep 17 00:00:00 2001 +From 4649ead943c2a16ced41cde27e9354eae57ded79 Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 9eb5cb3b11cc97e8e0c61ee216bd586b4793335f ] @@ -11 +13,0 @@ -Cc: stable@dpdk.org @@ -21 +23 @@ -index 2ed28ea563..e0723ac26a 100644 +index 7c24d8b4fd..dde0d6277b 100644