From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 012A2AF87 for ; Tue, 17 Jun 2014 22:23:18 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 17 Jun 2014 13:23:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,496,1400050800"; d="scan'208";a="549400729" Received: from irsmsx101.ger.corp.intel.com ([163.33.3.153]) by fmsmga001.fm.intel.com with ESMTP; 17 Jun 2014 13:23:29 -0700 Received: from irsmsx106.ger.corp.intel.com (163.33.3.31) by IRSMSX101.ger.corp.intel.com (163.33.3.153) with Microsoft SMTP Server (TLS) id 14.3.123.3; Tue, 17 Jun 2014 21:21:31 +0100 Received: from irsmsx103.ger.corp.intel.com ([169.254.3.58]) by IRSMSX106.ger.corp.intel.com ([169.254.8.14]) with mapi id 14.03.0123.003; Tue, 17 Jun 2014 21:21:31 +0100 From: "Richardson, Bruce" To: Neil Horman , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] vfio: correct system call error checking Thread-Index: AQHPil7+F1gbwD+goUyBm+ST1MCAbZt1vkPg Date: Tue, 17 Jun 2014 20:21:29 +0000 Message-ID: <59AF69C657FD0841A61C55336867B5B01AA37370@IRSMSX103.ger.corp.intel.com> References: <1403031832-28540-1-git-send-email-nhorman@tuxdriver.com> In-Reply-To: <1403031832-28540-1-git-send-email-nhorman@tuxdriver.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] vfio: correct system call error checking 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: Tue, 17 Jun 2014 20:23:19 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Neil Horman > Sent: Tuesday, June 17, 2014 12:04 PM > To: dev@dpdk.org > Subject: [dpdk-dev] [PATCH] vfio: correct system call error checking >=20 > Noticed today that ioctl error code return checking was incorrect in some= of the > vfio code. ioctl can return a negative value if the system detects an er= ror > before the target device/driver can produce a return code. The dpdk vfio= code > only checks specfically for the values that it expects, which leaves it o= pen to > accepting unexpected error codes as success. For instance, if the vfio l= ayer > noted that the iommu driver hadn't finished registering yet, it would ret= urn an > -EINVAL error code, but the dpdk would accept that as success, becuase it > wasn't > 0. >=20 > Fix this to specifically check for < 0 error codes >=20 > Signed-off-by: Neil Horman > CC: Thomas Monjalon > --- > lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 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 4de6061..65aa8ad 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c > +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c > @@ -319,16 +319,16 @@ pci_vfio_get_container_fd(void) >=20 > /* check VFIO API version */ > ret =3D ioctl(vfio_container_fd, VFIO_GET_API_VERSION); > - if (ret !=3D VFIO_API_VERSION) { > - RTE_LOG(ERR, EAL, " unknown VFIO API version!\n"); > + if ((ret < 0) || (ret !=3D VFIO_API_VERSION)) { > + RTE_LOG(ERR, EAL, " unknown VFIO API version! errno > =3D %d\n", errno); > close(vfio_container_fd); > return -1; > } Not sure how this change improves things, since the existing check will alr= eady trigger an error on all values <0. Can you please clarify why you thin= k this needs to be changed? >=20 > /* check if we support IOMMU type 1 */ > ret =3D ioctl(vfio_container_fd, VFIO_CHECK_EXTENSION, > VFIO_TYPE1_IOMMU); > - if (!ret) { > - RTE_LOG(ERR, EAL, " unknown IOMMU driver!\n"); > + if (ret <=3D 0) { > + RTE_LOG(ERR, EAL, " unknown IOMMU driver! errno =3D > %d\n", errno); > close(vfio_container_fd); > return -1; > } Ack on this change part. The previously code was incorrect according to wha= t I read in the docs for VFIO. /Bruce