Re: [RFC bpf-next 1/2] bpf, mips: Factor register moves into helpers

Nicholas Dudar <[email protected]>
Newsgroups dev.linux.lists.sashiko-reviews,org.kernel.vger.bpf
Message-ID <CAJZwKkg08J_ZD4cTDX+h6Dz3-Rv7FoRpknb9e=_r+=4rTjxmTA@mail.gmail.com>
Thanks for the review.

> This is a pre-existing issue, but does this switch case in build_insn()
> silently miscompile BPF_MOVSX (move with sign extension) instructions?

Yes.  Patch 1/2 is a behavior-preserving helper extraction, so that
intermediate retains the existing behavior.

> Since you are refactoring the MOV handlers here, should emit_mov_r32() be
> updated to take insn->off and implement the proper sign extension logic?

Patch 2/2 does that for both emit_mov_r32() and emit_mov_r64().  It passes
insn->off to the move helpers.  They handle these verifier-valid widths:
8 and 16 bits for ALU32, and 8, 16, and 32 bits for ALU64.  An offset of
zero remains an ordinary move.  The verifier-inserted zero-extension move
stays on its separate path.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.