1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2020 ARM Ltd.
8 #include <asm/compiler.h>
9 #include <asm/mte-def.h>
11 #define __MTE_PREAMBLE ARM64_ASM_PREAMBLE ".arch_extension memtag\n"
15 #include <linux/bitfield.h>
16 #include <linux/page-flags.h>
17 #include <linux/types.h>
19 #include <asm/pgtable-types.h>
21 void mte_clear_page_tags(void *addr);
22 unsigned long mte_copy_tags_from_user(void *to, const void __user *from,
24 unsigned long mte_copy_tags_to_user(void __user *to, void *from,
26 int mte_save_tags(struct page *page);
27 void mte_save_page_tags(const void *page_addr, void *tag_storage);
28 bool mte_restore_tags(swp_entry_t entry, struct page *page);
29 void mte_restore_page_tags(void *page_addr, const void *tag_storage);
30 void mte_invalidate_tags(int type, pgoff_t offset);
31 void mte_invalidate_tags_area(int type);
32 void *mte_allocate_tag_storage(void);
33 void mte_free_tag_storage(char *storage);
35 #ifdef CONFIG_ARM64_MTE
37 /* track which pages have valid allocation tags */
38 #define PG_mte_tagged PG_arch_2
40 void mte_sync_tags(pte_t *ptep, pte_t pte);
41 void mte_copy_page_tags(void *kto, const void *kfrom);
42 void flush_mte_state(void);
43 void mte_thread_switch(struct task_struct *next);
44 void mte_suspend_exit(void);
45 long set_mte_ctrl(struct task_struct *task, unsigned long arg);
46 long get_mte_ctrl(struct task_struct *task);
47 int mte_ptrace_copy_tags(struct task_struct *child, long request,
48 unsigned long addr, unsigned long data);
50 void mte_assign_mem_tag_range(void *addr, size_t size);
52 #else /* CONFIG_ARM64_MTE */
54 /* unused if !CONFIG_ARM64_MTE, silence the compiler */
55 #define PG_mte_tagged 0
57 static inline void mte_sync_tags(pte_t *ptep, pte_t pte)
60 static inline void mte_copy_page_tags(void *kto, const void *kfrom)
63 static inline void flush_mte_state(void)
66 static inline void mte_thread_switch(struct task_struct *next)
69 static inline void mte_suspend_exit(void)
72 static inline long set_mte_ctrl(struct task_struct *task, unsigned long arg)
76 static inline long get_mte_ctrl(struct task_struct *task)
80 static inline int mte_ptrace_copy_tags(struct task_struct *child,
81 long request, unsigned long addr,
87 static inline void mte_assign_mem_tag_range(void *addr, size_t size)
91 #endif /* CONFIG_ARM64_MTE */
93 #endif /* __ASSEMBLY__ */
94 #endif /* __ASM_MTE_H */