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 D53D7AFCE for ; Tue, 17 Jun 2014 22:42:55 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 17 Jun 2014 13:43:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,496,1400050800"; d="scan'208";a="557012659" Received: from irsmsx104.ger.corp.intel.com ([163.33.3.159]) by fmsmga002.fm.intel.com with ESMTP; 17 Jun 2014 13:43:07 -0700 Received: from irsmsx103.ger.corp.intel.com ([169.254.3.58]) by IRSMSX104.ger.corp.intel.com ([169.254.5.136]) with mapi id 14.03.0123.003; Tue, 17 Jun 2014 21:43:06 +0100 From: "Richardson, Bruce" To: Neil Horman Thread-Topic: [dpdk-dev] [PATCH] vfio: correct system call error checking Thread-Index: AQHPil7+F1gbwD+goUyBm+ST1MCAbZt1vkPg///05oCAABFS0A== Date: Tue, 17 Jun 2014 20:43:06 +0000 Message-ID: <59AF69C657FD0841A61C55336867B5B01AA373A8@IRSMSX103.ger.corp.intel.com> References: <1403031832-28540-1-git-send-email-nhorman@tuxdriver.com> <59AF69C657FD0841A61C55336867B5B01AA37370@IRSMSX103.ger.corp.intel.com> <20140617204011.GH8539@hmsreliant.think-freely.org> In-Reply-To: <20140617204011.GH8539@hmsreliant.think-freely.org> 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 Cc: "dev@dpdk.org" 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:42:56 -0000 > -----Original Message----- > From: Neil Horman [mailto:nhorman@tuxdriver.com] > Sent: Tuesday, June 17, 2014 1:40 PM > To: Richardson, Bruce > Cc: dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH] vfio: correct system call error checking >=20 > On Tue, Jun 17, 2014 at 08:21:29PM +0000, Richardson, Bruce wrote: > > > -----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 > > > > > > 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 a= n error > > > 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 open to > > > accepting unexpected error codes as success. For instance, if the vf= io layer > > > noted that the iommu driver hadn't finished registering yet, it would= return > an > > > -EINVAL error code, but the dpdk would accept that as success, becuas= e it > > > wasn't > > > 0. > > > > > > Fix this to specifically check for < 0 error codes > > > > > > 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(-) > > > > > > 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) > > > > > > /* 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= already > trigger an error on all values <0. Can you please clarify why you think t= his needs > to be changed? > Ah, my bad, the ret < 0 is superfulous, as the !=3D already catches it, b= ut the > log message change is valuable in that it differentiates bad API version > detection from other system errors. I can respin that if you like. > Neil Perhaps a respin separating out ioctl errors vs version errors might be goo= d, giving different error messages for each case. /Bruce