mprotect.c (f01387d2693813eb5271a3448e6a082322c7d75d) | mprotect.c (64e455079e1bd7787cc47be30b7f601ce682a5f6) |
---|---|
1/* 2 * mm/mprotect.c 3 * 4 * (C) Copyright 1994 Linus Torvalds 5 * (C) Copyright 2002 Christoph Hellwig 6 * 7 * Address space accounting code <alan@lxorguk.ukuu.org.uk> 8 * (C) Copyright 2002 Red Hat Inc, All Rights Reserved --- 15 unchanged lines hidden (view full) --- 24#include <linux/migrate.h> 25#include <linux/perf_event.h> 26#include <linux/ksm.h> 27#include <asm/uaccess.h> 28#include <asm/pgtable.h> 29#include <asm/cacheflush.h> 30#include <asm/tlbflush.h> 31 | 1/* 2 * mm/mprotect.c 3 * 4 * (C) Copyright 1994 Linus Torvalds 5 * (C) Copyright 2002 Christoph Hellwig 6 * 7 * Address space accounting code <alan@lxorguk.ukuu.org.uk> 8 * (C) Copyright 2002 Red Hat Inc, All Rights Reserved --- 15 unchanged lines hidden (view full) --- 24#include <linux/migrate.h> 25#include <linux/perf_event.h> 26#include <linux/ksm.h> 27#include <asm/uaccess.h> 28#include <asm/pgtable.h> 29#include <asm/cacheflush.h> 30#include <asm/tlbflush.h> 31 |
32#ifndef pgprot_modify 33static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot) 34{ 35 return newprot; 36} 37#endif 38 | |
39/* 40 * For a prot_numa update we only hold mmap_sem for read so there is a 41 * potential race with faulting where a pmd was temporarily none. This 42 * function checks for a transhuge pmd under the appropriate lock. It 43 * returns a pte if it was successfully locked or NULL if it raced with 44 * a transhuge insertion. 45 */ 46static pte_t *lock_pte_protection(struct vm_area_struct *vma, pmd_t *pmd, --- 41 unchanged lines hidden (view full) --- 88 ptent = ptep_modify_prot_start(mm, addr, pte); 89 if (pte_numa(ptent)) 90 ptent = pte_mknonnuma(ptent); 91 ptent = pte_modify(ptent, newprot); 92 /* 93 * Avoid taking write faults for pages we 94 * know to be dirty. 95 */ | 32/* 33 * For a prot_numa update we only hold mmap_sem for read so there is a 34 * potential race with faulting where a pmd was temporarily none. This 35 * function checks for a transhuge pmd under the appropriate lock. It 36 * returns a pte if it was successfully locked or NULL if it raced with 37 * a transhuge insertion. 38 */ 39static pte_t *lock_pte_protection(struct vm_area_struct *vma, pmd_t *pmd, --- 41 unchanged lines hidden (view full) --- 81 ptent = ptep_modify_prot_start(mm, addr, pte); 82 if (pte_numa(ptent)) 83 ptent = pte_mknonnuma(ptent); 84 ptent = pte_modify(ptent, newprot); 85 /* 86 * Avoid taking write faults for pages we 87 * know to be dirty. 88 */ |
96 if (dirty_accountable && pte_dirty(ptent)) | 89 if (dirty_accountable && pte_dirty(ptent) && 90 (pte_soft_dirty(ptent) || 91 !(vma->vm_flags & VM_SOFTDIRTY))) |
97 ptent = pte_mkwrite(ptent); 98 ptep_modify_prot_commit(mm, addr, pte, ptent); 99 updated = true; 100 } else { 101 struct page *page; 102 103 page = vm_normal_page(vma, addr, oldpte); 104 if (page && !PageKsm(page)) { --- 210 unchanged lines hidden (view full) --- 315 } 316 317success: 318 /* 319 * vm_flags and vm_page_prot are protected by the mmap_sem 320 * held in write mode. 321 */ 322 vma->vm_flags = newflags; | 92 ptent = pte_mkwrite(ptent); 93 ptep_modify_prot_commit(mm, addr, pte, ptent); 94 updated = true; 95 } else { 96 struct page *page; 97 98 page = vm_normal_page(vma, addr, oldpte); 99 if (page && !PageKsm(page)) { --- 210 unchanged lines hidden (view full) --- 310 } 311 312success: 313 /* 314 * vm_flags and vm_page_prot are protected by the mmap_sem 315 * held in write mode. 316 */ 317 vma->vm_flags = newflags; |
323 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot, 324 vm_get_page_prot(newflags)); | 318 dirty_accountable = vma_wants_writenotify(vma); 319 vma_set_page_prot(vma); |
325 | 320 |
326 if (vma_wants_writenotify(vma)) { 327 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED); 328 dirty_accountable = 1; 329 } 330 | |
331 change_protection(vma, start, end, vma->vm_page_prot, 332 dirty_accountable, 0); 333 334 vm_stat_account(mm, oldflags, vma->vm_file, -nrpages); 335 vm_stat_account(mm, newflags, vma->vm_file, nrpages); 336 perf_event_mmap(vma); 337 return 0; 338 --- 104 unchanged lines hidden --- | 321 change_protection(vma, start, end, vma->vm_page_prot, 322 dirty_accountable, 0); 323 324 vm_stat_account(mm, oldflags, vma->vm_file, -nrpages); 325 vm_stat_account(mm, newflags, vma->vm_file, nrpages); 326 perf_event_mmap(vma); 327 return 0; 328 --- 104 unchanged lines hidden --- |