Skip to content
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

Closed
wants to merge 5 commits into from

Conversation

kernel-patches-bot
Copy link

Pull request for series with
subject: bpf, arm64: support more atomic ops
version: 4
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259

@kernel-patches-bot
Copy link
Author

Master branch: 9b6eb04
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259
version: 4

@kernel-patches-bot
Copy link
Author

Master branch: 1b8c924
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259
version: 4

@kernel-patches-bot
Copy link
Author

Master branch: 9e98ace
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259
version: 4

@kernel-patches-bot
Copy link
Author

Master branch: 1b8c924
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259
version: 4

@kernel-patches-bot
Copy link
Author

Master branch: b38101c
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259
version: 4

@kernel-patches-bot
Copy link
Author

Master branch: b75daca
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259
version: 4

@kernel-patches-bot
Copy link
Author

Master branch: d24d2a2
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259
version: 4

@kernel-patches-bot
Copy link
Author

Master branch: 086d490
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259
version: 4

@kernel-patches-bot
Copy link
Author

Master branch: 9087c6f
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259
version: 4

@kernel-patches-bot
Copy link
Author

Master branch: a33c0c7
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259
version: 4

@kernel-patches-bot
Copy link
Author

Master branch: d0b3822
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259
version: 4

@kernel-patches-bot
Copy link
Author

Master branch: b03e194
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259
version: 4

@kernel-patches-bot
Copy link
Author

Master branch: 13c6a37
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259
version: 4

@kernel-patches-bot
Copy link
Author

Master branch: 6966d4c
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259
version: 4

@kernel-patches-bot
Copy link
Author

Master branch: b4f7278
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259
version: 4

@kernel-patches-bot
Copy link
Author

Master branch: a19df71
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259
version: 4

@kernel-patches-bot
Copy link
Author

Master branch: 08894d9
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259
version: 4

@kernel-patches-bot
Copy link
Author

Master branch: c561d11
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259
version: 4

@kernel-patches-bot
Copy link
Author

Master branch: 08d4dba
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259
version: 4

@kernel-patches-bot
Copy link
Author

Master branch: 80bebeb
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259
version: 4

@kernel-patches-bot
Copy link
Author

Master branch: dda7596
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259
version: 4

@kernel-patches-bot
Copy link
Author

Master branch: 5e214f2
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259
version: 4

Nobody and others added 4 commits February 28, 2022 07:18
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>
@kernel-patches-bot
Copy link
Author

Master branch: c62dd8a
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=615259
version: 4

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>
@kernel-patches-bot
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=615259 irrelevant now. Closing PR.

@kernel-patches-bot kernel-patches-bot deleted the series/611843=>bpf-next branch February 28, 2022 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant