Re: [PATCH bpf-next v3 1/6] bpf: Derive the atomic load register in one place
Eduard Zingerman <[email protected]>
| Newsgroups | org.kernel.vger.bpf |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 2026-08-11 at 15:15 +0200, Daniel Borkmann wrote: > check_atomic_rmw() open codes the mapping from a BPF_ATOMIC to the register > it reads the old value into, the BPF_STX case of insn_def_regno() open codes > the very same mapping a second time, the const folding and the liveness > transfer functions a third and a fourth time, and BPF JITs need it as well > to know which register a faulting BPF_PROBE_ATOMIC has to clear. > > Add a small helper so that all of them can share it. No functional change. > The BPF_LOAD_ACQ case is there for the JITs, which do walk all instruction > classes. const_reg_xfer() loses its explicit BPF_ATOMIC mode test since the > helper checks class and mode itself; the BPF_PROBE_ATOMIC it additionally > accepts cannot be seen there as it is only set from bpf_do_misc_fixups(), > that is, after const folding has run. arg_track_xfer() keeps its mode test > since that also guards the stack clearing next to it. > > Signed-off-by: Daniel Borkmann <[email protected]> > --- > v2 -> v3: > - Also use the helper for const_fold and liveness (bpf ci) > - Drop the return value comment in verifier since the helper > comment already covers it (Jakub) > v1 -> v2: > - also convert insn_def_regno (Eduard, sashiko) > > include/linux/filter.h | 24 ++++++++++++++++++++++++ > kernel/bpf/const_fold.c | 11 +++-------- > kernel/bpf/fixups.c | 11 +---------- > kernel/bpf/liveness.c | 9 +++------ > kernel/bpf/verifier.c | 13 ++----------- > 5 files changed, 33 insertions(+), 35 deletions(-) Acked-by: Eduard Zingerman <[email protected]> ...