rewrite sys_mmap() as sys_new_mmap()

This commit is contained in:
NAKAMURA Gou
2013-07-10 13:08:14 +09:00
parent dae884d572
commit 2aa5194958
10 changed files with 651 additions and 195 deletions

View File

@@ -9,6 +9,7 @@
#include <cls.h>
#include <process.h>
#include <page.h>
#include <mman.h>
//#define DEBUG_PRINT_HOST
@@ -47,6 +48,7 @@ static int process_msg_prepare_process(unsigned long rphys)
char **env;
int range_npages;
void *up_v;
unsigned long flags;
sz = sizeof(struct program_load_desc)
+ sizeof(struct program_image_section) * 16;
@@ -88,12 +90,14 @@ static int process_msg_prepare_process(unsigned long rphys)
e = (pn->sections[i].vaddr + pn->sections[i].len
+ PAGE_SIZE - 1) & PAGE_MASK;
range_npages = (e - s) >> PAGE_SHIFT;
flags = VR_NONE;
flags |= PROT_TO_VR_FLAG(pn->sections[i].prot);
if((up_v = ihk_mc_alloc_pages(range_npages, IHK_MC_AP_NOWAIT)) == NULL){
goto err;
}
up = virt_to_phys(up_v);
if(add_process_memory_range(proc, s, e, up, VR_NONE) != 0){
if(add_process_memory_range(proc, s, e, up, flags) != 0){
ihk_mc_free_pages(up_v, range_npages);
goto err;
}
@@ -163,25 +167,26 @@ static int process_msg_prepare_process(unsigned long rphys)
(USER_END / 3) & LARGE_PAGE_MASK;
/* Map system call stuffs */
flags = VR_RESERVED | VR_PROT_READ | VR_PROT_WRITE;
addr = proc->vm->region.map_start - PAGE_SIZE * SCD_RESERVED_COUNT;
e = addr + PAGE_SIZE * DOORBELL_PAGE_COUNT;
if(add_process_memory_range(proc, addr, e,
cpu_local_var(scp).doorbell_pa,
VR_REMOTE | VR_RESERVED) != 0){
VR_REMOTE | flags) != 0){
goto err;
}
addr = e;
e = addr + PAGE_SIZE * REQUEST_PAGE_COUNT;
if(add_process_memory_range(proc, addr, e,
cpu_local_var(scp).request_pa,
VR_REMOTE | VR_RESERVED) != 0){
VR_REMOTE | flags) != 0){
goto err;
}
addr = e;
e = addr + PAGE_SIZE * RESPONSE_PAGE_COUNT;
if(add_process_memory_range(proc, addr, e,
cpu_local_var(scp).response_pa,
VR_RESERVED) != 0){
flags) != 0){
goto err;
}
@@ -194,7 +199,8 @@ static int process_msg_prepare_process(unsigned long rphys)
}
args_envs_p = virt_to_phys(args_envs);
if(add_process_memory_range(proc, addr, e, args_envs_p, VR_NONE) != 0){
if(add_process_memory_range(proc, addr, e, args_envs_p,
VR_PROT_READ|VR_PROT_WRITE) != 0){
ihk_mc_free_pages(args_envs, ARGENV_PAGE_COUNT);
goto err;
}