Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bpf, docs: Correct source of offset for program-local call

The offset to use when calculating the target of a program-local call is
in the instruction's imm field, not its offset field.

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Acked-by: David Vernet <void@manifault.com>
Link: https://lore.kernel.org/bpf/20230826053258.1860167-1-hawkinsw@obs.cr

authored by

Will Hawkins and committed by
Daniel Borkmann
2d71a90f 5439cfa7

+3 -3
+3 -3
Documentation/bpf/standardization/instruction-set.rst
··· 373 373 BPF_JSGT 0x6 any PC += offset if dst > src signed 374 374 BPF_JSGE 0x7 any PC += offset if dst >= src signed 375 375 BPF_CALL 0x8 0x0 call helper function by address see `Helper functions`_ 376 - BPF_CALL 0x8 0x1 call PC += offset see `Program-local functions`_ 376 + BPF_CALL 0x8 0x1 call PC += imm see `Program-local functions`_ 377 377 BPF_CALL 0x8 0x2 call helper function by BTF ID see `Helper functions`_ 378 378 BPF_EXIT 0x9 0x0 return BPF_JMP only 379 379 BPF_JLT 0xa any PC += offset if dst < src unsigned ··· 424 424 ~~~~~~~~~~~~~~~~~~~~~~~ 425 425 Program-local functions are functions exposed by the same BPF program as the 426 426 caller, and are referenced by offset from the call instruction, similar to 427 - ``BPF_JA``. A ``BPF_EXIT`` within the program-local function will return to 428 - the caller. 427 + ``BPF_JA``. The offset is encoded in the imm field of the call instruction. 428 + A ``BPF_EXIT`` within the program-local function will return to the caller. 429 429 430 430 Load and store instructions 431 431 ===========================