hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/arch/arm64/include/asm/lse.h
....@@ -2,56 +2,47 @@
22 #ifndef __ASM_LSE_H
33 #define __ASM_LSE_H
44
5
-#if defined(CONFIG_AS_LSE) && defined(CONFIG_ARM64_LSE_ATOMICS)
5
+#include <asm/atomic_ll_sc.h>
6
+
7
+#if defined(CONFIG_ARM64_LSE_ATOMICS) && !defined(BUILD_FIPS140_KO)
68
79 #define __LSE_PREAMBLE ".arch_extension lse\n"
810
911 #include <linux/compiler_types.h>
1012 #include <linux/export.h>
13
+#include <linux/jump_label.h>
1114 #include <linux/stringify.h>
1215 #include <asm/alternative.h>
16
+#include <asm/atomic_lse.h>
1317 #include <asm/cpucaps.h>
1418
15
-#ifdef __ASSEMBLER__
19
+extern struct static_key_false cpu_hwcap_keys[ARM64_NCAPS];
20
+extern struct static_key_false arm64_const_caps_ready;
1621
17
-.arch_extension lse
22
+static inline bool system_uses_lse_atomics(void)
23
+{
24
+ return (static_branch_likely(&arm64_const_caps_ready)) &&
25
+ static_branch_likely(&cpu_hwcap_keys[ARM64_HAS_LSE_ATOMICS]);
26
+}
1827
19
-.macro alt_lse, llsc, lse
20
- alternative_insn "\llsc", "\lse", ARM64_HAS_LSE_ATOMICS
21
-.endm
22
-
23
-#else /* __ASSEMBLER__ */
24
-
25
-/* Move the ll/sc atomics out-of-line */
26
-#define __LL_SC_INLINE notrace
27
-#define __LL_SC_PREFIX(x) __ll_sc_##x
28
-#define __LL_SC_EXPORT(x) EXPORT_SYMBOL(__LL_SC_PREFIX(x))
29
-
30
-/* Macro for constructing calls to out-of-line ll/sc atomics */
31
-#define __LL_SC_CALL(op) "bl\t" __stringify(__LL_SC_PREFIX(op)) "\n"
32
-#define __LL_SC_CLOBBERS "x16", "x17", "x30"
28
+#define __lse_ll_sc_body(op, ...) \
29
+({ \
30
+ system_uses_lse_atomics() ? \
31
+ __lse_##op(__VA_ARGS__) : \
32
+ __ll_sc_##op(__VA_ARGS__); \
33
+})
3334
3435 /* In-line patching at runtime */
3536 #define ARM64_LSE_ATOMIC_INSN(llsc, lse) \
3637 ALTERNATIVE(llsc, __LSE_PREAMBLE lse, ARM64_HAS_LSE_ATOMICS)
3738
38
-#endif /* __ASSEMBLER__ */
39
-#else /* CONFIG_AS_LSE && CONFIG_ARM64_LSE_ATOMICS */
39
+#else /* CONFIG_ARM64_LSE_ATOMICS */
4040
41
-#ifdef __ASSEMBLER__
41
+static inline bool system_uses_lse_atomics(void) { return false; }
4242
43
-.macro alt_lse, llsc, lse
44
- \llsc
45
-.endm
46
-
47
-#else /* __ASSEMBLER__ */
48
-
49
-#define __LL_SC_INLINE static inline
50
-#define __LL_SC_PREFIX(x) x
51
-#define __LL_SC_EXPORT(x)
43
+#define __lse_ll_sc_body(op, ...) __ll_sc_##op(__VA_ARGS__)
5244
5345 #define ARM64_LSE_ATOMIC_INSN(llsc, lse) llsc
5446
55
-#endif /* __ASSEMBLER__ */
56
-#endif /* CONFIG_AS_LSE && CONFIG_ARM64_LSE_ATOMICS */
47
+#endif /* CONFIG_ARM64_LSE_ATOMICS */
5748 #endif /* __ASM_LSE_H */