aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Borkmann <daniel@iogearbox.net>2017-02-16 16:24:49 -0500
committerDavid S. Miller <davem@davemloft.net>2017-02-17 13:40:04 -0500
commit9383191da4e40360a5d880fbe6bb03911c61621b (patch)
treec92770092ea2f7d4d3fdc207c80b8266547572f6
parentc78f8bdfa11fcceb9723c61212e4bd8f76c87f9e (diff)
bpf: remove stubs for cBPF from arch code
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>
-rw-r--r--arch/arm64/net/bpf_jit_comp.c5
-rw-r--r--arch/powerpc/net/bpf_jit_comp64.c2
-rw-r--r--arch/s390/net/bpf_jit_comp.c8
-rw-r--r--arch/x86/net/bpf_jit_comp.c8
-rw-r--r--include/linux/filter.h6
-rw-r--r--kernel/bpf/core.c12
6 files changed, 14 insertions, 27 deletions
diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index b2fc97a2c56c..c444408d5a8c 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -813,11 +813,6 @@ static inline void bpf_flush_icache(void *start, void *end)
813 flush_icache_range((unsigned long)start, (unsigned long)end); 813 flush_icache_range((unsigned long)start, (unsigned long)end);
814} 814}
815 815
816void bpf_jit_compile(struct bpf_prog *prog)
817{
818 /* Nothing to do here. We support Internal BPF. */
819}
820
821struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) 816struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
822{ 817{
823 struct bpf_prog *tmp, *orig_prog = prog; 818 struct bpf_prog *tmp, *orig_prog = prog;
diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c
index 73a5cf18fd84..f9ebd02260da 100644
--- a/arch/powerpc/net/bpf_jit_comp64.c
+++ b/arch/powerpc/net/bpf_jit_comp64.c
@@ -961,8 +961,6 @@ common_load:
961 return 0; 961 return 0;
962} 962}
963 963
964void bpf_jit_compile(struct bpf_prog *fp) { }
965
966struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp) 964struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
967{ 965{
968 u32 proglen; 966 u32 proglen;
diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
index 167b31b186c1..6454efd22e63 100644
--- a/arch/s390/net/bpf_jit_comp.c
+++ b/arch/s390/net/bpf_jit_comp.c
@@ -1263,14 +1263,6 @@ static int bpf_jit_prog(struct bpf_jit *jit, struct bpf_prog *fp)
1263} 1263}
1264 1264
1265/* 1265/*
1266 * Classic BPF function stub. BPF programs will be converted into
1267 * eBPF and then bpf_int_jit_compile() will be called.
1268 */
1269void bpf_jit_compile(struct bpf_prog *fp)
1270{
1271}
1272
1273/*
1274 * Compile eBPF program "fp" 1266 * Compile eBPF program "fp"
1275 */ 1267 */
1276struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp) 1268struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index bb660e53cbd6..26123d0ae13a 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -1067,13 +1067,13 @@ common_load:
1067 1067
1068 ilen = prog - temp; 1068 ilen = prog - temp;
1069 if (ilen > BPF_MAX_INSN_SIZE) { 1069 if (ilen > BPF_MAX_INSN_SIZE) {
1070 pr_err("bpf_jit_compile fatal insn size error\n"); 1070 pr_err("bpf_jit: fatal insn size error\n");
1071 return -EFAULT; 1071 return -EFAULT;
1072 } 1072 }
1073 1073
1074 if (image) { 1074 if (image) {
1075 if (unlikely(proglen + ilen > oldproglen)) { 1075 if (unlikely(proglen + ilen > oldproglen)) {
1076 pr_err("bpf_jit_compile fatal error\n"); 1076 pr_err("bpf_jit: fatal error\n");
1077 return -EFAULT; 1077 return -EFAULT;
1078 } 1078 }
1079 memcpy(image + proglen, temp, ilen); 1079 memcpy(image + proglen, temp, ilen);
@@ -1085,10 +1085,6 @@ common_load:
1085 return proglen; 1085 return proglen;
1086} 1086}
1087 1087
1088void bpf_jit_compile(struct bpf_prog *prog)
1089{
1090}
1091
1092struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) 1088struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
1093{ 1089{
1094 struct bpf_binary_header *header = NULL; 1090 struct bpf_binary_header *header = NULL;
diff --git a/include/linux/filter.h b/include/linux/filter.h
index e4eb2546339a..c7a70e0cc3a0 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -607,6 +607,7 @@ void sk_filter_uncharge(struct sock *sk, struct sk_filter *fp);
607u64 __bpf_call_base(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5); 607u64 __bpf_call_base(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5);
608 608
609struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog); 609struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog);
610void bpf_jit_compile(struct bpf_prog *prog);
610bool bpf_helper_changes_pkt_data(void *func); 611bool bpf_helper_changes_pkt_data(void *func);
611 612
612struct bpf_prog *bpf_patch_insn_single(struct bpf_prog *prog, u32 off, 613struct 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,
625 bpf_jit_fill_hole_t bpf_fill_ill_insns); 626 bpf_jit_fill_hole_t bpf_fill_ill_insns);
626void bpf_jit_binary_free(struct bpf_binary_header *hdr); 627void bpf_jit_binary_free(struct bpf_binary_header *hdr);
627 628
628void bpf_jit_compile(struct bpf_prog *fp);
629void bpf_jit_free(struct bpf_prog *fp); 629void bpf_jit_free(struct bpf_prog *fp);
630 630
631struct bpf_prog *bpf_jit_blind_constants(struct bpf_prog *fp); 631struct bpf_prog *bpf_jit_blind_constants(struct bpf_prog *fp);
@@ -669,10 +669,6 @@ static inline bool bpf_jit_blinding_enabled(void)
669 return true; 669 return true;
670} 670}
671#else 671#else
672static inline void bpf_jit_compile(struct bpf_prog *fp)
673{
674}
675
676static inline void bpf_jit_free(struct bpf_prog *fp) 672static inline void bpf_jit_free(struct bpf_prog *fp)
677{ 673{
678 bpf_prog_unlock_free(fp); 674 bpf_prog_unlock_free(fp);
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index fddd76b1b627..2831ba1e71c1 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -1154,12 +1154,22 @@ const struct bpf_func_proto bpf_tail_call_proto = {
1154 .arg3_type = ARG_ANYTHING, 1154 .arg3_type = ARG_ANYTHING,
1155}; 1155};
1156 1156
1157/* For classic BPF JITs that don't implement bpf_int_jit_compile(). */ 1157/* Stub for JITs that only support cBPF. eBPF programs are interpreted.
1158 * It is encouraged to implement bpf_int_jit_compile() instead, so that
1159 * eBPF and implicitly also cBPF can get JITed!
1160 */
1158struct bpf_prog * __weak bpf_int_jit_compile(struct bpf_prog *prog) 1161struct bpf_prog * __weak bpf_int_jit_compile(struct bpf_prog *prog)
1159{ 1162{
1160 return prog; 1163 return prog;
1161} 1164}
1162 1165
1166/* Stub for JITs that support eBPF. All cBPF code gets transformed into
1167 * eBPF by the kernel and is later compiled by bpf_int_jit_compile().
1168 */
1169void __weak bpf_jit_compile(struct bpf_prog *prog)
1170{
1171}
1172
1163bool __weak bpf_helper_changes_pkt_data(void *func) 1173bool __weak bpf_helper_changes_pkt_data(void *func)
1164{ 1174{
1165 return false; 1175 return false;