bpf: remove stubs for cBPF from arch code
authorDaniel Borkmann <daniel@iogearbox.net>
Thu, 16 Feb 2017 21:24:49 +0000 (22:24 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 17 Feb 2017 18:40:04 +0000 (13:40 -0500)
Remove the dummy bpf_jit_compile() stubs for eBPF JITs and make
that a single __weak function in the core that can be overridden
similarly to the eBPF one. Also remove stale pr_err() mentions
of bpf_jit_compile.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
arch/arm64/net/bpf_jit_comp.c
arch/powerpc/net/bpf_jit_comp64.c
arch/s390/net/bpf_jit_comp.c
arch/x86/net/bpf_jit_comp.c
include/linux/filter.h
kernel/bpf/core.c

index b2fc97a2c56c80fe633777bbb18322c980949953..c444408d5a8c780fc10a15ba64ae10333500b53c 100644 (file)
@@ -813,11 +813,6 @@ static inline void bpf_flush_icache(void *start, void *end)
        flush_icache_range((unsigned long)start, (unsigned long)end);
 }
 
-void bpf_jit_compile(struct bpf_prog *prog)
-{
-       /* Nothing to do here. We support Internal BPF. */
-}
-
 struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
 {
        struct bpf_prog *tmp, *orig_prog = prog;
index 73a5cf18fd84f3553f564456f0e482977afdfbe2..f9ebd02260dae7b561031fdd790ed2a59c71212f 100644 (file)
@@ -961,8 +961,6 @@ common_load:
        return 0;
 }
 
-void bpf_jit_compile(struct bpf_prog *fp) { }
-
 struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
 {
        u32 proglen;
index 167b31b186c1313c2cea094ee3b972233d61a608..6454efd22e6339f295d14315166793bc30f99e68 100644 (file)
@@ -1262,14 +1262,6 @@ static int bpf_jit_prog(struct bpf_jit *jit, struct bpf_prog *fp)
        return 0;
 }
 
-/*
- * Classic BPF function stub. BPF programs will be converted into
- * eBPF and then bpf_int_jit_compile() will be called.
- */
-void bpf_jit_compile(struct bpf_prog *fp)
-{
-}
-
 /*
  * Compile eBPF program "fp"
  */
index bb660e53cbd6ba51eace412622fdd7342939ddc1..26123d0ae13a81e8a07fef0f615dd7ecb9986664 100644 (file)
@@ -1067,13 +1067,13 @@ common_load:
 
                ilen = prog - temp;
                if (ilen > BPF_MAX_INSN_SIZE) {
-                       pr_err("bpf_jit_compile fatal insn size error\n");
+                       pr_err("bpf_jit: fatal insn size error\n");
                        return -EFAULT;
                }
 
                if (image) {
                        if (unlikely(proglen + ilen > oldproglen)) {
-                               pr_err("bpf_jit_compile fatal error\n");
+                               pr_err("bpf_jit: fatal error\n");
                                return -EFAULT;
                        }
                        memcpy(image + proglen, temp, ilen);
@@ -1085,10 +1085,6 @@ common_load:
        return proglen;
 }
 
-void bpf_jit_compile(struct bpf_prog *prog)
-{
-}
-
 struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
 {
        struct bpf_binary_header *header = NULL;
index e4eb2546339afbf2764f5ba335e1e66947fc5af3..c7a70e0cc3a0a2cfa819d2beee6ea47bbb798784 100644 (file)
@@ -607,6 +607,7 @@ void sk_filter_uncharge(struct sock *sk, struct sk_filter *fp);
 u64 __bpf_call_base(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5);
 
 struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog);
+void bpf_jit_compile(struct bpf_prog *prog);
 bool bpf_helper_changes_pkt_data(void *func);
 
 struct bpf_prog *bpf_patch_insn_single(struct bpf_prog *prog, u32 off,
@@ -625,7 +626,6 @@ bpf_jit_binary_alloc(unsigned int proglen, u8 **image_ptr,
                     bpf_jit_fill_hole_t bpf_fill_ill_insns);
 void bpf_jit_binary_free(struct bpf_binary_header *hdr);
 
-void bpf_jit_compile(struct bpf_prog *fp);
 void bpf_jit_free(struct bpf_prog *fp);
 
 struct bpf_prog *bpf_jit_blind_constants(struct bpf_prog *fp);
@@ -669,10 +669,6 @@ static inline bool bpf_jit_blinding_enabled(void)
        return true;
 }
 #else
-static inline void bpf_jit_compile(struct bpf_prog *fp)
-{
-}
-
 static inline void bpf_jit_free(struct bpf_prog *fp)
 {
        bpf_prog_unlock_free(fp);
index fddd76b1b6270a0915dc90d71c400f4652001e3c..2831ba1e71c1116482e1342264f5bbef993629fa 100644 (file)
@@ -1154,12 +1154,22 @@ const struct bpf_func_proto bpf_tail_call_proto = {
        .arg3_type      = ARG_ANYTHING,
 };
 
-/* For classic BPF JITs that don't implement bpf_int_jit_compile(). */
+/* Stub for JITs that only support cBPF. eBPF programs are interpreted.
+ * It is encouraged to implement bpf_int_jit_compile() instead, so that
+ * eBPF and implicitly also cBPF can get JITed!
+ */
 struct bpf_prog * __weak bpf_int_jit_compile(struct bpf_prog *prog)
 {
        return prog;
 }
 
+/* Stub for JITs that support eBPF. All cBPF code gets transformed into
+ * eBPF by the kernel and is later compiled by bpf_int_jit_compile().
+ */
+void __weak bpf_jit_compile(struct bpf_prog *prog)
+{
+}
+
 bool __weak bpf_helper_changes_pkt_data(void *func)
 {
        return false;