linux-stable/arch
Puranjay Mohan e2707bcf66 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:44:38 +02:00
..
alpha Kbuild updates for v6.9 2024-03-21 14:41:00 -07:00
arc ARC: [plat-hsdk]: Remove misplaced interrupt-cells property 2024-04-16 10:45:57 -07:00
arm ARM: configs: sunxi: Enable DRM_DW_HDMI 2024-05-30 09:44:06 +02:00
arm64 arm64: Remove unnecessary irqflags alternative.h include 2024-05-30 09:44:19 +02:00
csky - Sumanth Korikkar has taught s390 to allocate hotplug-time page frames 2024-03-14 17:43:30 -07:00
hexagon hexagon: vmlinux.lds.S: handle attributes section 2024-03-26 11:07:23 -07:00
loongarch LoongArch: Lately init pmu after smp is online 2024-04-25 22:17:52 +08:00
m68k m68k: Move ARCH_HAS_CPU_CACHE_ALIASING 2024-05-30 09:44:34 +02:00
microblaze arch: define CONFIG_PAGE_SIZE_*KB on all architectures 2024-03-06 19:29:09 +01:00
mips Fix for syscall_get_nr() to make it work even if tracing is disabled 2024-04-12 08:46:58 -07:00
nios2 nios2: Only use built-in devicetree blob if configured to do so 2024-04-03 14:35:53 -05:00
openrisc openrisc: traps: Don't send signals to kernel mode threads 2024-05-30 09:44:21 +02:00
parisc parisc: add missing export of __cmpxchg_u8() 2024-05-30 09:44:04 +02:00
powerpc powerpc fixes for 6.9 #4 2024-05-05 10:44:04 -07:00
riscv riscv, bpf: make some atomic operations fully ordered 2024-05-30 09:44:38 +02:00
s390 s390/bpf: Emit a barrier for BPF_FETCH instructions 2024-05-30 09:44:38 +02:00
sh Revert "sh: Handle calling csum_partial with misaligned data" 2024-05-30 09:44:29 +02:00
sparc This includes the following changes related to sparc for v6.9: 2024-03-15 12:47:21 -07:00
um Devicetree updates for v6.9: 2024-03-15 12:37:59 -07:00
x86 x86/numa: Fix SRAT lookup of CFMWS ranges with numa_fill_memblks() 2024-05-30 09:44:33 +02:00
xtensa Xtensa fixes for v6.9: 2024-05-02 10:41:28 -07:00
.gitignore
Kconfig cpu: Re-enable CPU mitigations by default for !X86 architectures 2024-04-25 15:47:35 +02:00