Merge branch 'bpf-various-improvements'
Jakub Kicinski says: ==================== This series combines a number of random improvements ranging from libbpf to nfp driver. NFP patches make better use of the verifier log. There is a requested adjustment to the map offload code, and a warning fix for a W=1 build to the disassembler. Quentin also fixes the libbpf program type detection, while Jiong allows the use of libbfd compiled from source. ==================== Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
commit
f2f742f425
@ -2907,6 +2907,11 @@ void nfp_bpf_jit_prepare(struct nfp_prog *nfp_prog, unsigned int cnt)
|
||||
}
|
||||
}
|
||||
|
||||
bool nfp_bpf_supported_opcode(u8 code)
|
||||
{
|
||||
return !!instr_cb[code];
|
||||
}
|
||||
|
||||
void *nfp_bpf_relo_for_vnic(struct nfp_prog *nfp_prog, struct nfp_bpf_vnic *bv)
|
||||
{
|
||||
unsigned int i;
|
||||
|
@ -324,6 +324,7 @@ struct nfp_bpf_vnic {
|
||||
|
||||
void nfp_bpf_jit_prepare(struct nfp_prog *nfp_prog, unsigned int cnt);
|
||||
int nfp_bpf_jit(struct nfp_prog *prog);
|
||||
bool nfp_bpf_supported_opcode(u8 code);
|
||||
|
||||
extern const struct bpf_prog_offload_ops nfp_bpf_analyzer_ops;
|
||||
|
||||
|
@ -132,22 +132,24 @@ nfp_bpf_check_call(struct nfp_prog *nfp_prog, struct bpf_verifier_env *env,
|
||||
|
||||
case BPF_FUNC_map_lookup_elem:
|
||||
if (!bpf->helpers.map_lookup) {
|
||||
pr_info("map_lookup: not supported by FW\n");
|
||||
pr_vlog(env, "map_lookup: not supported by FW\n");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
if (reg2->type != PTR_TO_STACK) {
|
||||
pr_info("map_lookup: unsupported key ptr type %d\n",
|
||||
pr_vlog(env,
|
||||
"map_lookup: unsupported key ptr type %d\n",
|
||||
reg2->type);
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
if (!tnum_is_const(reg2->var_off)) {
|
||||
pr_info("map_lookup: variable key pointer\n");
|
||||
pr_vlog(env, "map_lookup: variable key pointer\n");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
off = reg2->var_off.value + reg2->off;
|
||||
if (-off % 4) {
|
||||
pr_info("map_lookup: unaligned stack pointer %lld\n",
|
||||
pr_vlog(env,
|
||||
"map_lookup: unaligned stack pointer %lld\n",
|
||||
-off);
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
@ -160,7 +162,7 @@ nfp_bpf_check_call(struct nfp_prog *nfp_prog, struct bpf_verifier_env *env,
|
||||
meta->arg2_var_off |= off != old_off;
|
||||
|
||||
if (meta->arg1.map_ptr != reg1->map_ptr) {
|
||||
pr_info("map_lookup: called for different map\n");
|
||||
pr_vlog(env, "map_lookup: called for different map\n");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
break;
|
||||
@ -263,7 +265,7 @@ nfp_bpf_check_ptr(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta,
|
||||
|
||||
if (reg->type == PTR_TO_MAP_VALUE) {
|
||||
if (is_mbpf_store(meta)) {
|
||||
pr_info("map writes not supported\n");
|
||||
pr_vlog(env, "map writes not supported\n");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
}
|
||||
@ -288,6 +290,12 @@ nfp_verify_insn(struct bpf_verifier_env *env, int insn_idx, int prev_insn_idx)
|
||||
meta = nfp_bpf_goto_meta(nfp_prog, meta, insn_idx, env->prog->len);
|
||||
nfp_prog->verifier_meta = meta;
|
||||
|
||||
if (!nfp_bpf_supported_opcode(meta->insn.code)) {
|
||||
pr_vlog(env, "instruction %#02x not supported\n",
|
||||
meta->insn.code);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (meta->insn.src_reg >= MAX_BPF_REG ||
|
||||
meta->insn.dst_reg >= MAX_BPF_REG) {
|
||||
pr_vlog(env, "program uses extended registers - jit hardening?\n");
|
||||
|
@ -29,8 +29,8 @@ extern const char *const bpf_class_string[8];
|
||||
|
||||
const char *func_id_name(int id);
|
||||
|
||||
typedef void (*bpf_insn_print_t)(struct bpf_verifier_env *env,
|
||||
const char *, ...);
|
||||
typedef __printf(2, 3) void (*bpf_insn_print_t)(struct bpf_verifier_env *env,
|
||||
const char *, ...);
|
||||
typedef const char *(*bpf_insn_revmap_call_t)(void *private_data,
|
||||
const struct bpf_insn *insn);
|
||||
typedef const char *(*bpf_insn_print_imm_t)(void *private_data,
|
||||
|
@ -395,10 +395,8 @@ bool bpf_offload_dev_match(struct bpf_prog *prog, struct bpf_map *map)
|
||||
struct bpf_prog_offload *offload;
|
||||
bool ret;
|
||||
|
||||
if (!!bpf_prog_is_dev_bound(prog->aux) != !!bpf_map_is_dev_bound(map))
|
||||
if (!bpf_prog_is_dev_bound(prog->aux) || !bpf_map_is_dev_bound(map))
|
||||
return false;
|
||||
if (!bpf_prog_is_dev_bound(prog->aux))
|
||||
return true;
|
||||
|
||||
down_read(&bpf_devs_lock);
|
||||
offload = prog->aux->offload;
|
||||
|
@ -39,7 +39,7 @@ CC = gcc
|
||||
|
||||
CFLAGS += -O2
|
||||
CFLAGS += -W -Wall -Wextra -Wno-unused-parameter -Wshadow
|
||||
CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/tools/include/uapi -I$(srctree)/tools/include -I$(srctree)/tools/lib/bpf -I$(srctree)/kernel/bpf/
|
||||
CFLAGS += -DPACKAGE='"bpftool"' -D__EXPORTED_HEADERS__ -I$(srctree)/tools/include/uapi -I$(srctree)/tools/include -I$(srctree)/tools/lib/bpf -I$(srctree)/kernel/bpf/
|
||||
CFLAGS += -DBPFTOOL_VERSION='"$(BPFTOOL_VERSION)"'
|
||||
LIBS = -lelf -lbfd -lopcodes $(LIBBPF)
|
||||
|
||||
|
@ -190,7 +190,7 @@ $(OUTPUT)test-libbfd.bin:
|
||||
$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
|
||||
|
||||
$(OUTPUT)test-disassembler-four-args.bin:
|
||||
$(BUILD) -lbfd -lopcodes
|
||||
$(BUILD) -DPACKAGE='"perf"' -lbfd -lopcodes
|
||||
|
||||
$(OUTPUT)test-liberty.bin:
|
||||
$(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty
|
||||
|
@ -1803,7 +1803,7 @@ BPF_PROG_TYPE_FNS(tracepoint, BPF_PROG_TYPE_TRACEPOINT);
|
||||
BPF_PROG_TYPE_FNS(xdp, BPF_PROG_TYPE_XDP);
|
||||
BPF_PROG_TYPE_FNS(perf_event, BPF_PROG_TYPE_PERF_EVENT);
|
||||
|
||||
#define BPF_PROG_SEC(string, type) { string, sizeof(string), type }
|
||||
#define BPF_PROG_SEC(string, type) { string, sizeof(string) - 1, type }
|
||||
static const struct {
|
||||
const char *sec;
|
||||
size_t len;
|
||||
|
Loading…
Reference in New Issue
Block a user