OpenCloudOS-Kernel/arch/s390
Ilya Leoshkevich 46f17e7d4f s390/bpf: Emit a barrier for BPF_FETCH instructions
[ Upstream commit 68378982f0b21de02ac3c6a11e2420badefcb4bc ]

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-12 11:11:53 +02:00
..
appldata sysctl: Add size to register_sysctl 2023-08-15 15:26:17 -07:00
boot mm/treewide: replace pud_large() with pud_leaf() 2024-04-10 16:35:46 +02:00
configs cred: get rid of CONFIG_DEBUG_CREDENTIALS 2023-12-20 17:01:51 +01:00
crypto crypto: s390/aes - Fix buffer overread in CTR mode 2024-01-31 16:18:50 -08:00
hypfs s390 updates for 6.6 merge window 2023-08-28 17:22:39 -07:00
include s390/mm: Re-enable the shared zeropage for !PV and !skeys KVM guests 2024-06-12 11:11:33 +02:00
kernel s390/vdso: Add CFI for RA register to asm macro vdso_func 2024-05-17 12:02:02 +02:00
kvm s390/mm: Re-enable the shared zeropage for !PV and !skeys KVM guests 2024-06-12 11:11:33 +02:00
lib s390: replace #include <asm/export.h> with #include <linux/export.h> 2023-08-09 15:20:50 +02:00
mm s390/mm: Re-enable the shared zeropage for !PV and !skeys KVM guests 2024-06-12 11:11:33 +02:00
net s390/bpf: Emit a barrier for BPF_FETCH instructions 2024-06-12 11:11:53 +02:00
pci s390: use the correct count for __iowrite64_copy() 2024-03-01 13:35:08 +01:00
purgatory s390 updates for 6.5 merge window part 2 2023-07-06 13:18:30 -07:00
tools KVM: s390: Add facility 197 to the allow list 2022-07-13 15:25:25 +02:00
Kbuild - An extensive rework of kexec and crash Kconfig from Eric DeVolder 2023-08-29 14:53:51 -07:00
Kconfig kexec: fix KEXEC_FILE dependencies 2024-01-05 15:19:41 +01:00
Kconfig.debug s390/Kconfig.debug: fix indentation 2022-06-01 12:03:15 +02:00
Makefile s390: use obj-y to descend into drivers/s390/ 2023-07-24 12:12:25 +02:00