diff options
author | Daniel Borkmann <daniel@iogearbox.net> | 2019-04-26 15:48:21 -0400 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2019-04-26 21:53:15 -0400 |
commit | 8968c67a82ab7501bc3b9439c3624a49b42fe54c (patch) | |
tree | b377d4184b0c45b275e6548e163961ece6443539 | |
parent | 0c0cad2c2824ac38106ad0649263eca30954beb6 (diff) |
bpf, arm64: remove prefetch insn in xadd mapping
Prefetch-with-intent-to-write is currently part of the XADD mapping in
the AArch64 JIT and follows the kernel's implementation of atomic_add.
This may interfere with other threads executing the LDXR/STXR loop,
leading to potential starvation and fairness issues. Drop the optional
prefetch instruction.
Fixes: 85f68fe89832 ("bpf, arm64: implement jiting of BPF_XADD")
Reported-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
-rw-r--r-- | arch/arm64/net/bpf_jit.h | 6 | ||||
-rw-r--r-- | arch/arm64/net/bpf_jit_comp.c | 1 |
2 files changed, 0 insertions, 7 deletions
diff --git a/arch/arm64/net/bpf_jit.h b/arch/arm64/net/bpf_jit.h index 783de51a6c4e..6c881659ee8a 100644 --- a/arch/arm64/net/bpf_jit.h +++ b/arch/arm64/net/bpf_jit.h | |||
@@ -100,12 +100,6 @@ | |||
100 | #define A64_STXR(sf, Rt, Rn, Rs) \ | 100 | #define A64_STXR(sf, Rt, Rn, Rs) \ |
101 | A64_LSX(sf, Rt, Rn, Rs, STORE_EX) | 101 | A64_LSX(sf, Rt, Rn, Rs, STORE_EX) |
102 | 102 | ||
103 | /* Prefetch */ | ||
104 | #define A64_PRFM(Rn, type, target, policy) \ | ||
105 | aarch64_insn_gen_prefetch(Rn, AARCH64_INSN_PRFM_TYPE_##type, \ | ||
106 | AARCH64_INSN_PRFM_TARGET_##target, \ | ||
107 | AARCH64_INSN_PRFM_POLICY_##policy) | ||
108 | |||
109 | /* Add/subtract (immediate) */ | 103 | /* Add/subtract (immediate) */ |
110 | #define A64_ADDSUB_IMM(sf, Rd, Rn, imm12, type) \ | 104 | #define A64_ADDSUB_IMM(sf, Rd, Rn, imm12, type) \ |
111 | aarch64_insn_gen_add_sub_imm(Rd, Rn, imm12, \ | 105 | aarch64_insn_gen_add_sub_imm(Rd, Rn, imm12, \ |
diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c index aaddc0217e73..a1420626fca2 100644 --- a/arch/arm64/net/bpf_jit_comp.c +++ b/arch/arm64/net/bpf_jit_comp.c | |||
@@ -762,7 +762,6 @@ emit_cond_jmp: | |||
762 | case BPF_STX | BPF_XADD | BPF_DW: | 762 | case BPF_STX | BPF_XADD | BPF_DW: |
763 | emit_a64_mov_i(1, tmp, off, ctx); | 763 | emit_a64_mov_i(1, tmp, off, ctx); |
764 | emit(A64_ADD(1, tmp, tmp, dst), ctx); | 764 | emit(A64_ADD(1, tmp, tmp, dst), ctx); |
765 | emit(A64_PRFM(tmp, PST, L1, STRM), ctx); | ||
766 | emit(A64_LDXR(isdw, tmp2, tmp), ctx); | 765 | emit(A64_LDXR(isdw, tmp2, tmp), ctx); |
767 | emit(A64_ADD(isdw, tmp2, tmp2, src), ctx); | 766 | emit(A64_ADD(isdw, tmp2, tmp2, src), ctx); |
768 | emit(A64_STXR(isdw, tmp2, tmp, tmp3), ctx); | 767 | emit(A64_STXR(isdw, tmp2, tmp, tmp3), ctx); |