From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60057.outbound.protection.outlook.com [40.107.6.57]) by dpdk.org (Postfix) with ESMTP id E36175F2A for ; Thu, 20 Dec 2018 01:22:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nJrjsc0fdMRx7LLIQT+iLQRT16eFAWRmBkqZZIsukRk=; b=Md5SFcGr02F+7NtG7AIjbaKl+wjQa4OCP7w6ADzu+UVLMc/N4HW2voalRi8Ehk+M3LpnBKIECfqlg3xkFJleBCspYQlNranCjbfD4iBpKyEKRUyYyg3PIcDBMwUaNyDUphXAg2tHBwZvkLNbnzayOxWZ4p3Htr6pgMg3x3bsTJg= Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com (52.134.72.27) by DB3PR0502MB4074.eurprd05.prod.outlook.com (52.134.72.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.20; Thu, 20 Dec 2018 00:22:03 +0000 Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::d43a:3775:8af7:29c6]) by DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::d43a:3775:8af7:29c6%3]) with mapi id 15.20.1425.025; Thu, 20 Dec 2018 00:22:03 +0000 From: Yongseok Koh To: Darek Stojaczyk CC: Anatoly Burakov , Maxime Coquelin , dpdk stable Thread-Topic: [dpdk-stable] patch 'vfio: do not needlessly setup device in secondary process' has been queued to LTS release 17.11.5 Thread-Index: AQHUiDmHROujOx3x/UmVtfzsXfv406WG45sA Date: Thu, 20 Dec 2018 00:22:03 +0000 Message-ID: <96077BDF-660B-4817-81AD-05A2C22A73E8@mellanox.com> References: <20181129231202.30436-1-yskoh@mellanox.com> <20181129231202.30436-127-yskoh@mellanox.com> In-Reply-To: <20181129231202.30436-127-yskoh@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=yskoh@mellanox.com; x-originating-ip: [69.181.245.183] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB3PR0502MB4074; 6:5w2hpI9wfZlC1IAEioVqxC6iEgTDOFxUM1rtxcHoeP1G94dM8jBY2vLgrQDpEOg8sivCQbDH8ork/ctHWlgKZLUseTSjA1fCMHf8jBMqC4tn0e0yF1le9dNNoxCCStn91m3ukhVmSR6vCY+qm4f5ZAtFjbVROGEhcd3Owrae8FYrr2pTQQiMH0jWX2MFJ0DsD023ltxxrDipu8IWOvi4v0kTJctv/4ffPLALL6cO73luQemxFYJ0wvuOVDV2qTcd/MsDYMae+0SuYJFOlVkAWax6AokNr5EMixRBWmyCu8qyzpcmv4yELNKiQ6e5m6eA9UdtM5awhUIf0NiejYzbtD3vGHW/UQr2JKv6UjZ6j3R+ernwa2gFMfGLKB7WXKttPE1buU0cXGXUQXDFM9VrGFtO0xik7ZeZ5+vKY9TvdRitZ3zf8HsCGaACyjm43TqUuonAsZvhyUyZceZPepaFgw==; 5:XQXYiO0BdkgKJlRsJvWAPv6IUrYswaMZ8XosbPtsmHKXef02Bi9MiCoEo0EPjwm1j9Vju2dlC3CBKC/pnLRJnGOeqXOJpHlQmSX7Rd3znPAh5x2QzymUOjaSK5dk44wVyXpWNr7ls3wkJGpIQx41ndb1nG6gCq5KOeTP2yfNVlE=; 7:I9hnoQD5gw5C/hjoiEanJtIBMP2m1uB7x7sm6lEDD2uoQ5PRmibePEnAp1yVmR3eMMIdvs+Qi9ebVZ/XGiBzyZ7Cy8NoxK7XQNYWKn+olDpAksDaQNShx2q9ChMmDAXR/dCXBV92c+2R1ZfevaYs2Q== x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 34c04223-25bd-4f15-9688-08d666112aae x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB3PR0502MB4074; x-ms-traffictypediagnostic: DB3PR0502MB4074: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(5005026)(6040522)(2401047)(8121501046)(93006095)(93001095)(3231475)(944501520)(4982022)(52105112)(10201501046)(3002001)(6055026)(149066)(150057)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:DB3PR0502MB4074; BCL:0; PCL:0; RULEID:; SRVR:DB3PR0502MB4074; x-forefront-prvs: 0892FA9A88 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(346002)(396003)(366004)(376002)(136003)(69234005)(199004)(189003)(28163001)(6436002)(82746002)(81166006)(81156014)(186003)(256004)(2616005)(486006)(476003)(305945005)(446003)(7736002)(5660300001)(33656002)(11346002)(53546011)(6506007)(97736004)(99286004)(106356001)(76176011)(105586002)(26005)(102836004)(6246003)(4001150100001)(6916009)(316002)(3846002)(6512007)(2906002)(54906003)(6116002)(229853002)(45080400002)(14454004)(68736007)(53936002)(4326008)(71200400001)(6486002)(86362001)(8936002)(83716004)(71190400001)(66066001)(575784001)(36756003)(478600001)(966005)(6306002)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0502MB4074; H:DB3PR0502MB3980.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 3YMsajOL1RbCLC7RY31N/S3ANvKjx0cBrdfZIz4JzFoTkeVruDpjtGo0Vzgb0XI0NUzmudq6osB2+WSoopLVlSvcAz1YIbgnkNj4BYr+HabOBuQV0pCp4LqPf6pUWdP2su/dGWtcUcxnmwVEyWxxAEMaWpp57h25Wn3NC09ocwOwIiahZ79bMEua3HCDeTF+Jll2OLANGwznlFOFP3v3Ue2VXcr0vSNVojFfYDPhzTvXOc8l4L0X8QfyJlRj8C+hpAKLGlPp2+afYvIaZsBjzvKp1Pk3Ty0fKqFMAohSLOsdGzUUyXQyfXM0G3NP0e0S spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: <82A82BDDA1B8C645B956BEF48ECF4CC2@eurprd05.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 34c04223-25bd-4f15-9688-08d666112aae X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Dec 2018 00:22:03.5440 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0502MB4074 Subject: Re: [dpdk-stable] patch 'vfio: do not needlessly setup device in secondary process' has been queued to LTS release 17.11.5 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Dec 2018 00:22:05 -0000 Hi, This patch is being removed from stable/17.11 as it was mistakenly merged. Patches having 'fix' keyword in the title were merged even though those don= 't have "Cc: stable@dpdk.org" tag in the commit message. If you think this patch is still needed for stable/17.11, please let me kno= w. Then I'll take it back. Thanks, Yongseok > On Nov 29, 2018, at 3:12 PM, Yongseok Koh wrote: >=20 > Hi, >=20 > FYI, your patch has been queued to LTS release 17.11.5 >=20 > Note it hasn't been pushed to https://emea01.safelinks.protection.outlook= .com/?url=3Dhttp%3A%2F%2Fdpdk.org%2Fbrowse%2Fdpdk-stable&data=3D02%7C01= %7Cyskoh%40mellanox.com%7C984a5148ee3f4d0911c508d65650a735%7Ca652971c7d2e4d= 9ba6a4d149256f461b%7C0%7C0%7C636791301732433081&sdata=3DxSYO3rfdcp080xZ= sdFughJwuHl10CW%2B6njLe8SLNR5o%3D&reserved=3D0 yet. > It will be pushed if I get no objections before 12/01/18. So please > shout if anyone has objections. >=20 > Also note that after the patch there's a diff of the upstream commit vs t= he patch applied > to the branch. If the code is different (ie: not only metadata diffs), du= e for example to > a change in context or macro names, please double check it. >=20 > Thanks. >=20 > Yongseok >=20 > --- > From ff44ba8002e2db8c02eb769d547bfd7659af14e1 Mon Sep 17 00:00:00 2001 > From: Darek Stojaczyk > Date: Wed, 21 Nov 2018 19:41:32 +0100 > Subject: [PATCH] vfio: do not needlessly setup device in secondary proces= s >=20 > [ upstream commit 047e3f9f2a4a4b73da86b707af8a32039ba1cad7 ] >=20 > Setting up a device that wasn't setup in the primary > process will possibly break the primary process. That's > because the IPC message to retrieve the group fd in the > primary will also *open* that group if it wasn't opened > before. Even though the secondary process closes that fd > soon after as a part of its error handling path, the > primary process leaks it. >=20 > What's worse, opening that fd on the primary will > increment the process-local counter of opened groups. > If it was 0 before, then the group will never be added > to the vfio container, nor dpdk memory will be ever > mapped. >=20 > This patch moves the proper error checks earlier in the > code to fully prevent setting up devices in secondary > processes that weren't setup in the primary process. >=20 > Fixes: 2f4adfad0a69 ("vfio: add multiprocess support") >=20 > Signed-off-by: Darek Stojaczyk > Acked-by: Anatoly Burakov > Reviewed-by: Maxime Coquelin > --- > drivers/bus/pci/linux/pci_vfio.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) >=20 > diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci= _vfio.c > index 745db260c..654897284 100644 > --- a/drivers/bus/pci/linux/pci_vfio.c > +++ b/drivers/bus/pci/linux/pci_vfio.c > @@ -580,11 +580,6 @@ pci_vfio_map_resource_secondary(struct rte_pci_devic= e *dev) > snprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT, > loc->domain, loc->bus, loc->devid, loc->function); >=20 > - ret =3D rte_vfio_setup_device(rte_pci_get_sysfs_path(), pci_addr, > - &vfio_dev_fd, &device_info); > - if (ret) > - return ret; > - > /* if we're in a secondary process, just find our tailq entry */ > TAILQ_FOREACH(vfio_res, vfio_res_list, next) { > if (rte_pci_addr_cmp(&vfio_res->pci_addr, > @@ -596,9 +591,14 @@ pci_vfio_map_resource_secondary(struct rte_pci_devic= e *dev) > if (vfio_res =3D=3D NULL) { > RTE_LOG(ERR, EAL, " %s cannot find TAILQ entry for PCI device!\n", > pci_addr); > - goto err_vfio_dev_fd; > + return -1; > } >=20 > + ret =3D rte_vfio_setup_device(rte_pci_get_sysfs_path(), pci_addr, > + &vfio_dev_fd, &device_info); > + if (ret) > + return ret; > + > /* map BARs */ > maps =3D vfio_res->maps; >=20 > --=20 > 2.11.0 >=20 > --- > Diff of the applied patch vs upstream commit (please double-check if non= -empty: > --- > --- - 2018-11-29 15:01:50.745484864 -0800 > +++ 0127-vfio-do-not-needlessly-setup-device-in-secondary-pro.patch 2018-= 11-29 15:01:45.335961000 -0800 > @@ -1,8 +1,10 @@ > -From 047e3f9f2a4a4b73da86b707af8a32039ba1cad7 Mon Sep 17 00:00:00 2001 > +From ff44ba8002e2db8c02eb769d547bfd7659af14e1 Mon Sep 17 00:00:00 2001 > From: Darek Stojaczyk > Date: Wed, 21 Nov 2018 19:41:32 +0100 > Subject: [PATCH] vfio: do not needlessly setup device in secondary proces= s >=20 > +[ upstream commit 047e3f9f2a4a4b73da86b707af8a32039ba1cad7 ] > + > Setting up a device that wasn't setup in the primary > process will possibly break the primary process. That's > because the IPC message to retrieve the group fd in the > @@ -31,10 +33,10 @@ > 1 file changed, 6 insertions(+), 6 deletions(-) >=20 > diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci= _vfio.c > -index ffd26f195..54a4c959e 100644 > +index 745db260c..654897284 100644 > --- a/drivers/bus/pci/linux/pci_vfio.c > +++ b/drivers/bus/pci/linux/pci_vfio.c > -@@ -794,11 +794,6 @@ pci_vfio_map_resource_secondary(struct rte_pci_devi= ce *dev) > +@@ -580,11 +580,6 @@ pci_vfio_map_resource_secondary(struct rte_pci_devi= ce *dev) > snprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT, > loc->domain, loc->bus, loc->devid, loc->function); >=20 > @@ -46,7 +48,7 @@ > /* if we're in a secondary process, just find our tailq entry */ > TAILQ_FOREACH(vfio_res, vfio_res_list, next) { > if (rte_pci_addr_cmp(&vfio_res->pci_addr, > -@@ -810,9 +805,14 @@ pci_vfio_map_resource_secondary(struct rte_pci_devi= ce *dev) > +@@ -596,9 +591,14 @@ pci_vfio_map_resource_secondary(struct rte_pci_devi= ce *dev) > if (vfio_res =3D=3D NULL) { > RTE_LOG(ERR, EAL, " %s cannot find TAILQ entry for PCI device!\n", > pci_addr);