create demand-paging mapping in case of MAP_SHARED

On current McKernel, only mappings for demand paging can be shared.
Therefore, if MAP_SHARED and MAP_ANONYMOUS are specified and
anon_on_demand is disabled, then mmap(2) should create a mapping which
is for demand paging and is entirely populated with physical pages.
This commit is contained in:
NAKAMURA Gou
2015-09-16 20:32:06 +09:00
parent b1b706453f
commit 7dfeb8e7ce

View File

@ -988,6 +988,7 @@ SYSCALL_DECLARE(mmap)
int denied;
int ro_vma_mapped = 0;
struct shmid_ds ads;
int populated_mapping = 0;
dkprintf("[%d]sys_mmap(%lx,%lx,%x,%x,%d,%lx)\n",
ihk_mc_get_processor_id(),
@ -1078,8 +1079,9 @@ SYSCALL_DECLARE(mmap)
}
#endif
else {
if (anon_on_demand) {
vrflags |= VR_DEMAND_PAGING;
vrflags |= VR_DEMAND_PAGING;
if (!anon_on_demand) {
populated_mapping = 1;
}
}
}
@ -1087,6 +1089,10 @@ SYSCALL_DECLARE(mmap)
vrflags |= VR_DEMAND_PAGING;
}
if (flags & (MAP_POPULATE | MAP_LOCKED)) {
populated_mapping = 1;
}
if (!(prot & PROT_WRITE)) {
error = set_host_vma(addr, len, PROT_READ);
if (error) {
@ -1202,7 +1208,7 @@ out:
}
ihk_mc_spinlock_unlock_noirq(&proc->vm->memory_range_lock);
if (!error && (flags & (MAP_POPULATE) || flags & (MAP_LOCKED))) {
if (!error && populated_mapping) {
error = populate_process_memory(proc, (void *)addr, len);
if (error) {
ekprintf("sys_mmap:populate_process_memory"