Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
[sfrench/cifs-2.6.git] / arch / arm64 / include / asm / memory.h
index 15018dc59554e1e80b5123f8129fe3dfc54f9c4b..87b90dc27a4327426466f73213fafea2de51aedf 100644 (file)
@@ -250,8 +250,8 @@ static inline const void *__tag_set(const void *addr, u8 tag)
 #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)
-#define arch_set_mem_tag_range(addr, size, tag)        \
-                       mte_set_mem_tag_range((addr), (size), (tag))
+#define arch_set_mem_tag_range(addr, size, tag, init)  \
+                       mte_set_mem_tag_range((addr), (size), (tag), (init))
 #endif /* CONFIG_KASAN_HW_TAGS */
 
 /*
@@ -323,6 +323,22 @@ static inline void *phys_to_virt(phys_addr_t x)
 #define virt_to_pfn(x)         __phys_to_pfn(__virt_to_phys((unsigned long)(x)))
 #define sym_to_pfn(x)          __phys_to_pfn(__pa_symbol(x))
 
+#ifdef CONFIG_CFI_CLANG
+/*
+ * With CONFIG_CFI_CLANG, the compiler replaces function address
+ * references with the address of the function's CFI jump table
+ * entry. The function_nocfi macro always returns the address of the
+ * actual function instead.
+ */
+#define function_nocfi(x) ({                                           \
+       void *addr;                                                     \
+       asm("adrp %0, " __stringify(x) "\n\t"                           \
+           "add  %0, %0, :lo12:" __stringify(x)                        \
+           : "=r" (addr));                                             \
+       addr;                                                           \
+})
+#endif
+
 /*
  *  virt_to_page(x)    convert a _valid_ virtual address to struct page *
  *  virt_addr_valid(x) indicates whether a virtual address is valid