From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by dpdk.org (Postfix) with ESMTP id 39E20ADA7 for ; Thu, 16 Apr 2015 13:44:11 +0200 (CEST) Received: by widdi4 with SMTP id di4so94010283wid.0 for ; Thu, 16 Apr 2015 04:44:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:references:in-reply-to:subject:date:message-id :mime-version:content-type:content-transfer-encoding:thread-index :content-language; bh=Kzobhx82cxbC1q5IoSE3tbG495NTQsCBfIqgYXXTqqs=; b=iCBQWqmMEreTk/liHcQpmUWl+TqAIHBqM8PKoq/9fmoAukWQhl0RWnfAYEASEGk6xl 7ByU8fH5hRZdf8RQ6egK1Dq3Xt+fUcpMlSk37dL1jbIcg5r/mC9yuNLtJFVykR1qQZw1 zKImX6GbeSV6Y0FTINUv8ejcCFCaPKfUgh3MP3TOIr/pQz1ASYtDCNYsQ3V7nvNUnmpO 19uVGdcj5bzF0CsxttZFJsn8SyrzTWhb/13zcEbGzo/NHJzElawXeeWuu6dGM4tn0lTe CzyxHs3wDjfHRXPQQ/i/bECUtvq9zzH+s2AcnB0levmwrSL6iNc1eJSjp8ODwQdvWbsv 0szA== X-Received: by 10.194.2.145 with SMTP id 17mr58561025wju.79.1429184651028; Thu, 16 Apr 2015 04:44:11 -0700 (PDT) Received: from laptop1 (84.95.210.61.forward.012.net.il. [84.95.210.61]) by mx.google.com with ESMTPSA id 14sm10071958wjv.0.2015.04.16.04.44.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Apr 2015 04:44:10 -0700 (PDT) From: "Raz Amir" To: "'Bruce Richardson'" References: <1428450303-97954-1-git-send-email-razamir22@gmail.com> <1429171323-33292-1-git-send-email-razamir22@gmail.com> <20150416093920.GA6556@bricha3-MOBL3> In-Reply-To: <20150416093920.GA6556@bricha3-MOBL3> Date: Thu, 16 Apr 2015 14:44:07 +0300 Message-ID: <171a01d0783a$a69986a0$f3cc93e0$@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 15.0 Thread-Index: AQKh04vm1iLk0SVFuqC8rqR6FNNrlgJSDOvaAjmkGzGbiHCkgA== Content-Language: en-gb Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH v6] Restore support for virtio on FreeBSD 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: Thu, 16 Apr 2015 11:44:11 -0000 Will do -----Original Message----- From: Bruce Richardson [mailto:bruce.richardson@intel.com] Sent: 16 April 2015 12:39 To: Raz Amir Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH v6] Restore support for virtio on FreeBSD On Thu, Apr 16, 2015 at 11:02:03AM +0300, Raz Amir wrote: > Fixes: 8a312224bcde ("eal/bsd: fix fd leak") > > Closing /dev/io fd causes SIGBUS in inb/outb instructions as the > process loses the IOPL privileges once the fd is closed: > (gdb) bt > 0 0x0000000000492f2c in outb (port=49170, data=0 '\000') at > /usr/include/machine/cpufunc.h:244 > 1 0x0000000000492f7a in outb_p (data=0 '\000', port=49170) at > /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.h:211 > 2 0x000000000049328d in vtpci_set_status (hw=0x80331f380, status=0 > '\000') at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.c:130 > 3 0x00000000004931fe in vtpci_reset (hw=0x80331f380) at > /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.c:108 > 4 0x00000000004a175e in eth_virtio_dev_init (eth_dev=0x831b80 > ) at > /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_ethdev.c:1150 > 5 0x0000000000462c09 in rte_eth_dev_init (pci_drv=0x79d1a0 > , > pci_dev=0x802417560) at > /dpdk/dpdk-2.0.0/lib/librte_ether/rte_ethdev.c:326 > 6 0x000000000046f03f in rte_eal_pci_probe_one_driver (dr=0x79d1a0 > , > dev=0x802417560) at > /dpdk/dpdk-2.0.0/lib/librte_eal/bsdapp/eal/eal_pci.c:487 > 7 0x0000000000475b06 in pci_probe_all_drivers (dev=0x802417560) at > /dpdk/dpdk-2.0.0/lib/librte_eal/common/eal_common_pci.c:116 > 8 0x0000000000475bb9 in rte_eal_pci_probe () at > /dpdk/dpdk-2.0.0/lib/librte_eal/common/eal_common_pci.c:246 > 9 0x000000000046cd63 in rte_eal_init (argc=5, argv=0x7fffffffeaf0) at > /dpdk/dpdk-2.0.0/lib/librte_eal/bsdapp/eal/eal.c:554 > 10 0x0000000000404544 in main () > > Signed-off-by: Raz Amir It does look the cleanest solution, though I don't like the idea of leaking the file handle. Can you perhaps just change things a little so that the fd variable is static - even locally in the function will do, as it helps indicate that the fd is persistent. /Bruce > --- > lib/librte_eal/bsdapp/eal/eal.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/librte_eal/bsdapp/eal/eal.c > b/lib/librte_eal/bsdapp/eal/eal.c index 871d5f4..e20f915 100644 > --- a/lib/librte_eal/bsdapp/eal/eal.c > +++ b/lib/librte_eal/bsdapp/eal/eal.c > @@ -426,7 +426,7 @@ rte_eal_iopl_init(void) > fd = open("/dev/io", O_RDWR); > if (fd < 0) > return -1; > - close(fd); > + /* keep fd open for iopl */ > return 0; > } > > -- > 2.1.2 >