]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
riscv, bpf: Track both a0 (RISC-V ABI) and a5 (BPF) return values
authorBjörn Töpel <bjorn@rivosinc.com>
Wed, 4 Oct 2023 12:07:06 +0000 (14:07 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 9 Oct 2023 13:21:25 +0000 (15:21 +0200)
commit7112cd26e606c7ba51f9cc5c1905f06039f6f379
tree53241bbd7ef75cbe08f16d114043797a0e895311
parent2f1b0d3d733169eb11680bfa97c266ae5e757148
riscv, bpf: Track both a0 (RISC-V ABI) and a5 (BPF) return values

The RISC-V BPF uses a5 for BPF return values, which are zero-extended,
whereas the RISC-V ABI uses a0 which is sign-extended. In other words,
a5 and a0 can differ, and are used in different context.

The BPF trampoline are used for both BPF programs, and regular kernel
functions.

Make sure that the RISC-V BPF trampoline saves, and restores both a0
and a5.

Fixes: 49b5e77ae3e2 ("riscv, bpf: Add bpf trampoline support for RV64")
Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20231004120706.52848-3-bjorn@kernel.org
arch/riscv/net/bpf_jit_comp64.c