1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2020 ARM Ltd.
8 #define MTE_GRANULE_SIZE UL(16)
9 #define MTE_GRANULE_MASK (~(MTE_GRANULE_SIZE - 1))
10 #define MTE_TAG_SHIFT 56
11 #define MTE_TAG_SIZE 4
15 #include <linux/page-flags.h>
17 #include <asm/pgtable-types.h>
19 void mte_clear_page_tags(void *addr);
20 unsigned long mte_copy_tags_from_user(void *to, const void __user *from,
22 unsigned long mte_copy_tags_to_user(void __user *to, void *from,
24 int mte_save_tags(struct page *page);
25 void mte_save_page_tags(const void *page_addr, void *tag_storage);
26 bool mte_restore_tags(swp_entry_t entry, struct page *page);
27 void mte_restore_page_tags(void *page_addr, const void *tag_storage);
28 void mte_invalidate_tags(int type, pgoff_t offset);
29 void mte_invalidate_tags_area(int type);
30 void *mte_allocate_tag_storage(void);
31 void mte_free_tag_storage(char *storage);
33 #ifdef CONFIG_ARM64_MTE
35 /* track which pages have valid allocation tags */
36 #define PG_mte_tagged PG_arch_2
38 void mte_sync_tags(pte_t *ptep, pte_t pte);
39 void mte_copy_page_tags(void *kto, const void *kfrom);
40 void flush_mte_state(void);
41 void mte_thread_switch(struct task_struct *next);
42 void mte_suspend_exit(void);
43 long set_mte_ctrl(struct task_struct *task, unsigned long arg);
44 long get_mte_ctrl(struct task_struct *task);
45 int mte_ptrace_copy_tags(struct task_struct *child, long request,
46 unsigned long addr, unsigned long data);
50 /* unused if !CONFIG_ARM64_MTE, silence the compiler */
51 #define PG_mte_tagged 0
53 static inline void mte_sync_tags(pte_t *ptep, pte_t pte)
56 static inline void mte_copy_page_tags(void *kto, const void *kfrom)
59 static inline void flush_mte_state(void)
62 static inline void mte_thread_switch(struct task_struct *next)
65 static inline void mte_suspend_exit(void)
68 static inline long set_mte_ctrl(struct task_struct *task, unsigned long arg)
72 static inline long get_mte_ctrl(struct task_struct *task)
76 static inline int mte_ptrace_copy_tags(struct task_struct *child,
77 long request, unsigned long addr,
85 #endif /* __ASSEMBLY__ */
86 #endif /* __ASM_MTE_H */