From 2627d4df5500bfc454d8e6c4b86067e91843aa1c Mon Sep 17 00:00:00 2001 From: Tomoki Shirasawa Date: Sun, 2 Jun 2013 13:57:44 +0900 Subject: [PATCH] add PTATTR_FOR_USER flag to enum ihk_mc_ap_flag --- arch/x86/kernel/include/arch-memory.h | 1 + arch/x86/kernel/memory.c | 3 ++- kernel/host.c | 12 ++++++------ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/include/arch-memory.h b/arch/x86/kernel/include/arch-memory.h index 9bbee81e..dca1abba 100644 --- a/arch/x86/kernel/include/arch-memory.h +++ b/arch/x86/kernel/include/arch-memory.h @@ -91,6 +91,7 @@ enum ihk_mc_pt_attribute { PTATTR_USER = 0x04, PTATTR_LARGEPAGE = 0x80, PTATTR_UNCACHABLE = 0x10000, + PTATTR_FOR_USER = 0x20000, }; typedef unsigned long pte_t; diff --git a/arch/x86/kernel/memory.c b/arch/x86/kernel/memory.c index 34d20626..6bbe43cc 100644 --- a/arch/x86/kernel/memory.c +++ b/arch/x86/kernel/memory.c @@ -302,7 +302,8 @@ static int __set_pt_page(struct page_table *pt, void *virt, unsigned long phys, struct page_table *newpt; enum ihk_mc_ap_flag ap_flag; - ap_flag = attr & PTATTR_USER? IHK_MC_AP_NOWAIT: IHK_MC_AP_CRITICAL; + ap_flag = (attr & (PTATTR_USER | PTATTR_FOR_USER)) ? + IHK_MC_AP_NOWAIT: IHK_MC_AP_CRITICAL; if (!pt) { pt = init_pt; diff --git a/kernel/host.c b/kernel/host.c index 41323255..0d703e5a 100644 --- a/kernel/host.c +++ b/kernel/host.c @@ -53,7 +53,7 @@ static int process_msg_prepare_process(unsigned long rphys) 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)) == NULL){ + if((p = ihk_mc_map_virtual(phys, npages, PTATTR_WRITABLE | PTATTR_FOR_USER)) == NULL){ ihk_mc_unmap_memory(NULL, phys, sz); return -ENOMEM; } @@ -243,7 +243,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)) == NULL){ + PTATTR_WRITABLE | PTATTR_FOR_USER)) == NULL){ goto err; } dkprintf("args_envs_r: 0x%lX\n", args_envs_r); @@ -263,7 +263,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)) == NULL){ + PTATTR_WRITABLE | PTATTR_FOR_USER)) == NULL){ goto err; } dkprintf("args_envs_r: 0x%lX\n", args_envs_r); @@ -349,7 +349,7 @@ static void process_msg_init_acked(unsigned long pphys) REQUEST_PAGE_COUNT * PAGE_SIZE); if((lparam->request_va = ihk_mc_map_virtual(lparam->request_pa, REQUEST_PAGE_COUNT, - PTATTR_WRITABLE)) == NULL){ + PTATTR_WRITABLE | PTATTR_FOR_USER)) == NULL){ // TODO: panic("ENOMEM"); } @@ -360,7 +360,7 @@ static void process_msg_init_acked(unsigned long pphys) PAGE_SIZE); if((lparam->doorbell_va = ihk_mc_map_virtual(lparam->doorbell_pa, DOORBELL_PAGE_COUNT, - PTATTR_WRITABLE)) == NULL){ + PTATTR_WRITABLE | PTATTR_FOR_USER)) == NULL){ // TODO: panic("ENOMEM"); } @@ -369,7 +369,7 @@ static void process_msg_init_acked(unsigned long pphys) 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)) == NULL){ + PTATTR_WRITABLE | PTATTR_FOR_USER)) == NULL){ // TODO: panic("ENOMEM"); }