diff options
author | Coly Li <coyli@suse.de> | 2007-10-19 02:39:15 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-19 14:53:34 -0400 |
commit | 3ed75eb8f1cd89565966599c4f77d2edb086d5b0 (patch) | |
tree | 54e77a47b40da80d76baf5eacc2259e0bc5bdf7c | |
parent | 1c7037db50ebecf3d5cfbf7082daa5d97d900fef (diff) |
setup vma->vm_page_prot by vm_get_page_prot()
This patch uses vm_get_page_prot() to setup vma->vm_page_prot.
Though inside vm_get_page_prot() the protection flags is AND with
(VM_READ|VM_WRITE|VM_EXEC|VM_SHARED), it does not hurt correct code.
Signed-off-by: Coly Li <coyli@suse.de>
Cc: Hugh Dickins <hugh@veritas.com>
Cc: Tony Luck <tony.luck@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | arch/ia64/mm/init.c | 2 | ||||
-rw-r--r-- | fs/exec.c | 2 | ||||
-rw-r--r-- | mm/mmap.c | 11 | ||||
-rw-r--r-- | mm/mprotect.c | 6 |
4 files changed, 8 insertions, 13 deletions
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c index 3e10152abbf0..c6c19bf11bec 100644 --- a/arch/ia64/mm/init.c +++ b/arch/ia64/mm/init.c | |||
@@ -127,8 +127,8 @@ ia64_init_addr_space (void) | |||
127 | vma->vm_mm = current->mm; | 127 | vma->vm_mm = current->mm; |
128 | vma->vm_start = current->thread.rbs_bot & PAGE_MASK; | 128 | vma->vm_start = current->thread.rbs_bot & PAGE_MASK; |
129 | vma->vm_end = vma->vm_start + PAGE_SIZE; | 129 | vma->vm_end = vma->vm_start + PAGE_SIZE; |
130 | vma->vm_page_prot = protection_map[VM_DATA_DEFAULT_FLAGS & 0x7]; | ||
131 | vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT; | 130 | vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT; |
131 | vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); | ||
132 | down_write(¤t->mm->mmap_sem); | 132 | down_write(¤t->mm->mmap_sem); |
133 | if (insert_vm_struct(current->mm, vma)) { | 133 | if (insert_vm_struct(current->mm, vma)) { |
134 | up_write(¤t->mm->mmap_sem); | 134 | up_write(¤t->mm->mmap_sem); |
@@ -234,7 +234,7 @@ static int __bprm_mm_init(struct linux_binprm *bprm) | |||
234 | vma->vm_start = vma->vm_end - PAGE_SIZE; | 234 | vma->vm_start = vma->vm_end - PAGE_SIZE; |
235 | 235 | ||
236 | vma->vm_flags = VM_STACK_FLAGS; | 236 | vma->vm_flags = VM_STACK_FLAGS; |
237 | vma->vm_page_prot = protection_map[vma->vm_flags & 0x7]; | 237 | vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); |
238 | err = insert_vm_struct(mm, vma); | 238 | err = insert_vm_struct(mm, vma); |
239 | if (err) { | 239 | if (err) { |
240 | up_write(&mm->mmap_sem); | 240 | up_write(&mm->mmap_sem); |
@@ -1048,8 +1048,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma) | |||
1048 | 1048 | ||
1049 | /* The open routine did something to the protections already? */ | 1049 | /* The open routine did something to the protections already? */ |
1050 | if (pgprot_val(vma->vm_page_prot) != | 1050 | if (pgprot_val(vma->vm_page_prot) != |
1051 | pgprot_val(protection_map[vm_flags & | 1051 | pgprot_val(vm_get_page_prot(vm_flags))) |
1052 | (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)])) | ||
1053 | return 0; | 1052 | return 0; |
1054 | 1053 | ||
1055 | /* Specialty mapping? */ | 1054 | /* Specialty mapping? */ |
@@ -1130,8 +1129,7 @@ munmap_back: | |||
1130 | vma->vm_start = addr; | 1129 | vma->vm_start = addr; |
1131 | vma->vm_end = addr + len; | 1130 | vma->vm_end = addr + len; |
1132 | vma->vm_flags = vm_flags; | 1131 | vma->vm_flags = vm_flags; |
1133 | vma->vm_page_prot = protection_map[vm_flags & | 1132 | vma->vm_page_prot = vm_get_page_prot(vm_flags); |
1134 | (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]; | ||
1135 | vma->vm_pgoff = pgoff; | 1133 | vma->vm_pgoff = pgoff; |
1136 | 1134 | ||
1137 | if (file) { | 1135 | if (file) { |
@@ -2002,8 +2000,7 @@ unsigned long do_brk(unsigned long addr, unsigned long len) | |||
2002 | vma->vm_end = addr + len; | 2000 | vma->vm_end = addr + len; |
2003 | vma->vm_pgoff = pgoff; | 2001 | vma->vm_pgoff = pgoff; |
2004 | vma->vm_flags = flags; | 2002 | vma->vm_flags = flags; |
2005 | vma->vm_page_prot = protection_map[flags & | 2003 | vma->vm_page_prot = vm_get_page_prot(flags); |
2006 | (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]; | ||
2007 | vma_link(mm, vma, prev, rb_link, rb_parent); | 2004 | vma_link(mm, vma, prev, rb_link, rb_parent); |
2008 | out: | 2005 | out: |
2009 | mm->total_vm += len >> PAGE_SHIFT; | 2006 | mm->total_vm += len >> PAGE_SHIFT; |
@@ -2209,7 +2206,7 @@ int install_special_mapping(struct mm_struct *mm, | |||
2209 | vma->vm_end = addr + len; | 2206 | vma->vm_end = addr + len; |
2210 | 2207 | ||
2211 | vma->vm_flags = vm_flags | mm->def_flags; | 2208 | vma->vm_flags = vm_flags | mm->def_flags; |
2212 | vma->vm_page_prot = protection_map[vma->vm_flags & 7]; | 2209 | vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); |
2213 | 2210 | ||
2214 | vma->vm_ops = &special_mapping_vmops; | 2211 | vma->vm_ops = &special_mapping_vmops; |
2215 | vma->vm_private_data = pages; | 2212 | vma->vm_private_data = pages; |
diff --git a/mm/mprotect.c b/mm/mprotect.c index 1d4d69790e59..55227845abbe 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c | |||
@@ -192,11 +192,9 @@ success: | |||
192 | * held in write mode. | 192 | * held in write mode. |
193 | */ | 193 | */ |
194 | vma->vm_flags = newflags; | 194 | vma->vm_flags = newflags; |
195 | vma->vm_page_prot = protection_map[newflags & | 195 | vma->vm_page_prot = vm_get_page_prot(newflags); |
196 | (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]; | ||
197 | if (vma_wants_writenotify(vma)) { | 196 | if (vma_wants_writenotify(vma)) { |
198 | vma->vm_page_prot = protection_map[newflags & | 197 | vma->vm_page_prot = vm_get_page_prot(newflags); |
199 | (VM_READ|VM_WRITE|VM_EXEC)]; | ||
200 | dirty_accountable = 1; | 198 | dirty_accountable = 1; |
201 | } | 199 | } |
202 | 200 | ||