]> git.baikalelectronics.ru Git - kernel.git/commit
bpf, riscv: clear high 32 bits for ALU32 add/sub/neg/lsh/rsh/arsh
authorLuke Nelson <luke.r.nels@gmail.com>
Thu, 30 May 2019 22:29:22 +0000 (15:29 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 1 Jun 2019 00:08:53 +0000 (17:08 -0700)
commit1f3f0b9465baa21965fad9f69e9909a5b013ecb1
treebd39ab619e1c156b8a8b6701527ba6b472dc3748
parent523ed868baa9798a0587e685f3822df7e8012844
bpf, riscv: clear high 32 bits for ALU32 add/sub/neg/lsh/rsh/arsh

In BPF, 32-bit ALU operations should zero-extend their results into
the 64-bit registers.

The current BPF JIT on RISC-V emits incorrect instructions that perform
sign extension only (e.g., addw, subw) on 32-bit add, sub, lsh, rsh,
arsh, and neg. This behavior diverges from the interpreter and JITs
for other architectures.

This patch fixes the bugs by performing zero extension on the destination
register of 32-bit ALU operations.

Fixes: 0b82ef241623 ("bpf, riscv: add BPF JIT for RV64G")
Cc: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Luke Nelson <luke.r.nels@gmail.com>
Acked-by: Song Liu <songliubraving@fb.com>
Acked-by: Björn Töpel <bjorn.topel@gmail.com>
Reviewed-by: Palmer Dabbelt <palmer@sifive.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
arch/riscv/net/bpf_jit_comp.c