linux-stable/arch/riscv
Puranjay Mohan 81e1d481e1 riscv, bpf: make some atomic operations fully ordered
[ Upstream commit 20a759df3b ]

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: dd642ccb45 ("riscv, bpf: Implement more atomic operations for RV64")
Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
Reviewed-by: Pu Lehui <pulehui@huawei.com>
Link: https://lore.kernel.org/r/20240505201633.123115-1-puranjay@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-05-30 09:49:27 +02:00
..
boot riscv: dts: starfive: jh7100: fix root clock names 2024-03-26 18:16:52 -04:00
configs Merge patch series "RISC-V SBI debug console extension support" 2024-01-11 07:36:27 -08:00
errata riscv: T-Head: Test availability bit before enabling MAE errata 2024-05-30 09:48:48 +02:00
include riscv: thead: Rename T-Head PBMT to MAE 2024-05-30 09:48:48 +02:00
kernel riscv: process: Fix kernel gp leakage 2024-04-10 16:38:20 +02:00
kvm RISC-V: KVM: Fix APLIC in_clrip[x] read emulation 2024-04-10 16:38:00 +02:00
lib work around gcc bugs with 'asm goto' with outputs 2024-02-09 15:57:48 -08:00
mm riscv: Fix loading 64-bit NOMMU kernels past the start of RAM 2024-05-02 16:35:33 +02:00
net riscv, bpf: make some atomic operations fully ordered 2024-05-30 09:49:27 +02:00
purgatory riscv: Use SYM_*() assembly macros instead of deprecated ones 2023-11-06 09:42:47 -08:00
tools riscv: Check relocations at compile time 2023-04-19 07:46:32 -07:00
Kbuild kexec: rename ARCH_HAS_KEXEC_PURGATORY 2023-08-18 10:18:54 -07:00
Kconfig RISC-V: Drop invalid test from CONFIG_AS_HAS_OPTION_ARCH 2024-02-16 16:07:08 -08:00
Kconfig.debug riscv: Add tests for riscv module loading 2023-11-07 14:59:32 -08:00
Kconfig.errata riscv: thead: Rename T-Head PBMT to MAE 2024-05-30 09:48:48 +02:00
Kconfig.socs SoC driver updates for 6.7 2023-11-01 14:46:51 -10:00
Makefile riscv: add dependency among Image(.gz), loader(.bin), and vmlinuz.efi 2024-01-17 18:18:20 -08:00
Makefile.postlink kbuild: remove ARCH_POSTLINK from module builds 2023-10-28 21:10:08 +09:00