ascend inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I931MI CVE: NA
-----------------------------------------------------------------
svsp_mm may still be used by hardware(aicore/dvpp) after process is gone, same as normal mm, thus release should happen when normal mm is actually released.
Signed-off-by: Yuan Can yuancan@huawei.com --- include/linux/mm_types.h | 3 +++ kernel/fork.c | 12 ++++++++++++ 2 files changed, 15 insertions(+)
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 4e22c878309a..5c04fddc8621 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -950,6 +950,9 @@ struct mm_struct { #endif #if IS_ENABLED(CONFIG_ETMEM) && IS_ENABLED(CONFIG_KVM) struct kvm *kvm; +#endif +#if defined(CONFIG_ASCEND_SVSP) + struct mm_struct *svsp_mm; #endif } __randomize_layout;
diff --git a/kernel/fork.c b/kernel/fork.c index 735bc670b49e..af283cec3444 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1322,6 +1322,10 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p, mm_init_uprobes_state(mm); hugetlb_count_init(mm);
+#ifdef CONFIG_ASCEND_SVSP + mm->svsp_mm = NULL; +#endif + if (current->mm) { mm->flags = mmf_init_flags(current->mm->flags); mm->def_flags = current->mm->def_flags & VM_INIT_DEF_MASK; @@ -1379,6 +1383,14 @@ static inline void __mmput(struct mm_struct *mm) { VM_BUG_ON(atomic_read(&mm->mm_users));
+#ifdef CONFIG_ASCEND_SVSP + if (mm->svsp_mm) { + exit_mmap(mm->svsp_mm); + mmdrop(mm->svsp_mm); + mm->svsp_mm = NULL; + } +#endif + uprobe_clear_state(mm); exit_aio(mm); ksm_exit(mm);