From 3f26e44f85ffd3d912bcff78b51552021278de88 Mon Sep 17 00:00:00 2001 From: Masamichi Takagi Date: Thu, 7 Jun 2018 13:29:35 +0900 Subject: [PATCH] mremap: Don't premap destination vm_range mremap works in the following steps: (1) Unmap the destination memory area (2) Create a new vm_range with add_process_memory_range (3) Move the PTEs of the source range to the destination range by using move_pte_range The problem is that step (3) expects the destination doesn't have any physical pages, but step (2) premaps the destination when the optimization of premapping anonymous map is turned on. Change-Id: Ieeebd799b7169b9a6f6f658c204c31f49817030f --- kernel/syscall.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/syscall.c b/kernel/syscall.c index 74288851..60e41b57 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -7966,8 +7966,10 @@ if (!strcmp("./lammps", thread->proc->saved_cmdline)) if (range->memobj) { memobj_ref(range->memobj); } + + /* Drop VR_PREALLOC to create vm_range without physical pages */ error = add_process_memory_range(thread->vm, newstart, newend, -1, - range->flag, range->memobj, + range->flag & ~VR_PREALLOC, range->memobj, range->objoff + (oldstart - range->start), range->pgshift, NULL); if (error) {