linux-stable/arch/s390
Ilya Leoshkevich 193377faff 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-05-30 09:44:38 +02:00
..
appldata S390: Remove now superfluous sentinel elem from ctl_table arrays 2023-10-10 15:22:02 -07:00
boot - Sumanth Korikkar has taught s390 to allocate hotplug-time page frames 2024-03-14 17:43:30 -07:00
configs s390/mm: provide simple ARCH_HAS_DEBUG_VIRTUAL support 2024-03-13 09:23:49 +01:00
crypto s390/paes: Reestablish retry loop in paes 2024-05-01 11:52:54 +02:00
hypfs s390/hypfs_sprp: remove unneeded DMA zone allocation 2024-02-09 13:58:14 +01:00
include s390/mm: Re-enable the shared zeropage for !PV and !skeys KVM guests 2024-05-30 09:44:07 +02:00
kernel s390: vmlinux.lds.S: Drop .hash and .gnu.hash for !CONFIG_PIE_BUILD 2024-05-30 09:44:09 +02:00
kvm s390/mm: Re-enable the shared zeropage for !PV and !skeys KVM guests 2024-05-30 09:44:07 +02:00
lib s390/checksum: provide csum_partial_copy_nocheck() 2024-02-16 14:30:17 +01:00
mm s390/mm: Re-enable the shared zeropage for !PV and !skeys KVM guests 2024-05-30 09:44:07 +02:00
net s390/bpf: Emit a barrier for BPF_FETCH instructions 2024-05-30 09:44:38 +02:00
pci s390 updates for 6.9 merge window 2024-03-12 10:14:22 -07:00
purgatory s390 updates for 6.5 merge window part 2 2023-07-06 13:18:30 -07:00
tools s390/tools: handle rela R_390_GOTPCDBL/R_390_GOTOFF64 2024-03-07 17:02:05 +01:00
Kbuild - An extensive rework of kexec and crash Kconfig from Eric DeVolder 2023-08-29 14:53:51 -07:00
Kconfig more s390 updates for 6.9 merge window 2024-03-19 11:38:27 -07:00
Kconfig.debug
Makefile s390/mm: provide simple ARCH_HAS_DEBUG_VIRTUAL support 2024-03-13 09:23:49 +01:00