linux/arch/s390
Ilya Leoshkevich 16da7f7728 s390/bpf: Emit a barrier for BPF_FETCH instructions
[ Upstream commit 68378982f0 ]

BPF_ATOMIC_OP() macro documentation states that "BPF_ADD | BPF_FETCH"
should be the same as atomic_fetch_add(), which is currently not the
case on s390x: the serialization instruction "bcr 14,0" is missing.
This applies to "and", "or" and "xor" variants too.

s390x is allowed to reorder stores with subsequent fetches from
different addresses, so code relying on BPF_FETCH acting as a barrier,
for example:

  stw [%r0], 1
  afadd [%r1], %r2
  ldxw %r3, [%r4]

may be broken. Fix it by emitting "bcr 14,0".

Note that a separate serialization instruction is not needed for
BPF_XCHG and BPF_CMPXCHG, because COMPARE AND SWAP performs
serialization itself.

Fixes: ba3b86b9ce ("s390/bpf: Implement new atomic ops")
Reported-by: Puranjay Mohan <puranjay12@gmail.com>
Closes: https://lore.kernel.org/bpf/mb61p34qvq3wf.fsf@kernel.org/
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Puranjay Mohan <puranjay@kernel.org>
Link: https://lore.kernel.org/r/20240507000557.12048-1-iii@linux.ibm.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-06-16 13:39:26 +02:00
..
appldata s390/appldata: use struct_size() helper 2020-06-29 16:32:34 +02:00
boot s390/ipl: add missing intersection check to ipl_report handling 2023-03-22 13:31:32 +01:00
configs s390: update defconfigs 2021-09-15 14:29:21 +02:00
crypto crypto: s390/aes - Fix buffer overread in CTR mode 2024-02-23 08:54:24 +01:00
hypfs s390/hypfs: avoid error message under KVM 2022-09-05 10:30:11 +02:00
include s390/vdso: Add CFI for RA register to asm macro vdso_func 2024-05-17 11:50:48 +02:00
kernel s390/vdso: Add CFI for RA register to asm macro vdso_func 2024-05-17 11:50:48 +02:00
kvm KVM: s390: fix setting of fpc register 2024-02-23 08:54:40 +01:00
lib s390/uaccess: add missing earlyclobber annotations to __clear_user() 2023-04-05 11:25:01 +02:00
mm s390/mm: Fix clearing storage keys for huge pages 2024-05-17 11:50:47 +02:00
net s390/bpf: Emit a barrier for BPF_FETCH instructions 2024-06-16 13:39:26 +02:00
pci s390: use the correct count for __iowrite64_copy() 2024-03-01 13:21:59 +01:00
purgatory s390/purgatory: disable branch profiling 2023-06-28 10:29:52 +02:00
tools s390/disassembler: add instructions 2021-07-27 09:39:19 +02:00
Kbuild s390/numa: move code to arch/s390/kernel 2020-08-11 18:16:55 +02:00
Kconfig s390: remove unneeded 'select BUILD_BIN2C' 2022-07-07 17:53:27 +02:00
Kconfig.debug tracing: Refactor TRACE_IRQFLAGS_SUPPORT in Kconfig 2021-08-16 11:37:21 -04:00
Makefile s390/decompressor: fix misaligned symbol build error 2023-07-23 13:47:55 +02:00