From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id B1A60DD2; Fri, 12 Jan 2018 04:01:16 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jan 2018 19:01:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,347,1511856000"; d="scan'208";a="10147700" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga008.jf.intel.com with ESMTP; 11 Jan 2018 19:01:14 -0800 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 11 Jan 2018 19:01:14 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX157.amr.corp.intel.com (10.18.116.73) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 11 Jan 2018 19:01:13 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.93]) with mapi id 14.03.0319.002; Fri, 12 Jan 2018 11:00:59 +0800 From: "Tan, Jianfeng" To: 'Maxime Coquelin' , "dev@dpdk.org" , "stable@dpdk.org" , "santosh.shukla@caviumnetworks.com" , "Burakov, Anatoly" , "thomas@monjalon.net" , "stephen@networkplumber.org" CC: "peterx@redhat.com" , "Zhang, Qi Z" Thread-Topic: [PATCH v2] bus/pci: forbid VA as IOVA mode if IOMMU address width too small Thread-Index: AQHTiUxWQHM0NduEwEiMYb8w9xQpMqNvcxVw Date: Fri, 12 Jan 2018 03:00:59 +0000 Message-ID: References: <20180109131801.26520-1-maxime.coquelin@redhat.com> In-Reply-To: <20180109131801.26520-1-maxime.coquelin@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZTY5NDlhMDMtZmEzNS00NTNhLWI5MmItYjNhMWQ1OTQ3N2U1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6InlSNEdNcCtDeWdNSlRxdjZiVWgrUFUyZ2ZJSFBpemhMYkJlZkZLdHdwdzQ9In0= dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2] bus/pci: forbid VA as IOVA mode if IOMMU address width too small 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: Fri, 12 Jan 2018 03:01:17 -0000 > -----Original Message----- > From: Maxime Coquelin [mailto:maxime.coquelin@redhat.com] > Sent: Tuesday, January 9, 2018 9:18 PM > To: dev@dpdk.org; stable@dpdk.org; Tan, Jianfeng; > santosh.shukla@caviumnetworks.com; Burakov, Anatoly; > thomas@monjalon.net; stephen@networkplumber.org > Cc: peterx@redhat.com; Maxime Coquelin > Subject: [PATCH v2] bus/pci: forbid VA as IOVA mode if IOMMU address > width too small >=20 > Intel VT-d supports different address widths for the IOVAs, from > 39 bits to 56 bits. >=20 > While recent processors support at least 48 bits, VT-d emulation > currently only supports 39 bits. It makes DMA mapping to fail in this > case when using VA as IOVA mode, as user-space virtual addresses uses > up to 47 bits (see kernel's Documentation/x86/x86_64/mm.txt). >=20 > This patch parses VT-d CAP register value available in sysfs, and > forbid VA as IOVA mode if the GAW is 39 bits or unknown. >=20 > Fixes: f37dfab21c98 ("drivers/net: enable IOVA mode for Intel PMDs") >=20 > Cc: stable@dpdk.org > Signed-off-by: Maxime Coquelin I don't have strong objection on this patch. Plus, this patch has been veri= fied with --no-huge, and Intel low-end processors (with the help of Zhang Q= i). Tested-by: Jianfeng Tan > --- >=20 > Changes in v2: > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > - Rework pci_one_device_iommu_support_va #ifdefery (Stephen) > - Don't inline introduced functions (Stephen) >=20 > drivers/bus/pci/linux/pci.c | 108 > ++++++++++++++++++++++++++++++++++++++++---- > 1 file changed, 99 insertions(+), 9 deletions(-) >=20 > diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c > index 25f907e04..0a43c4b89 100644 > --- a/drivers/bus/pci/linux/pci.c > +++ b/drivers/bus/pci/linux/pci.c > @@ -547,6 +547,100 @@ pci_one_device_has_iova_va(void) > return 0; > } >=20 > +#if defined(RTE_ARCH_X86) > +static bool > +pci_one_device_iommu_support_va(struct rte_pci_device *dev) > +{ > +#define VTD_CAP_SAGAW_SHIFT 8 > +#define VTD_CAP_SAGAW_MASK (0x1fULL << > VTD_CAP_SAGAW_SHIFT) > +#define X86_VA_WIDTH 47 /* From Documentation/x86/x86_64/mm.txt */ > + struct rte_pci_addr *addr =3D &dev->addr; > + char filename[PATH_MAX]; > + FILE *fp; > + uint64_t sagaw, vtd_cap_reg =3D 0; > + int guest_addr_width =3D 0; > + > + snprintf(filename, sizeof(filename), > + "%s/" PCI_PRI_FMT "/iommu/intel-iommu/cap", > + rte_pci_get_sysfs_path(), addr->domain, addr->bus, addr- > >devid, > + addr->function); > + if (access(filename, F_OK) =3D=3D -1) { > + /* We don't have an Intel IOMMU, assume VA supported*/ A nitpick: missed a space between "supported" and "*/" Thanks, Jianfeng