2019-09-16 10:51:17 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2020 ARM Ltd.
|
|
|
|
*/
|
|
|
|
#ifndef __ASM_MTE_H
|
|
|
|
#define __ASM_MTE_H
|
|
|
|
|
2020-03-30 09:29:38 +00:00
|
|
|
#define MTE_GRANULE_SIZE UL(16)
|
|
|
|
#define MTE_GRANULE_MASK (~(MTE_GRANULE_SIZE - 1))
|
|
|
|
#define MTE_TAG_SHIFT 56
|
|
|
|
#define MTE_TAG_SIZE 4
|
|
|
|
|
2019-09-16 10:51:17 +00:00
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
|
2020-05-04 13:42:36 +00:00
|
|
|
#include <linux/page-flags.h>
|
|
|
|
|
|
|
|
#include <asm/pgtable-types.h>
|
|
|
|
|
|
|
|
void mte_clear_page_tags(void *addr);
|
2020-03-30 09:29:38 +00:00
|
|
|
unsigned long mte_copy_tags_from_user(void *to, const void __user *from,
|
|
|
|
unsigned long n);
|
|
|
|
unsigned long mte_copy_tags_to_user(void __user *to, void *from,
|
|
|
|
unsigned long n);
|
2020-05-13 15:37:50 +00:00
|
|
|
int mte_save_tags(struct page *page);
|
|
|
|
void mte_save_page_tags(const void *page_addr, void *tag_storage);
|
|
|
|
bool mte_restore_tags(swp_entry_t entry, struct page *page);
|
|
|
|
void mte_restore_page_tags(void *page_addr, const void *tag_storage);
|
|
|
|
void mte_invalidate_tags(int type, pgoff_t offset);
|
|
|
|
void mte_invalidate_tags_area(int type);
|
|
|
|
void *mte_allocate_tag_storage(void);
|
|
|
|
void mte_free_tag_storage(char *storage);
|
2020-05-04 13:42:36 +00:00
|
|
|
|
2019-09-16 10:51:17 +00:00
|
|
|
#ifdef CONFIG_ARM64_MTE
|
|
|
|
|
2020-05-04 13:42:36 +00:00
|
|
|
/* track which pages have valid allocation tags */
|
|
|
|
#define PG_mte_tagged PG_arch_2
|
|
|
|
|
|
|
|
void mte_sync_tags(pte_t *ptep, pte_t pte);
|
2019-08-06 10:37:53 +00:00
|
|
|
void mte_copy_page_tags(void *kto, const void *kfrom);
|
2019-09-16 10:51:17 +00:00
|
|
|
void flush_mte_state(void);
|
2019-11-27 10:30:15 +00:00
|
|
|
void mte_thread_switch(struct task_struct *next);
|
2020-04-17 17:29:35 +00:00
|
|
|
void mte_suspend_exit(void);
|
2020-07-03 13:25:50 +00:00
|
|
|
long set_mte_ctrl(struct task_struct *task, unsigned long arg);
|
|
|
|
long get_mte_ctrl(struct task_struct *task);
|
2020-03-30 09:29:38 +00:00
|
|
|
int mte_ptrace_copy_tags(struct task_struct *child, long request,
|
|
|
|
unsigned long addr, unsigned long data);
|
2019-09-16 10:51:17 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2020-05-04 13:42:36 +00:00
|
|
|
/* unused if !CONFIG_ARM64_MTE, silence the compiler */
|
|
|
|
#define PG_mte_tagged 0
|
|
|
|
|
|
|
|
static inline void mte_sync_tags(pte_t *ptep, pte_t pte)
|
|
|
|
{
|
|
|
|
}
|
2019-08-06 10:37:53 +00:00
|
|
|
static inline void mte_copy_page_tags(void *kto, const void *kfrom)
|
|
|
|
{
|
|
|
|
}
|
2019-09-16 10:51:17 +00:00
|
|
|
static inline void flush_mte_state(void)
|
|
|
|
{
|
|
|
|
}
|
2019-11-27 10:30:15 +00:00
|
|
|
static inline void mte_thread_switch(struct task_struct *next)
|
|
|
|
{
|
|
|
|
}
|
2020-04-17 17:29:35 +00:00
|
|
|
static inline void mte_suspend_exit(void)
|
|
|
|
{
|
|
|
|
}
|
2020-07-03 13:25:50 +00:00
|
|
|
static inline long set_mte_ctrl(struct task_struct *task, unsigned long arg)
|
2019-11-27 10:30:15 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2020-07-03 13:25:50 +00:00
|
|
|
static inline long get_mte_ctrl(struct task_struct *task)
|
2019-11-27 10:30:15 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2020-03-30 09:29:38 +00:00
|
|
|
static inline int mte_ptrace_copy_tags(struct task_struct *child,
|
|
|
|
long request, unsigned long addr,
|
|
|
|
unsigned long data)
|
|
|
|
{
|
|
|
|
return -EIO;
|
|
|
|
}
|
2019-09-16 10:51:17 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
#endif /* __ASM_MTE_H */
|