提交 561d77b6 编写于 作者: Z Zhou Guanghui 提交者: Zheng Zengkai

mm/sharepool: Add an interface to obtain an id

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5DS9S
CVE: NA

-------------------------------------------------

The DVPP address space is per process or per sharing group.
During sp_free and unshare, you need to know which address
space the current address belongs to.
Signed-off-by: NZhou Guanghui <zhouguanghui1@huawei.com>
Reviewed-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 85d9c2fe
......@@ -284,6 +284,9 @@ extern bool mg_is_sharepool_addr(unsigned long addr);
extern int mg_sp_group_add_task(int pid, unsigned long prot, int spg_id);
extern int sp_group_add_task(int pid, int spg_id);
extern int sp_id_of_current(void);
extern int mg_sp_id_of_current(void);
extern void sp_area_drop(struct vm_area_struct *vma);
extern int sp_group_exit(struct mm_struct *mm);
extern void sp_group_post_exit(struct mm_struct *mm);
......@@ -431,6 +434,15 @@ static inline int mg_sp_unshare(unsigned long va, unsigned long size)
return -EPERM;
}
static inline int sp_id_of_current(void)
{
return -EPERM;
}
static inline int mg_sp_id_of_current(void)
{
return -EPERM;
}
static inline void sp_init_mm(struct mm_struct *mm)
{
......
......@@ -1734,6 +1734,43 @@ int sp_group_del_task(int pid, int spg_id)
}
EXPORT_SYMBOL_GPL(sp_group_del_task);
int sp_id_of_current(void)
{
int ret, spg_id;
struct sp_group_master *master;
if (current->flags & PF_KTHREAD || !current->mm)
return -EINVAL;
down_read(&sp_group_sem);
master = current->mm->sp_group_master;
if (master && master->local) {
spg_id = master->local->id;
up_read(&sp_group_sem);
return spg_id;
}
up_read(&sp_group_sem);
down_write(&sp_group_sem);
ret = sp_mapping_group_setup_local(current->mm);
if (ret) {
up_write(&sp_group_sem);
return ret;
}
master = current->mm->sp_group_master;
spg_id = master->local->id;
up_write(&sp_group_sem);
return spg_id;
}
EXPORT_SYMBOL_GPL(sp_id_of_current);
int mg_sp_id_of_current(void)
{
return sp_id_of_current();
}
EXPORT_SYMBOL_GPL(mg_sp_id_of_current);
/* the caller must hold sp_area_lock */
static void __insert_sp_area(struct sp_area *spa)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册