Skip to content

bpf, arm64: support more atomic ops#1876

Open
tsipa wants to merge 5 commits intobpf-nextfrom
series/611843=>bpf-next
Open

bpf, arm64: support more atomic ops#1876
tsipa wants to merge 5 commits intobpf-nextfrom
series/611843=>bpf-next

Conversation

@tsipa
Copy link
Owner

@tsipa tsipa commented Feb 7, 2022

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

@tsipa
Copy link
Owner Author

tsipa commented Feb 7, 2022

Master branch: 422ee58
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

@tsipa
Copy link
Owner Author

tsipa commented Feb 7, 2022

Master branch: e91d280
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

@tsipa tsipa force-pushed the series/611843=>bpf-next branch from e5a7e77 to a2bf40b Compare February 7, 2022 16:16
@tsipa
Copy link
Owner Author

tsipa commented Feb 7, 2022

Master branch: 128dac5
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

@tsipa tsipa force-pushed the series/611843=>bpf-next branch from a2bf40b to 54545d9 Compare February 7, 2022 20:23
@tsipa
Copy link
Owner Author

tsipa commented Feb 8, 2022

Master branch: 80123f0
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

@tsipa tsipa force-pushed the series/611843=>bpf-next branch from 54545d9 to 4c91f40 Compare February 8, 2022 02:24
@tsipa
Copy link
Owner Author

tsipa commented Feb 8, 2022

Master branch: 5d1e9f4
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

@tsipa tsipa force-pushed the series/611843=>bpf-next branch from 4c91f40 to 2115937 Compare February 8, 2022 02:35
@tsipa
Copy link
Owner Author

tsipa commented Feb 8, 2022

Master branch: f95f768
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

@tsipa tsipa force-pushed the series/611843=>bpf-next branch from 2115937 to 767ce3d Compare February 8, 2022 17:32
@tsipa
Copy link
Owner Author

tsipa commented Feb 8, 2022

Master branch: 5912fcb
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

@tsipa tsipa force-pushed the series/611843=>bpf-next branch from 767ce3d to 251e98b Compare February 8, 2022 20:33
@tsipa tsipa added the needs-ack label Feb 8, 2022
@tsipa
Copy link
Owner Author

tsipa commented Feb 8, 2022

Master branch: 4172843
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

@tsipa tsipa force-pushed the series/611843=>bpf-next branch from 251e98b to 7b70947 Compare February 8, 2022 21:42
@tsipa
Copy link
Owner Author

tsipa commented Feb 8, 2022

Master branch: 19face1
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

@tsipa
Copy link
Owner Author

tsipa commented Feb 9, 2022

Master branch: cca6242
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

@tsipa tsipa force-pushed the series/611843=>bpf-next branch from e817258 to 7be1b81 Compare February 9, 2022 02:41
@tsipa
Copy link
Owner Author

tsipa commented Feb 9, 2022

Master branch: 8dd039a
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

@tsipa tsipa force-pushed the series/611843=>bpf-next branch from 7be1b81 to d0b8789 Compare February 9, 2022 05:43
@tsipa
Copy link
Owner Author

tsipa commented Feb 9, 2022

Master branch: 3caa7d2
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

@tsipa tsipa force-pushed the series/611843=>bpf-next branch from d0b8789 to d4e9214 Compare February 9, 2022 05:51
@tsipa
Copy link
Owner Author

tsipa commented Feb 9, 2022

Master branch: dc37dc6
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

@tsipa tsipa force-pushed the series/611843=>bpf-next branch from d4e9214 to ebaafb4 Compare February 9, 2022 13:41
@tsipa
Copy link
Owner Author

tsipa commented Feb 9, 2022

Master branch: e531396
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

@tsipa tsipa force-pushed the series/611843=>bpf-next branch from ebaafb4 to d119788 Compare February 9, 2022 20:02
@tsipa
Copy link
Owner Author

tsipa commented Feb 10, 2022

Master branch: 1127170
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

@tsipa tsipa force-pushed the series/611843=>bpf-next branch from d119788 to e939276 Compare February 10, 2022 05:22
@tsipa
Copy link
Owner Author

tsipa commented Feb 10, 2022

Master branch: 85fbd23
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

@tsipa tsipa force-pushed the series/611843=>bpf-next branch from e939276 to 13623db Compare February 10, 2022 22:38
@tsipa
Copy link
Owner Author

tsipa commented Feb 11, 2022

Master branch: a5a358a
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

@tsipa tsipa force-pushed the series/611843=>bpf-next branch from 13623db to 5c4fec0 Compare February 11, 2022 01:56
@tsipa
Copy link
Owner Author

tsipa commented Feb 11, 2022

Master branch: 4cc0991
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

@tsipa tsipa force-pushed the series/611843=>bpf-next branch from 5c4fec0 to ec7784b Compare February 11, 2022 03:04
@tsipa
Copy link
Owner Author

tsipa commented Feb 11, 2022

Master branch: 4407fa0
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

@tsipa tsipa force-pushed the series/611843=>bpf-next branch from ec7784b to 49c34e0 Compare February 11, 2022 05:19
@tsipa
Copy link
Owner Author

tsipa commented Feb 11, 2022

Master branch: d130e95
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

@tsipa tsipa force-pushed the series/611843=>bpf-next branch from 49c34e0 to 8ff730a Compare February 11, 2022 21:02
@tsipa
Copy link
Owner Author

tsipa commented Feb 12, 2022

Master branch: 9c3de61
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

@tsipa tsipa force-pushed the series/611843=>bpf-next branch from 8ff730a to 9210bdb Compare February 12, 2022 16:10
@tsipa
Copy link
Owner Author

tsipa commented Feb 15, 2022

Master branch: edc21dc
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

@tsipa tsipa force-pushed the series/611843=>bpf-next branch from 9210bdb to 2a50cd6 Compare February 15, 2022 17:27
@tsipa
Copy link
Owner Author

tsipa commented Feb 15, 2022

Master branch: d2b94f3
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

@tsipa tsipa force-pushed the series/611843=>bpf-next branch from 2a50cd6 to 925fe58 Compare February 15, 2022 18:09
Nobody and others added 3 commits February 15, 2022 10:12
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>
@tsipa
Copy link
Owner Author

tsipa commented Feb 15, 2022

Master branch: 8cbf062
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=611843
version: 3

Hou Tao added 2 commits February 15, 2022 10:12
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>
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>
@tsipa tsipa force-pushed the series/611843=>bpf-next branch from 925fe58 to 9d5b5d4 Compare February 15, 2022 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant