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