summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorQuentin Monnet <quentin@isovalent.com>2023-04-05 14:21:15 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-05-17 11:13:13 +0200
commit1ad26fcb66b32a762f7ac57f4c780a216c37901b (patch)
tree1f418ce4e6b52f1849dcd397937e8d4deb98974d /tools
parentfdd067ce935a17e5c3276754284fb966f758b8fa (diff)
downloadlinux-1ad26fcb66b32a762f7ac57f4c780a216c37901b.tar.gz
linux-1ad26fcb66b32a762f7ac57f4c780a216c37901b.tar.bz2
linux-1ad26fcb66b32a762f7ac57f4c780a216c37901b.zip
bpftool: Fix bug for long instructions in program CFG dumps
[ Upstream commit 67cf52cdb6c8fa6365d29106555dacf95c9fd374 ] When dumping the control flow graphs for programs using the 16-byte long load instruction, we need to skip the second part of this instruction when looking for the next instruction to process. Otherwise, we end up printing "BUG_ld_00" from the kernel disassembler in the CFG. Fixes: efcef17a6d65 ("tools: bpftool: generate .dot graph from CFG information") Signed-off-by: Quentin Monnet <quentin@isovalent.com> Link: https://lore.kernel.org/r/20230405132120.59886-3-quentin@isovalent.com Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/bpf/bpftool/xlated_dumper.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/tools/bpf/bpftool/xlated_dumper.c b/tools/bpf/bpftool/xlated_dumper.c
index 3284759df98a..7f49347bf5aa 100644
--- a/tools/bpf/bpftool/xlated_dumper.c
+++ b/tools/bpf/bpftool/xlated_dumper.c
@@ -336,8 +336,15 @@ void dump_xlated_for_graph(struct dump_data *dd, void *buf_start, void *buf_end,
struct bpf_insn *insn_start = buf_start;
struct bpf_insn *insn_end = buf_end;
struct bpf_insn *cur = insn_start;
+ bool double_insn = false;
for (; cur <= insn_end; cur++) {
+ if (double_insn) {
+ double_insn = false;
+ continue;
+ }
+ double_insn = cur->code == (BPF_LD | BPF_IMM | BPF_DW);
+
printf("% 4d: ", (int)(cur - insn_start + start_idx));
print_bpf_insn(&cbs, cur, true);
if (cur != insn_end)