diff options
author | Hari Bathini <hbathini@linux.ibm.com> | 2022-06-10 21:25:49 +0530 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2022-06-29 19:37:08 +1000 |
commit | dbe6e2456fb0263a5a961a92836d2cebdbca979c (patch) | |
tree | 8780c65e223a2508ce0182a16436dfc1827abb86 /arch/powerpc/net | |
parent | 65112709115f48f16d7082bcabf173d08622e69f (diff) | |
download | linux-dbe6e2456fb0263a5a961a92836d2cebdbca979c.tar.gz linux-dbe6e2456fb0263a5a961a92836d2cebdbca979c.tar.bz2 linux-dbe6e2456fb0263a5a961a92836d2cebdbca979c.zip |
powerpc/bpf/64: add support for atomic fetch operations
Adding instructions for ppc64 for
atomic[64]_fetch_add
atomic[64]_fetch_and
atomic[64]_fetch_or
atomic[64]_fetch_xor
Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
Tested-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> (ppc64le)
Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220610155552.25892-3-hbathini@linux.ibm.com
Diffstat (limited to 'arch/powerpc/net')
-rw-r--r-- | arch/powerpc/net/bpf_jit_comp64.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c index c421bedd0e98..c53236b3a8b1 100644 --- a/arch/powerpc/net/bpf_jit_comp64.c +++ b/arch/powerpc/net/bpf_jit_comp64.c @@ -787,17 +787,25 @@ emit_clear: else EMIT(PPC_RAW_LWARX(tmp2_reg, tmp1_reg, dst_reg, 0)); + /* Save old value in _R0 */ + if (imm & BPF_FETCH) + EMIT(PPC_RAW_MR(_R0, tmp2_reg)); + switch (imm) { case BPF_ADD: + case BPF_ADD | BPF_FETCH: EMIT(PPC_RAW_ADD(tmp2_reg, tmp2_reg, src_reg)); break; case BPF_AND: + case BPF_AND | BPF_FETCH: EMIT(PPC_RAW_AND(tmp2_reg, tmp2_reg, src_reg)); break; case BPF_OR: + case BPF_OR | BPF_FETCH: EMIT(PPC_RAW_OR(tmp2_reg, tmp2_reg, src_reg)); break; case BPF_XOR: + case BPF_XOR | BPF_FETCH: EMIT(PPC_RAW_XOR(tmp2_reg, tmp2_reg, src_reg)); break; default: @@ -807,13 +815,17 @@ emit_clear: return -EOPNOTSUPP; } - /* store result back */ + /* store new value */ if (size == BPF_DW) EMIT(PPC_RAW_STDCX(tmp2_reg, tmp1_reg, dst_reg)); else EMIT(PPC_RAW_STWCX(tmp2_reg, tmp1_reg, dst_reg)); /* we're done if this succeeded */ PPC_BCC_SHORT(COND_NE, tmp_idx); + + /* For the BPF_FETCH variant, get old value into src_reg */ + if (imm & BPF_FETCH) + EMIT(PPC_RAW_MR(src_reg, _R0)); break; /* |