]> www.infradead.org Git - users/jedix/linux-maple.git/commit
bpf, riscv64: Skip redundant zext instruction after load-acquire
authorPeilin Ye <yepeilin@google.com>
Wed, 7 May 2025 03:43:07 +0000 (03:43 +0000)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 9 May 2025 17:05:27 +0000 (10:05 -0700)
commitdb7a3822b5f474b09db0a776e91f17c8b7d32137
tree41e7cbb678dbbe9b4d79a18d2ad53cfc11fe4813
parent8afd3170d5116385740aef8ab77d10b83f9b8e60
bpf, riscv64: Skip redundant zext instruction after load-acquire

Currently, the verifier inserts a zext instruction right after every 8-,
16- or 32-bit load-acquire, which is already zero-extending.  Skip such
redundant zext instructions.

While we are here, update that already-obsolete comment about "skip the
next instruction" in build_body().  Also change emit_atomic_rmw()'s
parameters to keep it consistent with emit_atomic_ld_st().

Note that checking 'insn[1]' relies on 'insn' not being the last
instruction, which should have been guaranteed by the verifier; we
already use 'insn[1]' elsewhere in the file for similar purposes.
Additionally, we don't check if 'insn[1]' is actually a zext for our
load-acquire's dst_reg, or some other registers - in other words, here
we are relying on the verifier to always insert a redundant zext right
after a 8/16/32-bit load-acquire, for its dst_reg.

Acked-by: Björn Töpel <bjorn@kernel.org>
Reviewed-by: Pu Lehui <pulehui@huawei.com>
Tested-by: Björn Töpel <bjorn@rivosinc.com> # QEMU/RVA23
Signed-off-by: Peilin Ye <yepeilin@google.com>
Link: https://lore.kernel.org/r/10e90e0eab042f924d35ad0d1c1f7ca29f673152.1746588351.git.yepeilin@google.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
arch/riscv/net/bpf_jit_comp64.c
arch/riscv/net/bpf_jit_core.c