Add a helper that exposes information about whether the system supports memory tagging to be called in generic code. Signed-off-by: Andrey Konovalov <andreyknvl@xxxxxxxxxx> Link: https://linux-review.googlesource.com/id/Ib4b56a42c57c6293df29a0cdfee334c3ca7bdab4 --- arch/arm64/include/asm/memory.h | 1 + mm/kasan/kasan.h | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index b5d6b824c21c..6d2b7c54780e 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -232,6 +232,7 @@ static inline const void *__tag_set(const void *addr, u8 tag) } #ifdef CONFIG_KASAN_HW_TAGS +#define arch_system_supports_tags() system_supports_mte() #define arch_init_tags(max_tag) mte_init_tags(max_tag) #define arch_get_random_tag() mte_get_random_tag() #define arch_get_mem_tag(addr) mte_get_mem_tag(addr) diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h index e5b8367a07f2..47d6074c7958 100644 --- a/mm/kasan/kasan.h +++ b/mm/kasan/kasan.h @@ -257,6 +257,9 @@ static inline const void *arch_kasan_set_tag(const void *addr, u8 tag) #define reset_tag(addr) ((void *)arch_kasan_reset_tag(addr)) #define get_tag(addr) arch_kasan_get_tag(addr) +#ifndef arch_system_supports_tags +#define arch_system_supports_tags() (false) +#endif #ifndef arch_init_tags #define arch_init_tags(max_tag) #endif @@ -270,6 +273,7 @@ static inline const void *arch_kasan_set_tag(const void *addr, u8 tag) #define arch_set_mem_tag_range(addr, size, tag) ((void *)(addr)) #endif +#define system_supports_tags() arch_system_supports_tags() #define init_tags(max_tag) arch_init_tags(max_tag) #define get_random_tag() arch_get_random_tag() #define get_mem_tag(addr) arch_get_mem_tag(addr) -- 2.28.0.1011.ga647a8990f-goog