From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40076.outbound.protection.outlook.com [40.107.4.76]) by dpdk.org (Postfix) with ESMTP id 1A15F1B4BB for ; Mon, 3 Dec 2018 08:25:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ciqbAEXjPBEz8JwRprSU7kWVWPVa2MEWKj/pU/8qNS8=; b=qN9FFeR0fZbVo89nSnQ7+3LY9NqHnbTAVLCQGkhT2ibMsZNzDdTNBojuJebFRKmdpPVQvCaQM1K9doSPj6pofUmrmB1UvwW/a9ZCifXmeuyyPk5szvVhrklgyHigV/T8ygebNnXixw6pV+YuO+/CuTAhGZ5q5YFD3OU96sAVjw0= Received: from AM0PR08MB3409.eurprd08.prod.outlook.com (20.177.109.139) by AM0PR08MB3331.eurprd08.prod.outlook.com (52.134.94.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1382.22; Mon, 3 Dec 2018 07:25:35 +0000 Received: from AM0PR08MB3409.eurprd08.prod.outlook.com ([fe80::2927:5a10:ee9d:6f3b]) by AM0PR08MB3409.eurprd08.prod.outlook.com ([fe80::2927:5a10:ee9d:6f3b%4]) with mapi id 15.20.1382.020; Mon, 3 Dec 2018 07:25:35 +0000 From: "Tone Zhang (Arm Technology China)" To: "Tone Zhang (Arm Technology China)" , "dev@dpdk.org" CC: "Gavin Hu (Arm Technology China)" , Honnappa Nagarahalli , Steve Capper , "anatoly.burakov@intel.com" , nd Thread-Topic: [dpdk-dev] [PATCH v3] pci_vfio: Support 64KB kernel page_size with vfio-pci driver Thread-Index: AQHUf7DXiEyvT0dSqEyQzelBB6xPiKVssAFQ Date: Mon, 3 Dec 2018 07:25:35 +0000 Message-ID: References: <1541743077-27994-1-git-send-email-tone.zhang@arm.com> <1542595044-27145-1-git-send-email-tone.zhang@arm.com> In-Reply-To: <1542595044-27145-1-git-send-email-tone.zhang@arm.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Tone.Zhang@arm.com; x-originating-ip: [113.29.88.7] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM0PR08MB3331; 6:RibAw8CI2u4YCWMJsB+jtA2GNOT6xbnMjV20pZ47hcICEac7CWiotcKW4NxnuZro1ACTLxb0qnUv4aNpY2RqIem8u+5TlMiKavddzRrCCxTkCu272VEbc8iDCsAGhMZaVb3kM4fdWijx7QsWKW3XE5e9Y8eYsZHxl29Nhzhj2esKw2vGeECqmtB2l46+plLjEn3Xh5DjBbQP8AWY56yioRzEaR7Dtk6YU0+Co0Fr6EfUnIorg+nOcE+YnKnBwYh7nrUvpQrtnT6fDAAb/e7u4lONYwUBAwzxZFMQADKv1bucyJ4+HA4/bIHqwPj0POObpZRNsNizFOhru64+aa9nDrnaknL6DI/F58ZX7vnVfk6j2YWexeTOjq8myxuIwHNFcoDhRsHToPlf9rFD42OiR9oHGhFu2jiI2vf4GQoSVsIJf3or9PlP2SXs1tznSg6g9Dv7S3UuffGwA0PXDqPLbg==; 5:3sBWlfV1LWoPtIfo6MPDpaNI3f+3i74K+e8phg9Euiv5aq+/yWErjaKlcUi6/9KP9Voz15rJDtYl/WX1qGwW0x0BmLYwYwTCJwBhc8n9CqtqHnX83ChQcoIIyBNSnCljyKqsXAgH4GA9axL4JXEtcGsJiC4gfh6obu8KjNj3ugM=; 7:5NAwMeI5yvCzUSt2qrb7tHjTh9MNtHSwyQvnJe4cCctNQkeWlVRT7RxmWXuCTMe8JkFUvtT0aGPhq372fI+lRYdURZClj/VGVeYRV6HJlgT1TErR+AU9p5N1LOtjKzuKRb/ACD8Hf8viUqvxIpiy7w== x-ms-exchange-antispam-srfa-diagnostics: SOS;SOR; x-ms-office365-filtering-correlation-id: 467fc7d5-780a-4cb3-7568-08d658f08440 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:AM0PR08MB3331; x-ms-traffictypediagnostic: AM0PR08MB3331: nodisclaimer: True x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231455)(999002)(944501493)(52105112)(3002001)(10201501046)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:AM0PR08MB3331; BCL:0; PCL:0; RULEID:; SRVR:AM0PR08MB3331; x-forefront-prvs: 08756AC3C8 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(396003)(39860400002)(376002)(346002)(136003)(13464003)(53754006)(189003)(199004)(486006)(478600001)(66066001)(74316002)(97736004)(55236004)(102836004)(5660300001)(8936002)(81156014)(81166006)(26005)(2501003)(7736002)(186003)(305945005)(25786009)(11346002)(476003)(72206003)(105586002)(6246003)(106356001)(53936002)(6116002)(3846002)(229853002)(71190400001)(6436002)(9686003)(71200400001)(86362001)(446003)(256004)(14444005)(99286004)(55016002)(2906002)(4326008)(6506007)(53546011)(316002)(110136005)(14454004)(76176011)(7696005)(54906003)(33656002)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB3331; H:AM0PR08MB3409.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: Zvk1p3A9oQ58JirkYLCq8qsNQLmV12YVqAOP9DWufAzEAPRXKPG8lZU1SQUIrYzN4MPZ9v2r2PMZvHZrz19KZpKoN0BId86Ma4Erli8Ag7W+4qrgpovVD1d9FzzXvGlTNbAyy+fBt2nm2pbGmMM4ykd8McTsmV2FC64HAth/uUu1ONVC6yX848pCOaJYVCzvHGD/oOzTNQhPmdnfFO7cuQrhdBQl7nT9lg1hCgFgWAxGDzj513r/th8bFl02xLVdnyG3p7evYg20dFJBy/6tF5MvvA25+NJ/39jnmv4fZNGM69RuS/bZKQTsPjvxVNR2Awwdl/dlPo+3saB2DgBSCkC1Dofd8hTr+I8irxk1yRQ= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 467fc7d5-780a-4cb3-7568-08d658f08440 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Dec 2018 07:25:35.3095 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3331 Subject: Re: [dpdk-dev] [PATCH v3] pci_vfio: Support 64KB kernel page_size with vfio-pci driver 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: Mon, 03 Dec 2018 07:25:37 -0000 Hi all, Could anyone please have a review and re-test the change? Thanks a lot! Br, Tone > -----Original Message----- > From: dev On Behalf Of tone.zhang > Sent: Monday, November 19, 2018 10:37 AM > To: dev@dpdk.org > Cc: Gavin Hu (Arm Technology China) ; Honnappa > Nagarahalli ; Steve Capper > ; anatoly.burakov@intel.com; nd > Subject: [dpdk-dev] [PATCH v3] pci_vfio: Support 64KB kernel page_size wi= th > vfio-pci driver >=20 > With a larger PAGE_SIZE it is possible for the MSI table to very close to= the end > of the BAR s.t. when we align the start and end of the MSI table to the > PAGE_SIZE, the end offset of the MSI table is out of the PCI BAR boundary= . >=20 > This patch addresses the issue by comparing both the start and the end of= fset of > the MSI table with the BAR size, and skip the mapping if it is out of Bar= scope. >=20 > The patch fixes the debug log as below: > EAL: Skipping BAR0 >=20 > Signed-off-by: tone.zhang > Reviewed-by: Gavin Hu > Reviewed-by: Honnappa Nagarahalli > Reviewed-by: Steve Capper > Reviewed-by: Anatoly Burakov > --- > drivers/bus/pci/linux/pci_vfio.c | 27 ++++++++++++++++++++++----- > 1 file changed, 22 insertions(+), 5 deletions(-) >=20 > diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci= _vfio.c > index ffd26f1..0e7bfd7 100644 > --- a/drivers/bus/pci/linux/pci_vfio.c > +++ b/drivers/bus/pci/linux/pci_vfio.c > @@ -457,9 +457,11 @@ pci_vfio_mmap_bar(int vfio_dev_fd, struct > mapped_pci_resource *vfio_res, > struct pci_msix_table *msix_table =3D &vfio_res->msix_table; > struct pci_map *bar =3D &vfio_res->maps[bar_index]; >=20 > - if (bar->size =3D=3D 0) > + if (bar->size =3D=3D 0) { > /* Skip this BAR */ > + RTE_LOG(INFO, EAL, "Skipping BAR%d\n", bar_index); > return 0; > + } >=20 > if (msix_table->bar_index =3D=3D bar_index) { > /* > @@ -468,8 +470,14 @@ pci_vfio_mmap_bar(int vfio_dev_fd, struct > mapped_pci_resource *vfio_res, > */ > uint32_t table_start =3D msix_table->offset; > uint32_t table_end =3D table_start + msix_table->size; > - table_end =3D (table_end + ~PAGE_MASK) & PAGE_MASK; > - table_start &=3D PAGE_MASK; > + table_end =3D RTE_ALIGN(table_end, PAGE_SIZE); > + table_start =3D RTE_ALIGN(table_start, PAGE_SIZE); > + > + /* If page-aligned start of MSI-X table is beyond BAR size, > + * shrink the mapping size to MSI-X table start address. > + */ > + if (table_start >=3D bar->size) > + table_start =3D msix_table->offset; >=20 > if (table_start =3D=3D 0 && table_end >=3D bar->size) { > /* Cannot map this BAR */ > @@ -481,8 +489,17 @@ pci_vfio_mmap_bar(int vfio_dev_fd, struct > mapped_pci_resource *vfio_res, >=20 > memreg[0].offset =3D bar->offset; > memreg[0].size =3D table_start; > - memreg[1].offset =3D bar->offset + table_end; > - memreg[1].size =3D bar->size - table_end; > + if (bar->size < table_end) { > + /* > + * If MSI-X table end is beyond BAR end, don't attempt > + * to perform second mapping. > + */ > + memreg[1].offset =3D 0; > + memreg[1].size =3D 0; > + } else { > + memreg[1].offset =3D bar->offset + table_end; > + memreg[1].size =3D bar->size - table_end; > + } >=20 > RTE_LOG(DEBUG, EAL, > "Trying to map BAR%d that contains the MSI-X " > -- > 2.7.4