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>
52 #include <asm/uaccess.h>
54 #include <asm/tlbflush.h>
55 #include <asm/pgtable.h>
57 #include <linux/swapops.h>
58 #include <linux/elf.h>
60 #ifndef CONFIG_DISCONTIGMEM
61 /* use the per-pgdat data instead for discontigmem - mbligh */
62 unsigned long max_mapnr;
65 EXPORT_SYMBOL(max_mapnr);
66 EXPORT_SYMBOL(mem_map);
69 unsigned long num_physpages;
71 struct page *highmem_start_page;
73 EXPORT_SYMBOL(num_physpages);
74 EXPORT_SYMBOL(highmem_start_page);
75 EXPORT_SYMBOL(high_memory);
78 * We special-case the C-O-W ZERO_PAGE, because it's such
79 * a common occurrence (no need to read the page to know
80 * that it's zero - better for the cache and memory subsystem).
82 static inline void copy_cow_page(struct page * from, struct page * to, unsigned long address)
84 if (from == ZERO_PAGE(address)) {
85 clear_user_highpage(to, address);
88 copy_user_highpage(to, from, address);
92 * Note: this doesn't free the actual pages themselves. That
93 * has been handled earlier when unmapping all the memory regions.
95 static inline void free_one_pmd(struct mmu_gather *tlb, pmd_t * dir)
106 page = pmd_page(*dir);
108 pgtable_remove_rmap(page);
109 pte_free_tlb(tlb, page);
112 static inline void free_one_pgd(struct mmu_gather *tlb, pgd_t * dir)
124 pmd = pmd_offset(dir, 0);
126 for (j = 0; j < PTRS_PER_PMD ; j++)
127 free_one_pmd(tlb, pmd+j);
128 pmd_free_tlb(tlb, pmd);
132 * This function clears all user-level page tables of a process - this
133 * is needed by execve(), so that old pages aren't in the way.
135 * Must be called with pagetable lock held.
137 void clear_page_tables(struct mmu_gather *tlb, unsigned long first, int nr)
139 pgd_t * page_dir = tlb->mm->pgd;
143 free_one_pgd(tlb, page_dir);
148 pte_t fastcall * pte_alloc_map(struct mm_struct *mm, pmd_t *pmd, unsigned long address)
150 if (!pmd_present(*pmd)) {
153 spin_unlock(&mm->page_table_lock);
154 new = pte_alloc_one(mm, address);
155 spin_lock(&mm->page_table_lock);
160 * Because we dropped the lock, we should re-check the
161 * entry, as somebody else could have populated it..
163 if (pmd_present(*pmd)) {
167 pgtable_add_rmap(new, mm, address);
168 pmd_populate(mm, pmd, new);
171 return pte_offset_map(pmd, address);
174 pte_t fastcall * pte_alloc_kernel(struct mm_struct *mm, pmd_t *pmd, unsigned long address)
176 if (!pmd_present(*pmd)) {
179 spin_unlock(&mm->page_table_lock);
180 new = pte_alloc_one_kernel(mm, address);
181 spin_lock(&mm->page_table_lock);
186 * Because we dropped the lock, we should re-check the
187 * entry, as somebody else could have populated it..
189 if (pmd_present(*pmd)) {
190 pte_free_kernel(new);
193 pgtable_add_rmap(virt_to_page(new), mm, address);
194 pmd_populate_kernel(mm, pmd, new);
197 return pte_offset_kernel(pmd, address);
199 #define PTE_TABLE_MASK ((PTRS_PER_PTE-1) * sizeof(pte_t))
200 #define PMD_TABLE_MASK ((PTRS_PER_PMD-1) * sizeof(pmd_t))
203 * copy one vm_area from one task to the other. Assumes the page tables
204 * already present in the new task to be cleared in the whole range
205 * covered by this vma.
207 * 08Jan98 Merged into one routine from several inline routines to reduce
208 * variable count and make things faster. -jj
210 * dst->page_table_lock is held on entry and exit,
211 * but may be dropped within pmd_alloc() and pte_alloc_map().
213 int copy_page_range(struct mm_struct *dst, struct mm_struct *src,
214 struct vm_area_struct *vma)
216 pgd_t * src_pgd, * dst_pgd;
217 unsigned long address = vma->vm_start;
218 unsigned long end = vma->vm_end;
220 struct pte_chain *pte_chain = NULL;
222 if (is_vm_hugetlb_page(vma))
223 return copy_hugetlb_page_range(dst, src, vma);
225 pte_chain = pte_chain_alloc(GFP_ATOMIC | __GFP_NOWARN);
227 spin_unlock(&dst->page_table_lock);
228 pte_chain = pte_chain_alloc(GFP_KERNEL);
229 spin_lock(&dst->page_table_lock);
234 cow = (vma->vm_flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE;
235 src_pgd = pgd_offset(src, address)-1;
236 dst_pgd = pgd_offset(dst, address)-1;
239 pmd_t * src_pmd, * dst_pmd;
241 src_pgd++; dst_pgd++;
245 if (pgd_none(*src_pgd))
246 goto skip_copy_pmd_range;
247 if (pgd_bad(*src_pgd)) {
250 skip_copy_pmd_range: address = (address + PGDIR_SIZE) & PGDIR_MASK;
251 if (!address || (address >= end))
256 src_pmd = pmd_offset(src_pgd, address);
257 dst_pmd = pmd_alloc(dst, dst_pgd, address);
262 pte_t * src_pte, * dst_pte;
266 if (pmd_none(*src_pmd))
267 goto skip_copy_pte_range;
268 if (pmd_bad(*src_pmd)) {
272 address = (address + PMD_SIZE) & PMD_MASK;
275 goto cont_copy_pmd_range;
278 dst_pte = pte_alloc_map(dst, dst_pmd, address);
281 spin_lock(&src->page_table_lock);
282 src_pte = pte_offset_map_nested(src_pmd, address);
284 pte_t pte = *src_pte;
291 goto cont_copy_pte_range_noset;
292 /* pte contains position in swap, so copy. */
293 if (!pte_present(pte)) {
295 swap_duplicate(pte_to_swp_entry(pte));
296 set_pte(dst_pte, pte);
297 goto cont_copy_pte_range_noset;
300 /* the pte points outside of valid memory, the
301 * mapping is assumed to be good, meaningful
302 * and not mapped via rmap - duplicate the
307 page = pfn_to_page(pfn);
309 if (!page || PageReserved(page)) {
310 set_pte(dst_pte, pte);
311 goto cont_copy_pte_range_noset;
315 * If it's a COW mapping, write protect it both
316 * in the parent and the child
319 ptep_set_wrprotect(src_pte);
324 * If it's a shared mapping, mark it clean in
327 if (vma->vm_flags & VM_SHARED)
328 pte = pte_mkclean(pte);
329 pte = pte_mkold(pte);
333 set_pte(dst_pte, pte);
334 pte_chain = page_add_rmap(page, dst_pte,
337 goto cont_copy_pte_range_noset;
338 pte_chain = pte_chain_alloc(GFP_ATOMIC | __GFP_NOWARN);
340 goto cont_copy_pte_range_noset;
343 * pte_chain allocation failed, and we need to
346 pte_unmap_nested(src_pte);
348 spin_unlock(&src->page_table_lock);
349 spin_unlock(&dst->page_table_lock);
350 pte_chain = pte_chain_alloc(GFP_KERNEL);
351 spin_lock(&dst->page_table_lock);
354 spin_lock(&src->page_table_lock);
355 dst_pte = pte_offset_map(dst_pmd, address);
356 src_pte = pte_offset_map_nested(src_pmd,
358 cont_copy_pte_range_noset:
359 address += PAGE_SIZE;
360 if (address >= end) {
361 pte_unmap_nested(src_pte);
367 } while ((unsigned long)src_pte & PTE_TABLE_MASK);
368 pte_unmap_nested(src_pte-1);
369 pte_unmap(dst_pte-1);
370 spin_unlock(&src->page_table_lock);
375 } while ((unsigned long)src_pmd & PMD_TABLE_MASK);
378 spin_unlock(&src->page_table_lock);
380 pte_chain_free(pte_chain);
383 pte_chain_free(pte_chain);
387 static void zap_pte_range(struct mmu_gather *tlb,
388 pmd_t *pmd, unsigned long address,
389 unsigned long size, struct zap_details *details)
391 unsigned long offset;
401 ptep = pte_offset_map(pmd, address);
402 offset = address & ~PMD_MASK;
403 if (offset + size > PMD_SIZE)
404 size = PMD_SIZE - offset;
406 for (offset=0; offset < size; ptep++, offset += PAGE_SIZE) {
410 if (pte_present(pte)) {
411 struct page *page = NULL;
412 unsigned long pfn = pte_pfn(pte);
413 if (pfn_valid(pfn)) {
414 page = pfn_to_page(pfn);
415 if (PageReserved(page))
418 if (unlikely(details) && page) {
420 * unmap_shared_mapping_pages() wants to
421 * invalidate cache without truncating:
422 * unmap shared but keep private pages.
424 if (details->check_mapping &&
425 details->check_mapping != page->mapping)
428 * Each page->index must be checked when
429 * invalidating or truncating nonlinear.
431 if (details->nonlinear_vma &&
432 (page->index < details->first_index ||
433 page->index > details->last_index))
436 pte = ptep_get_and_clear(ptep);
437 tlb_remove_tlb_entry(tlb, ptep, address+offset);
440 if (unlikely(details) && details->nonlinear_vma
441 && linear_page_index(details->nonlinear_vma,
442 address+offset) != page->index)
443 set_pte(ptep, pgoff_to_pte(page->index));
445 set_page_dirty(page);
446 if (pte_young(pte) && page_mapping(page))
447 mark_page_accessed(page);
449 page_remove_rmap(page, ptep);
450 tlb_remove_page(tlb, page);
454 * If details->check_mapping, we leave swap entries;
455 * if details->nonlinear_vma, we leave file entries.
457 if (unlikely(details))
460 free_swap_and_cache(pte_to_swp_entry(pte));
466 static void zap_pmd_range(struct mmu_gather *tlb,
467 pgd_t * dir, unsigned long address,
468 unsigned long size, struct zap_details *details)
480 pmd = pmd_offset(dir, address);
481 end = address + size;
482 if (end > ((address + PGDIR_SIZE) & PGDIR_MASK))
483 end = ((address + PGDIR_SIZE) & PGDIR_MASK);
485 zap_pte_range(tlb, pmd, address, end - address, details);
486 address = (address + PMD_SIZE) & PMD_MASK;
488 } while (address < end);
491 static void unmap_page_range(struct mmu_gather *tlb,
492 struct vm_area_struct *vma, unsigned long address,
493 unsigned long end, struct zap_details *details)
497 BUG_ON(address >= end);
498 dir = pgd_offset(vma->vm_mm, address);
499 tlb_start_vma(tlb, vma);
501 zap_pmd_range(tlb, dir, address, end - address, details);
502 address = (address + PGDIR_SIZE) & PGDIR_MASK;
504 } while (address && (address < end));
505 tlb_end_vma(tlb, vma);
508 /* Dispose of an entire struct mmu_gather per rescheduling point */
509 #if defined(CONFIG_SMP) && defined(CONFIG_PREEMPT)
510 #define ZAP_BLOCK_SIZE (FREE_PTE_NR * PAGE_SIZE)
513 /* For UP, 256 pages at a time gives nice low latency */
514 #if !defined(CONFIG_SMP) && defined(CONFIG_PREEMPT)
515 #define ZAP_BLOCK_SIZE (256 * PAGE_SIZE)
518 /* No preempt: go for improved straight-line efficiency */
519 #if !defined(CONFIG_PREEMPT)
520 #define ZAP_BLOCK_SIZE (1024 * PAGE_SIZE)
524 * unmap_vmas - unmap a range of memory covered by a list of vma's
525 * @tlbp: address of the caller's struct mmu_gather
526 * @mm: the controlling mm_struct
527 * @vma: the starting vma
528 * @start_addr: virtual address at which to start unmapping
529 * @end_addr: virtual address at which to end unmapping
530 * @nr_accounted: Place number of unmapped pages in vm-accountable vma's here
531 * @details: details of nonlinear truncation or shared cache invalidation
533 * Returns the number of vma's which were covered by the unmapping.
535 * Unmap all pages in the vma list. Called under page_table_lock.
537 * We aim to not hold page_table_lock for too long (for scheduling latency
538 * reasons). So zap pages in ZAP_BLOCK_SIZE bytecounts. This means we need to
539 * return the ending mmu_gather to the caller.
541 * Only addresses between `start' and `end' will be unmapped.
543 * The VMA list must be sorted in ascending virtual address order.
545 * unmap_vmas() assumes that the caller will flush the whole unmapped address
546 * range after unmap_vmas() returns. So the only responsibility here is to
547 * ensure that any thus-far unmapped pages are flushed before unmap_vmas()
548 * drops the lock and schedules.
550 int unmap_vmas(struct mmu_gather **tlbp, struct mm_struct *mm,
551 struct vm_area_struct *vma, unsigned long start_addr,
552 unsigned long end_addr, unsigned long *nr_accounted,
553 struct zap_details *details)
555 unsigned long zap_bytes = ZAP_BLOCK_SIZE;
556 unsigned long tlb_start = 0; /* For tlb_finish_mmu */
557 int tlb_start_valid = 0;
560 for ( ; vma && vma->vm_start < end_addr; vma = vma->vm_next) {
564 start = max(vma->vm_start, start_addr);
565 if (start >= vma->vm_end)
567 end = min(vma->vm_end, end_addr);
568 if (end <= vma->vm_start)
571 if (vma->vm_flags & VM_ACCOUNT)
572 *nr_accounted += (end - start) >> PAGE_SHIFT;
575 while (start != end) {
578 if (!tlb_start_valid) {
583 if (is_vm_hugetlb_page(vma)) {
585 unmap_hugepage_range(vma, start, end);
587 block = min(zap_bytes, end - start);
588 unmap_page_range(*tlbp, vma, start,
589 start + block, details);
594 if ((long)zap_bytes > 0)
596 if (need_resched()) {
597 int fullmm = tlb_is_full_mm(*tlbp);
598 tlb_finish_mmu(*tlbp, tlb_start, start);
599 cond_resched_lock(&mm->page_table_lock);
600 *tlbp = tlb_gather_mmu(mm, fullmm);
603 zap_bytes = ZAP_BLOCK_SIZE;
610 * zap_page_range - remove user pages in a given range
611 * @vma: vm_area_struct holding the applicable pages
612 * @address: starting address of pages to zap
613 * @size: number of bytes to zap
614 * @details: details of nonlinear truncation or shared cache invalidation
616 void zap_page_range(struct vm_area_struct *vma, unsigned long address,
617 unsigned long size, struct zap_details *details)
619 struct mm_struct *mm = vma->vm_mm;
620 struct mmu_gather *tlb;
621 unsigned long end = address + size;
622 unsigned long nr_accounted = 0;
626 if (is_vm_hugetlb_page(vma)) {
627 zap_hugepage_range(vma, address, size);
632 spin_lock(&mm->page_table_lock);
633 tlb = tlb_gather_mmu(mm, 0);
634 unmap_vmas(&tlb, mm, vma, address, end, &nr_accounted, details);
635 tlb_finish_mmu(tlb, address, end);
636 spin_unlock(&mm->page_table_lock);
640 * Do a quick page-table lookup for a single page.
641 * mm->page_table_lock must be held.
644 follow_page(struct mm_struct *mm, unsigned long address, int write)
652 page = follow_huge_addr(mm, address, write);
656 pgd = pgd_offset(mm, address);
657 if (pgd_none(*pgd) || pgd_bad(*pgd))
660 pmd = pmd_offset(pgd, address);
664 return follow_huge_pmd(mm, address, pmd, write);
668 ptep = pte_offset_map(pmd, address);
674 if (pte_present(pte)) {
675 if (write && !pte_write(pte))
677 if (write && !pte_dirty(pte)) {
678 struct page *page = pte_page(pte);
679 if (!PageDirty(page))
680 set_page_dirty(page);
683 if (pfn_valid(pfn)) {
684 struct page *page = pfn_to_page(pfn);
686 mark_page_accessed(page);
696 * Given a physical address, is there a useful struct page pointing to
697 * it? This may become more complex in the future if we start dealing
698 * with IO-aperture pages for direct-IO.
701 static inline struct page *get_page_map(struct page *page)
703 if (!pfn_valid(page_to_pfn(page)))
710 untouched_anonymous_page(struct mm_struct* mm, struct vm_area_struct *vma,
711 unsigned long address)
716 /* Check if the vma is for an anonymous mapping. */
717 if (vma->vm_ops && vma->vm_ops->nopage)
720 /* Check if page directory entry exists. */
721 pgd = pgd_offset(mm, address);
722 if (pgd_none(*pgd) || pgd_bad(*pgd))
725 /* Check if page middle directory entry exists. */
726 pmd = pmd_offset(pgd, address);
727 if (pmd_none(*pmd) || pmd_bad(*pmd))
730 /* There is a pte slot for 'address' in 'mm'. */
735 int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
736 unsigned long start, int len, int write, int force,
737 struct page **pages, struct vm_area_struct **vmas)
743 * Require read or write permissions.
744 * If 'force' is set, we only require the "MAY" flags.
746 flags = write ? (VM_WRITE | VM_MAYWRITE) : (VM_READ | VM_MAYREAD);
747 flags &= force ? (VM_MAYREAD | VM_MAYWRITE) : (VM_READ | VM_WRITE);
751 struct vm_area_struct * vma;
753 vma = find_extend_vma(mm, start);
754 if (!vma && in_gate_area(tsk, start)) {
755 unsigned long pg = start & PAGE_MASK;
756 struct vm_area_struct *gate_vma = get_gate_vma(tsk);
760 if (write) /* user gate pages are read-only */
761 return i ? : -EFAULT;
762 pgd = pgd_offset_k(pg);
764 return i ? : -EFAULT;
765 pmd = pmd_offset(pgd, pg);
767 return i ? : -EFAULT;
768 pte = pte_offset_kernel(pmd, pg);
769 if (!pte || !pte_present(*pte))
770 return i ? : -EFAULT;
772 pages[i] = pte_page(*pte);
783 if (!vma || (pages && (vma->vm_flags & VM_IO))
784 || !(flags & vma->vm_flags))
785 return i ? : -EFAULT;
787 if (is_vm_hugetlb_page(vma)) {
788 i = follow_hugetlb_page(mm, vma, pages, vmas,
792 spin_lock(&mm->page_table_lock);
795 int lookup_write = write;
796 while (!(map = follow_page(mm, start, lookup_write))) {
798 * Shortcut for anonymous pages. We don't want
799 * to force the creation of pages tables for
800 * insanly big anonymously mapped areas that
801 * nobody touched so far. This is important
802 * for doing a core dump for these mappings.
805 untouched_anonymous_page(mm,vma,start)) {
806 map = ZERO_PAGE(start);
809 spin_unlock(&mm->page_table_lock);
810 switch (handle_mm_fault(mm,vma,start,write)) {
817 case VM_FAULT_SIGBUS:
818 return i ? i : -EFAULT;
820 return i ? i : -ENOMEM;
825 * Now that we have performed a write fault
826 * and surely no longer have a shared page we
827 * shouldn't write, we shouldn't ignore an
828 * unwritable page in the page table if
829 * we are forcing write access.
831 lookup_write = write && !force;
832 spin_lock(&mm->page_table_lock);
835 pages[i] = get_page_map(map);
837 spin_unlock(&mm->page_table_lock);
839 page_cache_release(pages[i]);
843 flush_dcache_page(pages[i]);
844 if (!PageReserved(pages[i]))
845 page_cache_get(pages[i]);
852 } while(len && start < vma->vm_end);
853 spin_unlock(&mm->page_table_lock);
859 EXPORT_SYMBOL(get_user_pages);
861 static void zeromap_pte_range(pte_t * pte, unsigned long address,
862 unsigned long size, pgprot_t prot)
866 address &= ~PMD_MASK;
867 end = address + size;
871 pte_t zero_pte = pte_wrprotect(mk_pte(ZERO_PAGE(address), prot));
872 BUG_ON(!pte_none(*pte));
873 set_pte(pte, zero_pte);
874 address += PAGE_SIZE;
876 } while (address && (address < end));
879 static inline int zeromap_pmd_range(struct mm_struct *mm, pmd_t * pmd, unsigned long address,
880 unsigned long size, pgprot_t prot)
882 unsigned long base, end;
884 base = address & PGDIR_MASK;
885 address &= ~PGDIR_MASK;
886 end = address + size;
887 if (end > PGDIR_SIZE)
890 pte_t * pte = pte_alloc_map(mm, pmd, base + address);
893 zeromap_pte_range(pte, base + address, end - address, prot);
895 address = (address + PMD_SIZE) & PMD_MASK;
897 } while (address && (address < end));
901 int zeromap_page_range(struct vm_area_struct *vma, unsigned long address, unsigned long size, pgprot_t prot)
905 unsigned long beg = address;
906 unsigned long end = address + size;
907 struct mm_struct *mm = vma->vm_mm;
909 dir = pgd_offset(mm, address);
910 flush_cache_range(vma, beg, end);
914 spin_lock(&mm->page_table_lock);
916 pmd_t *pmd = pmd_alloc(mm, dir, address);
920 error = zeromap_pmd_range(mm, pmd, address, end - address, prot);
923 address = (address + PGDIR_SIZE) & PGDIR_MASK;
925 } while (address && (address < end));
927 * Why flush? zeromap_pte_range has a BUG_ON for !pte_none()
929 flush_tlb_range(vma, beg, end);
930 spin_unlock(&mm->page_table_lock);
935 * maps a range of physical memory into the requested pages. the old
936 * mappings are removed. any references to nonexistent pages results
937 * in null mappings (currently treated as "copy-on-access")
939 static inline void remap_pte_range(pte_t * pte, unsigned long address, unsigned long size,
940 unsigned long phys_addr, pgprot_t prot)
945 address &= ~PMD_MASK;
946 end = address + size;
949 pfn = phys_addr >> PAGE_SHIFT;
951 BUG_ON(!pte_none(*pte));
952 if (!pfn_valid(pfn) || PageReserved(pfn_to_page(pfn)))
953 set_pte(pte, pfn_pte(pfn, prot));
954 address += PAGE_SIZE;
957 } while (address && (address < end));
960 static inline int remap_pmd_range(struct mm_struct *mm, pmd_t * pmd, unsigned long address, unsigned long size,
961 unsigned long phys_addr, pgprot_t prot)
963 unsigned long base, end;
965 base = address & PGDIR_MASK;
966 address &= ~PGDIR_MASK;
967 end = address + size;
968 if (end > PGDIR_SIZE)
970 phys_addr -= address;
972 pte_t * pte = pte_alloc_map(mm, pmd, base + address);
975 remap_pte_range(pte, base + address, end - address, address + phys_addr, prot);
977 address = (address + PMD_SIZE) & PMD_MASK;
979 } while (address && (address < end));
983 /* Note: this is only safe if the mm semaphore is held when called. */
984 int remap_page_range(struct vm_area_struct *vma, unsigned long from, unsigned long phys_addr, unsigned long size, pgprot_t prot)
988 unsigned long beg = from;
989 unsigned long end = from + size;
990 struct mm_struct *mm = vma->vm_mm;
993 dir = pgd_offset(mm, from);
994 flush_cache_range(vma, beg, end);
998 spin_lock(&mm->page_table_lock);
1000 pmd_t *pmd = pmd_alloc(mm, dir, from);
1004 error = remap_pmd_range(mm, pmd, from, end - from, phys_addr + from, prot);
1007 from = (from + PGDIR_SIZE) & PGDIR_MASK;
1009 } while (from && (from < end));
1011 * Why flush? remap_pte_range has a BUG_ON for !pte_none()
1013 flush_tlb_range(vma, beg, end);
1014 spin_unlock(&mm->page_table_lock);
1018 EXPORT_SYMBOL(remap_page_range);
1021 * Do pte_mkwrite, but only if the vma says VM_WRITE. We do this when
1022 * servicing faults for write access. In the normal case, do always want
1023 * pte_mkwrite. But get_user_pages can cause write faults for mappings
1024 * that do not have writing enabled, when used by access_process_vm.
1026 static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct *vma)
1028 if (likely(vma->vm_flags & VM_WRITE))
1029 pte = pte_mkwrite(pte);
1034 * We hold the mm semaphore for reading and vma->vm_mm->page_table_lock
1036 static inline void break_cow(struct vm_area_struct * vma, struct page * new_page, unsigned long address,
1041 flush_cache_page(vma, address);
1042 entry = maybe_mkwrite(pte_mkdirty(mk_pte(new_page, vma->vm_page_prot)),
1044 ptep_establish(vma, address, page_table, entry);
1045 update_mmu_cache(vma, address, entry);
1049 * This routine handles present pages, when users try to write
1050 * to a shared page. It is done by copying the page to a new address
1051 * and decrementing the shared-page counter for the old page.
1053 * Goto-purists beware: the only reason for goto's here is that it results
1054 * in better assembly code.. The "default" path will see no jumps at all.
1056 * Note that this routine assumes that the protection checks have been
1057 * done by the caller (the low-level page fault routine in most cases).
1058 * Thus we can safely just mark it writable once we've done any necessary
1061 * We also mark the page dirty at this point even though the page will
1062 * change only once the write actually happens. This avoids a few races,
1063 * and potentially makes it more efficient.
1065 * We hold the mm semaphore and the page_table_lock on entry and exit
1066 * with the page_table_lock released.
1068 static int do_wp_page(struct mm_struct *mm, struct vm_area_struct * vma,
1069 unsigned long address, pte_t *page_table, pmd_t *pmd, pte_t pte)
1071 struct page *old_page, *new_page;
1072 unsigned long pfn = pte_pfn(pte);
1073 struct pte_chain *pte_chain;
1076 if (unlikely(!pfn_valid(pfn))) {
1078 * This should really halt the system so it can be debugged or
1079 * at least the kernel stops what it's doing before it corrupts
1080 * data, but for the moment just pretend this is OOM.
1082 pte_unmap(page_table);
1083 printk(KERN_ERR "do_wp_page: bogus page at address %08lx\n",
1085 spin_unlock(&mm->page_table_lock);
1086 return VM_FAULT_OOM;
1088 old_page = pfn_to_page(pfn);
1090 if (!TestSetPageLocked(old_page)) {
1091 int reuse = can_share_swap_page(old_page);
1092 unlock_page(old_page);
1094 flush_cache_page(vma, address);
1095 entry = maybe_mkwrite(pte_mkyoung(pte_mkdirty(pte)),
1097 ptep_establish(vma, address, page_table, entry);
1098 update_mmu_cache(vma, address, entry);
1099 pte_unmap(page_table);
1100 spin_unlock(&mm->page_table_lock);
1101 return VM_FAULT_MINOR;
1104 pte_unmap(page_table);
1107 * Ok, we need to copy. Oh, well..
1109 page_cache_get(old_page);
1110 spin_unlock(&mm->page_table_lock);
1112 pte_chain = pte_chain_alloc(GFP_KERNEL);
1115 new_page = alloc_page(GFP_HIGHUSER);
1118 copy_cow_page(old_page,new_page,address);
1121 * Re-check the pte - we dropped the lock
1123 spin_lock(&mm->page_table_lock);
1124 page_table = pte_offset_map(pmd, address);
1125 if (pte_same(*page_table, pte)) {
1126 if (PageReserved(old_page))
1128 page_remove_rmap(old_page, page_table);
1129 break_cow(vma, new_page, address, page_table);
1130 pte_chain = page_add_rmap(new_page, page_table, pte_chain);
1131 lru_cache_add_active(new_page);
1133 /* Free the old page.. */
1134 new_page = old_page;
1136 pte_unmap(page_table);
1137 page_cache_release(new_page);
1138 page_cache_release(old_page);
1139 spin_unlock(&mm->page_table_lock);
1140 pte_chain_free(pte_chain);
1141 return VM_FAULT_MINOR;
1144 pte_chain_free(pte_chain);
1146 page_cache_release(old_page);
1147 return VM_FAULT_OOM;
1151 * Helper function for unmap_mapping_range().
1153 static void unmap_mapping_range_list(struct list_head *head,
1154 struct zap_details *details)
1156 struct vm_area_struct *vma;
1157 pgoff_t vba, vea, zba, zea;
1159 list_for_each_entry(vma, head, shared) {
1160 if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
1161 details->nonlinear_vma = vma;
1162 zap_page_range(vma, vma->vm_start,
1163 vma->vm_end - vma->vm_start, details);
1164 details->nonlinear_vma = NULL;
1167 vba = vma->vm_pgoff;
1168 vea = vba + ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT) - 1;
1169 /* Assume for now that PAGE_CACHE_SHIFT == PAGE_SHIFT */
1170 if (vba > details->last_index || vea < details->first_index)
1171 continue; /* Mapping disjoint from hole. */
1172 zba = details->first_index;
1175 zea = details->last_index;
1179 ((zba - vba) << PAGE_SHIFT) + vma->vm_start,
1180 (zea - zba + 1) << PAGE_SHIFT,
1181 details->check_mapping? details: NULL);
1186 * unmap_mapping_range - unmap the portion of all mmaps
1187 * in the specified address_space corresponding to the specified
1188 * page range in the underlying file.
1189 * @address_space: the address space containing mmaps to be unmapped.
1190 * @holebegin: byte in first page to unmap, relative to the start of
1191 * the underlying file. This will be rounded down to a PAGE_SIZE
1192 * boundary. Note that this is different from vmtruncate(), which
1193 * must keep the partial page. In contrast, we must get rid of
1195 * @holelen: size of prospective hole in bytes. This will be rounded
1196 * up to a PAGE_SIZE boundary. A holelen of zero truncates to the
1198 * @even_cows: 1 when truncating a file, unmap even private COWed pages;
1199 * but 0 when invalidating pagecache, don't throw away private data.
1201 void unmap_mapping_range(struct address_space *mapping,
1202 loff_t const holebegin, loff_t const holelen, int even_cows)
1204 struct zap_details details;
1205 pgoff_t hba = holebegin >> PAGE_SHIFT;
1206 pgoff_t hlen = (holelen + PAGE_SIZE - 1) >> PAGE_SHIFT;
1208 /* Check for overflow. */
1209 if (sizeof(holelen) > sizeof(hlen)) {
1211 (holebegin + holelen + PAGE_SIZE - 1) >> PAGE_SHIFT;
1212 if (holeend & ~(long long)ULONG_MAX)
1213 hlen = ULONG_MAX - hba + 1;
1216 details.check_mapping = even_cows? NULL: mapping;
1217 details.nonlinear_vma = NULL;
1218 details.first_index = hba;
1219 details.last_index = hba + hlen - 1;
1220 if (details.last_index < details.first_index)
1221 details.last_index = ULONG_MAX;
1223 down(&mapping->i_shared_sem);
1224 /* Protect against page fault */
1225 atomic_inc(&mapping->truncate_count);
1226 if (unlikely(!list_empty(&mapping->i_mmap)))
1227 unmap_mapping_range_list(&mapping->i_mmap, &details);
1229 /* Don't waste time to check mapping on fully shared vmas */
1230 details.check_mapping = NULL;
1232 if (unlikely(!list_empty(&mapping->i_mmap_shared)))
1233 unmap_mapping_range_list(&mapping->i_mmap_shared, &details);
1234 up(&mapping->i_shared_sem);
1236 EXPORT_SYMBOL(unmap_mapping_range);
1239 * Handle all mappings that got truncated by a "truncate()"
1242 * NOTE! We have to be ready to update the memory sharing
1243 * between the file and the memory map for a potential last
1244 * incomplete page. Ugly, but necessary.
1246 int vmtruncate(struct inode * inode, loff_t offset)
1248 struct address_space *mapping = inode->i_mapping;
1249 unsigned long limit;
1251 if (inode->i_size < offset)
1253 i_size_write(inode, offset);
1254 unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1);
1255 truncate_inode_pages(mapping, offset);
1259 limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
1260 if (limit != RLIM_INFINITY && offset > limit)
1262 if (offset > inode->i_sb->s_maxbytes)
1264 i_size_write(inode, offset);
1267 if (inode->i_op && inode->i_op->truncate)
1268 inode->i_op->truncate(inode);
1271 send_sig(SIGXFSZ, current, 0);
1276 EXPORT_SYMBOL(vmtruncate);
1279 * Primitive swap readahead code. We simply read an aligned block of
1280 * (1 << page_cluster) entries in the swap area. This method is chosen
1281 * because it doesn't cost us any seek time. We also make sure to queue
1282 * the 'original' request together with the readahead ones...
1284 void swapin_readahead(swp_entry_t entry)
1287 struct page *new_page;
1288 unsigned long offset;
1291 * Get the number of handles we should do readahead io to.
1293 num = valid_swaphandles(entry, &offset);
1294 for (i = 0; i < num; offset++, i++) {
1295 /* Ok, do the async read-ahead now */
1296 new_page = read_swap_cache_async(swp_entry(swp_type(entry),
1300 page_cache_release(new_page);
1302 lru_add_drain(); /* Push any new pages onto the LRU now */
1306 * We hold the mm semaphore and the page_table_lock on entry and
1307 * should release the pagetable lock on exit..
1309 static int do_swap_page(struct mm_struct * mm,
1310 struct vm_area_struct * vma, unsigned long address,
1311 pte_t *page_table, pmd_t *pmd, pte_t orig_pte, int write_access)
1314 swp_entry_t entry = pte_to_swp_entry(orig_pte);
1316 int ret = VM_FAULT_MINOR;
1317 struct pte_chain *pte_chain = NULL;
1319 pte_unmap(page_table);
1320 spin_unlock(&mm->page_table_lock);
1321 page = lookup_swap_cache(entry);
1323 swapin_readahead(entry);
1324 page = read_swap_cache_async(entry);
1327 * Back out if somebody else faulted in this pte while
1328 * we released the page table lock.
1330 spin_lock(&mm->page_table_lock);
1331 page_table = pte_offset_map(pmd, address);
1332 if (pte_same(*page_table, orig_pte))
1335 ret = VM_FAULT_MINOR;
1336 pte_unmap(page_table);
1337 spin_unlock(&mm->page_table_lock);
1341 /* Had to read the page from swap area: Major fault */
1342 ret = VM_FAULT_MAJOR;
1343 inc_page_state(pgmajfault);
1346 mark_page_accessed(page);
1347 pte_chain = pte_chain_alloc(GFP_KERNEL);
1355 * Back out if somebody else faulted in this pte while we
1356 * released the page table lock.
1358 spin_lock(&mm->page_table_lock);
1359 page_table = pte_offset_map(pmd, address);
1360 if (!pte_same(*page_table, orig_pte)) {
1361 pte_unmap(page_table);
1362 spin_unlock(&mm->page_table_lock);
1364 page_cache_release(page);
1365 ret = VM_FAULT_MINOR;
1369 /* The page isn't present yet, go ahead with the fault. */
1373 remove_exclusive_swap_page(page);
1376 pte = mk_pte(page, vma->vm_page_prot);
1377 if (write_access && can_share_swap_page(page))
1378 pte = maybe_mkwrite(pte_mkdirty(pte), vma);
1381 flush_icache_page(vma, page);
1382 set_pte(page_table, pte);
1383 pte_chain = page_add_rmap(page, page_table, pte_chain);
1385 /* No need to invalidate - it was non-present before */
1386 update_mmu_cache(vma, address, pte);
1387 pte_unmap(page_table);
1388 spin_unlock(&mm->page_table_lock);
1390 pte_chain_free(pte_chain);
1395 * We are called with the MM semaphore and page_table_lock
1396 * spinlock held to protect against concurrent faults in
1397 * multithreaded programs.
1400 do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
1401 pte_t *page_table, pmd_t *pmd, int write_access,
1405 struct page * page = ZERO_PAGE(addr);
1406 struct pte_chain *pte_chain;
1409 pte_chain = pte_chain_alloc(GFP_ATOMIC | __GFP_NOWARN);
1411 pte_unmap(page_table);
1412 spin_unlock(&mm->page_table_lock);
1413 pte_chain = pte_chain_alloc(GFP_KERNEL);
1416 spin_lock(&mm->page_table_lock);
1417 page_table = pte_offset_map(pmd, addr);
1420 /* Read-only mapping of ZERO_PAGE. */
1421 entry = pte_wrprotect(mk_pte(ZERO_PAGE(addr), vma->vm_page_prot));
1423 /* ..except if it's a write access */
1425 /* Allocate our own private page. */
1426 pte_unmap(page_table);
1427 spin_unlock(&mm->page_table_lock);
1429 page = alloc_page(GFP_HIGHUSER);
1432 clear_user_highpage(page, addr);
1434 spin_lock(&mm->page_table_lock);
1435 page_table = pte_offset_map(pmd, addr);
1437 if (!pte_none(*page_table)) {
1438 pte_unmap(page_table);
1439 page_cache_release(page);
1440 spin_unlock(&mm->page_table_lock);
1441 ret = VM_FAULT_MINOR;
1445 entry = maybe_mkwrite(pte_mkdirty(mk_pte(page,
1446 vma->vm_page_prot)),
1448 lru_cache_add_active(page);
1449 mark_page_accessed(page);
1452 set_pte(page_table, entry);
1453 /* ignores ZERO_PAGE */
1454 pte_chain = page_add_rmap(page, page_table, pte_chain);
1455 pte_unmap(page_table);
1457 /* No need to invalidate - it was non-present before */
1458 update_mmu_cache(vma, addr, entry);
1459 spin_unlock(&mm->page_table_lock);
1460 ret = VM_FAULT_MINOR;
1466 pte_chain_free(pte_chain);
1471 * do_no_page() tries to create a new page mapping. It aggressively
1472 * tries to share with existing pages, but makes a separate copy if
1473 * the "write_access" parameter is true in order to avoid the next
1476 * As this is called only for pages that do not currently exist, we
1477 * do not need to flush old virtual caches or the TLB.
1479 * This is called with the MM semaphore held and the page table
1480 * spinlock held. Exit with the spinlock released.
1483 do_no_page(struct mm_struct *mm, struct vm_area_struct *vma,
1484 unsigned long address, int write_access, pte_t *page_table, pmd_t *pmd)
1486 struct page * new_page;
1487 struct address_space *mapping = NULL;
1489 struct pte_chain *pte_chain;
1491 int ret = VM_FAULT_MINOR;
1493 if (!vma->vm_ops || !vma->vm_ops->nopage)
1494 return do_anonymous_page(mm, vma, page_table,
1495 pmd, write_access, address);
1496 pte_unmap(page_table);
1497 spin_unlock(&mm->page_table_lock);
1500 mapping = vma->vm_file->f_mapping;
1501 sequence = atomic_read(&mapping->truncate_count);
1503 smp_rmb(); /* Prevent CPU from reordering lock-free ->nopage() */
1505 new_page = vma->vm_ops->nopage(vma, address & PAGE_MASK, &ret);
1507 /* no page was available -- either SIGBUS or OOM */
1508 if (new_page == NOPAGE_SIGBUS)
1509 return VM_FAULT_SIGBUS;
1510 if (new_page == NOPAGE_OOM)
1511 return VM_FAULT_OOM;
1513 pte_chain = pte_chain_alloc(GFP_KERNEL);
1518 * Should we do an early C-O-W break?
1520 if (write_access && !(vma->vm_flags & VM_SHARED)) {
1521 struct page * page = alloc_page(GFP_HIGHUSER);
1524 copy_user_highpage(page, new_page, address);
1525 page_cache_release(new_page);
1526 lru_cache_add_active(page);
1530 spin_lock(&mm->page_table_lock);
1532 * For a file-backed vma, someone could have truncated or otherwise
1533 * invalidated this page. If unmap_mapping_range got called,
1534 * retry getting the page.
1537 (unlikely(sequence != atomic_read(&mapping->truncate_count)))) {
1538 sequence = atomic_read(&mapping->truncate_count);
1539 spin_unlock(&mm->page_table_lock);
1540 page_cache_release(new_page);
1541 pte_chain_free(pte_chain);
1544 page_table = pte_offset_map(pmd, address);
1547 * This silly early PAGE_DIRTY setting removes a race
1548 * due to the bad i386 page protection. But it's valid
1549 * for other architectures too.
1551 * Note that if write_access is true, we either now have
1552 * an exclusive copy of the page, or this is a shared mapping,
1553 * so we can make it writable and dirty to avoid having to
1554 * handle that later.
1556 /* Only go through if we didn't race with anybody else... */
1557 if (pte_none(*page_table)) {
1558 if (!PageReserved(new_page))
1560 flush_icache_page(vma, new_page);
1561 entry = mk_pte(new_page, vma->vm_page_prot);
1563 entry = maybe_mkwrite(pte_mkdirty(entry), vma);
1564 set_pte(page_table, entry);
1565 pte_chain = page_add_rmap(new_page, page_table, pte_chain);
1566 pte_unmap(page_table);
1568 /* One of our sibling threads was faster, back out. */
1569 pte_unmap(page_table);
1570 page_cache_release(new_page);
1571 spin_unlock(&mm->page_table_lock);
1575 /* no need to invalidate: a not-present page shouldn't be cached */
1576 update_mmu_cache(vma, address, entry);
1577 spin_unlock(&mm->page_table_lock);
1580 page_cache_release(new_page);
1583 pte_chain_free(pte_chain);
1588 * Fault of a previously existing named mapping. Repopulate the pte
1589 * from the encoded file_pte if possible. This enables swappable
1592 static int do_file_page(struct mm_struct * mm, struct vm_area_struct * vma,
1593 unsigned long address, int write_access, pte_t *pte, pmd_t *pmd)
1595 unsigned long pgoff;
1598 BUG_ON(!vma->vm_ops || !vma->vm_ops->nopage);
1600 * Fall back to the linear mapping if the fs does not support
1603 if (!vma->vm_ops || !vma->vm_ops->populate ||
1604 (write_access && !(vma->vm_flags & VM_SHARED))) {
1606 return do_no_page(mm, vma, address, write_access, pte, pmd);
1609 pgoff = pte_to_pgoff(*pte);
1612 spin_unlock(&mm->page_table_lock);
1614 err = vma->vm_ops->populate(vma, address & PAGE_MASK, PAGE_SIZE, vma->vm_page_prot, pgoff, 0);
1616 return VM_FAULT_OOM;
1618 return VM_FAULT_SIGBUS;
1619 return VM_FAULT_MAJOR;
1623 * These routines also need to handle stuff like marking pages dirty
1624 * and/or accessed for architectures that don't do it in hardware (most
1625 * RISC architectures). The early dirtying is also good on the i386.
1627 * There is also a hook called "update_mmu_cache()" that architectures
1628 * with external mmu caches can use to update those (ie the Sparc or
1629 * PowerPC hashed page tables that act as extended TLBs).
1631 * Note the "page_table_lock". It is to protect against kswapd removing
1632 * pages from under us. Note that kswapd only ever _removes_ pages, never
1633 * adds them. As such, once we have noticed that the page is not present,
1634 * we can drop the lock early.
1636 * The adding of pages is protected by the MM semaphore (which we hold),
1637 * so we don't need to worry about a page being suddenly been added into
1640 * We enter with the pagetable spinlock held, we are supposed to
1641 * release it when done.
1643 static inline int handle_pte_fault(struct mm_struct *mm,
1644 struct vm_area_struct * vma, unsigned long address,
1645 int write_access, pte_t *pte, pmd_t *pmd)
1650 if (!pte_present(entry)) {
1652 * If it truly wasn't present, we know that kswapd
1653 * and the PTE updates will not touch it later. So
1656 if (pte_none(entry))
1657 return do_no_page(mm, vma, address, write_access, pte, pmd);
1658 if (pte_file(entry))
1659 return do_file_page(mm, vma, address, write_access, pte, pmd);
1660 return do_swap_page(mm, vma, address, pte, pmd, entry, write_access);
1664 if (!pte_write(entry))
1665 return do_wp_page(mm, vma, address, pte, pmd, entry);
1667 entry = pte_mkdirty(entry);
1669 entry = pte_mkyoung(entry);
1670 ptep_establish(vma, address, pte, entry);
1671 update_mmu_cache(vma, address, entry);
1673 spin_unlock(&mm->page_table_lock);
1674 return VM_FAULT_MINOR;
1678 * By the time we get here, we already hold the mm semaphore
1680 int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct * vma,
1681 unsigned long address, int write_access)
1686 __set_current_state(TASK_RUNNING);
1687 pgd = pgd_offset(mm, address);
1689 inc_page_state(pgfault);
1691 if (is_vm_hugetlb_page(vma))
1692 return VM_FAULT_SIGBUS; /* mapping truncation does this. */
1695 * We need the page table lock to synchronize with kswapd
1696 * and the SMP-safe atomic PTE updates.
1698 spin_lock(&mm->page_table_lock);
1699 pmd = pmd_alloc(mm, pgd, address);
1702 pte_t * pte = pte_alloc_map(mm, pmd, address);
1704 return handle_pte_fault(mm, vma, address, write_access, pte, pmd);
1706 spin_unlock(&mm->page_table_lock);
1707 return VM_FAULT_OOM;
1711 * Allocate page middle directory.
1713 * We've already handled the fast-path in-line, and we own the
1716 * On a two-level page table, this ends up actually being entirely
1719 pmd_t fastcall *__pmd_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
1723 spin_unlock(&mm->page_table_lock);
1724 new = pmd_alloc_one(mm, address);
1725 spin_lock(&mm->page_table_lock);
1730 * Because we dropped the lock, we should re-check the
1731 * entry, as somebody else could have populated it..
1733 if (pgd_present(*pgd)) {
1737 pgd_populate(mm, pgd, new);
1739 return pmd_offset(pgd, address);
1742 int make_pages_present(unsigned long addr, unsigned long end)
1744 int ret, len, write;
1745 struct vm_area_struct * vma;
1747 vma = find_vma(current->mm, addr);
1748 write = (vma->vm_flags & VM_WRITE) != 0;
1751 if (end > vma->vm_end)
1753 len = (end+PAGE_SIZE-1)/PAGE_SIZE-addr/PAGE_SIZE;
1754 ret = get_user_pages(current, current->mm, addr,
1755 len, write, 0, NULL, NULL);
1758 return ret == len ? 0 : -1;
1762 * Map a vmalloc()-space virtual address to the physical page.
1764 struct page * vmalloc_to_page(void * vmalloc_addr)
1766 unsigned long addr = (unsigned long) vmalloc_addr;
1767 struct page *page = NULL;
1768 pgd_t *pgd = pgd_offset_k(addr);
1772 if (!pgd_none(*pgd)) {
1773 pmd = pmd_offset(pgd, addr);
1774 if (!pmd_none(*pmd)) {
1776 ptep = pte_offset_map(pmd, addr);
1778 if (pte_present(pte))
1779 page = pte_page(pte);
1787 EXPORT_SYMBOL(vmalloc_to_page);
1789 #if !defined(CONFIG_ARCH_GATE_AREA)
1791 #if defined(AT_SYSINFO_EHDR)
1792 struct vm_area_struct gate_vma;
1794 static int __init gate_vma_init(void)
1796 gate_vma.vm_mm = NULL;
1797 gate_vma.vm_start = FIXADDR_USER_START;
1798 gate_vma.vm_end = FIXADDR_USER_END;
1799 gate_vma.vm_page_prot = PAGE_READONLY;
1800 gate_vma.vm_flags = 0;
1803 __initcall(gate_vma_init);
1806 struct vm_area_struct *get_gate_vma(struct task_struct *tsk)
1808 #ifdef AT_SYSINFO_EHDR
1815 int in_gate_area(struct task_struct *task, unsigned long addr)
1817 #ifdef AT_SYSINFO_EHDR
1818 if ((addr >= FIXADDR_USER_START) && (addr < FIXADDR_USER_END))