Merge branch 'master' of postpeta.pccluster.org:mckernel
This commit is contained in:
@@ -69,13 +69,16 @@ static int process_msg_prepare_process(unsigned long rphys)
|
||||
unsigned long flags;
|
||||
uintptr_t interp_obase = -1;
|
||||
uintptr_t interp_nbase = -1;
|
||||
enum ihk_mc_pt_attribute attr;
|
||||
|
||||
attr = PTATTR_NO_EXECUTE | PTATTR_WRITABLE | PTATTR_FOR_USER;
|
||||
|
||||
sz = sizeof(struct program_load_desc)
|
||||
+ sizeof(struct program_image_section) * 16;
|
||||
npages = ((rphys + sz - 1) >> PAGE_SHIFT) - (rphys >> PAGE_SHIFT) + 1;
|
||||
|
||||
phys = ihk_mc_map_memory(NULL, rphys, sz);
|
||||
if((p = ihk_mc_map_virtual(phys, npages, PTATTR_WRITABLE | PTATTR_FOR_USER)) == NULL){
|
||||
if((p = ihk_mc_map_virtual(phys, npages, attr)) == NULL){
|
||||
ihk_mc_unmap_memory(NULL, phys, sz);
|
||||
return -ENOMEM;
|
||||
}
|
||||
@@ -264,7 +267,7 @@ static int process_msg_prepare_process(unsigned long rphys)
|
||||
args_envs_rp = ihk_mc_map_memory(NULL, (unsigned long)p->args, p->args_len);
|
||||
dkprintf("args_envs_rp: 0x%lX\n", args_envs_rp);
|
||||
if((args_envs_r = (char *)ihk_mc_map_virtual(args_envs_rp, args_envs_npages,
|
||||
PTATTR_WRITABLE | PTATTR_FOR_USER)) == NULL){
|
||||
attr)) == NULL){
|
||||
goto err;
|
||||
}
|
||||
dkprintf("args_envs_r: 0x%lX\n", args_envs_r);
|
||||
@@ -285,7 +288,7 @@ static int process_msg_prepare_process(unsigned long rphys)
|
||||
args_envs_rp = ihk_mc_map_memory(NULL, (unsigned long)p->envs, p->envs_len);
|
||||
dkprintf("args_envs_rp: 0x%lX\n", args_envs_rp);
|
||||
if((args_envs_r = (char *)ihk_mc_map_virtual(args_envs_rp, args_envs_npages,
|
||||
PTATTR_WRITABLE | PTATTR_FOR_USER)) == NULL){
|
||||
attr)) == NULL){
|
||||
goto err;
|
||||
}
|
||||
dkprintf("args_envs_r: 0x%lX\n", args_envs_r);
|
||||
@@ -363,6 +366,9 @@ static void process_msg_init_acked(struct ihk_ikc_channel_desc *c, unsigned long
|
||||
{
|
||||
struct ikc_scd_init_param *param = (void *)pphys;
|
||||
struct syscall_params *lparam;
|
||||
enum ihk_mc_pt_attribute attr;
|
||||
|
||||
attr = PTATTR_NO_EXECUTE | PTATTR_WRITABLE | PTATTR_FOR_USER;
|
||||
|
||||
lparam = &cpu_local_var(scp);
|
||||
if(cpu_local_var(syscall_channel2) == c)
|
||||
@@ -372,7 +378,7 @@ static void process_msg_init_acked(struct ihk_ikc_channel_desc *c, unsigned long
|
||||
REQUEST_PAGE_COUNT * PAGE_SIZE);
|
||||
if((lparam->request_va = ihk_mc_map_virtual(lparam->request_pa,
|
||||
REQUEST_PAGE_COUNT,
|
||||
PTATTR_WRITABLE | PTATTR_FOR_USER)) == NULL){
|
||||
attr)) == NULL){
|
||||
// TODO:
|
||||
panic("ENOMEM");
|
||||
}
|
||||
@@ -383,7 +389,7 @@ static void process_msg_init_acked(struct ihk_ikc_channel_desc *c, unsigned long
|
||||
PAGE_SIZE);
|
||||
if((lparam->doorbell_va = ihk_mc_map_virtual(lparam->doorbell_pa,
|
||||
DOORBELL_PAGE_COUNT,
|
||||
PTATTR_WRITABLE | PTATTR_FOR_USER)) == NULL){
|
||||
attr)) == NULL){
|
||||
// TODO:
|
||||
panic("ENOMEM");
|
||||
}
|
||||
@@ -392,7 +398,7 @@ static void process_msg_init_acked(struct ihk_ikc_channel_desc *c, unsigned long
|
||||
lparam->post_pa = ihk_mc_map_memory(NULL, param->post_page,
|
||||
PAGE_SIZE);
|
||||
if((lparam->post_va = ihk_mc_map_virtual(lparam->post_pa, 1,
|
||||
PTATTR_WRITABLE | PTATTR_FOR_USER)) == NULL){
|
||||
attr)) == NULL){
|
||||
// TODO:
|
||||
panic("ENOMEM");
|
||||
}
|
||||
|
||||
@@ -109,6 +109,7 @@ struct program_load_desc {
|
||||
int cpu;
|
||||
int pid;
|
||||
int err;
|
||||
int stack_prot;
|
||||
unsigned long entry;
|
||||
unsigned long user_start;
|
||||
unsigned long user_end;
|
||||
|
||||
@@ -347,6 +347,7 @@ int update_process_page_table(struct process *process,
|
||||
|
||||
attr = flag | PTATTR_USER | PTATTR_FOR_USER;
|
||||
attr |= (range->flag & VR_PROT_WRITE)? PTATTR_WRITABLE: 0;
|
||||
attr |= (range->flag & VR_PROT_EXEC)? 0: PTATTR_NO_EXECUTE;
|
||||
|
||||
p = range->start;
|
||||
while (p < range->end) {
|
||||
@@ -689,6 +690,10 @@ enum ihk_mc_pt_attribute vrflag_to_ptattr(unsigned long flag)
|
||||
attr |= PTATTR_WRITABLE;
|
||||
}
|
||||
|
||||
if (!(flag & VR_PROT_EXEC)) {
|
||||
attr |= PTATTR_NO_EXECUTE;
|
||||
}
|
||||
|
||||
return attr;
|
||||
}
|
||||
|
||||
@@ -1197,7 +1202,9 @@ static int do_page_fault_process(struct process *proc, void *fault_addr0, uint64
|
||||
|
||||
if (((range->flag & VR_PROT_MASK) == VR_PROT_NONE)
|
||||
|| ((reason & PF_WRITE)
|
||||
&& !(range->flag & VR_PROT_WRITE))) {
|
||||
&& !(range->flag & VR_PROT_WRITE))
|
||||
|| ((reason & PF_INSTR)
|
||||
&& !(range->flag & VR_PROT_EXEC))) {
|
||||
error = -EFAULT;
|
||||
kprintf("[%d]do_page_fault_process(%p,%lx,%lx):"
|
||||
"access denied. %d\n",
|
||||
@@ -1325,8 +1332,8 @@ int init_process_stack(struct process *process, struct program_load_desc *pn,
|
||||
start = end - size;
|
||||
|
||||
vrflag = VR_STACK | VR_DEMAND_PAGING;
|
||||
vrflag |= VR_PROT_READ | VR_PROT_WRITE | VR_PROT_EXEC;
|
||||
vrflag |= VRFLAG_PROT_TO_MAXPROT(vrflag);
|
||||
vrflag |= PROT_TO_VR_FLAG(pn->stack_prot);
|
||||
vrflag |= VR_MAXPROT_READ | VR_MAXPROT_WRITE | VR_MAXPROT_EXEC;
|
||||
#define NOPHYS ((uintptr_t)-1)
|
||||
if ((rc = add_process_memory_range(process, start, end, NOPHYS,
|
||||
vrflag, NULL, 0)) != 0) {
|
||||
|
||||
Reference in New Issue
Block a user