Merge tag 'soc-fixes-5.18-1' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
[linux-2.6-microblaze.git] / include / linux / kasan-enabled.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_KASAN_ENABLED_H
3 #define _LINUX_KASAN_ENABLED_H
4
5 #include <linux/static_key.h>
6
7 #ifdef CONFIG_KASAN_HW_TAGS
8
9 DECLARE_STATIC_KEY_FALSE(kasan_flag_enabled);
10
11 static __always_inline bool kasan_enabled(void)
12 {
13         return static_branch_likely(&kasan_flag_enabled);
14 }
15
16 static inline bool kasan_hw_tags_enabled(void)
17 {
18         return kasan_enabled();
19 }
20
21 #else /* CONFIG_KASAN_HW_TAGS */
22
23 static inline bool kasan_enabled(void)
24 {
25         return IS_ENABLED(CONFIG_KASAN);
26 }
27
28 static inline bool kasan_hw_tags_enabled(void)
29 {
30         return false;
31 }
32
33 #endif /* CONFIG_KASAN_HW_TAGS */
34
35 #endif /* LINUX_KASAN_ENABLED_H */