bpf: jmp_offset() and verbose_insn() utility functions
authorEduard Zingerman <eddyz87@gmail.com>
Tue, 4 Mar 2025 19:50:20 +0000 (11:50 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 15 Mar 2025 18:48:29 +0000 (11:48 -0700)
commit80ca3f1d77bb82fe84fad55a013832e03a4f5087
treea53664c642f43d5ab30c75b456b35943bf6cbb6b
parent5bde5750135615971ea52b936c50fe1a1290ba8f
bpf: jmp_offset() and verbose_insn() utility functions

Extract two utility functions:
- One BPF jump instruction uses .imm field to encode jump offset,
  while the rest use .off. Encapsulate this detail as jmp_offset()
  function.
- Avoid duplicating instruction printing callback definitions by
  defining a verbose_insn() function, which disassembles an
  instruction into the verifier log while hiding this detail.

These functions will be used in the next patch.

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20250304195024.2478889-2-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c