From 05a944e050bb34d3d798f6c48f32e6d376190a78 Mon Sep 17 00:00:00 2001 From: Wang Wensheng Date: Thu, 30 Dec 2021 16:26:59 +0800 Subject: [PATCH] share_pool: Add VM_SHARE_POOL flag for vm_area_struct ascend inclusion category: Feature bugzilla: https://gitee.com/openeuler/kernel/issues/I4NDAW CVE: NA ------------------- This flag specify that the vm_area_struct is related to share_pool (in detail, has a spa corresponding to it). Signed-off-by: Wang Wensheng Signed-off-by: Tang Yizhou Reviewed-by: Kefeng Wang Reviewed-by: Weilong Chen Signed-off-by: Zheng Zengkai --- include/linux/mm.h | 6 ++++++ include/linux/share_pool.h | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index a4996e11cda6..e2eb3ea63d6a 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -378,6 +378,12 @@ extern unsigned int kobjsize(const void *objp); # define VM_MTE_ALLOWED VM_NONE #endif +#if defined(CONFIG_ASCEND_SHARE_POOL) +# define VM_SHARE_POOL VM_HIGH_ARCH_4 +#else +# define VM_SHARE_POOL VM_NONE +#endif + #ifndef VM_GROWSUP # define VM_GROWSUP VM_NONE #endif diff --git a/include/linux/share_pool.h b/include/linux/share_pool.h index 3a56238c8a4d..c39780ab5a87 100644 --- a/include/linux/share_pool.h +++ b/include/linux/share_pool.h @@ -272,6 +272,14 @@ static inline void sp_area_work_around(struct vm_unmapped_area_info *info, info->high_limit = min(info->high_limit, MMAP_SHARE_POOL_START); } +static inline bool sp_check_vm_share_pool(unsigned long vm_flags) +{ + if (sp_is_enabled() && (vm_flags & VM_SHARE_POOL)) + return true; + + return false; +} + #else /* CONFIG_ASCEND_SHARE_POOL */ static inline int mg_sp_group_add_task(int pid, unsigned long prot, int spg_id) -- GitLab