Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
nommu.c File Reference
#include <linux/export.h>
#include <linux/mm.h>
#include <linux/mman.h>
#include <linux/swap.h>
#include <linux/file.h>
#include <linux/highmem.h>
#include <linux/pagemap.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/blkdev.h>
#include <linux/backing-dev.h>
#include <linux/mount.h>
#include <linux/personality.h>
#include <linux/security.h>
#include <linux/syscalls.h>
#include <linux/audit.h>
#include <asm/uaccess.h>
#include <asm/tlb.h>
#include <asm/tlbflush.h>
#include <asm/mmu_context.h>
#include "internal.h"

Go to the source code of this file.

Macros

#define kenter(FMT,...)   no_printk(KERN_DEBUG "==> %s("FMT")\n", __func__, ##__VA_ARGS__)
 
#define kleave(FMT,...)   no_printk(KERN_DEBUG "<== %s()"FMT"\n", __func__, ##__VA_ARGS__)
 
#define kdebug(FMT,...)   no_printk(KERN_DEBUG FMT"\n", ##__VA_ARGS__)
 
#define PAGE_KERNEL_EXEC   PAGE_KERNEL
 

Functions

 EXPORT_SYMBOL (mem_map)
 
 EXPORT_SYMBOL (num_physpages)
 
 DECLARE_RWSEM (nommu_region_sem)
 
unsigned int kobjsize (const void *objp)
 
int __get_user_pages (struct task_struct *tsk, struct mm_struct *mm, unsigned long start, int nr_pages, unsigned int foll_flags, struct page **pages, struct vm_area_struct **vmas, int *retry)
 
int get_user_pages (struct task_struct *tsk, struct mm_struct *mm, unsigned long start, int nr_pages, int write, int force, struct page **pages, struct vm_area_struct **vmas)
 
 EXPORT_SYMBOL (get_user_pages)
 
int follow_pfn (struct vm_area_struct *vma, unsigned long address, unsigned long *pfn)
 
 EXPORT_SYMBOL (follow_pfn)
 
 DEFINE_RWLOCK (vmlist_lock)
 
void vfree (const void *addr)
 
 EXPORT_SYMBOL (vfree)
 
void__vmalloc (unsigned long size, gfp_t gfp_mask, pgprot_t prot)
 
 EXPORT_SYMBOL (__vmalloc)
 
voidvmalloc_user (unsigned long size)
 
 EXPORT_SYMBOL (vmalloc_user)
 
struct pagevmalloc_to_page (const void *addr)
 
 EXPORT_SYMBOL (vmalloc_to_page)
 
unsigned long vmalloc_to_pfn (const void *addr)
 
 EXPORT_SYMBOL (vmalloc_to_pfn)
 
long vread (char *buf, char *addr, unsigned long count)
 
long vwrite (char *buf, char *addr, unsigned long count)
 
voidvmalloc (unsigned long size)
 
 EXPORT_SYMBOL (vmalloc)
 
voidvzalloc (unsigned long size)
 
 EXPORT_SYMBOL (vzalloc)
 
voidvmalloc_node (unsigned long size, int node)
 
 EXPORT_SYMBOL (vmalloc_node)
 
voidvzalloc_node (unsigned long size, int node)
 
 EXPORT_SYMBOL (vzalloc_node)
 
voidvmalloc_exec (unsigned long size)
 
voidvmalloc_32 (unsigned long size)
 
 EXPORT_SYMBOL (vmalloc_32)
 
voidvmalloc_32_user (unsigned long size)
 
 EXPORT_SYMBOL (vmalloc_32_user)
 
voidvmap (struct page **pages, unsigned int count, unsigned long flags, pgprot_t prot)
 
 EXPORT_SYMBOL (vmap)
 
void vunmap (const void *addr)
 
 EXPORT_SYMBOL (vunmap)
 
voidvm_map_ram (struct page **pages, unsigned int count, int node, pgprot_t prot)
 
 EXPORT_SYMBOL (vm_map_ram)
 
void vm_unmap_ram (const void *mem, unsigned int count)
 
 EXPORT_SYMBOL (vm_unmap_ram)
 
void vm_unmap_aliases (void)
 
 EXPORT_SYMBOL_GPL (vm_unmap_aliases)
 
void __attribute__ ((weak))
 
struct vm_structalloc_vm_area (size_t size, pte_t **ptes)
 
 EXPORT_SYMBOL_GPL (alloc_vm_area)
 
void free_vm_area (struct vm_struct *area)
 
 EXPORT_SYMBOL_GPL (free_vm_area)
 
int vm_insert_page (struct vm_area_struct *vma, unsigned long addr, struct page *page)
 
 EXPORT_SYMBOL (vm_insert_page)
 
 SYSCALL_DEFINE1 (brk, unsigned long, brk)
 
void __init mmap_init (void)
 
struct vm_area_structfind_vma (struct mm_struct *mm, unsigned long addr)
 
 EXPORT_SYMBOL (find_vma)
 
struct vm_area_structfind_extend_vma (struct mm_struct *mm, unsigned long addr)
 
int expand_stack (struct vm_area_struct *vma, unsigned long address)
 
unsigned long do_mmap_pgoff (struct file *file, unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long pgoff)
 
 SYSCALL_DEFINE6 (mmap_pgoff, unsigned long, addr, unsigned long, len, unsigned long, prot, unsigned long, flags, unsigned long, fd, unsigned long, pgoff)
 
int split_vma (struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, int new_below)
 
int do_munmap (struct mm_struct *mm, unsigned long start, size_t len)
 
 EXPORT_SYMBOL (do_munmap)
 
int vm_munmap (unsigned long addr, size_t len)
 
 EXPORT_SYMBOL (vm_munmap)
 
 SYSCALL_DEFINE2 (munmap, unsigned long, addr, size_t, len)
 
void exit_mmap (struct mm_struct *mm)
 
unsigned long vm_brk (unsigned long addr, unsigned long len)
 
unsigned long do_mremap (unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags, unsigned long new_addr)
 
 EXPORT_SYMBOL (do_mremap)
 
 SYSCALL_DEFINE5 (mremap, unsigned long, addr, unsigned long, old_len, unsigned long, new_len, unsigned long, flags, unsigned long, new_addr)
 
struct pagefollow_page (struct vm_area_struct *vma, unsigned long address, unsigned int foll_flags)
 
int remap_pfn_range (struct vm_area_struct *vma, unsigned long addr, unsigned long pfn, unsigned long size, pgprot_t prot)
 
 EXPORT_SYMBOL (remap_pfn_range)
 
int remap_vmalloc_range (struct vm_area_struct *vma, void *addr, unsigned long pgoff)
 
 EXPORT_SYMBOL (remap_vmalloc_range)
 
unsigned long arch_get_unmapped_area (struct file *file, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
 
void arch_unmap_area (struct mm_struct *mm, unsigned long addr)
 
void unmap_mapping_range (struct address_space *mapping, loff_t const holebegin, loff_t const holelen, int even_cows)
 
 EXPORT_SYMBOL (unmap_mapping_range)
 
int __vm_enough_memory (struct mm_struct *mm, long pages, int cap_sys_admin)
 
int in_gate_area_no_mm (unsigned long addr)
 
int filemap_fault (struct vm_area_struct *vma, struct vm_fault *vmf)
 
 EXPORT_SYMBOL (filemap_fault)
 
int generic_file_remap_pages (struct vm_area_struct *vma, unsigned long addr, unsigned long size, pgoff_t pgoff)
 
 EXPORT_SYMBOL (generic_file_remap_pages)
 
int access_remote_vm (struct mm_struct *mm, unsigned long addr, void *buf, int len, int write)
 
int access_process_vm (struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
 
int nommu_shrink_inode_mappings (struct inode *inode, size_t size, size_t newsize)
 

Variables

voidhigh_memory
 
struct pagemem_map
 
unsigned long max_mapnr
 
unsigned long num_physpages
 
unsigned long highest_memmap_pfn
 
struct percpu_counter vm_committed_as
 
int sysctl_overcommit_memory = OVERCOMMIT_GUESS
 
int sysctl_overcommit_ratio = 50
 
int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT
 
int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS
 
int heap_stack_gap = 0
 
atomic_long_t mmap_pages_allocated
 
struct rb_root nommu_region_tree = RB_ROOT
 
struct vm_operations_struct generic_file_vm_ops
 
struct vm_structvmlist
 

Macro Definition Documentation

#define kdebug (   FMT,
  ... 
)    no_printk(KERN_DEBUG FMT"\n", ##__VA_ARGS__)

Definition at line 51 of file nommu.c.

#define kenter (   FMT,
  ... 
)    no_printk(KERN_DEBUG "==> %s("FMT")\n", __func__, ##__VA_ARGS__)

Definition at line 47 of file nommu.c.

#define kleave (   FMT,
  ... 
)    no_printk(KERN_DEBUG "<== %s()"FMT"\n", __func__, ##__VA_ARGS__)

Definition at line 49 of file nommu.c.

#define PAGE_KERNEL_EXEC   PAGE_KERNEL

Definition at line 353 of file nommu.c.

Function Documentation

void __attribute__ ( (weak)  )
read

read_persistent_clock - Return time from the persistent clock.

Weak dummy function for arches that do not yet support it. Reads the time from the battery backed persistent clock. Returns a timespec with tv_sec=0 and tv_nsec=0 if unsupported.

XXX - Do be sure to remove it once all arches implement it.

read_boot_clock - Return time of the system start.

Weak dummy function for arches that do not yet support it. Function to read the exact time the system has been started. Returns a timespec with tv_sec=0 and tv_nsec=0 if unsupported.

XXX - Do be sure to remove it once all arches implement it.

__iowrite32_copy - copy data to MMIO space, in 32-bit units : destination, in MMIO space (must be 32-bit aligned) : source (must be 32-bit aligned) : number of 32-bit quantities to copy

Copy data from kernel space to MMIO space, in units of 32 bits at a time. Order of access is not guaranteed, nor is a memory barrier performed afterwards.

__iowrite64_copy - copy data to MMIO space, in 64-bit or 32-bit units : destination, in MMIO space (must be 64-bit aligned) : source (must be 64-bit aligned) : number of 64-bit quantities to copy

Copy data from kernel space to MMIO space, in units of 32 or 64 bits at a time. Order of access is not guaranteed, nor is a memory barrier performed afterwards.

Definition at line 441 of file nommu.c.

int __get_user_pages ( struct task_struct tsk,
struct mm_struct mm,
unsigned long  start,
int  nr_pages,
unsigned int  foll_flags,
struct page **  pages,
struct vm_area_struct **  vmas,
int retry 
)

Definition at line 127 of file nommu.c.

int __vm_enough_memory ( struct mm_struct mm,
long  pages,
int  cap_sys_admin 
)

Definition at line 1867 of file nommu.c.

void* __vmalloc ( unsigned long  size,
gfp_t  gfp_mask,
pgprot_t  prot 
)

Definition at line 223 of file nommu.c.

int access_process_vm ( struct task_struct tsk,
unsigned long  addr,
void buf,
int  len,
int  write 
)

Definition at line 2015 of file nommu.c.

int access_remote_vm ( struct mm_struct mm,
unsigned long  addr,
void buf,
int  len,
int  write 
)

- access another process' address space : the mm_struct of the target address space : start address to access : source or destination buffer : number of bytes to transfer : whether the access is a write

The caller must hold a reference on .

Definition at line 2005 of file nommu.c.

struct vm_struct* alloc_vm_area ( size_t  size,
pte_t **  ptes 
)
read

alloc_vm_area - allocate a range of kernel address space : size of the area

Returns: NULL on failure, vm_struct on success

This function reserves a range of kernel address space, and allocates pagetables to map that range. No actual mappings are created. If the kernel address space is not shared between processes, it syncs the pagetable across all processes.

Definition at line 457 of file nommu.c.

unsigned long arch_get_unmapped_area ( struct file file,
unsigned long  addr,
unsigned long  len,
unsigned long  pgoff,
unsigned long  flags 
)

Definition at line 1834 of file nommu.c.

void arch_unmap_area ( struct mm_struct mm,
unsigned long  addr 
)

Definition at line 1840 of file nommu.c.

DECLARE_RWSEM ( nommu_region_sem  )
DEFINE_RWLOCK ( vmlist_lock  )
unsigned long do_mmap_pgoff ( struct file file,
unsigned long  addr,
unsigned long  len,
unsigned long  prot,
unsigned long  flags,
unsigned long  pgoff 
)

Definition at line 1232 of file nommu.c.

unsigned long do_mremap ( unsigned long  addr,
unsigned long  old_len,
unsigned long  new_len,
unsigned long  flags,
unsigned long  new_addr 
)

Definition at line 1753 of file nommu.c.

int do_munmap ( struct mm_struct mm,
unsigned long  start,
size_t  len 
)

Definition at line 1621 of file nommu.c.

void exit_mmap ( struct mm_struct mm)

Definition at line 1717 of file nommu.c.

int expand_stack ( struct vm_area_struct vma,
unsigned long  address 
)

Definition at line 839 of file nommu.c.

EXPORT_SYMBOL ( mem_map  )
EXPORT_SYMBOL ( num_physpages  )
EXPORT_SYMBOL ( get_user_pages  )
EXPORT_SYMBOL ( follow_pfn  )
EXPORT_SYMBOL ( vfree  )
EXPORT_SYMBOL ( __vmalloc  )
EXPORT_SYMBOL ( vmalloc_user  )
EXPORT_SYMBOL ( vmalloc_to_page  )
EXPORT_SYMBOL ( vmalloc_to_pfn  )
EXPORT_SYMBOL ( vmalloc  )
EXPORT_SYMBOL ( vzalloc  )
EXPORT_SYMBOL ( vmalloc_node  )
EXPORT_SYMBOL ( vzalloc_node  )
EXPORT_SYMBOL ( vmalloc_32  )
EXPORT_SYMBOL ( vmalloc_32_user  )
EXPORT_SYMBOL ( vmap  )
EXPORT_SYMBOL ( vunmap  )
EXPORT_SYMBOL ( vm_map_ram  )
EXPORT_SYMBOL ( vm_unmap_ram  )
EXPORT_SYMBOL ( vm_insert_page  )
EXPORT_SYMBOL ( find_vma  )
EXPORT_SYMBOL ( do_munmap  )
EXPORT_SYMBOL ( vm_munmap  )
EXPORT_SYMBOL ( do_mremap  )
EXPORT_SYMBOL ( remap_pfn_range  )
EXPORT_SYMBOL ( remap_vmalloc_range  )
EXPORT_SYMBOL ( unmap_mapping_range  )
EXPORT_SYMBOL ( filemap_fault  )
EXPORT_SYMBOL ( generic_file_remap_pages  )
EXPORT_SYMBOL_GPL ( vm_unmap_aliases  )
EXPORT_SYMBOL_GPL ( alloc_vm_area  )
EXPORT_SYMBOL_GPL ( free_vm_area  )
int filemap_fault ( struct vm_area_struct vma,
struct vm_fault *  vmf 
)

Definition at line 1948 of file nommu.c.

struct vm_area_struct* find_extend_vma ( struct mm_struct mm,
unsigned long  addr 
)
read

Definition at line 830 of file nommu.c.

struct vm_area_struct* find_vma ( struct mm_struct mm,
unsigned long  addr 
)
read

Definition at line 802 of file nommu.c.

struct page* follow_page ( struct vm_area_struct vma,
unsigned long  address,
unsigned int  foll_flags 
)
read

Definition at line 1802 of file nommu.c.

int follow_pfn ( struct vm_area_struct vma,
unsigned long  address,
unsigned long pfn 
)

follow_pfn - look up PFN at a user virtual address : memory mapping : user virtual address : location to store found PFN

Only IO mappings and raw PFN mappings are allowed.

Returns zero and the pfn at on success, -ve otherwise.

Definition at line 203 of file nommu.c.

void free_vm_area ( struct vm_struct area)

Definition at line 464 of file nommu.c.

int generic_file_remap_pages ( struct vm_area_struct vma,
unsigned long  addr,
unsigned long  size,
pgoff_t  pgoff 
)

Definition at line 1955 of file nommu.c.

int get_user_pages ( struct task_struct tsk,
struct mm_struct mm,
unsigned long  start,
int  nr_pages,
int  write,
int  force,
struct page **  pages,
struct vm_area_struct **  vmas 
)

Definition at line 177 of file nommu.c.

int in_gate_area_no_mm ( unsigned long  addr)

Definition at line 1943 of file nommu.c.

unsigned int kobjsize ( const void objp)

Definition at line 86 of file nommu.c.

void __init mmap_init ( void  )

Definition at line 512 of file nommu.c.

int nommu_shrink_inode_mappings ( struct inode inode,
size_t  size,
size_t  newsize 
)

nommu_shrink_inode_mappings - Shrink the shared mappings on an inode : The inode to check : The current filesize of the inode : The proposed filesize of the inode

Check the shared mappings on an inode on behalf of a shrinking truncate to make sure that that any outstanding VMAs aren't broken and then shrink the vm_regions that extend that beyond so that do_mmap_pgoff() doesn't automatically grant mappings that are too large.

Definition at line 2043 of file nommu.c.

int remap_pfn_range ( struct vm_area_struct vma,
unsigned long  addr,
unsigned long  pfn,
unsigned long  size,
pgprot_t  prot 
)

remap_pfn_range - remap kernel memory to userspace : user vma to map to : target user address to start at : physical address of kernel memory : size of map area : page protection flags for this mapping

Note: this is only safe if the mm semaphore is held when called.

Definition at line 1808 of file nommu.c.

int remap_vmalloc_range ( struct vm_area_struct vma,
void addr,
unsigned long  pgoff 
)

Definition at line 1819 of file nommu.c.

int split_vma ( struct mm_struct mm,
struct vm_area_struct vma,
unsigned long  addr,
int  new_below 
)

Definition at line 1514 of file nommu.c.

SYSCALL_DEFINE1 ( brk  ,
unsigned  long,
brk   
)

Definition at line 484 of file nommu.c.

SYSCALL_DEFINE2 ( munmap  ,
unsigned  long,
addr  ,
size_t  ,
len   
)

Definition at line 1709 of file nommu.c.

SYSCALL_DEFINE5 ( mremap  ,
unsigned  long,
addr  ,
unsigned  long,
old_len  ,
unsigned  long,
new_len  ,
unsigned  long,
flags  ,
unsigned  long,
new_addr   
)

Definition at line 1790 of file nommu.c.

SYSCALL_DEFINE6 ( mmap_pgoff  ,
unsigned  long,
addr  ,
unsigned  long,
len  ,
unsigned  long,
prot  ,
unsigned  long,
flags  ,
unsigned  long,
fd  ,
unsigned  long,
pgoff   
)

Definition at line 1462 of file nommu.c.

void unmap_mapping_range ( struct address_space mapping,
loff_t const  holebegin,
loff_t const  holelen,
int  even_cows 
)

Definition at line 1844 of file nommu.c.

void vfree ( const void addr)

Definition at line 217 of file nommu.c.

unsigned long vm_brk ( unsigned long  addr,
unsigned long  len 
)

Definition at line 1738 of file nommu.c.

int vm_insert_page ( struct vm_area_struct vma,
unsigned long  addr,
struct page page 
)

Definition at line 470 of file nommu.c.

void* vm_map_ram ( struct page **  pages,
unsigned int  count,
int  node,
pgprot_t  prot 
)

Definition at line 419 of file nommu.c.

int vm_munmap ( unsigned long  addr,
size_t  len 
)

Definition at line 1697 of file nommu.c.

void vm_unmap_aliases ( void  )

Definition at line 432 of file nommu.c.

void vm_unmap_ram ( const void mem,
unsigned int  count 
)

Definition at line 426 of file nommu.c.

void* vmalloc ( unsigned long  size)

Definition at line 292 of file nommu.c.

void* vmalloc_32 ( unsigned long  size)

vmalloc_32 - allocate virtually contiguous memory (32bit addressable) : allocation size

Allocate enough 32bit PA addressable pages to cover from the page level allocator and map them into continguos kernel virtual space.

Definition at line 380 of file nommu.c.

void* vmalloc_32_user ( unsigned long  size)

vmalloc_32_user - allocate zeroed virtually contiguous 32bit memory : allocation size

The resulting memory area is 32bit addressable and zeroed so it can be mapped to userspace without leaking data.

VM_USERMAP is set on the corresponding VMA so that subsequent calls to remap_vmalloc_range() are permissible.

Definition at line 396 of file nommu.c.

void* vmalloc_exec ( unsigned long  size)

vmalloc_exec - allocate virtually contiguous, executable memory : allocation size

Kernel-internal function to allocate enough pages to cover the page level allocator and map them into contiguous and executable kernel virtual space.

For tight control over page level allocator and protection flags use __vmalloc() instead.

Definition at line 368 of file nommu.c.

void* vmalloc_node ( unsigned long  size,
int  node 
)

vmalloc_node - allocate memory on a specific node : allocation size : numa node

Allocate enough pages to cover from the page level allocator and map them into contiguous kernel virtual space.

For tight control over page level allocator and protection flags use __vmalloc() instead.

Definition at line 328 of file nommu.c.

struct page* vmalloc_to_page ( const void addr)
read

Definition at line 253 of file nommu.c.

unsigned long vmalloc_to_pfn ( const void addr)

Definition at line 259 of file nommu.c.

void* vmalloc_user ( unsigned long  size)

Definition at line 233 of file nommu.c.

void* vmap ( struct page **  pages,
unsigned int  count,
unsigned long  flags,
pgprot_t  prot 
)

Definition at line 406 of file nommu.c.

long vread ( char buf,
char addr,
unsigned long  count 
)

Definition at line 265 of file nommu.c.

void vunmap ( const void addr)

Definition at line 413 of file nommu.c.

long vwrite ( char buf,
char addr,
unsigned long  count 
)

Definition at line 271 of file nommu.c.

void* vzalloc ( unsigned long  size)

Definition at line 310 of file nommu.c.

void* vzalloc_node ( unsigned long  size,
int  node 
)

vzalloc_node - allocate memory on a specific node with zero fill : allocation size : numa node

Allocate enough pages to cover from the page level allocator and map them into contiguous kernel virtual space. The memory allocated is set to zero.

For tight control over page level allocator and protection flags use __vmalloc() instead.

Definition at line 346 of file nommu.c.

Variable Documentation

struct vm_operations_struct generic_file_vm_ops
Initial value:
= {
}

Definition at line 77 of file nommu.c.

int heap_stack_gap = 0

Definition at line 65 of file nommu.c.

void* high_memory

Definition at line 55 of file nommu.c.

unsigned long highest_memmap_pfn

Definition at line 59 of file nommu.c.

unsigned long max_mapnr

Definition at line 57 of file nommu.c.

struct page* mem_map

Definition at line 56 of file nommu.c.

atomic_long_t mmap_pages_allocated

Definition at line 67 of file nommu.c.

struct rb_root nommu_region_tree = RB_ROOT

Definition at line 74 of file nommu.c.

unsigned long num_physpages

Definition at line 58 of file nommu.c.

int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT

Definition at line 63 of file nommu.c.

int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS

Definition at line 64 of file nommu.c.

int sysctl_overcommit_memory = OVERCOMMIT_GUESS

Definition at line 61 of file nommu.c.

int sysctl_overcommit_ratio = 50

Definition at line 62 of file nommu.c.

struct percpu_counter vm_committed_as

Definition at line 60 of file nommu.c.

struct vm_struct* vmlist

Definition at line 215 of file nommu.c.