]> Git Repo - linux.git/commit
riscv, bpf: make some atomic operations fully ordered
authorPuranjay Mohan <[email protected]>
Sun, 5 May 2024 20:16:33 +0000 (20:16 +0000)
committerAlexei Starovoitov <[email protected]>
Mon, 13 May 2024 00:00:06 +0000 (17:00 -0700)
commit20a759df3bba35bf5c3ddec0c02ad69b603b584c
tree7006fd829bd640badfba46ab78baa7c03ff5f4d8
parent80c5a07ae673a740ef7ef0fe1ab588075a25ce8d
riscv, bpf: make some atomic operations fully ordered

The BPF atomic operations with the BPF_FETCH modifier along with
BPF_XCHG and BPF_CMPXCHG are fully ordered but the RISC-V JIT implements
all atomic operations except BPF_CMPXCHG with relaxed ordering.

Section 8.1 of the "The RISC-V Instruction Set Manual Volume I:
Unprivileged ISA" [1], titled, "Specifying Ordering of Atomic
Instructions" says:

| To provide more efficient support for release consistency [5], each
| atomic instruction has two bits, aq and rl, used to specify additional
| memory ordering constraints as viewed by other RISC-V harts.

and

| If only the aq bit is set, the atomic memory operation is treated as
| an acquire access.
| If only the rl bit is set, the atomic memory operation is treated as a
| release access.
|
| If both the aq and rl bits are set, the atomic memory operation is
| sequentially consistent.

Fix this by setting both aq and rl bits as 1 for operations with
BPF_FETCH and BPF_XCHG.

[1] https://riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf

Fixes: dd642ccb45ec ("riscv, bpf: Implement more atomic operations for RV64")
Signed-off-by: Puranjay Mohan <[email protected]>
Reviewed-by: Pu Lehui <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>
arch/riscv/net/bpf_jit_comp64.c
This page took 0.053834 seconds and 4 git commands to generate.