]> git.baikalelectronics.ru Git - kernel.git/commit
arm64: insn: add encoders for atomic operations
authorHou Tao <houtao1@huawei.com>
Thu, 17 Feb 2022 07:22:30 +0000 (15:22 +0800)
committerWill Deacon <will@kernel.org>
Tue, 22 Feb 2022 21:25:48 +0000 (21:25 +0000)
commitede5730031f4398ec83c56eb15482d3dc682de8b
tree3c28b1a2af95190120e8ad71dce9d8147c8f6602
parent780dea02744f6a176a2c4b407f349d346c367beb
arm64: insn: add encoders for atomic operations

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>
Link: https://lore.kernel.org/r/20220217072232.1186625-3-houtao1@huawei.com
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/include/asm/insn.h
arch/arm64/lib/insn.c
arch/arm64/net/bpf_jit.h