]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/bpf-arm64-remove-prefetch-insn-in-xadd-mapping.patch
Linux 4.14.121
[thirdparty/kernel/stable-queue.git] / queue-4.19 / bpf-arm64-remove-prefetch-insn-in-xadd-mapping.patch
1 From 8968c67a82ab7501bc3b9439c3624a49b42fe54c Mon Sep 17 00:00:00 2001
2 From: Daniel Borkmann <daniel@iogearbox.net>
3 Date: Fri, 26 Apr 2019 21:48:21 +0200
4 Subject: bpf, arm64: remove prefetch insn in xadd mapping
5
6 From: Daniel Borkmann <daniel@iogearbox.net>
7
8 commit 8968c67a82ab7501bc3b9439c3624a49b42fe54c upstream.
9
10 Prefetch-with-intent-to-write is currently part of the XADD mapping in
11 the AArch64 JIT and follows the kernel's implementation of atomic_add.
12 This may interfere with other threads executing the LDXR/STXR loop,
13 leading to potential starvation and fairness issues. Drop the optional
14 prefetch instruction.
15
16 Fixes: 85f68fe89832 ("bpf, arm64: implement jiting of BPF_XADD")
17 Reported-by: Will Deacon <will.deacon@arm.com>
18 Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
19 Acked-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
20 Acked-by: Will Deacon <will.deacon@arm.com>
21 Signed-off-by: Alexei Starovoitov <ast@kernel.org>
22 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23
24 ---
25 arch/arm64/net/bpf_jit.h | 6 ------
26 arch/arm64/net/bpf_jit_comp.c | 1 -
27 2 files changed, 7 deletions(-)
28
29 --- a/arch/arm64/net/bpf_jit.h
30 +++ b/arch/arm64/net/bpf_jit.h
31 @@ -100,12 +100,6 @@
32 #define A64_STXR(sf, Rt, Rn, Rs) \
33 A64_LSX(sf, Rt, Rn, Rs, STORE_EX)
34
35 -/* Prefetch */
36 -#define A64_PRFM(Rn, type, target, policy) \
37 - aarch64_insn_gen_prefetch(Rn, AARCH64_INSN_PRFM_TYPE_##type, \
38 - AARCH64_INSN_PRFM_TARGET_##target, \
39 - AARCH64_INSN_PRFM_POLICY_##policy)
40 -
41 /* Add/subtract (immediate) */
42 #define A64_ADDSUB_IMM(sf, Rd, Rn, imm12, type) \
43 aarch64_insn_gen_add_sub_imm(Rd, Rn, imm12, \
44 --- a/arch/arm64/net/bpf_jit_comp.c
45 +++ b/arch/arm64/net/bpf_jit_comp.c
46 @@ -736,7 +736,6 @@ emit_cond_jmp:
47 case BPF_STX | BPF_XADD | BPF_DW:
48 emit_a64_mov_i(1, tmp, off, ctx);
49 emit(A64_ADD(1, tmp, tmp, dst), ctx);
50 - emit(A64_PRFM(tmp, PST, L1, STRM), ctx);
51 emit(A64_LDXR(isdw, tmp2, tmp), ctx);
52 emit(A64_ADD(isdw, tmp2, tmp2, src), ctx);
53 emit(A64_STXR(isdw, tmp2, tmp, tmp3), ctx);