Eric Dumazet
0a14842f5a
net: filter: Just In Time compiler for x86-64
In order to speedup packet filtering, here is an implementation of a
JIT compiler for x86_64
It is disabled by default, and must be enabled by the admin.
echo 1 >/proc/sys/net/core/bpf_jit_enable
It uses module_alloc() and module_free() to get memory in the 2GB text
kernel range since we call helpers functions from the generated code.
EAX : BPF A accumulator
EBX : BPF X accumulator
RDI : pointer to skb (first argument given to JIT function)
RBP : frame pointer (even if CONFIG_FRAME_POINTER=n)
r9d : skb->len - skb->data_len (headlen)
r8 : skb->data
To get a trace of generated code, use :
echo 2 >/proc/sys/net/core/bpf_jit_enable
Example of generated code :
# tcpdump -p -n -s 0 -i eth1 host 192.168.20.0/24
flen=18 proglen=147 pass=3 image=ffffffffa00b5000
JIT code: ffffffffa00b5000: 55 48 89 e5 48 83 ec 60 48 89 5d f8 44 8b 4f 60
JIT code: ffffffffa00b5010: 44 2b 4f 64 4c 8b 87 b8 00 00 00 be 0c 00 00 00
JIT code: ffffffffa00b5020: e8 24 7b f7 e0 3d 00 08 00 00 75 28 be 1a 00 00
JIT code: ffffffffa00b5030: 00 e8 fe 7a f7 e0 24 00 3d 00 14 a8 c0 74 49 be
JIT code: ffffffffa00b5040: 1e 00 00 00 e8 eb 7a f7 e0 24 00 3d 00 14 a8 c0
JIT code: ffffffffa00b5050: 74 36 eb 3b 3d 06 08 00 00 74 07 3d 35 80 00 00
JIT code: ffffffffa00b5060: 75 2d be 1c 00 00 00 e8 c8 7a f7 e0 24 00 3d 00
JIT code: ffffffffa00b5070: 14 a8 c0 74 13 be 26 00 00 00 e8 b5 7a f7 e0 24
JIT code: ffffffffa00b5080: 00 3d 00 14 a8 c0 75 07 b8 ff ff 00 00 eb 02 31
JIT code: ffffffffa00b5090: c0 c9 c3
BPF program is 144 bytes long, so native program is almost same size ;)
(000) ldh [12]
(001) jeq #0x800 jt 2 jf 8
(002) ld [26]
(003) and #0xffffff00
(004) jeq #0xc0a81400 jt 16 jf 5
(005) ld [30]
(006) and #0xffffff00
(007) jeq #0xc0a81400 jt 16 jf 17
(008) jeq #0x806 jt 10 jf 9
(009) jeq #0x8035 jt 10 jf 17
(010) ld [28]
(011) and #0xffffff00
(012) jeq #0xc0a81400 jt 16 jf 13
(013) ld [38]
(014) and #0xffffff00
(015) jeq #0xc0a81400 jt 16 jf 17
(016) ret #65535
(017) ret #0
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: Ben Hutchings <bhutchings@solarflare.com>
Cc: Hagen Paul Pfeifer <hagen@jauu.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
2011-04-27 23:05:08 -07:00
..
2011-04-07 11:14:49 -07:00
2010-12-22 19:43:34 -08:00
2011-03-21 22:59:08 -04:00
2010-08-04 15:21:40 +02:00
2011-03-31 11:26:23 -03:00
2009-09-24 07:20:57 -07:00
2010-08-06 12:55:52 -04:00
2011-03-31 11:26:23 -03:00
2010-08-04 15:21:40 +02:00
2010-08-04 15:21:40 +02:00
2011-04-04 17:51:47 -07:00
2010-04-23 02:09:52 +02:00
2010-02-24 13:51:32 +01:00
2011-03-16 17:54:31 -04:00
2011-03-25 14:30:31 -06:00
2011-03-31 11:26:23 -03:00
2011-04-07 11:14:49 -07:00
2011-03-31 11:26:23 -03:00
2010-11-10 16:57:11 -08:00
2011-04-07 11:14:49 -07:00
2010-03-06 11:26:32 -08:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2010-08-05 13:53:34 -07:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2010-08-04 15:21:40 +02:00
2011-03-31 11:26:23 -03:00
2011-03-24 09:50:13 -07:00
2011-03-31 11:26:23 -03:00
2010-08-04 15:21:40 +02:00
2011-03-31 11:26:23 -03:00
2010-11-25 14:36:38 +01:00
2010-11-15 23:50:13 +01:00
2011-03-31 11:26:23 -03:00
2011-04-04 17:51:47 -07:00
2011-04-04 17:51:47 -07:00
2011-01-20 21:37:29 +10:30
2010-12-14 22:16:19 +01:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2010-08-12 08:43:30 -07:00
2010-08-04 15:21:40 +02:00
2010-04-23 02:09:52 +02:00
2011-04-13 19:15:50 -07:00
2011-01-13 08:03:19 -08:00
2011-03-31 11:26:23 -03:00
2010-09-29 17:20:24 +02:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2011-01-13 08:03:21 -08:00
2011-03-23 19:46:41 -07:00
2011-03-04 08:05:25 -08:00
2011-04-04 17:51:47 -07:00
2011-03-31 13:00:35 +02:00
2011-04-07 11:14:49 -07:00
2011-03-31 11:26:23 -03:00
2010-11-15 18:25:12 +09:00
2011-04-07 11:14:49 -07:00
2011-03-31 11:26:23 -03:00
2011-04-27 23:05:08 -07:00
2011-03-23 11:36:45 -05:00
2011-03-31 11:26:23 -03:00
2011-01-12 00:08:35 -05:00
2010-11-01 15:38:34 -04:00
2011-03-31 11:26:23 -03:00
2010-08-04 15:21:40 +02:00
2011-02-04 11:46:57 -08:00
2011-04-07 11:14:49 -07:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2011-03-22 17:44:11 -07:00
2011-02-28 19:30:48 -08:00
2010-04-08 11:34:34 +02:00
2011-04-04 17:51:47 -07:00
2010-08-02 15:35:15 +10:00
2010-04-23 02:09:52 +02:00
2010-08-04 15:21:40 +02:00
2010-07-20 17:49:30 +00:00
2010-04-23 02:09:52 +02:00
2011-03-22 17:44:17 -07:00
2010-03-24 16:31:22 -07:00
2010-12-03 12:27:01 +01:00
2011-03-22 17:44:16 -07:00
2011-03-31 11:26:23 -03:00
2010-09-09 20:41:25 +02:00
2010-07-29 15:16:18 -07:00
2009-10-03 09:28:11 +02:00
2011-03-31 11:26:23 -03:00
2010-10-28 09:35:11 -07:00
2010-08-14 11:56:46 -07:00
2010-08-11 08:59:21 -07:00
2011-01-06 09:59:37 -08:00
2011-03-27 19:46:59 -07:00
2011-04-07 11:14:49 -07:00
2011-03-31 11:26:23 -03:00
2011-01-13 08:03:15 -08:00
2011-04-12 16:18:44 -04:00
2009-10-15 07:25:20 -06:00
2009-09-21 15:14:56 +02:00
2011-01-13 17:26:46 -08:00
2010-08-04 15:21:40 +02:00
2011-02-17 09:52:03 -08:00
2010-03-06 11:26:29 -08:00
2010-08-04 15:21:40 +02:00
2009-09-19 09:37:23 -07:00
2011-03-23 20:44:18 +01:00
2010-12-14 00:22:00 -05:00
2011-03-31 11:26:23 -03:00
2010-09-11 16:49:21 -07:00
2011-01-06 09:59:38 -08:00
2011-04-07 11:14:49 -07:00
2011-03-08 11:17:18 +11:00
2010-11-29 08:55:25 +11:00
2011-03-08 11:17:22 +11:00
2011-04-04 17:51:46 -07:00
2010-03-19 07:12:20 -07:00
2010-11-01 15:38:34 -04:00
2011-03-07 13:20:05 -08:00
2010-08-04 15:21:40 +02:00
2009-12-06 13:20:02 +01:00
2011-01-12 20:02:48 -05:00
2010-12-29 08:17:12 -02:00
2010-08-04 15:21:40 +02:00
2011-03-31 11:26:23 -03:00
2011-03-04 08:05:49 -08:00
2011-02-03 16:08:57 -08:00
2009-09-22 07:17:26 -07:00
2010-09-03 08:19:51 +02:00
2009-12-15 08:53:24 -08:00
2009-09-22 07:17:39 -07:00
2010-05-19 08:37:43 +01:00
2010-08-11 08:59:18 -07:00
2010-02-05 12:22:44 +01:00
2010-11-11 12:09:59 +01:00
2010-03-10 17:09:33 -05:00
2010-06-05 17:39:09 +02:00
2011-03-09 11:25:10 -08:00
2011-03-31 11:26:23 -03:00
2010-04-23 02:09:52 +02:00
2010-07-19 10:56:54 +02:00
2011-01-27 12:30:38 +01:00
2010-04-22 15:24:56 -07:00
2010-05-24 07:31:20 -07:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2010-03-16 11:47:56 +01:00
2010-10-26 17:32:41 -07:00
2010-08-02 15:35:10 +10:00
2009-12-16 11:28:58 -08:00
2010-03-24 16:31:20 -07:00
2011-02-16 17:48:59 +01:00
2011-01-13 08:03:24 -08:00