mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
Current futex atomic operations are implemented using LL/SC instructions
while temporarily clearing PSTATE.PAN and setting PSTATE.TCO (if
KASAN_HW_TAGS is enabled). With Armv9.6, FEAT_LSUI provides atomic
instructions for user memory access in the kernel without the need for
PSTATE bits toggling.
Use the FEAT_LSUI instructions to implement the futex atomic operations.
Note that some futex operations do not have a matching LSUI instruction,
(eor or word-sized cmpxchg). For such cases, use cas{al}t to implement
the operation.
Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
[catalin.marinas@arm.com: add comment on -EAGAIN in __lsui_futex_cmpxchg()]
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
28 lines
627 B
C
28 lines
627 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __ASM_LSUI_H
|
|
#define __ASM_LSUI_H
|
|
|
|
#include <linux/compiler_types.h>
|
|
#include <linux/stringify.h>
|
|
#include <asm/alternative.h>
|
|
#include <asm/alternative-macros.h>
|
|
#include <asm/cpucaps.h>
|
|
|
|
#define __LSUI_PREAMBLE ".arch_extension lsui\n"
|
|
|
|
#ifdef CONFIG_ARM64_LSUI
|
|
|
|
#define __lsui_llsc_body(op, ...) \
|
|
({ \
|
|
alternative_has_cap_unlikely(ARM64_HAS_LSUI) ? \
|
|
__lsui_##op(__VA_ARGS__) : __llsc_##op(__VA_ARGS__); \
|
|
})
|
|
|
|
#else /* CONFIG_ARM64_LSUI */
|
|
|
|
#define __lsui_llsc_body(op, ...) __llsc_##op(__VA_ARGS__)
|
|
|
|
#endif /* CONFIG_ARM64_LSUI */
|
|
|
|
#endif /* __ASM_LSUI_H */
|