From owner-svn-src-projects@FreeBSD.ORG Thu Dec 6 18:12:00 2012 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C72809FD; Thu, 6 Dec 2012 18:12:00 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from hammer.pct.niksun.com (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 3D1B88FC08; Thu, 6 Dec 2012 18:12:00 +0000 (UTC) Message-ID: <50C0DFB0.6030007@FreeBSD.org> Date: Thu, 06 Dec 2012 13:10:56 -0500 From: Jung-uk Kim User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Roman Divacky Subject: Re: svn commit: r243914 - projects/bpfjit References: <201212052312.qB5NC2Hn056351@svn.freebsd.org> <20121206084936.GA58940@freebsd.org> In-Reply-To: <20121206084936.GA58940@freebsd.org> X-Enigmail-Version: 1.4.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: svn-src-projects@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Dec 2012 18:12:00 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 2012-12-06 03:49:36 -0500, Roman Divacky wrote: > Hi, > > David Chisnall started bpf jitter based on llvm. You can check it > out here: > > http://people.freebsd.org/~theraven/bpfjit/ > > > It's based on the idea of jitting the code in userspace and > passing the resulting code to the kernel via some interface (this > part is not done yet). Long time ago (about 10 years ago), I implemented something like that (i.e., compile BPF program to native machine code in userspace, then upload to kernel space) for my $job but I quickly replace it with BPF_JITTER for several reasons. First of all, there is a big security risk. A BPF filter program can be easily validated by kernel with bpf_validate(9). We cannot do that for native machine code and we must not allow uploading arbitrary code to kernel space. You may say it is well protected by /dev/bpf permissions but it is not good enough, i.e., all you need is read permission to inject code to kernel space. Second, LLVM is too heavy for BPF filter machine. For example, libtrace did that long ago: http://www.wand.net.nz/trac/libtrace/changeset/1586 Someone actually benchmarked it with other JIT implementations: http://carnivore.it/2011/12/28/bpf_performance LLVM compilation took too much time to be useful: engine filter cycles compile cycles - ---------------+---------------+---------------- jit-linux 106468 33126+72796 jit-freebsd 113958 48292+72796 llvm 157394 380843640+72796 pcap 276910 72796 linux 351391 9245+72796 I haven't tried theraven's implementation but I am afraid the result may be similar. On top of that, it cannot be easily embedded in kernel. BTW, NetBSD actually imported my BPF_JITTER first, then it was replaced by bpfjit: http://mail-index.netbsd.org/tech-net/2012/08/19/msg003619.html http://mail-index.netbsd.org/source-changes/2012/10/27/msg038310.html I wanted to try it out because I think it has great potential. ;-) Jung-uk Kim -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iQEcBAEBAgAGBQJQwN+wAAoJECXpabHZMqHObcIH/0VN0ssRB9nNPwKq0WnxYZdO 7rnhymuYh8gRIGXkcHAu1ma/egJFk7tFTx37fm1q9iT/f+1TB2U5ZNi+6h9pnxSl W7U+yrEFvE4FkI6xnHq26amLTAQv3xdmNhB67M+glXj+emRuFfckgShnvgd4brRy ZJnaqJ3frCXld/1WG7dSmq1OIN4mT/7stw6BwwtzrkbdtcTQRgukNIFEyObMmReE RNligaB0l2Yj0S+6lI+6VQTyDc7NhSHMAUw32F385EuKYcJwkrj24eYxbCcWyP+g +9lGAYhLUOXUfM+7IISwdguWnQnIcpOxvo4I2shAglJYygnN+hSXZWn9IzTU5Gw= =4Ov6 -----END PGP SIGNATURE-----