> powerpc32/bpf: mark all argument registers seen in function calls
TL;DR: Commit message only: the first Fixes: tag (51c66ad849a7) looks wrong,
since the register remapping bug came from 40272035e1d0; should the tag be
replaced?
> powerpc32/bpf: mark all argument registers seen in function calls
>
> The JIT code tracks which registers are used and remaps based on that,
> but currently does not account for the fact that function calls implicitly
> use registers because the called function will treat them as arguments.
>
> Therefore, if a function merely passes through one of its arguments
> to another function call, it will incorrectly be considered unused and may
> be overwritten with another register's contents.
>
> In practice, this is unlikely to affect main programs as they only get
> one argument (the context, which they are very likely to touch somehow
> in addition to passing it on), so they'll have to touch other registers
> if they want to pass them as arguments. Subprograms, however, are much
> likelier to hit this.
>
> Similarly, tail calls pass R1 to the callee, so mark it used as well.
>
> Fixes: 51c66ad849a7 ("powerpc/bpf: Implement extended BPF on PPC32")
> Fixes: a8936569a07b ("powerpc/bpf: Always reallocate BPF_REG_5, BPF_REG_AX
> and TMP_REG when possible")
> Signed-off-by: Lukas Stockner <[email protected]>
Is the first Fixes: tag pointing at the right commit?
51c66ad849a7 ("powerpc/bpf: Implement extended BPF on PPC32") used a fixed
BPF-to-PPC register mapping with no register reallocation, so an unseen
argument register could not be overwritten by a remapped register.
The remapping that causes this problem, including the tail call case where
SEEN_FUNC is not set and the full reallocation applies, was introduced by:
Fixes: 40272035e1d0 ("powerpc/bpf: Reallocate BPF registers to volatile
registers when possible on PPC32")
The a8936569a07b tag looks correct, since it enabled reallocation of
BPF_REG_5, BPF_REG_AX and TMP_REG even when SEEN_FUNC is set. Should the
51c66ad849a7 tag be replaced with 40272035e1d0?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/46701268444