4 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds
8 * demand-loading started 01.12.91 - seems it is high on the list of
9 * things wanted, and it should be easy to implement. - Linus
13 * Ok, demand-loading was easy, shared pages a little bit tricker. Shared
14 * pages started 02.12.91, seems to work. - Linus.
16 * Tested sharing by executing about 30 /bin/sh: under the old kernel it
17 * would have taken more than the 6M I have free, but it worked well as
20 * Also corrected some "invalidate()"s - I wasn't doing enough of them.
24 * Real VM (paging to/from disk) started 18.12.91. Much more work and
25 * thought has to go into this. Oh, well..
26 * 19.12.91 - works, somewhat. Sometimes I get faults, don't know why.
27 * Found it. Everything seems to work now.
28 * 20.12.91 - Ok, making the swap-device changeable like the root.
32 * 05.04.94 - Multi-page memory management added for v1.1.
33 * Idea by Alex Bligh (alex@cconcepts.co.uk)
35 * 16.07.99 - Support of BIGMEM added by Gerhard Wichert, Siemens AG
36 * (Gerhard.Wichert@pdb.siemens.de)
39 #include <linux/kernel_stat.h>
41 #include <linux/hugetlb.h>
42 #include <linux/mman.h>
43 #include <linux/swap.h>
44 #include <linux/highmem.h>
45 #include <linux/pagemap.h>
46 #include <linux/rmap.h>
47 #include <linux/module.h>
48 #include <linux/init.h>
50 #include <asm/pgalloc.h>
51 #include <asm/uaccess.h>
53 #include <asm/tlbflush.h>
54 #include <asm/pgtable.h>
56 #include <linux/swapops.h>
57 #include <linux/elf.h>
59 #ifndef CONFIG_DISCONTIGMEM
60 /* use the per-pgdat data instead for discontigmem - mbligh */
61 unsigned long max_mapnr;
64 EXPORT_SYMBOL(max_mapnr);
65 EXPORT_SYMBOL(mem_map);
68 unsigned long num_physpages;
70 struct page *highmem_start_page;
72 EXPORT_SYMBOL(num_physpages);
73 EXPORT_SYMBOL(highmem_start_page);
74 EXPORT_SYMBOL(high_memory);
77 * We special-case the C-O-W ZERO_PAGE, because it's such
78 * a common occurrence (no need to read the page to know
79 * that it's zero - better for the cache and memory subsystem).
81 static inline void copy_cow_page(struct page * from, struct page * to, unsigned long address)
83 if (from == ZERO_PAGE(address)) {
84 clear_user_highpage(to, address);
87 copy_user_highpage(to, from, address);
91 * Note: this doesn't free the actual pages themselves. That
92 * has been handled earlier when unmapping all the memory regions.
94 static inline void free_one_pmd(struct mmu_gather *tlb, pmd_t * dir)
100 if (unlikely(pmd_bad(*dir))) {
105 page = pmd_page(*dir);
107 dec_page_state(nr_page_table_pages);
108 pte_free_tlb(tlb, page);
111 static inline void free_one_pgd(struct mmu_gather *tlb, pgd_t * dir)
118 if (unlikely(pgd_bad(*dir))) {
123 pmd = pmd_offset(dir, 0);
125 for (j = 0; j < PTRS_PER_PMD ; j++)
126 free_one_pmd(tlb, pmd+j);
127 pmd_free_tlb(tlb, pmd);
131 * This function clears all user-level page tables of a process - this
132 * is needed by execve(), so that old pages aren't in the way.
134 * Must be called with pagetable lock held.
136 void clear_page_tables(struct mmu_gather *tlb, unsigned long first, int nr)
138 pgd_t * page_dir = tlb->mm->pgd;
142 free_one_pgd(tlb, page_dir);
147 pte_t fastcall * pte_alloc_map(struct mm_struct *mm, pmd_t *pmd, unsigned long address)
149 if (!pmd_present(*pmd)) {
152 spin_unlock(&mm->page_table_lock);
153 new = pte_alloc_one(mm, address);
154 spin_lock(&mm->page_table_lock);
159 * Because we dropped the lock, we should re-check the
160 * entry, as somebody else could have populated it..
162 if (pmd_present(*pmd)) {
166 inc_page_state(nr_page_table_pages);
167 pmd_populate(mm, pmd, new);
170 return pte_offset_map(pmd, address);
173 pte_t fastcall * pte_alloc_kernel(struct mm_struct *mm, pmd_t *pmd, unsigned long address)
175 if (!pmd_present(*pmd)) {
178 spin_unlock(&mm->page_table_lock);
179 new = pte_alloc_one_kernel(mm, address);
180 spin_lock(&mm->page_table_lock);
185 * Because we dropped the lock, we should re-check the
186 * entry, as somebody else could have populated it..
188 if (pmd_present(*pmd)) {
189 pte_free_kernel(new);
192 pmd_populate_kernel(mm, pmd, new);
195 return pte_offset_kernel(pmd, address);
197 #define PTE_TABLE_MASK ((PTRS_PER_PTE-1) * sizeof(pte_t))
198 #define PMD_TABLE_MASK ((PTRS_PER_PMD-1) * sizeof(pmd_t))
201 * copy one vm_area from one task to the other. Assumes the page tables
202 * already present in the new task to be cleared in the whole range
203 * covered by this vma.
205 * 08Jan98 Merged into one routine from several inline routines to reduce
206 * variable count and make things faster. -jj
208 * dst->page_table_lock is held on entry and exit,
209 * but may be dropped within pmd_alloc() and pte_alloc_map().
211 int copy_page_range(struct mm_struct *dst, struct mm_struct *src,
212 struct vm_area_struct *vma)
214 pgd_t * src_pgd, * dst_pgd;
215 unsigned long address = vma->vm_start;
216 unsigned long end = vma->vm_end;
219 if (is_vm_hugetlb_page(vma))
220 return copy_hugetlb_page_range(dst, src, vma);
222 cow = (vma->vm_flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE;
223 src_pgd = pgd_offset(src, address)-1;
224 dst_pgd = pgd_offset(dst, address)-1;
227 pmd_t * src_pmd, * dst_pmd;
229 src_pgd++; dst_pgd++;
233 if (pgd_none(*src_pgd))
234 goto skip_copy_pmd_range;
235 if (unlikely(pgd_bad(*src_pgd))) {
238 skip_copy_pmd_range: address = (address + PGDIR_SIZE) & PGDIR_MASK;
239 if (!address || (address >= end))
244 src_pmd = pmd_offset(src_pgd, address);
245 dst_pmd = pmd_alloc(dst, dst_pgd, address);
250 pte_t * src_pte, * dst_pte;
254 if (pmd_none(*src_pmd))
255 goto skip_copy_pte_range;
256 if (unlikely(pmd_bad(*src_pmd))) {
260 address = (address + PMD_SIZE) & PMD_MASK;
263 goto cont_copy_pmd_range;
266 dst_pte = pte_alloc_map(dst, dst_pmd, address);
269 spin_lock(&src->page_table_lock);
270 src_pte = pte_offset_map_nested(src_pmd, address);
272 pte_t pte = *src_pte;
276 if (!vx_rsspages_avail(dst, 1)) {
277 spin_unlock(&src->page_table_lock);
283 goto cont_copy_pte_range_noset;
284 /* pte contains position in swap, so copy. */
285 if (!pte_present(pte)) {
287 swap_duplicate(pte_to_swp_entry(pte));
288 set_pte(dst_pte, pte);
289 goto cont_copy_pte_range_noset;
292 /* the pte points outside of valid memory, the
293 * mapping is assumed to be good, meaningful
294 * and not mapped via rmap - duplicate the
299 page = pfn_to_page(pfn);
301 if (!page || PageReserved(page)) {
302 set_pte(dst_pte, pte);
303 goto cont_copy_pte_range_noset;
307 * If it's a COW mapping, write protect it both
308 * in the parent and the child
311 ptep_set_wrprotect(src_pte);
316 * If it's a shared mapping, mark it clean in
319 if (vma->vm_flags & VM_SHARED)
320 pte = pte_mkclean(pte);
321 pte = pte_mkold(pte);
324 vx_rsspages_inc(dst);
325 set_pte(dst_pte, pte);
327 cont_copy_pte_range_noset:
328 address += PAGE_SIZE;
329 if (address >= end) {
330 pte_unmap_nested(src_pte);
336 } while ((unsigned long)src_pte & PTE_TABLE_MASK);
337 pte_unmap_nested(src_pte-1);
338 pte_unmap(dst_pte-1);
339 spin_unlock(&src->page_table_lock);
340 cond_resched_lock(&dst->page_table_lock);
344 } while ((unsigned long)src_pmd & PMD_TABLE_MASK);
347 spin_unlock(&src->page_table_lock);
354 static void zap_pte_range(struct mmu_gather *tlb,
355 pmd_t *pmd, unsigned long address,
356 unsigned long size, struct zap_details *details)
358 unsigned long offset;
363 if (unlikely(pmd_bad(*pmd))) {
368 ptep = pte_offset_map(pmd, address);
369 offset = address & ~PMD_MASK;
370 if (offset + size > PMD_SIZE)
371 size = PMD_SIZE - offset;
373 if (details && !details->check_mapping && !details->nonlinear_vma)
375 for (offset=0; offset < size; ptep++, offset += PAGE_SIZE) {
379 if (pte_present(pte)) {
380 struct page *page = NULL;
381 unsigned long pfn = pte_pfn(pte);
382 if (pfn_valid(pfn)) {
383 page = pfn_to_page(pfn);
384 if (PageReserved(page))
387 if (unlikely(details) && page) {
389 * unmap_shared_mapping_pages() wants to
390 * invalidate cache without truncating:
391 * unmap shared but keep private pages.
393 if (details->check_mapping &&
394 details->check_mapping != page->mapping)
397 * Each page->index must be checked when
398 * invalidating or truncating nonlinear.
400 if (details->nonlinear_vma &&
401 (page->index < details->first_index ||
402 page->index > details->last_index))
405 pte = ptep_get_and_clear(ptep);
406 tlb_remove_tlb_entry(tlb, ptep, address+offset);
409 if (unlikely(details) && details->nonlinear_vma
410 && linear_page_index(details->nonlinear_vma,
411 address+offset) != page->index)
412 set_pte(ptep, pgoff_to_pte(page->index));
414 set_page_dirty(page);
415 if (pte_young(pte) && page_mapping(page))
416 mark_page_accessed(page);
418 page_remove_rmap(page);
419 tlb_remove_page(tlb, page);
423 * If details->check_mapping, we leave swap entries;
424 * if details->nonlinear_vma, we leave file entries.
426 if (unlikely(details))
429 free_swap_and_cache(pte_to_swp_entry(pte));
435 static void zap_pmd_range(struct mmu_gather *tlb,
436 pgd_t * dir, unsigned long address,
437 unsigned long size, struct zap_details *details)
444 if (unlikely(pgd_bad(*dir))) {
449 pmd = pmd_offset(dir, address);
450 end = address + size;
451 if (end > ((address + PGDIR_SIZE) & PGDIR_MASK))
452 end = ((address + PGDIR_SIZE) & PGDIR_MASK);
454 zap_pte_range(tlb, pmd, address, end - address, details);
455 address = (address + PMD_SIZE) & PMD_MASK;
457 } while (address && (address < end));
460 static void unmap_page_range(struct mmu_gather *tlb,
461 struct vm_area_struct *vma, unsigned long address,
462 unsigned long end, struct zap_details *details)
466 BUG_ON(address >= end);
467 dir = pgd_offset(vma->vm_mm, address);
468 tlb_start_vma(tlb, vma);
470 zap_pmd_range(tlb, dir, address, end - address, details);
471 address = (address + PGDIR_SIZE) & PGDIR_MASK;
473 } while (address && (address < end));
474 tlb_end_vma(tlb, vma);
477 /* Dispose of an entire struct mmu_gather per rescheduling point */
478 #if defined(CONFIG_SMP) && defined(CONFIG_PREEMPT)
479 #define ZAP_BLOCK_SIZE (FREE_PTE_NR * PAGE_SIZE)
482 /* For UP, 256 pages at a time gives nice low latency */
483 #if !defined(CONFIG_SMP) && defined(CONFIG_PREEMPT)
484 #define ZAP_BLOCK_SIZE (256 * PAGE_SIZE)
487 /* No preempt: go for improved straight-line efficiency */
488 #if !defined(CONFIG_PREEMPT)
489 #define ZAP_BLOCK_SIZE (1024 * PAGE_SIZE)
493 * unmap_vmas - unmap a range of memory covered by a list of vma's
494 * @tlbp: address of the caller's struct mmu_gather
495 * @mm: the controlling mm_struct
496 * @vma: the starting vma
497 * @start_addr: virtual address at which to start unmapping
498 * @end_addr: virtual address at which to end unmapping
499 * @nr_accounted: Place number of unmapped pages in vm-accountable vma's here
500 * @details: details of nonlinear truncation or shared cache invalidation
502 * Returns the number of vma's which were covered by the unmapping.
504 * Unmap all pages in the vma list. Called under page_table_lock.
506 * We aim to not hold page_table_lock for too long (for scheduling latency
507 * reasons). So zap pages in ZAP_BLOCK_SIZE bytecounts. This means we need to
508 * return the ending mmu_gather to the caller.
510 * Only addresses between `start' and `end' will be unmapped.
512 * The VMA list must be sorted in ascending virtual address order.
514 * unmap_vmas() assumes that the caller will flush the whole unmapped address
515 * range after unmap_vmas() returns. So the only responsibility here is to
516 * ensure that any thus-far unmapped pages are flushed before unmap_vmas()
517 * drops the lock and schedules.
519 int unmap_vmas(struct mmu_gather **tlbp, struct mm_struct *mm,
520 struct vm_area_struct *vma, unsigned long start_addr,
521 unsigned long end_addr, unsigned long *nr_accounted,
522 struct zap_details *details)
524 unsigned long zap_bytes = ZAP_BLOCK_SIZE;
525 unsigned long tlb_start = 0; /* For tlb_finish_mmu */
526 int tlb_start_valid = 0;
528 int atomic = details && details->atomic;
530 for ( ; vma && vma->vm_start < end_addr; vma = vma->vm_next) {
534 start = max(vma->vm_start, start_addr);
535 if (start >= vma->vm_end)
537 end = min(vma->vm_end, end_addr);
538 if (end <= vma->vm_start)
541 if (vma->vm_flags & VM_ACCOUNT)
542 *nr_accounted += (end - start) >> PAGE_SHIFT;
545 while (start != end) {
548 if (!tlb_start_valid) {
553 if (is_vm_hugetlb_page(vma)) {
555 unmap_hugepage_range(vma, start, end);
557 block = min(zap_bytes, end - start);
558 unmap_page_range(*tlbp, vma, start,
559 start + block, details);
564 if ((long)zap_bytes > 0)
566 if (!atomic && need_resched()) {
567 int fullmm = tlb_is_full_mm(*tlbp);
568 tlb_finish_mmu(*tlbp, tlb_start, start);
569 cond_resched_lock(&mm->page_table_lock);
570 *tlbp = tlb_gather_mmu(mm, fullmm);
573 zap_bytes = ZAP_BLOCK_SIZE;
580 * zap_page_range - remove user pages in a given range
581 * @vma: vm_area_struct holding the applicable pages
582 * @address: starting address of pages to zap
583 * @size: number of bytes to zap
584 * @details: details of nonlinear truncation or shared cache invalidation
586 void zap_page_range(struct vm_area_struct *vma, unsigned long address,
587 unsigned long size, struct zap_details *details)
589 struct mm_struct *mm = vma->vm_mm;
590 struct mmu_gather *tlb;
591 unsigned long end = address + size;
592 unsigned long nr_accounted = 0;
594 if (is_vm_hugetlb_page(vma)) {
595 zap_hugepage_range(vma, address, size);
600 spin_lock(&mm->page_table_lock);
601 tlb = tlb_gather_mmu(mm, 0);
602 unmap_vmas(&tlb, mm, vma, address, end, &nr_accounted, details);
603 tlb_finish_mmu(tlb, address, end);
604 spin_unlock(&mm->page_table_lock);
608 * Do a quick page-table lookup for a single page.
609 * mm->page_table_lock must be held.
612 follow_page(struct mm_struct *mm, unsigned long address, int write)
620 page = follow_huge_addr(mm, address, write);
624 pgd = pgd_offset(mm, address);
625 if (pgd_none(*pgd) || unlikely(pgd_bad(*pgd)))
628 pmd = pmd_offset(pgd, address);
632 return follow_huge_pmd(mm, address, pmd, write);
633 if (unlikely(pmd_bad(*pmd)))
636 ptep = pte_offset_map(pmd, address);
642 if (pte_present(pte)) {
643 if (write && !pte_write(pte))
646 if (pfn_valid(pfn)) {
647 page = pfn_to_page(pfn);
648 if (write && !pte_dirty(pte) && !PageDirty(page))
649 set_page_dirty(page);
650 mark_page_accessed(page);
660 * Given a physical address, is there a useful struct page pointing to
661 * it? This may become more complex in the future if we start dealing
662 * with IO-aperture pages for direct-IO.
665 static inline struct page *get_page_map(struct page *page)
667 if (!pfn_valid(page_to_pfn(page)))
674 untouched_anonymous_page(struct mm_struct* mm, struct vm_area_struct *vma,
675 unsigned long address)
680 /* Check if the vma is for an anonymous mapping. */
681 if (vma->vm_ops && vma->vm_ops->nopage)
684 /* Check if page directory entry exists. */
685 pgd = pgd_offset(mm, address);
686 if (pgd_none(*pgd) || unlikely(pgd_bad(*pgd)))
689 /* Check if page middle directory entry exists. */
690 pmd = pmd_offset(pgd, address);
691 if (pmd_none(*pmd) || unlikely(pmd_bad(*pmd)))
694 /* There is a pte slot for 'address' in 'mm'. */
699 int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
700 unsigned long start, int len, int write, int force,
701 struct page **pages, struct vm_area_struct **vmas)
707 * Require read or write permissions.
708 * If 'force' is set, we only require the "MAY" flags.
710 flags = write ? (VM_WRITE | VM_MAYWRITE) : (VM_READ | VM_MAYREAD);
711 flags &= force ? (VM_MAYREAD | VM_MAYWRITE) : (VM_READ | VM_WRITE);
715 struct vm_area_struct * vma;
717 vma = find_extend_vma(mm, start);
718 if (!vma && in_gate_area(tsk, start)) {
719 unsigned long pg = start & PAGE_MASK;
720 struct vm_area_struct *gate_vma = get_gate_vma(tsk);
724 if (write) /* user gate pages are read-only */
725 return i ? : -EFAULT;
726 pgd = pgd_offset_k(pg);
728 return i ? : -EFAULT;
729 pmd = pmd_offset(pgd, pg);
731 return i ? : -EFAULT;
732 pte = pte_offset_kernel(pmd, pg);
733 if (!pte || !pte_present(*pte))
734 return i ? : -EFAULT;
736 pages[i] = pte_page(*pte);
747 if (!vma || (pages && (vma->vm_flags & VM_IO))
748 || !(flags & vma->vm_flags))
749 return i ? : -EFAULT;
751 if (is_vm_hugetlb_page(vma)) {
752 i = follow_hugetlb_page(mm, vma, pages, vmas,
756 spin_lock(&mm->page_table_lock);
759 int lookup_write = write;
760 while (!(map = follow_page(mm, start, lookup_write))) {
762 * Shortcut for anonymous pages. We don't want
763 * to force the creation of pages tables for
764 * insanly big anonymously mapped areas that
765 * nobody touched so far. This is important
766 * for doing a core dump for these mappings.
769 untouched_anonymous_page(mm,vma,start)) {
770 map = ZERO_PAGE(start);
773 spin_unlock(&mm->page_table_lock);
774 switch (handle_mm_fault(mm,vma,start,write)) {
781 case VM_FAULT_SIGBUS:
782 return i ? i : -EFAULT;
784 return i ? i : -ENOMEM;
789 * Now that we have performed a write fault
790 * and surely no longer have a shared page we
791 * shouldn't write, we shouldn't ignore an
792 * unwritable page in the page table if
793 * we are forcing write access.
795 lookup_write = write && !force;
796 spin_lock(&mm->page_table_lock);
799 pages[i] = get_page_map(map);
801 spin_unlock(&mm->page_table_lock);
803 page_cache_release(pages[i]);
807 flush_dcache_page(pages[i]);
808 if (!PageReserved(pages[i]))
809 page_cache_get(pages[i]);
816 } while(len && start < vma->vm_end);
817 spin_unlock(&mm->page_table_lock);
823 EXPORT_SYMBOL(get_user_pages);
825 static void zeromap_pte_range(pte_t * pte, unsigned long address,
826 unsigned long size, pgprot_t prot)
830 address &= ~PMD_MASK;
831 end = address + size;
835 pte_t zero_pte = pte_wrprotect(mk_pte(ZERO_PAGE(address), prot));
836 BUG_ON(!pte_none(*pte));
837 set_pte(pte, zero_pte);
838 address += PAGE_SIZE;
840 } while (address && (address < end));
843 static inline int zeromap_pmd_range(struct mm_struct *mm, pmd_t * pmd, unsigned long address,
844 unsigned long size, pgprot_t prot)
846 unsigned long base, end;
848 base = address & PGDIR_MASK;
849 address &= ~PGDIR_MASK;
850 end = address + size;
851 if (end > PGDIR_SIZE)
854 pte_t * pte = pte_alloc_map(mm, pmd, base + address);
857 zeromap_pte_range(pte, base + address, end - address, prot);
859 address = (address + PMD_SIZE) & PMD_MASK;
861 } while (address && (address < end));
865 int zeromap_page_range(struct vm_area_struct *vma, unsigned long address, unsigned long size, pgprot_t prot)
869 unsigned long beg = address;
870 unsigned long end = address + size;
871 struct mm_struct *mm = vma->vm_mm;
873 dir = pgd_offset(mm, address);
874 flush_cache_range(vma, beg, end);
878 spin_lock(&mm->page_table_lock);
880 pmd_t *pmd = pmd_alloc(mm, dir, address);
884 error = zeromap_pmd_range(mm, pmd, address, end - address, prot);
887 address = (address + PGDIR_SIZE) & PGDIR_MASK;
889 } while (address && (address < end));
891 * Why flush? zeromap_pte_range has a BUG_ON for !pte_none()
893 flush_tlb_range(vma, beg, end);
894 spin_unlock(&mm->page_table_lock);
899 * maps a range of physical memory into the requested pages. the old
900 * mappings are removed. any references to nonexistent pages results
901 * in null mappings (currently treated as "copy-on-access")
903 static inline void remap_pte_range(pte_t * pte, unsigned long address, unsigned long size,
904 unsigned long phys_addr, pgprot_t prot)
909 address &= ~PMD_MASK;
910 end = address + size;
913 pfn = phys_addr >> PAGE_SHIFT;
915 BUG_ON(!pte_none(*pte));
916 if (!pfn_valid(pfn) || PageReserved(pfn_to_page(pfn)))
917 set_pte(pte, pfn_pte(pfn, prot));
918 address += PAGE_SIZE;
921 } while (address && (address < end));
924 static inline int remap_pmd_range(struct mm_struct *mm, pmd_t * pmd, unsigned long address, unsigned long size,
925 unsigned long phys_addr, pgprot_t prot)
927 unsigned long base, end;
929 base = address & PGDIR_MASK;
930 address &= ~PGDIR_MASK;
931 end = address + size;
932 if (end > PGDIR_SIZE)
934 phys_addr -= address;
936 pte_t * pte = pte_alloc_map(mm, pmd, base + address);
939 remap_pte_range(pte, base + address, end - address, address + phys_addr, prot);
941 address = (address + PMD_SIZE) & PMD_MASK;
943 } while (address && (address < end));
947 /* Note: this is only safe if the mm semaphore is held when called. */
948 int remap_page_range(struct vm_area_struct *vma, unsigned long from, unsigned long phys_addr, unsigned long size, pgprot_t prot)
952 unsigned long beg = from;
953 unsigned long end = from + size;
954 struct mm_struct *mm = vma->vm_mm;
957 dir = pgd_offset(mm, from);
958 flush_cache_range(vma, beg, end);
962 spin_lock(&mm->page_table_lock);
964 pmd_t *pmd = pmd_alloc(mm, dir, from);
968 error = remap_pmd_range(mm, pmd, from, end - from, phys_addr + from, prot);
971 from = (from + PGDIR_SIZE) & PGDIR_MASK;
973 } while (from && (from < end));
975 * Why flush? remap_pte_range has a BUG_ON for !pte_none()
977 flush_tlb_range(vma, beg, end);
978 spin_unlock(&mm->page_table_lock);
982 EXPORT_SYMBOL(remap_page_range);
985 * Do pte_mkwrite, but only if the vma says VM_WRITE. We do this when
986 * servicing faults for write access. In the normal case, do always want
987 * pte_mkwrite. But get_user_pages can cause write faults for mappings
988 * that do not have writing enabled, when used by access_process_vm.
990 static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct *vma)
992 if (likely(vma->vm_flags & VM_WRITE))
993 pte = pte_mkwrite(pte);
998 * We hold the mm semaphore for reading and vma->vm_mm->page_table_lock
1000 static inline void break_cow(struct vm_area_struct * vma, struct page * new_page, unsigned long address,
1005 flush_cache_page(vma, address);
1006 entry = maybe_mkwrite(pte_mkdirty(mk_pte(new_page, vma->vm_page_prot)),
1008 ptep_establish(vma, address, page_table, entry);
1009 update_mmu_cache(vma, address, entry);
1013 * This routine handles present pages, when users try to write
1014 * to a shared page. It is done by copying the page to a new address
1015 * and decrementing the shared-page counter for the old page.
1017 * Goto-purists beware: the only reason for goto's here is that it results
1018 * in better assembly code.. The "default" path will see no jumps at all.
1020 * Note that this routine assumes that the protection checks have been
1021 * done by the caller (the low-level page fault routine in most cases).
1022 * Thus we can safely just mark it writable once we've done any necessary
1025 * We also mark the page dirty at this point even though the page will
1026 * change only once the write actually happens. This avoids a few races,
1027 * and potentially makes it more efficient.
1029 * We hold the mm semaphore and the page_table_lock on entry and exit
1030 * with the page_table_lock released.
1032 static int do_wp_page(struct mm_struct *mm, struct vm_area_struct * vma,
1033 unsigned long address, pte_t *page_table, pmd_t *pmd, pte_t pte)
1035 struct page *old_page, *new_page;
1036 unsigned long pfn = pte_pfn(pte);
1039 if (unlikely(!pfn_valid(pfn))) {
1041 * This should really halt the system so it can be debugged or
1042 * at least the kernel stops what it's doing before it corrupts
1043 * data, but for the moment just pretend this is OOM.
1045 pte_unmap(page_table);
1046 printk(KERN_ERR "do_wp_page: bogus page at address %08lx\n",
1048 spin_unlock(&mm->page_table_lock);
1049 return VM_FAULT_OOM;
1051 old_page = pfn_to_page(pfn);
1053 if (!TestSetPageLocked(old_page)) {
1054 int reuse = can_share_swap_page(old_page);
1055 unlock_page(old_page);
1057 flush_cache_page(vma, address);
1058 entry = maybe_mkwrite(pte_mkyoung(pte_mkdirty(pte)),
1060 ptep_set_access_flags(vma, address, page_table, entry, 1);
1061 update_mmu_cache(vma, address, entry);
1062 pte_unmap(page_table);
1063 spin_unlock(&mm->page_table_lock);
1064 return VM_FAULT_MINOR;
1067 pte_unmap(page_table);
1070 * Ok, we need to copy. Oh, well..
1072 page_cache_get(old_page);
1073 spin_unlock(&mm->page_table_lock);
1075 if (unlikely(anon_vma_prepare(vma)))
1077 new_page = alloc_page_vma(GFP_HIGHUSER, vma, address);
1080 copy_cow_page(old_page,new_page,address);
1083 * Re-check the pte - we dropped the lock
1085 spin_lock(&mm->page_table_lock);
1086 page_table = pte_offset_map(pmd, address);
1087 if (likely(pte_same(*page_table, pte))) {
1088 if (PageReserved(old_page))
1090 vx_rsspages_inc(mm);
1092 page_remove_rmap(old_page);
1093 break_cow(vma, new_page, address, page_table);
1094 lru_cache_add_active(new_page);
1095 page_add_anon_rmap(new_page, vma, address);
1097 /* Free the old page.. */
1098 new_page = old_page;
1100 pte_unmap(page_table);
1101 page_cache_release(new_page);
1102 page_cache_release(old_page);
1103 spin_unlock(&mm->page_table_lock);
1104 return VM_FAULT_MINOR;
1107 page_cache_release(old_page);
1108 return VM_FAULT_OOM;
1112 * Helper function for unmap_mapping_range().
1114 static inline void unmap_mapping_range_list(struct prio_tree_root *root,
1115 struct zap_details *details)
1117 struct vm_area_struct *vma = NULL;
1118 struct prio_tree_iter iter;
1119 pgoff_t vba, vea, zba, zea;
1121 while ((vma = vma_prio_tree_next(vma, root, &iter,
1122 details->first_index, details->last_index)) != NULL) {
1123 vba = vma->vm_pgoff;
1124 vea = vba + ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT) - 1;
1125 /* Assume for now that PAGE_CACHE_SHIFT == PAGE_SHIFT */
1126 zba = details->first_index;
1129 zea = details->last_index;
1133 ((zba - vba) << PAGE_SHIFT) + vma->vm_start,
1134 (zea - zba + 1) << PAGE_SHIFT, details);
1139 * unmap_mapping_range - unmap the portion of all mmaps
1140 * in the specified address_space corresponding to the specified
1141 * page range in the underlying file.
1142 * @address_space: the address space containing mmaps to be unmapped.
1143 * @holebegin: byte in first page to unmap, relative to the start of
1144 * the underlying file. This will be rounded down to a PAGE_SIZE
1145 * boundary. Note that this is different from vmtruncate(), which
1146 * must keep the partial page. In contrast, we must get rid of
1148 * @holelen: size of prospective hole in bytes. This will be rounded
1149 * up to a PAGE_SIZE boundary. A holelen of zero truncates to the
1151 * @even_cows: 1 when truncating a file, unmap even private COWed pages;
1152 * but 0 when invalidating pagecache, don't throw away private data.
1154 void unmap_mapping_range(struct address_space *mapping,
1155 loff_t const holebegin, loff_t const holelen, int even_cows)
1157 struct zap_details details;
1158 pgoff_t hba = holebegin >> PAGE_SHIFT;
1159 pgoff_t hlen = (holelen + PAGE_SIZE - 1) >> PAGE_SHIFT;
1161 /* Check for overflow. */
1162 if (sizeof(holelen) > sizeof(hlen)) {
1164 (holebegin + holelen + PAGE_SIZE - 1) >> PAGE_SHIFT;
1165 if (holeend & ~(long long)ULONG_MAX)
1166 hlen = ULONG_MAX - hba + 1;
1169 details.check_mapping = even_cows? NULL: mapping;
1170 details.nonlinear_vma = NULL;
1171 details.first_index = hba;
1172 details.last_index = hba + hlen - 1;
1173 details.atomic = 1; /* A spinlock is held */
1174 if (details.last_index < details.first_index)
1175 details.last_index = ULONG_MAX;
1177 spin_lock(&mapping->i_mmap_lock);
1178 /* Protect against page fault */
1179 atomic_inc(&mapping->truncate_count);
1181 if (unlikely(!prio_tree_empty(&mapping->i_mmap)))
1182 unmap_mapping_range_list(&mapping->i_mmap, &details);
1185 * In nonlinear VMAs there is no correspondence between virtual address
1186 * offset and file offset. So we must perform an exhaustive search
1187 * across *all* the pages in each nonlinear VMA, not just the pages
1188 * whose virtual address lies outside the file truncation point.
1190 if (unlikely(!list_empty(&mapping->i_mmap_nonlinear))) {
1191 struct vm_area_struct *vma;
1192 list_for_each_entry(vma, &mapping->i_mmap_nonlinear,
1193 shared.vm_set.list) {
1194 details.nonlinear_vma = vma;
1195 zap_page_range(vma, vma->vm_start,
1196 vma->vm_end - vma->vm_start, &details);
1199 spin_unlock(&mapping->i_mmap_lock);
1201 EXPORT_SYMBOL(unmap_mapping_range);
1204 * Handle all mappings that got truncated by a "truncate()"
1207 * NOTE! We have to be ready to update the memory sharing
1208 * between the file and the memory map for a potential last
1209 * incomplete page. Ugly, but necessary.
1211 int vmtruncate(struct inode * inode, loff_t offset)
1213 struct address_space *mapping = inode->i_mapping;
1214 unsigned long limit;
1216 if (inode->i_size < offset)
1218 i_size_write(inode, offset);
1219 unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1);
1220 truncate_inode_pages(mapping, offset);
1224 limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
1225 if (limit != RLIM_INFINITY && offset > limit)
1227 if (offset > inode->i_sb->s_maxbytes)
1229 i_size_write(inode, offset);
1232 if (inode->i_op && inode->i_op->truncate)
1233 inode->i_op->truncate(inode);
1236 send_sig(SIGXFSZ, current, 0);
1241 EXPORT_SYMBOL(vmtruncate);
1244 * Primitive swap readahead code. We simply read an aligned block of
1245 * (1 << page_cluster) entries in the swap area. This method is chosen
1246 * because it doesn't cost us any seek time. We also make sure to queue
1247 * the 'original' request together with the readahead ones...
1249 * This has been extended to use the NUMA policies from the mm triggering
1252 * Caller must hold down_read on the vma->vm_mm if vma is not NULL.
1254 void swapin_readahead(swp_entry_t entry, unsigned long addr,struct vm_area_struct *vma)
1257 struct vm_area_struct *next_vma = vma ? vma->vm_next : NULL;
1260 struct page *new_page;
1261 unsigned long offset;
1264 * Get the number of handles we should do readahead io to.
1266 num = valid_swaphandles(entry, &offset);
1267 for (i = 0; i < num; offset++, i++) {
1268 /* Ok, do the async read-ahead now */
1269 new_page = read_swap_cache_async(swp_entry(swp_type(entry),
1270 offset), vma, addr);
1273 page_cache_release(new_page);
1276 * Find the next applicable VMA for the NUMA policy.
1282 if (addr >= vma->vm_end) {
1284 next_vma = vma ? vma->vm_next : NULL;
1286 if (vma && addr < vma->vm_start)
1289 if (next_vma && addr >= next_vma->vm_start) {
1291 next_vma = vma->vm_next;
1296 lru_add_drain(); /* Push any new pages onto the LRU now */
1300 * We hold the mm semaphore and the page_table_lock on entry and
1301 * should release the pagetable lock on exit..
1303 static int do_swap_page(struct mm_struct * mm,
1304 struct vm_area_struct * vma, unsigned long address,
1305 pte_t *page_table, pmd_t *pmd, pte_t orig_pte, int write_access)
1308 swp_entry_t entry = pte_to_swp_entry(orig_pte);
1310 int ret = VM_FAULT_MINOR;
1312 pte_unmap(page_table);
1313 spin_unlock(&mm->page_table_lock);
1314 page = lookup_swap_cache(entry);
1316 swapin_readahead(entry, address, vma);
1317 page = read_swap_cache_async(entry, vma, address);
1320 * Back out if somebody else faulted in this pte while
1321 * we released the page table lock.
1323 spin_lock(&mm->page_table_lock);
1324 page_table = pte_offset_map(pmd, address);
1325 if (likely(pte_same(*page_table, orig_pte)))
1328 ret = VM_FAULT_MINOR;
1329 pte_unmap(page_table);
1330 spin_unlock(&mm->page_table_lock);
1334 /* Had to read the page from swap area: Major fault */
1335 ret = VM_FAULT_MAJOR;
1336 inc_page_state(pgmajfault);
1339 if (!vx_rsspages_avail(mm, 1)) {
1343 mark_page_accessed(page);
1347 * Back out if somebody else faulted in this pte while we
1348 * released the page table lock.
1350 spin_lock(&mm->page_table_lock);
1351 page_table = pte_offset_map(pmd, address);
1352 if (unlikely(!pte_same(*page_table, orig_pte))) {
1353 pte_unmap(page_table);
1354 spin_unlock(&mm->page_table_lock);
1356 page_cache_release(page);
1357 ret = VM_FAULT_MINOR;
1361 /* The page isn't present yet, go ahead with the fault. */
1365 remove_exclusive_swap_page(page);
1368 vx_rsspages_inc(mm);
1369 pte = mk_pte(page, vma->vm_page_prot);
1370 if (write_access && can_share_swap_page(page)) {
1371 pte = maybe_mkwrite(pte_mkdirty(pte), vma);
1376 flush_icache_page(vma, page);
1377 set_pte(page_table, pte);
1378 page_add_anon_rmap(page, vma, address);
1381 if (do_wp_page(mm, vma, address,
1382 page_table, pmd, pte) == VM_FAULT_OOM)
1387 /* No need to invalidate - it was non-present before */
1388 update_mmu_cache(vma, address, pte);
1389 pte_unmap(page_table);
1390 spin_unlock(&mm->page_table_lock);
1396 * We are called with the MM semaphore and page_table_lock
1397 * spinlock held to protect against concurrent faults in
1398 * multithreaded programs.
1401 do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
1402 pte_t *page_table, pmd_t *pmd, int write_access,
1406 struct page * page = ZERO_PAGE(addr);
1408 /* Read-only mapping of ZERO_PAGE. */
1409 entry = pte_wrprotect(mk_pte(ZERO_PAGE(addr), vma->vm_page_prot));
1411 /* ..except if it's a write access */
1413 /* Allocate our own private page. */
1414 pte_unmap(page_table);
1415 spin_unlock(&mm->page_table_lock);
1417 if (unlikely(anon_vma_prepare(vma)))
1419 if (!vx_rsspages_avail(mm, 1))
1422 page = alloc_page_vma(GFP_HIGHUSER, vma, addr);
1425 clear_user_highpage(page, addr);
1427 spin_lock(&mm->page_table_lock);
1428 page_table = pte_offset_map(pmd, addr);
1430 if (!pte_none(*page_table)) {
1431 pte_unmap(page_table);
1432 page_cache_release(page);
1433 spin_unlock(&mm->page_table_lock);
1437 vx_rsspages_inc(mm);
1438 entry = maybe_mkwrite(pte_mkdirty(mk_pte(page,
1439 vma->vm_page_prot)),
1441 lru_cache_add_active(page);
1442 mark_page_accessed(page);
1443 page_add_anon_rmap(page, vma, addr);
1446 set_pte(page_table, entry);
1447 pte_unmap(page_table);
1449 /* No need to invalidate - it was non-present before */
1450 update_mmu_cache(vma, addr, entry);
1451 spin_unlock(&mm->page_table_lock);
1453 return VM_FAULT_MINOR;
1455 return VM_FAULT_OOM;
1459 * do_no_page() tries to create a new page mapping. It aggressively
1460 * tries to share with existing pages, but makes a separate copy if
1461 * the "write_access" parameter is true in order to avoid the next
1464 * As this is called only for pages that do not currently exist, we
1465 * do not need to flush old virtual caches or the TLB.
1467 * This is called with the MM semaphore held and the page table
1468 * spinlock held. Exit with the spinlock released.
1471 do_no_page(struct mm_struct *mm, struct vm_area_struct *vma,
1472 unsigned long address, int write_access, pte_t *page_table, pmd_t *pmd)
1474 struct page * new_page;
1475 struct address_space *mapping = NULL;
1478 int ret = VM_FAULT_MINOR;
1481 if (!vma->vm_ops || !vma->vm_ops->nopage)
1482 return do_anonymous_page(mm, vma, page_table,
1483 pmd, write_access, address);
1484 pte_unmap(page_table);
1485 spin_unlock(&mm->page_table_lock);
1488 mapping = vma->vm_file->f_mapping;
1489 sequence = atomic_read(&mapping->truncate_count);
1491 smp_rmb(); /* Prevent CPU from reordering lock-free ->nopage() */
1493 new_page = vma->vm_ops->nopage(vma, address & PAGE_MASK, &ret);
1495 /* no page was available -- either SIGBUS or OOM */
1496 if (new_page == NOPAGE_SIGBUS)
1497 return VM_FAULT_SIGBUS;
1498 if (new_page == NOPAGE_OOM)
1499 return VM_FAULT_OOM;
1500 if (!vx_rsspages_avail(mm, 1))
1501 return VM_FAULT_OOM;
1504 * Should we do an early C-O-W break?
1506 if (write_access && !(vma->vm_flags & VM_SHARED)) {
1509 if (unlikely(anon_vma_prepare(vma)))
1511 page = alloc_page_vma(GFP_HIGHUSER, vma, address);
1514 copy_user_highpage(page, new_page, address);
1515 page_cache_release(new_page);
1520 spin_lock(&mm->page_table_lock);
1522 * For a file-backed vma, someone could have truncated or otherwise
1523 * invalidated this page. If unmap_mapping_range got called,
1524 * retry getting the page.
1527 (unlikely(sequence != atomic_read(&mapping->truncate_count)))) {
1528 sequence = atomic_read(&mapping->truncate_count);
1529 spin_unlock(&mm->page_table_lock);
1530 page_cache_release(new_page);
1533 page_table = pte_offset_map(pmd, address);
1536 * This silly early PAGE_DIRTY setting removes a race
1537 * due to the bad i386 page protection. But it's valid
1538 * for other architectures too.
1540 * Note that if write_access is true, we either now have
1541 * an exclusive copy of the page, or this is a shared mapping,
1542 * so we can make it writable and dirty to avoid having to
1543 * handle that later.
1545 /* Only go through if we didn't race with anybody else... */
1546 if (pte_none(*page_table)) {
1547 if (!PageReserved(new_page))
1549 vx_rsspages_inc(mm);
1550 flush_icache_page(vma, new_page);
1551 entry = mk_pte(new_page, vma->vm_page_prot);
1553 entry = maybe_mkwrite(pte_mkdirty(entry), vma);
1554 set_pte(page_table, entry);
1556 lru_cache_add_active(new_page);
1557 page_add_anon_rmap(new_page, vma, address);
1559 page_add_file_rmap(new_page);
1560 pte_unmap(page_table);
1562 /* One of our sibling threads was faster, back out. */
1563 pte_unmap(page_table);
1564 page_cache_release(new_page);
1565 spin_unlock(&mm->page_table_lock);
1569 /* no need to invalidate: a not-present page shouldn't be cached */
1570 update_mmu_cache(vma, address, entry);
1571 spin_unlock(&mm->page_table_lock);
1575 page_cache_release(new_page);
1581 * Fault of a previously existing named mapping. Repopulate the pte
1582 * from the encoded file_pte if possible. This enables swappable
1585 static int do_file_page(struct mm_struct * mm, struct vm_area_struct * vma,
1586 unsigned long address, int write_access, pte_t *pte, pmd_t *pmd)
1588 unsigned long pgoff;
1591 BUG_ON(!vma->vm_ops || !vma->vm_ops->nopage);
1593 * Fall back to the linear mapping if the fs does not support
1596 if (!vma->vm_ops || !vma->vm_ops->populate ||
1597 (write_access && !(vma->vm_flags & VM_SHARED))) {
1599 return do_no_page(mm, vma, address, write_access, pte, pmd);
1602 pgoff = pte_to_pgoff(*pte);
1605 spin_unlock(&mm->page_table_lock);
1607 err = vma->vm_ops->populate(vma, address & PAGE_MASK, PAGE_SIZE, vma->vm_page_prot, pgoff, 0);
1609 return VM_FAULT_OOM;
1611 return VM_FAULT_SIGBUS;
1612 return VM_FAULT_MAJOR;
1616 * These routines also need to handle stuff like marking pages dirty
1617 * and/or accessed for architectures that don't do it in hardware (most
1618 * RISC architectures). The early dirtying is also good on the i386.
1620 * There is also a hook called "update_mmu_cache()" that architectures
1621 * with external mmu caches can use to update those (ie the Sparc or
1622 * PowerPC hashed page tables that act as extended TLBs).
1624 * Note the "page_table_lock". It is to protect against kswapd removing
1625 * pages from under us. Note that kswapd only ever _removes_ pages, never
1626 * adds them. As such, once we have noticed that the page is not present,
1627 * we can drop the lock early.
1629 * The adding of pages is protected by the MM semaphore (which we hold),
1630 * so we don't need to worry about a page being suddenly been added into
1633 * We enter with the pagetable spinlock held, we are supposed to
1634 * release it when done.
1636 static inline int handle_pte_fault(struct mm_struct *mm,
1637 struct vm_area_struct * vma, unsigned long address,
1638 int write_access, pte_t *pte, pmd_t *pmd)
1643 if (!pte_present(entry)) {
1645 * If it truly wasn't present, we know that kswapd
1646 * and the PTE updates will not touch it later. So
1649 if (pte_none(entry))
1650 return do_no_page(mm, vma, address, write_access, pte, pmd);
1651 if (pte_file(entry))
1652 return do_file_page(mm, vma, address, write_access, pte, pmd);
1653 return do_swap_page(mm, vma, address, pte, pmd, entry, write_access);
1657 if (!pte_write(entry))
1658 return do_wp_page(mm, vma, address, pte, pmd, entry);
1660 entry = pte_mkdirty(entry);
1662 entry = pte_mkyoung(entry);
1663 ptep_set_access_flags(vma, address, pte, entry, write_access);
1664 update_mmu_cache(vma, address, entry);
1666 spin_unlock(&mm->page_table_lock);
1667 return VM_FAULT_MINOR;
1671 * By the time we get here, we already hold the mm semaphore
1673 int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct * vma,
1674 unsigned long address, int write_access)
1679 __set_current_state(TASK_RUNNING);
1680 pgd = pgd_offset(mm, address);
1682 inc_page_state(pgfault);
1684 if (is_vm_hugetlb_page(vma))
1685 return VM_FAULT_SIGBUS; /* mapping truncation does this. */
1688 * We need the page table lock to synchronize with kswapd
1689 * and the SMP-safe atomic PTE updates.
1691 spin_lock(&mm->page_table_lock);
1692 pmd = pmd_alloc(mm, pgd, address);
1695 pte_t * pte = pte_alloc_map(mm, pmd, address);
1697 return handle_pte_fault(mm, vma, address, write_access, pte, pmd);
1699 spin_unlock(&mm->page_table_lock);
1700 return VM_FAULT_OOM;
1704 * Allocate page middle directory.
1706 * We've already handled the fast-path in-line, and we own the
1709 * On a two-level page table, this ends up actually being entirely
1712 pmd_t fastcall *__pmd_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
1716 spin_unlock(&mm->page_table_lock);
1717 new = pmd_alloc_one(mm, address);
1718 spin_lock(&mm->page_table_lock);
1723 * Because we dropped the lock, we should re-check the
1724 * entry, as somebody else could have populated it..
1726 if (pgd_present(*pgd)) {
1730 pgd_populate(mm, pgd, new);
1732 return pmd_offset(pgd, address);
1735 int make_pages_present(unsigned long addr, unsigned long end)
1737 int ret, len, write;
1738 struct vm_area_struct * vma;
1740 vma = find_vma(current->mm, addr);
1741 write = (vma->vm_flags & VM_WRITE) != 0;
1744 if (end > vma->vm_end)
1746 len = (end+PAGE_SIZE-1)/PAGE_SIZE-addr/PAGE_SIZE;
1747 ret = get_user_pages(current, current->mm, addr,
1748 len, write, 0, NULL, NULL);
1751 return ret == len ? 0 : -1;
1755 * Map a vmalloc()-space virtual address to the physical page.
1757 struct page * vmalloc_to_page(void * vmalloc_addr)
1759 unsigned long addr = (unsigned long) vmalloc_addr;
1760 struct page *page = NULL;
1761 pgd_t *pgd = pgd_offset_k(addr);
1765 if (!pgd_none(*pgd)) {
1766 pmd = pmd_offset(pgd, addr);
1767 if (!pmd_none(*pmd)) {
1769 ptep = pte_offset_map(pmd, addr);
1771 if (pte_present(pte))
1772 page = pte_page(pte);
1780 EXPORT_SYMBOL(vmalloc_to_page);
1782 #if !defined(CONFIG_ARCH_GATE_AREA)
1784 #if defined(AT_SYSINFO_EHDR)
1785 struct vm_area_struct gate_vma;
1787 static int __init gate_vma_init(void)
1789 gate_vma.vm_mm = NULL;
1790 gate_vma.vm_start = FIXADDR_USER_START;
1791 gate_vma.vm_end = FIXADDR_USER_END;
1792 gate_vma.vm_page_prot = PAGE_READONLY;
1793 gate_vma.vm_flags = 0;
1796 __initcall(gate_vma_init);
1799 struct vm_area_struct *get_gate_vma(struct task_struct *tsk)
1801 #ifdef AT_SYSINFO_EHDR
1808 int in_gate_area(struct task_struct *task, unsigned long addr)
1810 #ifdef AT_SYSINFO_EHDR
1811 if ((addr >= FIXADDR_USER_START) && (addr < FIXADDR_USER_END))