Re: [PATCH RFC net-next 01/14] net: filter: split filter.c into two files

2014-07-01 Thread Alexei Starovoitov
On Tue, Jul 1, 2014 at 9:23 PM, Namhyung Kim namhy...@gmail.com wrote: Hi Alexei, On Fri, 27 Jun 2014 17:05:53 -0700, Alexei Starovoitov wrote: BPF is used in several kernel components. This split creates logical boundary between generic eBPF core and the rest kernel/bpf/core.c: eBPF

Re: [PATCH RFC] arm64: eBPF JIT compiler

2014-07-01 Thread Alexei Starovoitov
On Tue, Jul 1, 2014 at 10:20 PM, Zi Shen Lim zlim@gmail.com wrote: The JIT compiler emits A64 instructions. It supports eBPF only. Legacy BPF is supported thanks to conversion by BPF core. JIT is enabled in the same way as for other architectures: echo 1

Re: [PATCH RFC net-next 08/14] bpf: add eBPF verifier

2014-07-01 Thread Alexei Starovoitov
On Tue, Jul 1, 2014 at 10:05 PM, Namhyung Kim namhy...@gmail.com wrote: Mostly questions and few nitpicks.. :) great questions. Thank you for review! Answers below: On Fri, 27 Jun 2014 17:06:00 -0700, Alexei Starovoitov wrote: +/* types of values: + * - stored in an eBPF register

Re: [PATCH RFC net-next 11/14] tracing: allow eBPF programs to be attached to events

2014-07-02 Thread Alexei Starovoitov
On Tue, Jul 1, 2014 at 10:32 PM, Namhyung Kim namhy...@gmail.com wrote: On Fri, 27 Jun 2014 17:06:03 -0700, Alexei Starovoitov wrote: User interface: cat bpf_123 /sys/kernel/debug/tracing/__event__/filter where 123 is an id of the eBPF program priorly loaded. __event__ is static tracepoint

Re: [PATCH RFC net-next 11/14] tracing: allow eBPF programs to be attached to events

2014-07-02 Thread Alexei Starovoitov
On Tue, Jul 1, 2014 at 11:39 PM, Namhyung Kim namhy...@kernel.org wrote: On Wed, Jul 2, 2014 at 3:14 PM, Alexei Starovoitov a...@plumgrid.com wrote: Can manipulate what at compile time? Entry records of tracepoints are hard coded based on the event. For verifier it's easier to treat all

Re: [PATCH RFC] arm64: eBPF JIT compiler

2014-07-02 Thread Alexei Starovoitov
On Tue, Jul 1, 2014 at 10:20 PM, Zi Shen Lim zlim@gmail.com wrote: The JIT compiler emits A64 instructions. It supports eBPF only. Legacy BPF is supported thanks to conversion by BPF core. JIT is enabled in the same way as for other architectures: echo 1

Re: [PATCH RFC net-next 08/14] bpf: add eBPF verifier

2014-07-02 Thread Alexei Starovoitov
On Wed, Jul 2, 2014 at 1:11 AM, David Laight david.lai...@aculab.com wrote: From: Alexei Starovoitov ... +#define _(OP) ({ int ret = OP; if (ret 0) return ret; }) ... + _(get_map_info(env, map_id, map)); Nit: such macros should be removed, please. It may surely look

Re: [PATCH RFC net-next 08/14] bpf: add eBPF verifier

2014-07-02 Thread Alexei Starovoitov
On Wed, Jul 2, 2014 at 3:22 PM, Chema Gonzalez ch...@google.com wrote: + * - unreachable insns exist (shouldn't be a forest. program = one function) This seems to me an unnecessary style restriction on user code. unreachable instructions to me is a ticking time bomb of potential exploits.

Re: [PATCH RFC net-next 08/14] bpf: add eBPF verifier

2014-07-02 Thread Alexei Starovoitov
On Wed, Jul 2, 2014 at 4:35 PM, Chema Gonzalez ch...@google.com wrote: On Wed, Jul 2, 2014 at 4:04 PM, Alexei Starovoitov a...@plumgrid.com wrote: + reg = regs + BPF_REG_1; /* 1st arg to a function */ + reg-ptr = PTR_TO_CTX; Wait, doesn't this depend on doing BPF_MOV64_REG

Re: [PATCH RFC net-next 03/14] bpf: introduce syscall(BPF, ...) and BPF maps

2014-07-02 Thread Alexei Starovoitov
On Wed, Jul 2, 2014 at 6:43 PM, Andy Lutomirski l...@amacapital.net wrote: On Tue, Jul 1, 2014 at 10:33 PM, Alexei Starovoitov a...@plumgrid.com wrote: I want to avoid string names, since they will force new 'strtab', 'symtab' sections in the programs/maps and will uglify the user interface

Re: [PATCHv2 net-next] net: filter: move load_pointer() into filter.h

2014-07-03 Thread Alexei Starovoitov
() for clarity. Signed-off-by: Zi Shen Lim zlim@gmail.com Acked-by: Alexei Starovoitov a...@plumgrid.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please

Re: [PATCH RFC net-next 08/14] bpf: add eBPF verifier

2014-07-03 Thread Alexei Starovoitov
On Thu, Jul 3, 2014 at 2:13 AM, David Laight david.lai...@aculab.com wrote: From: Alexei Starovoitov +#define _(OP) ({ int ret = OP; if (ret 0) return ret; }) +1 to removing the _ macro. If you want to avoid the 3 lines (is there anything in the style guide against if ((err=OP) 0

[RFC PATCH v2 tip 7/7] tracing filter examples in BPF

2014-02-05 Thread Alexei Starovoitov
filter_check/ - userspace correctness checker of BPF filter examples/ - BPF filter examples in C will be compiled by LLVM into .bpf $cd examples $make - compile .c into .bpf $make check - check correctness of *.bpf $make try - to apply netif_rcv.bpf as a tracing filter Signed-off-by: Alexei

[RFC PATCH v2 tip 0/7] 64-bit BPF insn set and tracing filters

2014-02-05 Thread Alexei Starovoitov
there. Future deltas will be easier to review. Thanks Alexei Starovoitov (7): Extended BPF core framework Extended BPF JIT for x86-64 Extended BPF (64-bit BPF) design document Revert x86/ptrace: Remove unused regs_get_argument_nth API use BPF in tracing filters LLVM BPF backend tracing

[RFC PATCH v2 tip 3/7] Extended BPF (64-bit BPF) design document

2014-02-05 Thread Alexei Starovoitov
Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- Documentation/bpf_jit.txt | 204 + 1 file changed, 204 insertions(+) create mode 100644 Documentation/bpf_jit.txt diff --git a/Documentation/bpf_jit.txt b/Documentation/bpf_jit.txt new file mode

[RFC PATCH v2 tip 4/7] Revert x86/ptrace: Remove unused regs_get_argument_nth API

2014-02-05 Thread Alexei Starovoitov
This reverts commit aa5add93e92019018e905146f8c3d3f8e3c08300. Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- arch/x86/include/asm/ptrace.h |3 +++ arch/x86/kernel/ptrace.c | 24 2 files changed, 27 insertions(+) diff --git a/arch/x86/include/asm

[RFC PATCH v2 tip 5/7] use BPF in tracing filters

2014-02-05 Thread Alexei Starovoitov
prototype is 'int dst_discard(struct sk_buff *skb);' bpf_load_pointer() will try to fetch 'dev' field of 'sk_buff' structure and will suppress page-fault if pointer is incorrect. Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- include/linux/ftrace_event.h |5 + include/trace

[RFC PATCH v2 tip 2/7] Extended BPF JIT for x86-64

2014-02-05 Thread Alexei Starovoitov
. Allowing zero-overhead calls between BPF filter and safe kernel functions Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- arch/x86/Kconfig |1 + arch/x86/net/Makefile |1 + arch/x86/net/bpf64_jit_comp.c | 625 + arch

[RFC PATCH v2 tip 1/7] Extended BPF core framework

2014-02-05 Thread Alexei Starovoitov
for efficient mapping to native instructions on 64-bit CPUs Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- include/linux/bpf.h| 149 +++ include/linux/bpf_jit.h| 134 ++ kernel/Makefile|1 + kernel/bpf_jit/Makefile|3 + kernel/bpf_jit/bpf_check.c | 1054

Re: [RFC PATCH v2 tip 0/7] 64-bit BPF insn set and tracing filters

2014-02-05 Thread Alexei Starovoitov
On Wed, Feb 5, 2014 at 4:27 PM, David Miller da...@redhat.com wrote: From: Alexei Starovoitov a...@plumgrid.com Date: Wed, 5 Feb 2014 16:10:00 -0800 this patch set addresses main sticking points of the previous discussion: http://thread.gmane.org/gmane.linux.kernel/1605783 You really

[RFC PATCH v2 tip 0/7] 64-bit BPF insn set and tracing filters

2014-02-05 Thread Alexei Starovoitov
or staging tree and continue working there. Future deltas will be easier to review. Thanks Alexei Starovoitov (7): Extended BPF core framework Extended BPF JIT for x86-64 Extended BPF (64-bit BPF) design document Revert x86/ptrace: Remove unused regs_get_argument_nth API use BPF in tracing

[RFC PATCH v2 tip 7/7] tracing filter examples in BPF

2014-02-05 Thread Alexei Starovoitov
filter_check/ - userspace correctness checker of BPF filter examples/ - BPF filter examples in C will be compiled by LLVM into .bpf $cd examples $make - compile .c into .bpf $make check - check correctness of *.bpf $make try - to apply netif_rcv.bpf as a tracing filter Signed-off-by: Alexei

[RFC PATCH v2 tip 4/7] Revert x86/ptrace: Remove unused regs_get_argument_nth API

2014-02-05 Thread Alexei Starovoitov
This reverts commit aa5add93e92019018e905146f8c3d3f8e3c08300. Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- arch/x86/include/asm/ptrace.h |3 +++ arch/x86/kernel/ptrace.c | 24 2 files changed, 27 insertions(+) diff --git a/arch/x86/include/asm

[RFC PATCH v2 tip 3/7] Extended BPF (64-bit BPF) design document

2014-02-05 Thread Alexei Starovoitov
Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- Documentation/bpf_jit.txt | 204 + 1 file changed, 204 insertions(+) create mode 100644 Documentation/bpf_jit.txt diff --git a/Documentation/bpf_jit.txt b/Documentation/bpf_jit.txt new file mode

[RFC PATCH v2 tip 5/7] use BPF in tracing filters

2014-02-05 Thread Alexei Starovoitov
prototype is 'int dst_discard(struct sk_buff *skb);' bpf_load_pointer() will try to fetch 'dev' field of 'sk_buff' structure and will suppress page-fault if pointer is incorrect. Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- include/linux/ftrace_event.h |5 + include/trace

[RFC PATCH v2 tip 1/7] Extended BPF core framework

2014-02-05 Thread Alexei Starovoitov
for efficient mapping to native instructions on 64-bit CPUs Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- include/linux/bpf.h| 149 +++ include/linux/bpf_jit.h| 134 ++ kernel/Makefile|1 + kernel/bpf_jit/Makefile|3 + kernel/bpf_jit/bpf_check.c | 1054

[RFC PATCH v2 tip 2/7] Extended BPF JIT for x86-64

2014-02-05 Thread Alexei Starovoitov
. Allowing zero-overhead calls between BPF filter and safe kernel functions Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- arch/x86/Kconfig |1 + arch/x86/net/Makefile |1 + arch/x86/net/bpf64_jit_comp.c | 625 + arch

Re: [RFC PATCH v2 tip 0/7] 64-bit BPF insn set and tracing filters

2014-02-06 Thread Alexei Starovoitov
On Thu, Feb 6, 2014 at 2:42 AM, Daniel Borkmann dbork...@redhat.com wrote: Hi Alexei, On 02/06/2014 02:10 AM, Alexei Starovoitov wrote: Hi All, this patch set addresses main sticking points of the previous discussion: http://thread.gmane.org/gmane.linux.kernel/1605783 Main difference

Re: [PATCH net-next] net: filter: rename 'struct sk_filter' to 'struct bpf_prog'

2014-07-26 Thread Alexei Starovoitov
On Fri, Jul 25, 2014 at 3:17 PM, Pablo Neira Ayuso pa...@netfilter.org wrote: On Fri, Jul 25, 2014 at 10:24:29AM -0700, Alexei Starovoitov wrote: On Fri, Jul 25, 2014 at 6:00 AM, Daniel Borkmann dbork...@redhat.com wrote: On 07/25/2014 01:54 PM, Pablo Neira Ayuso wrote: On Fri, Jul 25

Re: Random panic in load_balance() with 3.16-rc

2014-07-28 Thread Alexei Starovoitov
On Mon, Jul 28, 2014 at 09:45:45AM -0700, Linus Torvalds wrote: On Mon, Jul 28, 2014 at 5:26 AM, Frank Ch. Eigler f...@redhat.com wrote: Please note that the data produced by -g -fvar-tracking is consumed by tools like systemtap, perf, crash, and makes a significant difference to the

Re: [PATCH net-next] net: filter: rename 'struct sk_filter' to 'struct bpf_prog'

2014-07-28 Thread Alexei Starovoitov
On Mon, Jul 28, 2014 at 2:45 PM, Pablo Neira Ayuso pa...@netfilter.org wrote: struct sk_filter_cb { int type; struct module *me; void (*charge)(struct sock *sk, struct sk_filter *fp); void (*uncharge)(struct sock *sk, struct sk_filter *fp);

[PATCH v3 net-next] net: filter: cleanup sk_* and bpf_* names

2014-07-29 Thread Alexei Starovoitov
charging logic was complicated, since we had to charge/uncharge a socket multiple times while preparing a filter. Simplify it by fully preparing bpf program (through classic-ebpf conversion and JITing) and then charge the socket memory once. Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- v2

Re: [PATCH v3 net-next] net: filter: cleanup sk_* and bpf_* names

2014-07-29 Thread Alexei Starovoitov
On Tue, Jul 29, 2014 at 8:31 AM, Pablo Neira Ayuso pa...@netfilter.org wrote: On Mon, Jul 28, 2014 at 11:29:40PM -0700, Alexei Starovoitov wrote: Socket charging logic was complicated, since we had to charge/uncharge a socket multiple times while preparing a filter. Simplify it by fully

Re: [PATCH v3 net-next] net: filter: cleanup sk_* and bpf_* names

2014-07-29 Thread Alexei Starovoitov
On Tue, Jul 29, 2014 at 9:42 AM, Pablo Neira Ayuso pa...@netfilter.org wrote: On Tue, Jul 29, 2014 at 08:55:04AM -0700, Alexei Starovoitov wrote: I don't think this is the right moment to add this, but we have to keep in mind that something similar to this will need to be accomodated

Re: [PATCH RFC v3 net-next 3/3] samples: bpf: eBPF dropmon example in C

2014-07-30 Thread Alexei Starovoitov
On Wed, Jul 30, 2014 at 8:45 AM, Frank Ch. Eigler f...@redhat.com wrote: For the record, this is not entirely accurate as to dtrace. dtrace delegates aggregation and most reporting to userspace. Also, systemtap is short and deterministic even for aggregations nice graphs, but since it

Re: [PATCH 6/7] x86_64,entry: Treat regs-ax the same in fastpath and slowpath syscalls

2014-07-16 Thread Alexei Starovoitov
On Tue, Jul 15, 2014 at 12:32 PM, Andy Lutomirski l...@amacapital.net wrote: For slowpath syscalls, we initialize regs-ax to -ENOSYS and stick the syscall number into regs-orig_ax prior to any possible tracing and syscall execution. This is user-visible ABI used by ptrace syscall emulation

Re: [PATCH RFCv3 01/14] arm64: introduce aarch64_insn_gen_comp_branch_imm()

2014-07-17 Thread Alexei Starovoitov
On Thu, Jul 17, 2014 at 2:19 AM, Will Deacon will.dea...@arm.com wrote: On Wed, Jul 16, 2014 at 10:19:31PM +0100, Zi Shen Lim wrote: Is a BUG_ON justifiable here? Is there not a nicer way to fail? In general, it'd be nice if we returned something like -EINVAL and have all callers handle

[PATCH RFC v2 net-next 03/16] net: filter: rename struct sock_filter_int into bpf_insn

2014-07-17 Thread Alexei Starovoitov
follow on patch exposes eBPF to user space and 'sock_filter_int' name no longer makes sense, so rename it to 'bpf_insn' Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- arch/x86/net/bpf_jit_comp.c |2 +- include/linux/filter.h | 50

[PATCH RFC v2 net-next 13/16] tracing: allow eBPF programs to be attached to events

2014-07-17 Thread Alexei Starovoitov
-by: Alexei Starovoitov a...@plumgrid.com --- include/linux/ftrace_event.h |5 + include/trace/bpf_trace.h | 29 + include/trace/ftrace.h | 10 ++ include/uapi/linux/bpf.h |5 + kernel/trace/Kconfig |1 + kernel/trace/Makefile

[PATCH RFC v2 net-next 15/16] samples: bpf: example of stateful socket filtering

2014-07-17 Thread Alexei Starovoitov
(map_id, fp - 4); if (value) (*(u64*)value) += 1; - attaches this program to eth0 raw socket - every second user space reads map[6] and map[17] to see how many TCP and UDP packets were seen on eth0 Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- samples/bpf/.gitignore

[PATCH RFC v2 net-next 05/16] bpf: introduce syscall(BPF, ...) and BPF maps

2014-07-17 Thread Alexei Starovoitov
different attributes as well. The concept of type-lenght-value is borrowed from netlink, but netlink itself is not applicable here, since BPF programs and maps can be used in NET-less configurations. Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- Documentation/networking/filter.txt | 69

[PATCH RFC v2 net-next 16/16] samples: bpf: example of tracing filters with eBPF

2014-07-17 Thread Alexei Starovoitov
simple packet drop monitor: - in-kernel eBPF program attaches to kfree_skb() event and records number of packet drops at given location - userspace iterates over the map every second and prints stats Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- samples/bpf/Makefile |4

[PATCH RFC v2 net-next 11/16] bpf: allow eBPF programs to use maps

2014-07-17 Thread Alexei Starovoitov
expose bpf_map_lookup_elem(), bpf_map_update_elem(), bpf_map_delete_elem() map accessors to eBPF programs Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- include/linux/bpf.h |5 +++ include/uapi/linux/bpf.h |3 ++ kernel/bpf/syscall.c | 85

[PATCH RFC v2 net-next 14/16] samples: bpf: add mini eBPF library to manipulate maps and programs

2014-07-17 Thread Alexei Starovoitov
(int fd, void *key, void *next_key); int bpf_prog_load(enum bpf_prog_type prog_type, const struct sock_filter_int *insns, int insn_len, const char *license, const struct bpf_map_fixup *fixups, int fixup_len); Signed-off-by: Alexei Starovoitov

[PATCH RFC v2 net-next 12/16] net: sock: allow eBPF programs to be attached to sockets

2014-07-17 Thread Alexei Starovoitov
-by: Alexei Starovoitov a...@plumgrid.com --- arch/alpha/include/uapi/asm/socket.h |2 + arch/avr32/include/uapi/asm/socket.h |2 + arch/cris/include/uapi/asm/socket.h|2 + arch/frv/include/uapi/asm/socket.h |2 + arch/ia64/include/uapi/asm/socket.h|2 + arch/m32r

[PATCH RFC v2 net-next 09/16] bpf: expand BPF syscall with program load/unload

2014-07-17 Thread Alexei Starovoitov
(__NR_bpf, BPF_PROG_LOAD, prog_type, ...) follows in later patches Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- include/linux/bpf.h | 33 + include/linux/filter.h |9 +- include/uapi/linux/bpf.h | 29 + kernel/bpf/core.c|5 +- kernel/bpf/syscall.c

[PATCH RFC v2 net-next 06/16] bpf: enable bpf syscall on x64

2014-07-17 Thread Alexei Starovoitov
done as separate commit to ease conflict resolution Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- arch/x86/syscalls/syscall_64.tbl |1 + include/linux/syscalls.h |2 ++ include/uapi/asm-generic/unistd.h |4 +++- kernel/sys_ni.c |3 +++ 4

[PATCH RFC v2 net-next 08/16] bpf: add hashtable type of BPF maps

2014-07-17 Thread Alexei Starovoitov
add new map type: BPF_MAP_TYPE_HASH and its simple (not auto resizeable) hash table implementation Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- include/uapi/linux/bpf.h |1 + kernel/bpf/Makefile |2 +- kernel/bpf/hashtab.c | 371

[PATCH RFC v2 net-next 07/16] bpf: add lookup/update/delete/iterate methods to BPF maps

2014-07-17 Thread Alexei Starovoitov
) returns zero or negative error - find and delete element by key in a given map err = bpf_map_delete_elem(int fd, void *key) - iterate map elements (based on input key return next_key) err = bpf_map_get_next_key(int fd, void *key, void *next_key) - close(fd) deletes the map Signed-off-by: Alexei

[PATCH RFC v2 net-next 04/16] net: filter: split filter.h and expose eBPF to user space

2014-07-17 Thread Alexei Starovoitov
cannot go into uapi/linux/filter.h, since the names may conflict with existing applications. Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- include/linux/filter.h| 294 +-- include/uapi/linux/Kbuild |1 + include/uapi/linux/bpf.h | 303

[PATCH RFC v2 net-next 00/16] BPF syscall, maps, verifier, samples

2014-07-17 Thread Alexei Starovoitov
) Alexei Starovoitov (16): net: filter: split filter.c into two files bpf: update MAINTAINERS entry net: filter: rename struct sock_filter_int into bpf_insn net: filter: split filter.h and expose eBPF to user space bpf: introduce

[PATCH RFC v2 net-next 02/16] bpf: update MAINTAINERS entry

2014-07-17 Thread Alexei Starovoitov
Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- MAINTAINERS |7 +++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index ae8cd00215b2..32e24ff46da3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1912,6 +1912,13 @@ S: Supported F: drivers/net

[PATCH RFC v2 net-next 01/16] net: filter: split filter.c into two files

2014-07-17 Thread Alexei Starovoitov
. The new + * internal format has been designed by PLUMgrid: + * + * Copyright (c) 2011 - 2014 PLUMgrid, http://plumgrid.com + * + * Authors: + * + * Jay Schulist jsch...@samba.org + * Alexei Starovoitov a...@plumgrid.com + * Daniel Borkmann dbork...@redhat.com + * + * This program

[PATCH v5 net-next 00/29] BPF syscall, maps, verifier, samples, llvm

2014-08-24 Thread Alexei Starovoitov
from Namhyung, Chema, Joe - added more comments to verifier - renamed sock_filter_int - bpf_insn - rebased on net-next As always all patches are available at: git://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf master -- Alexei Starovoitov (29): bpf: x86: add missing 'shift by register

[PATCH v5 net-next 03/29] net: filter: split filter.h and expose eBPF to user space

2014-08-24 Thread Alexei Starovoitov
cannot go into uapi/linux/filter.h, since the names may conflict with existing applications. Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- include/linux/filter.h| 312 +-- include/uapi/linux/Kbuild |1 + include/uapi/linux/bpf.h | 321

[PATCH v5 net-next 15/29] bpf: verifier (add state prunning optimization)

2014-08-24 Thread Alexei Starovoitov
strict state leads to valid bpf_exit. Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- kernel/bpf/verifier.c | 134 + 1 file changed, 134 insertions(+) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 14a0262b101c..49374066a5bd

[PATCH v5 net-next 23/29] samples: bpf: example of tracing filters with eBPF

2014-08-24 Thread Alexei Starovoitov
simple packet drop monitor: - in-kernel eBPF program attaches to kfree_skb() event and records number of packet drops at given location - userspace iterates over the map every second and prints stats Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- samples/bpf/Makefile | 12

[PATCH v5 net-next 24/29] bpf: verifier test

2014-08-24 Thread Alexei Starovoitov
alignment OK #41 sometimes access memory with incorrect alignment OK Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- samples/bpf/Makefile|3 +- samples/bpf/test_verifier.c | 599 +++ 2 files changed, 601 insertions(+), 1 deletion

[PATCH v5 net-next 13/29] bpf: verifier (add branch/goto checks)

2014-08-24 Thread Alexei Starovoitov
check that control flow graph of eBPF program is a directed acyclic graph check_cfg() does: - detect loops - detect unreachable instructions - check that program terminates with BPF_EXIT insn - check that all branches are within program boundary Signed-off-by: Alexei Starovoitov

[PATCH v5 net-next 11/29] bpf: verifier (add ability to receive verification log)

2014-08-24 Thread Alexei Starovoitov
supplied buffer which can be used by humans to analyze why verifier rejected given program Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- include/uapi/linux/bpf.h |4 + kernel/bpf/syscall.c |3 + kernel/bpf/verifier.c| 236 ++ 3

[PATCH v5 net-next 29/29] samples: bpf: IO latency analysis (iosnoop/heatmap)

2014-08-24 Thread Alexei Starovoitov
latencies, syscalls, etc Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- samples/bpf/Makefile |6 +- samples/bpf/ex3_kern.c | 104 + samples/bpf/ex3_user.c | 149 3 files changed, 257 insertions(+), 2

[PATCH v5 net-next 28/29] samples: bpf: counting eBPF example in C

2014-08-24 Thread Alexei Starovoitov
| | Ctrl-C at any time. Kernel will auto cleanup maps and programs Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- samples/bpf/Makefile |6 ++-- samples/bpf/ex2_kern.c | 73 + samples/bpf/ex2_user.c | 94

[PATCH v5 net-next 26/29] samples: bpf: elf file loader

2014-08-24 Thread Alexei Starovoitov
); bpf_helpers.h is a set of in-kernel helper functions available to eBPF programs Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- samples/bpf/bpf_helpers.h | 27 ++ samples/bpf/bpf_load.c| 234 + samples/bpf/bpf_load.h| 26 + 3

[PATCH v5 net-next 22/29] samples: bpf: add mini eBPF library to manipulate maps and programs

2014-08-24 Thread Alexei Starovoitov
(int fd, void *key, void *next_key); int bpf_prog_load(enum bpf_prog_type prog_type, const struct sock_filter_int *insns, int insn_len, const char *license); bpf_prog_load() stores verifier log into global bpf_log_buf[] array Signed-off-by: Alexei Starovoitov

[PATCH v5 net-next 20/29] tracing: allow eBPF programs to be attached to kprobe/kretprobe

2014-08-24 Thread Alexei Starovoitov
Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- kernel/trace/trace_kprobe.c | 28 1 file changed, 28 insertions(+) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 282f6e4e5539..b6db92207c99 100644 --- a/kernel/trace

[PATCH v5 net-next 27/29] samples: bpf: eBPF example in C

2014-08-24 Thread Alexei Starovoitov
] ..s3 5640.716272: __netif_receive_skb_core: skb 5d06300 dev b9e6000 Ctrl-C at any time, kernel will auto cleanup Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- samples/bpf/Makefile | 15 +-- samples/bpf/ex1_kern.c | 27 +++ samples/bpf

[PATCH v5 net-next 21/29] tracing: allow eBPF programs to call ktime_get_ns() and get_current()

2014-08-24 Thread Alexei Starovoitov
Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- include/uapi/linux/bpf.h |2 ++ kernel/trace/bpf_trace.c | 20 2 files changed, 22 insertions(+) diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 5adaad826471..e866a2fcba8b 100644

[PATCH v5 net-next 18/29] tracing: allow eBPF programs to be attached to events

2014-08-24 Thread Alexei Starovoitov
probe_kernel_read(), so that eBPF program can walk any kernel data structures Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- fs/btrfs/super.c |3 + include/linux/ftrace_event.h |5 + include/trace/bpf_trace.h | 23 + include/trace/ftrace.h

[PATCH v5 net-next 19/29] tracing: allow eBPF programs call printk()

2014-08-24 Thread Alexei Starovoitov
limited printk() with %d %u %x %p modifiers only Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- include/uapi/linux/bpf.h |1 + kernel/trace/bpf_trace.c | 61 ++ 2 files changed, 62 insertions(+) diff --git a/include/uapi/linux/bpf.h b

[PATCH v5 net-next 17/29] bpf: split eBPF out of NET

2014-08-24 Thread Alexei Starovoitov
let eBPF have its own CONFIG_BPF, so that tracing and other subsystems don't need to depend on all of NET Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- arch/Kconfig |4 kernel/Makefile |2 +- kernel/bpf/core.c | 12 net/Kconfig |1 + 4 files

[PATCH v5 net-next 16/29] bpf: allow eBPF programs to use maps

2014-08-24 Thread Alexei Starovoitov
expose bpf_map_lookup_elem(), bpf_map_update_elem(), bpf_map_delete_elem() map accessors to eBPF programs Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- include/linux/bpf.h |5 include/uapi/linux/bpf.h |3 ++ kernel/bpf/syscall.c | 68

[PATCH v5 net-next 14/29] bpf: verifier (add verifier core)

2014-08-24 Thread Alexei Starovoitov
/filter.txt and in kernel/bpf/verifier.c Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- include/linux/bpf.h | 47 ++ include/uapi/linux/bpf.h |1 + kernel/bpf/verifier.c| 1061 +- 3 files changed, 1108 insertions(+), 1 deletion

[PATCH v5 net-next 09/29] bpf: handle pseudo BPF_CALL insn

2014-08-24 Thread Alexei Starovoitov
with in-kernel function pointer. eBPF interpreter just calls the function. In-kernel eBPF users continue to use generic BPF_CALL. Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- kernel/bpf/syscall.c | 37 + 1 file changed, 37 insertions(+) diff

[PATCH v5 net-next 12/29] bpf: handle pseudo BPF_LD_IMM64 insn

2014-08-24 Thread Alexei Starovoitov
() calls. If program passes verifier, convert pseudo BPF_LD_IMM64 into generic by dropping BPF_PSEUDO_MAP_FD flag. Note that eBPF interpreter is generic and knows nothing about pseudo insns. Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- include/uapi/linux/bpf.h |6 ++ kernel/bpf

[PATCH v5 net-next 10/29] bpf: verifier (add docs)

2014-08-24 Thread Alexei Starovoitov
stack access - misaligned stack access - out of range stack access - invalid calling convention More details in Documentation/networking/filter.txt Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- Documentation/networking/filter.txt | 230 +++ include/linux

[PATCH v5 net-next 05/29] bpf: enable bpf syscall on x64 and i386

2014-08-24 Thread Alexei Starovoitov
done as separate commit to ease conflict resolution Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- arch/x86/syscalls/syscall_32.tbl |1 + arch/x86/syscalls/syscall_64.tbl |1 + include/linux/syscalls.h |3 ++- include/uapi/asm-generic/unistd.h |4 +++- kernel

[PATCH v5 net-next 04/29] bpf: introduce syscall(BPF, ...) and BPF maps

2014-08-24 Thread Alexei Starovoitov
-by: Alexei Starovoitov a...@plumgrid.com --- Documentation/networking/filter.txt | 71 include/linux/bpf.h | 42 ++ include/uapi/linux/bpf.h| 24 ++ kernel/bpf/Makefile |2 +- kernel/bpf/syscall.c| 156

[PATCH v5 net-next 07/29] bpf: add hashtable type of BPF maps

2014-08-24 Thread Alexei Starovoitov
add new map type: BPF_MAP_TYPE_HASH and its simple (not auto resizeable) hash table implementation Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- include/uapi/linux/bpf.h |1 + kernel/bpf/Makefile |2 +- kernel/bpf/hashtab.c | 372

[PATCH v5 net-next 08/29] bpf: expand BPF syscall with program load/unload

2014-08-24 Thread Alexei Starovoitov
of eBPF instructions LICENSE - must be GPL compatible to call helper functions marked gpl_only - unload eBPF program close(fd) User space example of syscall(__NR_bpf, BPF_PROG_LOAD, prog_type, ...) follows in later patches Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- include/linux

[PATCH v5 net-next 06/29] bpf: add lookup/update/delete/iterate methods to BPF maps

2014-08-24 Thread Alexei Starovoitov
) returns zero or negative error - find and delete element by key in a given map err = bpf_map_delete_elem(int fd, void *key) - iterate map elements (based on input key return next_key) err = bpf_map_get_next_key(int fd, void *key, void *next_key) - close(fd) deletes the map Signed-off-by: Alexei

[PATCH v5 net-next 02/29] net: filter: add load 64-bit immediate eBPF instruction

2014-08-24 Thread Alexei Starovoitov
to check validity of the programs. Later LLVM compiler is using this insn as generic load of 64-bit immediate constant and as a load of map pointer with relocation. Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- Documentation/networking/filter.txt |8 +++- arch/x86/net

[PATCH v5 net-next 01/29] bpf: x86: add missing 'shift by register' instructions to x64 eBPF JIT

2014-08-24 Thread Alexei Starovoitov
'shift by register' operations are supported by eBPF interpreter, but were accidently left out of x64 JIT compiler. Fix it and add a testcase. Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- arch/x86/net/bpf_jit_comp.c | 42 ++ lib/test_bpf.c

Re: [PATCH v5 net-next 06/29] bpf: add lookup/update/delete/iterate methods to BPF maps

2014-08-25 Thread Alexei Starovoitov
On Mon, Aug 25, 2014 at 2:33 PM, Cong Wang cw...@twopensource.com wrote: On Sun, Aug 24, 2014 at 1:21 PM, Alexei Starovoitov a...@plumgrid.com wrote: 'maps' is a generic storage of different types for sharing data between kernel and userspace. The maps are accessed from user space via BPF

[PATCH v6 net-next 0/6] introduce BPF syscall

2014-08-25 Thread Alexei Starovoitov
readability - rebased V5 thread: https://lkml.org/lkml/2014/8/24/107 All patches: git://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf master Alexei Starovoitov (6): net: filter: add load 64-bit immediate eBPF instruction net: filter: split filter.h and expose eBPF to user space bpf: introduce

[PATCH v6 net-next 1/6] net: filter: add load 64-bit immediate eBPF instruction

2014-08-25 Thread Alexei Starovoitov
to check validity of the programs. Later LLVM compiler is using this insn as generic load of 64-bit immediate constant and as a load of map pointer with relocation. Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- Documentation/networking/filter.txt |8 +++- arch/x86/net

[PATCH v6 net-next 5/6] bpf: add lookup/update/delete/iterate methods to BPF maps

2014-08-25 Thread Alexei Starovoitov
) returns zero or negative error - find and delete element by key in a given map err = bpf_map_delete_elem(int fd, void *key) - iterate map elements (based on input key return next_key) err = bpf_map_get_next_key(int fd, void *key, void *next_key) - close(fd) deletes the map Signed-off-by: Alexei

[PATCH v6 net-next 6/6] bpf: add hashtable type of BPF maps

2014-08-25 Thread Alexei Starovoitov
multiple times from eBPF program which itself is triggered by high volume of events - in the future JIT compiler may recognize lookup() call and optimize it further, since key_size is constant for life of eBPF program Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- Note, lib/rhashtable.c

[PATCH v6 net-next 3/6] bpf: introduce syscall(BPF, ...) and BPF maps

2014-08-25 Thread Alexei Starovoitov
-by: Alexei Starovoitov a...@plumgrid.com --- Documentation/networking/filter.txt | 71 include/linux/bpf.h | 42 ++ include/uapi/linux/bpf.h| 24 ++ kernel/bpf/Makefile |2 +- kernel/bpf/syscall.c| 156

[PATCH v6 net-next 4/6] bpf: enable bpf syscall on x64 and i386

2014-08-25 Thread Alexei Starovoitov
done as separate commit to ease conflict resolution Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- arch/x86/syscalls/syscall_32.tbl |1 + arch/x86/syscalls/syscall_64.tbl |1 + include/linux/syscalls.h |3 ++- include/uapi/asm-generic/unistd.h |4 +++- kernel

[PATCH v6 net-next 2/6] net: filter: split filter.h and expose eBPF to user space

2014-08-25 Thread Alexei Starovoitov
cannot go into uapi/linux/filter.h, since the names may conflict with existing applications. Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- include/linux/filter.h| 312 +-- include/uapi/linux/Kbuild |1 + include/uapi/linux/bpf.h | 321

Re: [PATCH v6 net-next 1/6] net: filter: add load 64-bit immediate eBPF instruction

2014-08-25 Thread Alexei Starovoitov
On Mon, Aug 25, 2014 at 6:06 PM, David Miller da...@davemloft.net wrote: From: Alexei Starovoitov a...@plumgrid.com Date: Mon, 25 Aug 2014 18:00:53 -0700 add BPF_LD_IMM64 instruction to load 64-bit immediate value into a register. I think you need to rethink this. I understand that you

Re: [PATCH v6 net-next 4/6] bpf: enable bpf syscall on x64 and i386

2014-08-25 Thread Alexei Starovoitov
On Mon, Aug 25, 2014 at 6:07 PM, David Miller da...@davemloft.net wrote: From: Alexei Starovoitov a...@plumgrid.com Date: Mon, 25 Aug 2014 18:00:56 -0700 - +asmlinkage long sys_bpf(int cmd, unsigned long arg2, unsigned long arg3, + unsigned long arg4, unsigned long arg5

Re: [PATCH v6 net-next 1/6] net: filter: add load 64-bit immediate eBPF instruction

2014-08-25 Thread Alexei Starovoitov
On Mon, Aug 25, 2014 at 6:38 PM, Andy Lutomirski l...@amacapital.net wrote: On Mon, Aug 25, 2014 at 6:35 PM, Alexei Starovoitov a...@plumgrid.com wrote: On Mon, Aug 25, 2014 at 6:06 PM, David Miller da...@davemloft.net wrote: From: Alexei Starovoitov a...@plumgrid.com Date: Mon, 25 Aug 2014 18

Re: [PATCH v6 net-next 1/6] net: filter: add load 64-bit immediate eBPF instruction

2014-08-25 Thread Alexei Starovoitov
On Mon, Aug 25, 2014 at 6:54 PM, Andy Lutomirski l...@amacapital.net wrote: On Mon, Aug 25, 2014 at 6:53 PM, Alexei Starovoitov a...@plumgrid.com wrote: On Mon, Aug 25, 2014 at 6:38 PM, Andy Lutomirski l...@amacapital.net wrote: On Mon, Aug 25, 2014 at 6:35 PM, Alexei Starovoitov

Re: [PATCH v6 net-next 1/6] net: filter: add load 64-bit immediate eBPF instruction

2014-08-25 Thread Alexei Starovoitov
On Mon, Aug 25, 2014 at 6:06 PM, David Miller da...@davemloft.net wrote: Instead I would rather you look into a model like what the quake engine uses for it's VM. Thanks for the tip! I wasn't aware of quake vm. I've looked through several papers and slides. I'm surely missing something in what

Re: [PATCH v6 net-next 4/6] bpf: enable bpf syscall on x64 and i386

2014-08-25 Thread Alexei Starovoitov
On Mon, Aug 25, 2014 at 8:52 PM, Stephen Hemminger step...@networkplumber.org wrote: Per discussion at Kernel Summit. Every new syscall requires a manual page and test programs. We have had too many new syscalls that are DOA. There is verifier testsuite that is testing eBPF verifier from

Re: [PATCH v6 net-next 4/6] bpf: enable bpf syscall on x64 and i386

2014-08-26 Thread Alexei Starovoitov
On Tue, Aug 26, 2014 at 12:45 AM, Ingo Molnar mi...@kernel.org wrote: * Alexei Starovoitov a...@plumgrid.com wrote: On Mon, Aug 25, 2014 at 6:07 PM, David Miller da...@davemloft.net wrote: From: Alexei Starovoitov a...@plumgrid.com Date: Mon, 25 Aug 2014 18:00:56 -0700 - +asmlinkage

Re: [PATCH v6 net-next 4/6] bpf: enable bpf syscall on x64 and i386

2014-08-26 Thread Alexei Starovoitov
On Tue, Aug 26, 2014 at 1:02 AM, Ingo Molnar mi...@kernel.org wrote: That said, I think Alexei is referring to the examples et al from the bigger previous proposed patch set. I mean, if all the testing already exists, it should be part of an initial submission and such. That's what I did.

Re: Post-merge-window ping (Re: [PATCH v4 0/5] x86: two-phase syscall tracing and seccomp fastpath)

2014-08-26 Thread Alexei Starovoitov
On Tue, Aug 26, 2014 at 6:32 PM, Andy Lutomirski l...@amacapital.net wrote: On Mon, Jul 28, 2014 at 8:38 PM, Andy Lutomirski l...@amacapital.net wrote: This applies to: git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git seccomp-fastpath Gitweb:

[PATCH RFC v7 net-next 05/28] bpf: add lookup/update/delete/iterate methods to BPF maps

2014-08-26 Thread Alexei Starovoitov
on input key return next_key) err = bpf(BPF_MAP_GET_NEXT_KEY, union bpf_attr *attr, u32 size) using attr-map_fd, attr-key, attr-next_key - close(fd) deletes the map Signed-off-by: Alexei Starovoitov a...@plumgrid.com --- include/linux/bpf.h |8 ++ include/uapi/linux/bpf.h | 42

<    1   2   3   4   5   6   7   8   9   10   >