Merge branch 'for-next/mte-async-kernel-mode' into for-next/core
authorCatalin Marinas <catalin.marinas@arm.com>
Thu, 15 Apr 2021 13:00:47 +0000 (14:00 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Thu, 15 Apr 2021 13:00:47 +0000 (14:00 +0100)
* for-next/mte-async-kernel-mode:
  : Add MTE asynchronous kernel mode support
  kasan, arm64: tests supports for HW_TAGS async mode
  arm64: mte: Report async tag faults before suspend
  arm64: mte: Enable async tag check fault
  arm64: mte: Conditionally compile mte_enable_kernel_*()
  arm64: mte: Enable TCO in functions that can read beyond buffer limits
  kasan: Add report for async mode
  arm64: mte: Drop arch_enable_tagging()
  kasan: Add KASAN mode kernel parameter
  arm64: mte: Add asynchronous mode support

1  2 
arch/arm64/include/asm/mte.h

@@@ -82,7 -88,55 +86,51 @@@ static inline int mte_ptrace_copy_tags(
        return -EIO;
  }
  
 -static inline void mte_assign_mem_tag_range(void *addr, size_t size)
 -{
 -}
 -
  #endif /* CONFIG_ARM64_MTE */
  
+ #ifdef CONFIG_KASAN_HW_TAGS
+ /* Whether the MTE asynchronous mode is enabled. */
+ DECLARE_STATIC_KEY_FALSE(mte_async_mode);
+ static inline bool system_uses_mte_async_mode(void)
+ {
+       return static_branch_unlikely(&mte_async_mode);
+ }
+ void mte_check_tfsr_el1(void);
+ static inline void mte_check_tfsr_entry(void)
+ {
+       mte_check_tfsr_el1();
+ }
+ static inline void mte_check_tfsr_exit(void)
+ {
+       /*
+        * The asynchronous faults are sync'ed automatically with
+        * TFSR_EL1 on kernel entry but for exit an explicit dsb()
+        * is required.
+        */
+       dsb(nsh);
+       isb();
+       mte_check_tfsr_el1();
+ }
+ #else
+ static inline bool system_uses_mte_async_mode(void)
+ {
+       return false;
+ }
+ static inline void mte_check_tfsr_el1(void)
+ {
+ }
+ static inline void mte_check_tfsr_entry(void)
+ {
+ }
+ static inline void mte_check_tfsr_exit(void)
+ {
+ }
+ #endif /* CONFIG_KASAN_HW_TAGS */
  #endif /* __ASSEMBLY__ */
  #endif /* __ASM_MTE_H  */