From: Johannes Berg <johannes.b...@intel.com> The reason to flush here is to resynchronize the mm after a copy. For exec we don't need to since flush_thread() will anyway clear everything.
Thus, we can just do this in arch_dup_mmap(), since when that's invoked, the new mm has been setup sufficiently. This isn't true if we just flush in init_new_context(). Signed-off-by: Johannes Berg <johannes.b...@intel.com> --- arch/um/include/asm/Kbuild | 1 - arch/um/include/asm/mm_hooks.h | 22 ++++++++++++++++++++++ arch/um/include/asm/mmu_context.h | 2 +- arch/um/kernel/process.c | 2 -- arch/um/kernel/skas/mmu.c | 7 +++++++ arch/um/kernel/tlb.c | 5 +---- 6 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 arch/um/include/asm/mm_hooks.h diff --git a/arch/um/include/asm/Kbuild b/arch/um/include/asm/Kbuild index b2d834a29f3a..de8d82a6fd7b 100644 --- a/arch/um/include/asm/Kbuild +++ b/arch/um/include/asm/Kbuild @@ -26,5 +26,4 @@ generic-y += switch_to.h generic-y += topology.h generic-y += trace_clock.h generic-y += kprobes.h -generic-y += mm_hooks.h generic-y += vga.h diff --git a/arch/um/include/asm/mm_hooks.h b/arch/um/include/asm/mm_hooks.h new file mode 100644 index 000000000000..b1016520c5b8 --- /dev/null +++ b/arch/um/include/asm/mm_hooks.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_UM_MM_HOOKS_H +#define _ASM_UM_MM_HOOKS_H + +int arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm); + +static inline void arch_exit_mmap(struct mm_struct *mm) +{ +} + +static inline void arch_unmap(struct mm_struct *mm, + unsigned long start, unsigned long end) +{ +} + +static inline bool arch_vma_access_permitted(struct vm_area_struct *vma, + bool write, bool execute, bool foreign) +{ + /* by default, allow everything */ + return true; +} +#endif /* _ASM_UM_MM_HOOKS_H */ diff --git a/arch/um/include/asm/mmu_context.h b/arch/um/include/asm/mmu_context.h index 68e2eb9cfb47..8668861d4a85 100644 --- a/arch/um/include/asm/mmu_context.h +++ b/arch/um/include/asm/mmu_context.h @@ -13,7 +13,7 @@ #include <asm/mm_hooks.h> #include <asm/mmu.h> -extern void force_flush_all(void); +void force_flush_all(struct mm_struct *mm); #define activate_mm activate_mm static inline void activate_mm(struct mm_struct *old, struct mm_struct *new) diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c index 6daffb9d8a8d..d7545ba6522a 100644 --- a/arch/um/kernel/process.c +++ b/arch/um/kernel/process.c @@ -139,8 +139,6 @@ void new_thread_handler(void) /* Called magically, see new_thread_handler above */ void fork_handler(void) { - force_flush_all(); - schedule_tail(current->thread.prev_sched); /* diff --git a/arch/um/kernel/skas/mmu.c b/arch/um/kernel/skas/mmu.c index ea0c37b92581..97e731180f70 100644 --- a/arch/um/kernel/skas/mmu.c +++ b/arch/um/kernel/skas/mmu.c @@ -10,6 +10,7 @@ #include <asm/pgalloc.h> #include <asm/sections.h> +#include <asm/mmu_context.h> #include <as-layout.h> #include <os.h> #include <skas.h> @@ -69,6 +70,12 @@ int init_new_context(struct task_struct *task, struct mm_struct *mm) return ret; } +int arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm) +{ + force_flush_all(mm); + return 0; +} + void destroy_context(struct mm_struct *mm) { struct mm_context *mmu = &mm->context; diff --git a/arch/um/kernel/tlb.c b/arch/um/kernel/tlb.c index 34ec8e677fb9..7c0161321fd9 100644 --- a/arch/um/kernel/tlb.c +++ b/arch/um/kernel/tlb.c @@ -600,14 +600,11 @@ void flush_tlb_mm(struct mm_struct *mm) fix_range(mm, vma->vm_start, vma->vm_end, 0); } -void force_flush_all(void) +void force_flush_all(struct mm_struct *mm) { - struct mm_struct *mm = current->mm; struct vm_area_struct *vma; VMA_ITERATOR(vmi, mm, 0); - mmap_read_lock(mm); for_each_vma(vmi, vma) fix_range(mm, vma->vm_start, vma->vm_end, 1); - mmap_read_unlock(mm); } -- 2.41.0 _______________________________________________ linux-um mailing list linux-um@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-um