Skip to content

Commit

Permalink
tools: bpftool: teach cfg code about JMP32
Browse files Browse the repository at this point in the history
The cfg code need to be aware of the new JMP32 instruction class so it
could partition functions correctly.

Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Jiong Wang <jiong.wang@netronome.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
  • Loading branch information
Jiong Wang authored and Alexei Starovoitov committed Jan 26, 2019
1 parent 56cbd82 commit df791dc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tools/bpf/bpftool/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ static bool cfg_partition_funcs(struct cfg *cfg, struct bpf_insn *cur,
return false;
}

static bool is_jmp_insn(u8 code)
{
return BPF_CLASS(code) == BPF_JMP || BPF_CLASS(code) == BPF_JMP32;
}

static bool func_partition_bb_head(struct func_node *func)
{
struct bpf_insn *cur, *end;
Expand All @@ -170,7 +175,7 @@ static bool func_partition_bb_head(struct func_node *func)
return true;

for (; cur <= end; cur++) {
if (BPF_CLASS(cur->code) == BPF_JMP) {
if (is_jmp_insn(cur->code)) {
u8 opcode = BPF_OP(cur->code);

if (opcode == BPF_EXIT || opcode == BPF_CALL)
Expand Down Expand Up @@ -296,7 +301,7 @@ static bool func_add_bb_edges(struct func_node *func)
e->src = bb;

insn = bb->tail;
if (BPF_CLASS(insn->code) != BPF_JMP ||
if (!is_jmp_insn(insn->code) ||
BPF_OP(insn->code) == BPF_EXIT) {
e->dst = bb_next(bb);
e->flags |= EDGE_FLAG_FALLTHROUGH;
Expand Down

0 comments on commit df791dc

Please sign in to comment.