From 96f02a1d08437c5963a457a1cda5a13351d66d4e Mon Sep 17 00:00:00 2001 From: NAKAMURA Gou Date: Wed, 19 Jun 2013 11:39:38 +0900 Subject: [PATCH] delete the access restrictions of whole page table. access restrictions will be set on individual pages. --- arch/x86/kernel/include/arch-memory.h | 5 +++++ arch/x86/kernel/memory.c | 17 +++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/arch/x86/kernel/include/arch-memory.h b/arch/x86/kernel/include/arch-memory.h index dca1abba..a1c9196c 100644 --- a/arch/x86/kernel/include/arch-memory.h +++ b/arch/x86/kernel/include/arch-memory.h @@ -84,6 +84,11 @@ #define PFL2_KERN_ATTR (PFL2_PRESENT | PFL2_WRITABLE) #define PFL1_KERN_ATTR (PFL1_PRESENT | PFL1_WRITABLE) +/* for the page table entry that points another page table */ +#define PFL4_PDIR_ATTR (PFL4_PRESENT | PFL4_WRITABLE | PFL4_USER) +#define PFL3_PDIR_ATTR (PFL3_PRESENT | PFL3_WRITABLE | PFL3_USER) +#define PFL2_PDIR_ATTR (PFL2_PRESENT | PFL2_WRITABLE | PFL2_USER) + /* For easy conversion, it is better to be the same as architecture's ones */ enum ihk_mc_pt_attribute { PTATTR_ACTIVE = 0x01, diff --git a/arch/x86/kernel/memory.c b/arch/x86/kernel/memory.c index 4ecbb67f..50419478 100644 --- a/arch/x86/kernel/memory.c +++ b/arch/x86/kernel/memory.c @@ -135,7 +135,7 @@ static unsigned long setup_l3(struct page_table *pt, } pt_phys = setup_l2(arch_alloc_page(IHK_MC_AP_CRITICAL), phys, start, end); - pt->entry[i] = pt_phys | PFL3_KERN_ATTR; + pt->entry[i] = pt_phys | PFL3_PDIR_ATTR; } return virt_to_phys(pt); @@ -160,8 +160,8 @@ static void init_normal_area(struct page_table *pt) pt_phys = setup_l3(arch_alloc_page(IHK_MC_AP_CRITICAL), phys, map_start, map_end); - pt->entry[ident_index++] = pt_phys | PFL4_KERN_ATTR; - pt->entry[virt_index++] = pt_phys | PFL4_KERN_ATTR; + pt->entry[ident_index++] = pt_phys | PFL4_PDIR_ATTR; + pt->entry[virt_index++] = pt_phys | PFL4_PDIR_ATTR; } } @@ -181,6 +181,7 @@ static struct page_table *__alloc_new_pt(enum ihk_mc_ap_flag ap_flag) */ #define ATTR_MASK (PTATTR_WRITABLE | PTATTR_USER | PTATTR_ACTIVE) +#if 0 static unsigned long attr_to_l4attr(enum ihk_mc_pt_attribute attr) { return (attr & ATTR_MASK) | PFL4_PRESENT; @@ -189,6 +190,7 @@ static unsigned long attr_to_l3attr(enum ihk_mc_pt_attribute attr) { return (attr & ATTR_MASK) | PFL3_PRESENT; } +#endif static unsigned long attr_to_l2attr(enum ihk_mc_pt_attribute attr) { unsigned long r = (attr & (ATTR_MASK | PTATTR_LARGEPAGE)); @@ -322,7 +324,7 @@ static int __set_pt_page(struct page_table *pt, void *virt, unsigned long phys, } else { if((newpt = __alloc_new_pt(ap_flag)) == NULL) return -ENOMEM; - pt->entry[l4idx] = virt_to_phys(newpt) | attr_to_l4attr(attr); + pt->entry[l4idx] = virt_to_phys(newpt) | PFL4_PDIR_ATTR; pt = newpt; } @@ -331,7 +333,7 @@ static int __set_pt_page(struct page_table *pt, void *virt, unsigned long phys, } else { if((newpt = __alloc_new_pt(ap_flag)) == NULL) return -ENOMEM; - pt->entry[l3idx] = virt_to_phys(newpt) | attr_to_l3attr(attr); + pt->entry[l3idx] = virt_to_phys(newpt) | PFL3_PDIR_ATTR; pt = newpt; } @@ -354,8 +356,7 @@ static int __set_pt_page(struct page_table *pt, void *virt, unsigned long phys, } else { if((newpt = __alloc_new_pt(ap_flag)) == NULL) return -ENOMEM; - pt->entry[l2idx] = virt_to_phys(newpt) | attr_to_l2attr(attr) - | PFL2_PRESENT; + pt->entry[l2idx] = virt_to_phys(newpt) | PFL2_PDIR_ATTR; pt = newpt; } @@ -547,7 +548,7 @@ int ihk_mc_pt_prepare_map(page_table_t p, void *virt, unsigned long size, ret = -ENOMEM; } else { pt->entry[l4idx] = virt_to_phys(newpt) - | attr_to_l4attr(attr); + | PFL4_PDIR_ATTR; } } }