From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 1FC2B4AC7 for ; Fri, 15 Jul 2016 15:05:54 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 15 Jul 2016 06:05:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,368,1464678000"; d="scan'208";a="1017502804" Received: from irsmsx104.ger.corp.intel.com ([163.33.3.159]) by orsmga002.jf.intel.com with ESMTP; 15 Jul 2016 06:05:41 -0700 Received: from irsmsx156.ger.corp.intel.com (10.108.20.68) by IRSMSX104.ger.corp.intel.com (163.33.3.159) with Microsoft SMTP Server (TLS) id 14.3.248.2; Fri, 15 Jul 2016 14:05:40 +0100 Received: from irsmsx109.ger.corp.intel.com ([169.254.13.193]) by IRSMSX156.ger.corp.intel.com ([10.108.20.68]) with mapi id 14.03.0248.002; Fri, 15 Jul 2016 14:05:40 +0100 From: "Burakov, Anatoly" To: Yong Wang , "dev@dpdk.org" CC: "dan@kernelim.com" , "thomas.monjalon@6wind.com" , Ronghua Zhang Thread-Topic: [PATCH v2] vfio: fix pci_vfio_map_resource Thread-Index: AQHR3jBreDYVO8rs8kGCZzC5xHj276AZdhiA Date: Fri, 15 Jul 2016 13:05:39 +0000 Message-ID: References: <20160714153415.GA8329@gmail.com> <1468541710-47751-1-git-send-email-yongwang@vmware.com> In-Reply-To: <1468541710-47751-1-git-send-email-yongwang@vmware.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMjRjMmNjMTItMzQzMS00YWJjLWI2Y2ItNzUzNmQyZTM1ZDFkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IlpXamRHNVZRZ1VYdjJ3aTIrVU5cL3htQ1wvUzIwV0dhbmJwWHh4eUJJT05qMD0ifQ== x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2] vfio: fix pci_vfio_map_resource X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jul 2016 13:05:55 -0000 > The offset of the 2nd mmap() when mapping the region after msix_bar > needs to take region address into consideration as mmap() takes address > that is resource-relative instead of bar-relative. This is exposed when > binding vmxnet3 to vfio-pci. >=20 > Fixes: 90a1633b2347 ("eal/linux: allow to map BARs with MSI-X tables") >=20 > Signed-off-by: Yong Wang > Signed-off-by: Ronghua Zhang > --- > v2: > * Addressed review comment from Dan >=20 > lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) >=20 > diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c > b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c > index 46cd683..bf7cf61 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c > +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c > @@ -431,7 +431,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev) > } else { > memreg[0].offset =3D reg.offset; > memreg[0].size =3D table_start; > - memreg[1].offset =3D table_end; > + memreg[1].offset =3D reg.offset + table_end; > memreg[1].size =3D reg.size - table_end; >=20 > RTE_LOG(DEBUG, EAL, > @@ -474,7 +474,8 @@ pci_vfio_map_resource(struct rte_pci_device *dev) > /* if there's a second part, try to map it */ > if (map_addr !=3D MAP_FAILED > && memreg[1].offset && memreg[1].size) { > - void *second_addr =3D > RTE_PTR_ADD(bar_addr, memreg[1].offset); > + void *second_addr =3D > RTE_PTR_ADD(bar_addr, > + > memreg[1].offset - reg.offset); > map_addr =3D > pci_map_resource(second_addr, > vfio_dev_fd, > memreg[1].offset, > memreg[1].size, > -- > 1.9.1 Thomas, I guess we can put it in? It doesn't affect anything outside the st= ated use case, and code wise there's nothing preventing this from being mer= ged either. I've done cursory testing with an ixgbe device just in case, no= thing exploded. So, Acked-by: Anatoly Burakov