From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0043.outbound.protection.outlook.com [104.47.42.43]) by dpdk.org (Postfix) with ESMTP id 381022C3F for ; Tue, 9 May 2017 06:14:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=nKienuM0aA/erWc/+6Sg8vkvjIeTfWpiHpfaq4F4Vxg=; b=R81T3t6GIKQrq6TUbkt/jDcCo8S/wMktXW3ZNbv4BAJ5O1JMEel+J9yKEpgta81ESTIbYvWtj9x1GgWHO/Gfe2ECYZKBYw367jdrH2eg+d9C/Ab7xGfM7YksnZgo+fd14lFJAp9mncXtKVkQqIFwmbRKgXZwV9bOcyC9v2V3zSk= Authentication-Results: netronome.com; dkim=none (message not signed) header.d=none;netronome.com; dmarc=none action=none header.from=caviumnetworks.com; Received: from jerin (111.93.218.67) by BN3PR0701MB1718.namprd07.prod.outlook.com (10.163.39.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1075.11; Tue, 9 May 2017 04:14:10 +0000 Date: Tue, 9 May 2017 09:43:53 +0530 From: Jerin Jacob To: Alejandro Lucero Cc: Thomas Monjalon , dev , "Burakov, Anatoly" Message-ID: <20170509041352.GB6207@jerin> References: <1493203787-25555-1-git-send-email-alejandro.lucero@netronome.com> <1528500.cNnDXbOJL1@xps> <20170508152006.GA28180@jerin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.2 (2017-04-18) X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: MA1PR01CA0113.INDPRD01.PROD.OUTLOOK.COM (10.174.56.157) To BN3PR0701MB1718.namprd07.prod.outlook.com (10.163.39.17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ed4f9426-0076-4e4f-db3d-08d49691d957 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:BN3PR0701MB1718; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 3:X8jiLc5zfOAJMTLDTnP66/K84apEq8xx1Bz9UHRLIFlENpIfwLnyose/RJUSAlFrnIwp00Ja3dequCWVhEq7rWpEk7VhC6dIbvF/NX1uJAWSjNcl9mmN5vj50BYRxGWVWsg1Rd/uqC1jrFEYDnGf6yAYrzo66fQOA1rrktyjeLubkn/njSxW6zgp8vMWc0RA+PsLJCU/dVDZp1Rt84jUc/+wru2zscfGZpvQXfkB/2E1c+OFXiabP5mZKBJwk+RSgPMccClSBsPIKD76vvslZkr0f2zv2j1k6fbqGskOtHyAunD1RYiuZ73FNvY/uDIuKgSmJKkAsl5jojdzRcRD1A==; 25:OmaQZJLmTlWJZex1mSyHF5/fB9jTSoV5FV3L87gmbavRSaF/wbgF5NvDCilyl6sH2ZhKTYJGyj3MyABYd21nm41V777Mu0XSxwVjAT/Vp/nGREtUJ4pEzFkootVONW0F97KETsD9Z2Bd0h3+F+N08UFUQSEU4WVcO3cTanTK1kCEQarFH34/bIcUXJhzokTGYnTVR5SmAus9Vhuz45YNHeUICy7dcfzDY4E/z59+AuclYKBewku+AMrVH3BHIOMwZEx+ElilzWwMwnmy+4ck+QFSgDHkAL0xWD9YXr2YOeRdjBGBx07Yhggwd0oGSEoH10r10nhnAZPdTZ4uU844Vz975f702Au3ER7Bm2/QFcljjWGAEntmMMcLWKdKmRC34kUCuaq1tGRJ5bqCgy/djOrNmwBUTWvB+VTOuI4RKjdGfgvUIrnx8/sNfoAFzXklZW6CHF4ll9JcSm4gIsylfkr2A4z4vjKq+uH9iINMXCg= X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 31:SPahvgYZN6kEwnaOqf5wtbne+vbu7MXaclMP+irRAJSZl09iQU/zKi1I0rOBI0cGbMMayyA2J2xBGOHcIX8J/I1HpyEEPhDQdmkQsxz/ZqIEqoaTFwzkCIYmSa+9xd+pwb5sdZJagGuaZe3PjyaaCZ32n+l497jUDfq1JV15XIhRuhPkjpJAd6F8zIxyJWMxkIVyiY5DVtdxwr3lgEzA/WDlKv/se97vxHr1ySPKJ0AuC7J2xFbNgZa7URDz+JeOVl4S+t74iybuxhDe3CsA8i1NPXfqxHRyhkpy02QWOoE=; 20:QajzfjDaa3jn1fvmVnQMF+sH146x9/rINUZBba8it3XxMYoV/bGMAmztcrPXQ8jxfJN4VtqUfmR/uh2Nkl2RDbQKsUSebMxLv48t1XofNP17vR2bR3lW5VK4Hw9tPeINBnzbtCP2XRLGSEC7J4izJkx3gDfgUY+veB+XWp1lZXv/Brs+jbAEiD0sgsSewQtV/IyRsMQ8hu6HN0+6YVaOQDLMuocmxvbb1w342DzJPXPR3qrZsyNzWLXyRwMlr86suXDtg/JJTzeZ+nLLx5M1nnzPTFL33/1htf11SyXNn7W8Ur0r4P1FxEc/V4E/OHpXGUbaIz3b4C1UnYkHc68kP953XFQ2kdvZtQwnYX6oWAT6oTUPSuO2/WvuBjYsdHyyHujhyAEFc6LkaUkHoCjsne9r9rwmQzdPCDx9ujAf5HnKwbM0oq2qQQudm3uXduLfhSir8BXdODRD9GEwxFPT82Ret4PC/GmXlGgnIdlwRZuE9vJRR13V9BWwHAN8KQ/OGDWso5ZpxBE/zG/BD/Bhah6SNiMVHVH1VUKYoKAQoisnJUerELwMWN5Ney83WQ8PdpgGp1TcN3eTzIdkiNtL6KxwQgwct2FHVMPFG9/2pNY= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(3002001)(10201501046)(6041248)(20161123558100)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123564025)(20161123562025)(6072148); SRVR:BN3PR0701MB1718; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0701MB1718; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 4:h5gUDHAkW3FFxjPfYovJ5V3SAKvKNkoX+eSIf4HQmFiCx4R7mNYwdu45yVtj7XY94sj1EhhWHJLc65rU6z9rjVDO/+sHVq9BF/RHPLSc3A1FjC2VqB0xjp462mo/O2jiUZbEQ1BveBc57ikjp1qNUGIHCD0RODzec5o1qkEGxj+XD0iEbCMRq6NIh08uPupgbIp5LUmZWEGUv9tuk03GHDxL6jGGNRJrP9KiTetJZr2fWNkQxKiVwKEHUSMqc/HgxaMG1BZN/DevqHNSF2F1ocXwoLYTQ7Z7Qbdx9kfqpvdyAvH5IREIznE0edV20U2F4l80PEG87z4mH1YuRp5t4ctISVWZxYNl5j9Qol2hjpLKF0Ym5W7rgXWCIskD7M3MqgwE1GIU/cs2IszUAbeGS0ViGED4PiSpreKvfO5+cOB+O6c5TQwXZ9CQkTyhqVr0CCPN6UnEnezRSGOrc7rd6pemVCy2bEq7pxjl9eoRu9o97G8akne362KhxaGpnsUDvUageLmsl6VN1MbDU8PUTc/rbLORiZQy9uDdLvWnP4DMduPTPO9K+W/QYn+LIgg2Yln410OhzZPMWfFGmKxx7HC01xfmFSKPOVsNAOgqpeoVw1FP4D4Gf4OWdSJyMw05uunpmGd9CN518SQZsVwHfZpAQs+zXc/QPnpGNzGV9lEN+eoedK6trmQhbJgjYeZRf46ltQ/fp9ofAXN2/1HvBzb5q0zuZJoNVS3WQVFnC5WWZ88D5uy+frqtVyxFNTMROhEk/3l4uaXzrRVZdsn+MqopRnzqzAxJyC3vUy34S0Ndut9z/Wz0vgD1qYhgiMJ6 X-Forefront-PRVS: 0302D4F392 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39410400002)(39450400003)(39400400002)(39840400002)(377454003)(24454002)(13464003)(25786009)(8676002)(1076002)(9686003)(53546009)(83506001)(55016002)(6116002)(50466002)(3846002)(81166006)(54906002)(42882006)(23726003)(47776003)(5009440100003)(4326008)(6496005)(478600001)(33716001)(38730400002)(110136004)(66066001)(189998001)(6916009)(54356999)(42186005)(76176999)(2950100002)(229853002)(305945005)(7736002)(50986999)(5890100001)(93886004)(2906002)(4001350100001)(5660300001)(33656002)(6666003)(18370500001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR0701MB1718; H:jerin; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR0701MB1718; 23:RixlQwWwu8YzXr++/zZ+mN7N+COlj9EG/M0BuG2?= =?us-ascii?Q?ujzE3XYq+FV2dJFRZSmVouJ8qrfIxrprmgMuoPhzi/jut+zez1PvjvD1NU5v?= =?us-ascii?Q?xtxWrzhrC+xF0r9jVKv5rpiKuXKkTS97APmpo6qPMBvqENXX4lZvUUSdgnIx?= =?us-ascii?Q?fo+bFKzVKHhlvG8sNBVKXSWzCS5tI2jiNl8yPQ1HNTC8rNKxzZqHTf4YL+eW?= =?us-ascii?Q?RdFPowdU/bAi4d50QCoCay+BVi4RbQsdaoY+ehEGCEFDyXZrCMIMOydpzR36?= =?us-ascii?Q?87rloKtOInLgQpQZ8m0lJ/VHETLq2nAWjXHANJhqhaBBv5H/0RC4f70Bnp9l?= =?us-ascii?Q?XmI64CVMAmewhyKuI0NM6GCjqNavM75QWog9BhF3+WHjGt9IYCFAoHyhWV1Y?= =?us-ascii?Q?gDzT5NuWNtkPoeye3vCTbinNM+JcXEn58GuF6AqDUdxZO+/cZifu78C66pIW?= =?us-ascii?Q?8HYeitGPH+axILTmfziiXs2jbphsJ/RjjC/mz1MBZmyMf6W3d7IPgFYXlQwh?= =?us-ascii?Q?4QaEoLsps/lRNo06Sqgg3SHNKdNu2rNuwWtrFxmT26VJSRHjE7ljl7XdL7yd?= =?us-ascii?Q?odrUiko4et868xRvlt2sTFKCQSjCDaWcjU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ON7Xi1HT5uc30V1La7byGBa/W4U1EWrnCS35tOqzET6n6HDgn9IwQB/zt7vqXzJRBsTRWExK6RXGIgZM5JehHmudgPWrogbdfg8qnGQopI3mHB1Yj9PiJyapd2uWALtM3Ecq15slm2XuTcrjRRVK5KVGMDHMQgn/V+dgaXva6B7HotFyWlVqCvyDpcMMenBP8qhfAwdpdEJfJHir5CTMRL/ESwQPPv1pGoW0t8yId34LKAVR7br2y/zwZTXlyZXSr5F2RE5MUFhISgK+s8VXLvM37h0Jfjb0OEZfg==; 5:YA562b1y13gFzzzS4YtJQ5ULT8efIuDpdgmfFxhHG7ikM8l+bistuFOJ3MCKaYJqcY4GXuhOMbiPzLIpBZZtxm56HCZyXQvA6i0cIF68eYXa6PpgsML2gbtLP6IJZ9RsI2nEj0QGsZS7G4wjPpLvKg==; 24:+q3/Ueh1wxLMwOTg5bKV7T1Hzc0f4vbT2jJ7iPswtMlx6c+LT4sBb4P1P7vzgWc+GbJHJfvRHsOzrNl8MgUCY+7g0PMz6TZd+viKUmJcMq0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 7:CWraVq82MSWurfBSj7b4PDfckSNCQzr+2FTElR4B5moU8TxEJWSsni86oX1Q13Sw6Jh/QHZ2JvOogj7jwu8NQfBqyygOpRnbWxA/iu0zrZueUpadnlH8R4HSSew/dfsK7qVgO24liJWoDw/SrY8RUvDZeqKxYkzd9rPfgT5lxZH6DrShrKdUVc1TppLzxhJ3VFcGDRY7glpaDxiSc2xaudkPHwFSn/yGSXP3n+/f5tNkTRAqxtQWd8dKFasOFjYJ4Ocjh1uA9GDOjs82/AXOh/BK/dSWe30oIKY6qV0SN60ATkPlW8/d3hLNpb4jizZmNtZJzQNOeuWb3hQ4xpHICQ== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2017 04:14:10.6294 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1718 Subject: Re: [dpdk-dev] [PATCH] vfio: fix device unplug when several devices per vfio group X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 May 2017 04:14:15 -0000 -----Original Message----- > Date: Mon, 8 May 2017 17:44:37 +0100 > From: Alejandro Lucero > To: Jerin Jacob > Cc: Thomas Monjalon , dev , "Burakov, > Anatoly" > Subject: Re: [dpdk-dev] [PATCH] vfio: fix device unplug when several > devices per vfio group > > Hi Jerin, > > On Mon, May 8, 2017 at 4:20 PM, Jerin Jacob > wrote: > > > -----Original Message----- > > > Date: Sun, 30 Apr 2017 19:29:49 +0200 > > > From: Thomas Monjalon > > > To: Alejandro Lucero > > > Cc: dev@dpdk.org, "Burakov, Anatoly" > > > Subject: Re: [dpdk-dev] [PATCH] vfio: fix device unplug when several > > > devices per vfio group > > > > > > 28/04/2017 15:25, Burakov, Anatoly: > > > > From: Alejandro Lucero [mailto:alejandro.lucero@netronome.com] > > > > > VFIO allows a secure way of assigning devices to user space and those > > > > > devices which can not be isolated from other ones are set in same > > VFIO > > > > > group. Releasing or unplugging a device should be aware of remaining > > > > > devices is the same group for avoiding to close such a group. > > > > > > > > > > Fixes: 94c0776b1bad ("vfio: support hotplug") > > > > > > > > > > Signed-off-by: Alejandro Lucero > > > > > > > > I have tested this on my setup on an old kernel with multiple > > attach/detaches, and it works (whereas it fails without this patch). > > > > > > > > Acked-by: Anatoly Burakov > > > > > > Applied, thanks > > > > This patch creates issue when large number of PCIe devices connected to > > system. > > Found it through git bisect. > > > > This issue is, vfio_group_fd goes beyond 64(VFIO_MAX_GROUPS) and writes > > to wrong memory on following code execution and sub sequentially creates > > issues in vfio mapping or such. > > > vfio_cfg.vfio_groups[vfio_group_fd].devices++; > > > > I can increase VFIO_MAX_GROUPS, but I think, it is not correct fix as > > vfio_group_fd generated from open system call. > > > > I add some prints the code for debug. Please find below the output. > > Any thoughts from VFIO experts? > > > > > That is a silly but serious bug. We are using the file descriptor as the > index for updating devices counter of a vfio group structure internal to > DPDK VFIO code. We should be using the vfio_group that file descriptor is > registered with. > > I will send a fix where vfio_group_device_get/put/count functions are > implemented which take the file descriptor as a parameter and then go > through the vfio_group array for working with the right one. > > Thomas, is this fix in time yet for 17.05? I will send the patch today but > I can just test it against a system with the "normal" case for VFIO device > groups. Maybe Jerin or/and Anatoly can test it against the other case. Thanks Alejandro for the patch. Tested your patch on failure setup, it works fine after applying your patch. IMO, for v17.05, this fix must go in or we need to revert the original offending patch(a9c349e3a100 ("vfio: fix device unplug when several devices per group")) as it breaks DPDK running on the system with few PCIe devices connected in.