New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpf, arm64: support more atomic ops #2577
Conversation
Master branch: 9b6eb04 |
Master branch: 1b8c924 |
c06cb47
to
04bb3a4
Compare
Master branch: 9e98ace |
04bb3a4
to
1a3e904
Compare
9e98ace
to
1b8c924
Compare
Master branch: 1b8c924 |
1a3e904
to
f1a2ba0
Compare
Master branch: b38101c |
f1a2ba0
to
bd7afae
Compare
Master branch: b75daca |
bd7afae
to
6055e91
Compare
Master branch: d24d2a2 |
6055e91
to
4fa61d4
Compare
Master branch: 086d490 |
4fa61d4
to
e9161eb
Compare
Master branch: 9087c6f |
e9161eb
to
5eda530
Compare
Master branch: a33c0c7 |
5eda530
to
b886ec2
Compare
Master branch: d0b3822 |
b886ec2
to
3994681
Compare
Master branch: b03e194 |
3994681
to
a31d028
Compare
Master branch: 13c6a37 |
a31d028
to
ebbdb16
Compare
Master branch: 6966d4c |
ebbdb16
to
d94bbb1
Compare
Master branch: b4f7278 |
d94bbb1
to
e381dc5
Compare
Master branch: a19df71 |
e381dc5
to
6d3ea7e
Compare
Master branch: 08894d9 |
6d3ea7e
to
ce28a09
Compare
Master branch: c561d11 |
ce28a09
to
1892705
Compare
Master branch: 08d4dba |
1892705
to
8db16b6
Compare
Master branch: 80bebeb |
8db16b6
to
5a15c84
Compare
Master branch: dda7596 |
5a15c84
to
4a24cc6
Compare
Master branch: 5e214f2 |
4a24cc6
to
581d044
Compare
If CONFIG_ARM64_LSE_ATOMICS is off, encoders for LSE-related instructions can return AARCH64_BREAK_FAULT directly in insn.h. In order to access AARCH64_BREAK_FAULT in insn.h, we can not include debug-monitors.h in insn.h, because debug-monitors.h has already depends on insn.h, so just move AARCH64_BREAK_FAULT into insn-def.h. It will be used by the following patch to eliminate unnecessary LSE-related encoders when CONFIG_ARM64_LSE_ATOMICS is off. Signed-off-by: Hou Tao <houtao1@huawei.com>
It is a preparation patch for eBPF atomic supports under arm64. eBPF needs support atomic[64]_fetch_add, atomic[64]_[fetch_]{and,or,xor} and atomic[64]_{xchg|cmpxchg}. The ordering semantics of eBPF atomics are the same with the implementations in linux kernel. Add three helpers to support LDCLR/LDEOR/LDSET/SWP, CAS and DMB instructions. STADD/STCLR/STEOR/STSET are simply encoded as aliases for LDADD/LDCLR/LDEOR/LDSET with XZR as the destination register, so no extra helper is added. atomic_fetch_add() and other atomic ops needs support for STLXR instruction, so extend enum aarch64_insn_ldst_type to do that. LDADD/LDEOR/LDSET/SWP and CAS instructions are only available when LSE atomics is enabled, so just return AARCH64_BREAK_FAULT directly in these newly-added helpers if CONFIG_ARM64_LSE_ATOMICS is disabled. Signed-off-by: Hou Tao <houtao1@huawei.com>
Atomics for eBPF patch series adds support for atomic[64]_fetch_add, atomic[64]_[fetch_]{and,or,xor} and atomic[64]_{xchg|cmpxchg}, but it only adds support for x86-64, so support these atomic operations for arm64 as well. Basically the implementation procedure is almost mechanical translation of code snippets in atomic_ll_sc.h & atomic_lse.h & cmpxchg.h located under arch/arm64/include/asm. When LSE atomic is unavailable, an extra temporary register is needed for (BPF_ADD | BPF_FETCH) to save the value of src register, instead of adding TMP_REG_4 just use BPF_REG_AX instead. Also make emit_lse_atomic() as an empty inline function when CONFIG_ARM64_LSE_ATOMICS is disabled. For cpus_have_cap(ARM64_HAS_LSE_ATOMICS) case and no-LSE-ATOMICS case, the following three tests: "./test_verifier", "./test_progs -t atomic" and "insmod ./test_bpf.ko" are exercised and passed. Signed-off-by: Hou Tao <houtao1@huawei.com>
Master branch: c62dd8a |
Now atomic tests will attach fentry program and run it through bpf_prog_test_run_opts(), but attaching fentry program depends on bpf trampoline which is only available under x86-64. Considering many archs have atomic support, using raw_tp program instead. Signed-off-by: Hou Tao <houtao1@huawei.com> Acked-by: Andrii Nakryiko <andrii@kernel.org>
581d044
to
d6993df
Compare
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=615259 irrelevant now. Closing PR. |
Pull request for series with
subject: bpf, arm64: support more atomic ops
version: 4
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259