From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 76EF8A04DB for ; Thu, 15 Oct 2020 19:37:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E85DE1DCAB; Thu, 15 Oct 2020 19:37:41 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 65E821DC3C; Thu, 15 Oct 2020 19:37:38 +0200 (CEST) Received: from pps.filterd (m0045847.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 09FHajWt001418; Thu, 15 Oct 2020 10:37:36 -0700 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-0016f401.pphosted.com with ESMTP id 343cav0kvf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Oct 2020 10:37:36 -0700 Received: from pps.reinject (m0045847.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 09FHbKHY001916; Thu, 15 Oct 2020 10:37:36 -0700 Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0a-0016f401.pphosted.com with ESMTP id 343aanugaa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 15 Oct 2020 04:50:23 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 15 Oct 2020 04:50:22 -0700 Received: from SC-EXCH02.marvell.com (10.93.176.82) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 15 Oct 2020 04:50:21 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.176) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Thu, 15 Oct 2020 04:50:21 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y0R1fAIgo3IIY4z6J2xFrdOlzrKdNEtNP3EjFPomJpaRn7vxa7tts0BH91fEtaUh/rzE+hd9qI+OdTsGWWmaf5QKTp0YFIkqzjOw3kBM3HTQjXhB0j/aN2eZcOIc9tstJme0GkC0BDmROaQ8GIczZaWI7BLxk4WPuT6UbEt46kz/8jjwep58d/i4/TpsL+35i+R12jo+zVg5X76zhvovsDjjr+hdliZIUqmEwOJRyYsLB0ksfhO1FKdzeh5+XIKz+9HRPSmmNIRBpetHUpHSmSDjlOcHBiR9CZsv1VYdPr5UN6OJOyOim1amRkjFnw03oLUi1CmOVGQLb/XH4IYs9w== 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-SenderADCheck; bh=8ox8WJZTeV/WRnpY5bAREjU4aOK98yG+t/kbAANI8MM=; b=aI3/m4OG43P8pPtMCg9/59tc55gC34xtmvd4umLqRREST+yUEZdA8HnQvnWnvwn30fjtU4/fJRbJc2JiL+AEJPwObowj2NtbGZkoGzWSVJS7Ioj+yfb0RnbgO0Dwo+pa6TAbUI13W7wz/xrRkBDQz0XLLk60tVkVXRDHRlUlrkLSxHKYnbK3Eo8pcL66OqoIQ8iaDGKPkr/4QzKxvK3fYjo3olWHz4EsAjX+5G36af69kK0WdjpoEjM1AD+yULIonbcqqsG8GMYW2VU3CYWYeEJEOQCaMubE1T92e09ljUDZIEor92O8k7/kwHQB43WgJ2iA7zEtLwr5JYnTe3Sk3A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8ox8WJZTeV/WRnpY5bAREjU4aOK98yG+t/kbAANI8MM=; b=m3Xmng9rg0yGS6CuDXGHO3rA79IuDJjyHbQ7yWJ55sQjjtOkF1JL5Bdj0vSOGh7Du0x6wcJ8GQoBvbz5vgPn/l2AqFic0Hg57+svcHiuB1jgwl91HQKJBmAX031vRwO6iV7a5iIrs5ONESJZxggori4ltORzCF6pSdOEoA+Q5OY= Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=marvell.com; Received: from BN8PR18MB2386.namprd18.prod.outlook.com (2603:10b6:408:68::25) by BN8PR18MB2433.namprd18.prod.outlook.com (2603:10b6:408:69::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.23; Thu, 15 Oct 2020 11:50:20 +0000 Received: from BN8PR18MB2386.namprd18.prod.outlook.com ([fe80::25af:7baf:528d:1dab]) by BN8PR18MB2386.namprd18.prod.outlook.com ([fe80::25af:7baf:528d:1dab%5]) with mapi id 15.20.3455.035; Thu, 15 Oct 2020 11:50:20 +0000 Date: Thu, 15 Oct 2020 17:20:09 +0530 From: Nithin Dabilpuram To: "Burakov, Anatoly" CC: , , Message-ID: <20201015115009.GC15756@outlook.office365.com> References: <20201012081106.10610-1-ndabilpuram@marvell.com> <20201012081106.10610-3-ndabilpuram@marvell.com> <05afb7f5-96bf-dffd-15dd-2024586f7290@intel.com> <20201015060914.GA32207@outlook.office365.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (34cd43c) (2019-09-21) X-Originating-IP: [1.6.215.26] X-ClientProxiedBy: SG2P153CA0004.APCP153.PROD.OUTLOOK.COM (2603:1096::14) To BN8PR18MB2386.namprd18.prod.outlook.com (2603:10b6:408:68::25) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from outlook.office365.com (1.6.215.26) by SG2P153CA0004.APCP153.PROD.OUTLOOK.COM (2603:1096::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.3 via Frontend Transport; Thu, 15 Oct 2020 11:50:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a4d1fb06-5f07-4891-3cd8-08d871007dea X-MS-TrafficTypeDiagnostic: BN8PR18MB2433: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1360; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HrbRrFfJY52cp7YlEcLZqQFp5seRR0NC/te/vibWzL+PJqeUKByS1h4s8sGfuMK35YAHz3uRxAF0n9Xv9OpJqp1beGf4J7z/jjFI9+fJHhN/+Ue7wKk7hTh6D/czTMvHDl8F6iQaDfhJ0s6SkqVxfiJRiRDcliMZvoReUbh6U3lw6K67A+DHf6GrBawRBFoOjndDOXBmJFDSI4l3er+S2d6Cv4Z0O6a9Sgi4tUsyGCofehH55RDBe0jtKmEOJ1DE8+9uO/VHMCemjqXDKQ0AYYskZdRiEj3mJfczeZsrR/hqvxmRR8y885DFeon2nHuMN4lC0UMltqI6vbV6Dna2JGe0mF+qiQBYEfI3rYkTm8t8vWaekHp+CcEJosgJLLXus4kCJuRLR9LxP617PWWnm3gB+6uMQYI5GZxf85zTqsCwDGTodSrfHSjJFROIBsMsbQT0KBht8VCAQc9Sz4kulQKhD3Y2IUECN8riLs3DUbLcgI2VIN3c3QHakIvn68Mf X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN8PR18MB2386.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39860400002)(346002)(366004)(396003)(136003)(6506007)(6916009)(966005)(26005)(53546011)(52116002)(7696005)(6666004)(1006002)(478600001)(2906002)(4326008)(66476007)(66556008)(66946007)(83080400001)(34490700002)(83380400001)(33656002)(86362001)(9686003)(8936002)(8676002)(1076003)(956004)(316002)(55016002)(5660300002)(186003)(16526019)(36456003)(42976004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: iG0ewpV+oyWODcvZhmFkFs5Wz0+BLKcB/I3QlU1hbMvDWEfUfW2d3X3Gav4FeoL1mlh6U9v9K+ISnH4kOnueZRiGMzL2dksQ1fCYXmcbqY/9AL66yS5VFB/YNSSRbTigBqDyeAUEqWHlAkirxm9ne42ha/BTxS/QEbSs/746FAaW4f3b2Wa/kJ0ycW8PvyOMlOfBPuOA3mFm3vUdnCDvzBhw9ETlj2TU4LvlNJ/0BGk6ft5mFm2gUYyCuA5ZT5RJeH/Q9CP51NUHvNsxfcSKZkKX4KBCiqanrYYUrlJVjNme6ajVQnONb8oCi6pu1RwJBLB2mKMvB/BxZaOMKEqYE/eXmg5PMJZfBNCeKa0uf9n/VFjxlWlSZSR0otwWdfYYbi8QptdtAqPKjG/AsQe6mLVIihzrR53Xo0dD4OZIZfdA3u6Ko6l7mb71uaFtFMDJ59pmsJK6BYPjgnVPqrO764hROeFmJCC3uJbwXOvARtvi2SM50+9n3jn4Ks6j31anFwlb/TzWCaLDoTZiuUr6V+2y6f3GNo8K4K/xArqQAShLRM/FB6lmZT/CNzNwKNueXNrDQU+zCgjrO0iUuUn53bmYT7r4DHE9veqPGJVlJenYXDy0loeJy5M0CziOjDuFlXmObR7Bz9yA+7Gmk4BeoA== X-MS-Exchange-CrossTenant-Network-Message-Id: a4d1fb06-5f07-4891-3cd8-08d871007dea X-MS-Exchange-CrossTenant-AuthSource: BN8PR18MB2386.namprd18.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2020 11:50:20.0316 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Cp0tlwEJ6A9tAuwjTXhcn3MESMwVd+NX0PPaPP3tYBrReZ8SFpzgV1lNhgxMQQStkleFUvc7iM7YOECVbGvz2A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR18MB2433 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-10-15_07:2020-10-14, 2020-10-15 signatures=0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-10-15_14:2020-10-14, 2020-10-15 signatures=0 Subject: Re: [dpdk-stable] [EXT] Re: [PATCH 2/2] vfio: fix partial DMA unmapping for VFIO type1 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: , Errors-To: stable-bounces@dpdk.org Sender: "stable" On Thu, Oct 15, 2020 at 11:00:59AM +0100, Burakov, Anatoly wrote: > On 15-Oct-20 7:09 AM, Nithin Dabilpuram wrote: > > On Wed, Oct 14, 2020 at 04:07:10PM +0100, Burakov, Anatoly wrote: > > > External Email > > > > > > ---------------------------------------------------------------------- > > > On 12-Oct-20 9:11 AM, Nithin Dabilpuram wrote: > > > > Partial unmapping is not supported for VFIO IOMMU type1 > > > > by kernel. Though kernel gives return as zero, the unmapped size > > > > returned will not be same as expected. So check for > > > > returned unmap size and return error. > > > > > > > > For case of DMA map/unmap triggered by heap allocations, > > > > maintain granularity of memseg page size so that heap > > > > expansion and contraction does not have this issue. > > > > > > This is quite unfortunate, because there was a different bug that had to do > > > with kernel having a very limited number of mappings available [1], as a > > > result of which the page concatenation code was added. > > > > > > It should therefore be documented that the dma_entry_limit parameter should > > > be adjusted should the user run out of the DMA entries. > > > > > > [1] https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_lkml_155414977872.12780.13728555131525362206.stgit-40gimli.home_T_&d=DwICaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=FZ_tPCbgFOh18zwRPO9H0yDx8VW38vuapifdDfc8SFQ&m=3GMg-634_cdUCY4WpQPwjzZ_S4ckuMHOnt2FxyyjXMk&s=TJLzppkaDS95VGyRHX2hzflQfb9XLK0OiOszSXoeXKk&e= > > > > > > > RTE_LOG(ERR, EAL, " cannot clear DMA remapping, error %i (%s)\n", > > > > errno, strerror(errno)); > > > > return -1; > > > > + } else if (dma_unmap.size != len) { > > > > + RTE_LOG(ERR, EAL, " unexpected size %"PRIu64" of DMA " > > > > + "remapping cleared instead of %"PRIu64"\n", > > > > + (uint64_t)dma_unmap.size, len); > > > > + rte_errno = EIO; > > > > + return -1; > > > > } > > > > } > > > > @@ -1853,6 +1869,12 @@ container_dma_unmap(struct vfio_config *vfio_cfg, uint64_t vaddr, uint64_t iova, > > > > /* we're partially unmapping a previously mapped region, so we > > > > * need to split entry into two. > > > > */ > > > > + if (!vfio_cfg->vfio_iommu_type->partial_unmap) { > > > > + RTE_LOG(DEBUG, EAL, "DMA partial unmap unsupported\n"); > > > > + rte_errno = ENOTSUP; > > > > + ret = -1; > > > > + goto out; > > > > + } > > > > > > How would we ever arrive here if we never do more than 1 page worth of > > > memory anyway? I don't think this is needed. > > > > container_dma_unmap() is called by user via rte_vfio_container_dma_unmap() > > and when he maps we don't split it as we don't about his memory. > > So if he maps multiple pages and tries to unmap partially, then we should fail. > > Should we map it in page granularity then, instead of adding this > discrepancy between EAL and user mapping? I.e. instead of adding a > workaround, how about we just do the same thing for user mem mappings? In heap mapping's we map and unmap it at huge page granularity as we will always maintain that. But here I think we don't know if user's allocation is huge page or collection of system pages. Only thing we can do here is map it at system page granularity which could waste entries if he say really is working with hugepages. Isn't ? > > -- > Thanks, > Anatoly