vmalloc.c (92eac16819e47ab919bd8f28ed49f8fadad0954e) vmalloc.c (a862f68a8b360086f248cbc3606029441b5f5197)
1/*
2 * linux/mm/vmalloc.c
3 *
4 * Copyright (C) 1993 Linus Torvalds
5 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
6 * SMP-safe vmalloc/vfree/ioremap, Tigran Aivazian <tigran@veritas.com>, May 2000
7 * Major rework to support vmap/vunmap, Christoph Hellwig, SGI, August 2002
8 * Numa awareness, Christoph Lameter, SGI, June 2005

--- 830 unchanged lines hidden (view full) ---

839}
840
841/**
842 * new_vmap_block - allocates new vmap_block and occupies 2^order pages in this
843 * block. Of course pages number can't exceed VMAP_BBMAP_BITS
844 * @order: how many 2^order pages should be occupied in newly allocated block
845 * @gfp_mask: flags for the page level allocator
846 *
1/*
2 * linux/mm/vmalloc.c
3 *
4 * Copyright (C) 1993 Linus Torvalds
5 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
6 * SMP-safe vmalloc/vfree/ioremap, Tigran Aivazian <tigran@veritas.com>, May 2000
7 * Major rework to support vmap/vunmap, Christoph Hellwig, SGI, August 2002
8 * Numa awareness, Christoph Lameter, SGI, June 2005

--- 830 unchanged lines hidden (view full) ---

839}
840
841/**
842 * new_vmap_block - allocates new vmap_block and occupies 2^order pages in this
843 * block. Of course pages number can't exceed VMAP_BBMAP_BITS
844 * @order: how many 2^order pages should be occupied in newly allocated block
845 * @gfp_mask: flags for the page level allocator
846 *
847 * Returns: virtual address in a newly allocated block or ERR_PTR(-errno)
847 * Return: virtual address in a newly allocated block or ERR_PTR(-errno)
848 */
849static void *new_vmap_block(unsigned int order, gfp_t gfp_mask)
850{
851 struct vmap_block_queue *vbq;
852 struct vmap_block *vb;
853 struct vmap_area *va;
854 unsigned long vb_idx;
855 int node, err;

--- 572 unchanged lines hidden (view full) ---

1428/**
1429 * get_vm_area - reserve a contiguous kernel virtual area
1430 * @size: size of the area
1431 * @flags: %VM_IOREMAP for I/O mappings or VM_ALLOC
1432 *
1433 * Search an area of @size in the kernel virtual mapping area,
1434 * and reserved it for out purposes. Returns the area descriptor
1435 * on success or %NULL on failure.
848 */
849static void *new_vmap_block(unsigned int order, gfp_t gfp_mask)
850{
851 struct vmap_block_queue *vbq;
852 struct vmap_block *vb;
853 struct vmap_area *va;
854 unsigned long vb_idx;
855 int node, err;

--- 572 unchanged lines hidden (view full) ---

1428/**
1429 * get_vm_area - reserve a contiguous kernel virtual area
1430 * @size: size of the area
1431 * @flags: %VM_IOREMAP for I/O mappings or VM_ALLOC
1432 *
1433 * Search an area of @size in the kernel virtual mapping area,
1434 * and reserved it for out purposes. Returns the area descriptor
1435 * on success or %NULL on failure.
1436 *
1437 * Return: the area descriptor on success or %NULL on failure.
1436 */
1437struct vm_struct *get_vm_area(unsigned long size, unsigned long flags)
1438{
1439 return __get_vm_area_node(size, 1, flags, VMALLOC_START, VMALLOC_END,
1440 NUMA_NO_NODE, GFP_KERNEL,
1441 __builtin_return_address(0));
1442}
1443

--- 6 unchanged lines hidden (view full) ---

1450
1451/**
1452 * find_vm_area - find a continuous kernel virtual area
1453 * @addr: base address
1454 *
1455 * Search for the kernel VM area starting at @addr, and return it.
1456 * It is up to the caller to do all required locking to keep the returned
1457 * pointer valid.
1438 */
1439struct vm_struct *get_vm_area(unsigned long size, unsigned long flags)
1440{
1441 return __get_vm_area_node(size, 1, flags, VMALLOC_START, VMALLOC_END,
1442 NUMA_NO_NODE, GFP_KERNEL,
1443 __builtin_return_address(0));
1444}
1445

--- 6 unchanged lines hidden (view full) ---

1452
1453/**
1454 * find_vm_area - find a continuous kernel virtual area
1455 * @addr: base address
1456 *
1457 * Search for the kernel VM area starting at @addr, and return it.
1458 * It is up to the caller to do all required locking to keep the returned
1459 * pointer valid.
1460 *
1461 * Return: pointer to the found area or %NULL on faulure
1458 */
1459struct vm_struct *find_vm_area(const void *addr)
1460{
1461 struct vmap_area *va;
1462
1463 va = find_vmap_area((unsigned long)addr);
1464 if (va && va->flags & VM_VM_AREA)
1465 return va->vm;
1466
1467 return NULL;
1468}
1469
1470/**
1471 * remove_vm_area - find and remove a continuous kernel virtual area
1472 * @addr: base address
1473 *
1474 * Search for the kernel VM area starting at @addr, and remove it.
1475 * This function returns the found VM area, but using it is NOT safe
1476 * on SMP machines, except for its size or flags.
1462 */
1463struct vm_struct *find_vm_area(const void *addr)
1464{
1465 struct vmap_area *va;
1466
1467 va = find_vmap_area((unsigned long)addr);
1468 if (va && va->flags & VM_VM_AREA)
1469 return va->vm;
1470
1471 return NULL;
1472}
1473
1474/**
1475 * remove_vm_area - find and remove a continuous kernel virtual area
1476 * @addr: base address
1477 *
1478 * Search for the kernel VM area starting at @addr, and remove it.
1479 * This function returns the found VM area, but using it is NOT safe
1480 * on SMP machines, except for its size or flags.
1481 *
1482 * Return: pointer to the found area or %NULL on faulure
1477 */
1478struct vm_struct *remove_vm_area(const void *addr)
1479{
1480 struct vmap_area *va;
1481
1482 might_sleep();
1483
1484 va = find_vmap_area((unsigned long)addr);

--- 146 unchanged lines hidden (view full) ---

1631 * vmap - map an array of pages into virtually contiguous space
1632 * @pages: array of page pointers
1633 * @count: number of pages to map
1634 * @flags: vm_area->flags
1635 * @prot: page protection for the mapping
1636 *
1637 * Maps @count pages from @pages into contiguous kernel virtual
1638 * space.
1483 */
1484struct vm_struct *remove_vm_area(const void *addr)
1485{
1486 struct vmap_area *va;
1487
1488 might_sleep();
1489
1490 va = find_vmap_area((unsigned long)addr);

--- 146 unchanged lines hidden (view full) ---

1637 * vmap - map an array of pages into virtually contiguous space
1638 * @pages: array of page pointers
1639 * @count: number of pages to map
1640 * @flags: vm_area->flags
1641 * @prot: page protection for the mapping
1642 *
1643 * Maps @count pages from @pages into contiguous kernel virtual
1644 * space.
1645 *
1646 * Return: the address of the area or %NULL on failure
1639 */
1640void *vmap(struct page **pages, unsigned int count,
1641 unsigned long flags, pgprot_t prot)
1642{
1643 struct vm_struct *area;
1644 unsigned long size; /* In bytes */
1645
1646 might_sleep();

--- 87 unchanged lines hidden (view full) ---

1734 * @prot: protection mask for the allocated pages
1735 * @vm_flags: additional vm area flags (e.g. %VM_NO_GUARD)
1736 * @node: node to use for allocation or NUMA_NO_NODE
1737 * @caller: caller's return address
1738 *
1739 * Allocate enough pages to cover @size from the page level
1740 * allocator with @gfp_mask flags. Map them into contiguous
1741 * kernel virtual space, using a pagetable protection of @prot.
1647 */
1648void *vmap(struct page **pages, unsigned int count,
1649 unsigned long flags, pgprot_t prot)
1650{
1651 struct vm_struct *area;
1652 unsigned long size; /* In bytes */
1653
1654 might_sleep();

--- 87 unchanged lines hidden (view full) ---

1742 * @prot: protection mask for the allocated pages
1743 * @vm_flags: additional vm area flags (e.g. %VM_NO_GUARD)
1744 * @node: node to use for allocation or NUMA_NO_NODE
1745 * @caller: caller's return address
1746 *
1747 * Allocate enough pages to cover @size from the page level
1748 * allocator with @gfp_mask flags. Map them into contiguous
1749 * kernel virtual space, using a pagetable protection of @prot.
1750 *
1751 * Return: the address of the area or %NULL on failure
1742 */
1743void *__vmalloc_node_range(unsigned long size, unsigned long align,
1744 unsigned long start, unsigned long end, gfp_t gfp_mask,
1745 pgprot_t prot, unsigned long vm_flags, int node,
1746 const void *caller)
1747{
1748 struct vm_struct *area;
1749 void *addr;

--- 51 unchanged lines hidden (view full) ---

1801 * allocator with @gfp_mask flags. Map them into contiguous
1802 * kernel virtual space, using a pagetable protection of @prot.
1803 *
1804 * Reclaim modifiers in @gfp_mask - __GFP_NORETRY, __GFP_RETRY_MAYFAIL
1805 * and __GFP_NOFAIL are not supported
1806 *
1807 * Any use of gfp flags outside of GFP_KERNEL should be consulted
1808 * with mm people.
1752 */
1753void *__vmalloc_node_range(unsigned long size, unsigned long align,
1754 unsigned long start, unsigned long end, gfp_t gfp_mask,
1755 pgprot_t prot, unsigned long vm_flags, int node,
1756 const void *caller)
1757{
1758 struct vm_struct *area;
1759 void *addr;

--- 51 unchanged lines hidden (view full) ---

1811 * allocator with @gfp_mask flags. Map them into contiguous
1812 * kernel virtual space, using a pagetable protection of @prot.
1813 *
1814 * Reclaim modifiers in @gfp_mask - __GFP_NORETRY, __GFP_RETRY_MAYFAIL
1815 * and __GFP_NOFAIL are not supported
1816 *
1817 * Any use of gfp flags outside of GFP_KERNEL should be consulted
1818 * with mm people.
1819 *
1820 * Return: pointer to the allocated memory or %NULL on error
1809 */
1810static void *__vmalloc_node(unsigned long size, unsigned long align,
1811 gfp_t gfp_mask, pgprot_t prot,
1812 int node, const void *caller)
1813{
1814 return __vmalloc_node_range(size, align, VMALLOC_START, VMALLOC_END,
1815 gfp_mask, prot, 0, node, caller);
1816}

--- 23 unchanged lines hidden (view full) ---

1840 * vmalloc - allocate virtually contiguous memory
1841 * @size: allocation size
1842 *
1843 * Allocate enough pages to cover @size from the page level
1844 * allocator and map them into contiguous kernel virtual space.
1845 *
1846 * For tight control over page level allocator and protection flags
1847 * use __vmalloc() instead.
1821 */
1822static void *__vmalloc_node(unsigned long size, unsigned long align,
1823 gfp_t gfp_mask, pgprot_t prot,
1824 int node, const void *caller)
1825{
1826 return __vmalloc_node_range(size, align, VMALLOC_START, VMALLOC_END,
1827 gfp_mask, prot, 0, node, caller);
1828}

--- 23 unchanged lines hidden (view full) ---

1852 * vmalloc - allocate virtually contiguous memory
1853 * @size: allocation size
1854 *
1855 * Allocate enough pages to cover @size from the page level
1856 * allocator and map them into contiguous kernel virtual space.
1857 *
1858 * For tight control over page level allocator and protection flags
1859 * use __vmalloc() instead.
1860 *
1861 * Return: pointer to the allocated memory or %NULL on error
1848 */
1849void *vmalloc(unsigned long size)
1850{
1851 return __vmalloc_node_flags(size, NUMA_NO_NODE,
1852 GFP_KERNEL);
1853}
1854EXPORT_SYMBOL(vmalloc);
1855
1856/**
1857 * vzalloc - allocate virtually contiguous memory with zero fill
1858 * @size: allocation size
1859 *
1860 * Allocate enough pages to cover @size from the page level
1861 * allocator and map them into contiguous kernel virtual space.
1862 * The memory allocated is set to zero.
1863 *
1864 * For tight control over page level allocator and protection flags
1865 * use __vmalloc() instead.
1862 */
1863void *vmalloc(unsigned long size)
1864{
1865 return __vmalloc_node_flags(size, NUMA_NO_NODE,
1866 GFP_KERNEL);
1867}
1868EXPORT_SYMBOL(vmalloc);
1869
1870/**
1871 * vzalloc - allocate virtually contiguous memory with zero fill
1872 * @size: allocation size
1873 *
1874 * Allocate enough pages to cover @size from the page level
1875 * allocator and map them into contiguous kernel virtual space.
1876 * The memory allocated is set to zero.
1877 *
1878 * For tight control over page level allocator and protection flags
1879 * use __vmalloc() instead.
1880 *
1881 * Return: pointer to the allocated memory or %NULL on error
1866 */
1867void *vzalloc(unsigned long size)
1868{
1869 return __vmalloc_node_flags(size, NUMA_NO_NODE,
1870 GFP_KERNEL | __GFP_ZERO);
1871}
1872EXPORT_SYMBOL(vzalloc);
1873
1874/**
1875 * vmalloc_user - allocate zeroed virtually contiguous memory for userspace
1876 * @size: allocation size
1877 *
1878 * The resulting memory area is zeroed so it can be mapped to userspace
1879 * without leaking data.
1882 */
1883void *vzalloc(unsigned long size)
1884{
1885 return __vmalloc_node_flags(size, NUMA_NO_NODE,
1886 GFP_KERNEL | __GFP_ZERO);
1887}
1888EXPORT_SYMBOL(vzalloc);
1889
1890/**
1891 * vmalloc_user - allocate zeroed virtually contiguous memory for userspace
1892 * @size: allocation size
1893 *
1894 * The resulting memory area is zeroed so it can be mapped to userspace
1895 * without leaking data.
1896 *
1897 * Return: pointer to the allocated memory or %NULL on error
1880 */
1881void *vmalloc_user(unsigned long size)
1882{
1883 return __vmalloc_node_range(size, SHMLBA, VMALLOC_START, VMALLOC_END,
1884 GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL,
1885 VM_USERMAP, NUMA_NO_NODE,
1886 __builtin_return_address(0));
1887}

--- 4 unchanged lines hidden (view full) ---

1892 * @size: allocation size
1893 * @node: numa node
1894 *
1895 * Allocate enough pages to cover @size from the page level
1896 * allocator and map them into contiguous kernel virtual space.
1897 *
1898 * For tight control over page level allocator and protection flags
1899 * use __vmalloc() instead.
1898 */
1899void *vmalloc_user(unsigned long size)
1900{
1901 return __vmalloc_node_range(size, SHMLBA, VMALLOC_START, VMALLOC_END,
1902 GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL,
1903 VM_USERMAP, NUMA_NO_NODE,
1904 __builtin_return_address(0));
1905}

--- 4 unchanged lines hidden (view full) ---

1910 * @size: allocation size
1911 * @node: numa node
1912 *
1913 * Allocate enough pages to cover @size from the page level
1914 * allocator and map them into contiguous kernel virtual space.
1915 *
1916 * For tight control over page level allocator and protection flags
1917 * use __vmalloc() instead.
1918 *
1919 * Return: pointer to the allocated memory or %NULL on error
1900 */
1901void *vmalloc_node(unsigned long size, int node)
1902{
1903 return __vmalloc_node(size, 1, GFP_KERNEL, PAGE_KERNEL,
1904 node, __builtin_return_address(0));
1905}
1906EXPORT_SYMBOL(vmalloc_node);
1907
1908/**
1909 * vzalloc_node - allocate memory on a specific node with zero fill
1910 * @size: allocation size
1911 * @node: numa node
1912 *
1913 * Allocate enough pages to cover @size from the page level
1914 * allocator and map them into contiguous kernel virtual space.
1915 * The memory allocated is set to zero.
1916 *
1917 * For tight control over page level allocator and protection flags
1918 * use __vmalloc_node() instead.
1920 */
1921void *vmalloc_node(unsigned long size, int node)
1922{
1923 return __vmalloc_node(size, 1, GFP_KERNEL, PAGE_KERNEL,
1924 node, __builtin_return_address(0));
1925}
1926EXPORT_SYMBOL(vmalloc_node);
1927
1928/**
1929 * vzalloc_node - allocate memory on a specific node with zero fill
1930 * @size: allocation size
1931 * @node: numa node
1932 *
1933 * Allocate enough pages to cover @size from the page level
1934 * allocator and map them into contiguous kernel virtual space.
1935 * The memory allocated is set to zero.
1936 *
1937 * For tight control over page level allocator and protection flags
1938 * use __vmalloc_node() instead.
1939 *
1940 * Return: pointer to the allocated memory or %NULL on error
1919 */
1920void *vzalloc_node(unsigned long size, int node)
1921{
1922 return __vmalloc_node_flags(size, node,
1923 GFP_KERNEL | __GFP_ZERO);
1924}
1925EXPORT_SYMBOL(vzalloc_node);
1926
1927/**
1928 * vmalloc_exec - allocate virtually contiguous, executable memory
1929 * @size: allocation size
1930 *
1931 * Kernel-internal function to allocate enough pages to cover @size
1932 * the page level allocator and map them into contiguous and
1933 * executable kernel virtual space.
1934 *
1935 * For tight control over page level allocator and protection flags
1936 * use __vmalloc() instead.
1941 */
1942void *vzalloc_node(unsigned long size, int node)
1943{
1944 return __vmalloc_node_flags(size, node,
1945 GFP_KERNEL | __GFP_ZERO);
1946}
1947EXPORT_SYMBOL(vzalloc_node);
1948
1949/**
1950 * vmalloc_exec - allocate virtually contiguous, executable memory
1951 * @size: allocation size
1952 *
1953 * Kernel-internal function to allocate enough pages to cover @size
1954 * the page level allocator and map them into contiguous and
1955 * executable kernel virtual space.
1956 *
1957 * For tight control over page level allocator and protection flags
1958 * use __vmalloc() instead.
1959 *
1960 * Return: pointer to the allocated memory or %NULL on error
1937 */
1938void *vmalloc_exec(unsigned long size)
1939{
1940 return __vmalloc_node(size, 1, GFP_KERNEL, PAGE_KERNEL_EXEC,
1941 NUMA_NO_NODE, __builtin_return_address(0));
1942}
1943
1944#if defined(CONFIG_64BIT) && defined(CONFIG_ZONE_DMA32)

--- 9 unchanged lines hidden (view full) ---

1954#endif
1955
1956/**
1957 * vmalloc_32 - allocate virtually contiguous memory (32bit addressable)
1958 * @size: allocation size
1959 *
1960 * Allocate enough 32bit PA addressable pages to cover @size from the
1961 * page level allocator and map them into contiguous kernel virtual space.
1961 */
1962void *vmalloc_exec(unsigned long size)
1963{
1964 return __vmalloc_node(size, 1, GFP_KERNEL, PAGE_KERNEL_EXEC,
1965 NUMA_NO_NODE, __builtin_return_address(0));
1966}
1967
1968#if defined(CONFIG_64BIT) && defined(CONFIG_ZONE_DMA32)

--- 9 unchanged lines hidden (view full) ---

1978#endif
1979
1980/**
1981 * vmalloc_32 - allocate virtually contiguous memory (32bit addressable)
1982 * @size: allocation size
1983 *
1984 * Allocate enough 32bit PA addressable pages to cover @size from the
1985 * page level allocator and map them into contiguous kernel virtual space.
1986 *
1987 * Return: pointer to the allocated memory or %NULL on error
1962 */
1963void *vmalloc_32(unsigned long size)
1964{
1965 return __vmalloc_node(size, 1, GFP_VMALLOC32, PAGE_KERNEL,
1966 NUMA_NO_NODE, __builtin_return_address(0));
1967}
1968EXPORT_SYMBOL(vmalloc_32);
1969
1970/**
1971 * vmalloc_32_user - allocate zeroed virtually contiguous 32bit memory
1972 * @size: allocation size
1973 *
1974 * The resulting memory area is 32bit addressable and zeroed so it can be
1975 * mapped to userspace without leaking data.
1988 */
1989void *vmalloc_32(unsigned long size)
1990{
1991 return __vmalloc_node(size, 1, GFP_VMALLOC32, PAGE_KERNEL,
1992 NUMA_NO_NODE, __builtin_return_address(0));
1993}
1994EXPORT_SYMBOL(vmalloc_32);
1995
1996/**
1997 * vmalloc_32_user - allocate zeroed virtually contiguous 32bit memory
1998 * @size: allocation size
1999 *
2000 * The resulting memory area is 32bit addressable and zeroed so it can be
2001 * mapped to userspace without leaking data.
2002 *
2003 * Return: pointer to the allocated memory or %NULL on error
1976 */
1977void *vmalloc_32_user(unsigned long size)
1978{
1979 return __vmalloc_node_range(size, SHMLBA, VMALLOC_START, VMALLOC_END,
1980 GFP_VMALLOC32 | __GFP_ZERO, PAGE_KERNEL,
1981 VM_USERMAP, NUMA_NO_NODE,
1982 __builtin_return_address(0));
1983}

--- 81 unchanged lines hidden (view full) ---

2065}
2066
2067/**
2068 * vread() - read vmalloc area in a safe way.
2069 * @buf: buffer for reading data
2070 * @addr: vm address.
2071 * @count: number of bytes to be read.
2072 *
2004 */
2005void *vmalloc_32_user(unsigned long size)
2006{
2007 return __vmalloc_node_range(size, SHMLBA, VMALLOC_START, VMALLOC_END,
2008 GFP_VMALLOC32 | __GFP_ZERO, PAGE_KERNEL,
2009 VM_USERMAP, NUMA_NO_NODE,
2010 __builtin_return_address(0));
2011}

--- 81 unchanged lines hidden (view full) ---

2093}
2094
2095/**
2096 * vread() - read vmalloc area in a safe way.
2097 * @buf: buffer for reading data
2098 * @addr: vm address.
2099 * @count: number of bytes to be read.
2100 *
2073 * Returns # of bytes which addr and buf should be increased.
2074 * (same number to @count). Returns 0 if [addr...addr+count) doesn't
2075 * includes any intersect with alive vmalloc area.
2076 *
2077 * This function checks that addr is a valid vmalloc'ed area, and
2078 * copy data from that area to a given buffer. If the given memory range
2079 * of [addr...addr+count) includes some valid address, data is copied to
2080 * proper area of @buf. If there are memory holes, they'll be zero-filled.
2081 * IOREMAP area is treated as memory hole and no copy is done.
2082 *
2083 * If [addr...addr+count) doesn't includes any intersects with alive
2084 * vm_struct area, returns 0. @buf should be kernel's buffer.
2085 *
2086 * Note: In usual ops, vread() is never necessary because the caller
2087 * should know vmalloc() area is valid and can use memcpy().
2088 * This is for routines which have to access vmalloc area without
2089 * any informaion, as /dev/kmem.
2101 * This function checks that addr is a valid vmalloc'ed area, and
2102 * copy data from that area to a given buffer. If the given memory range
2103 * of [addr...addr+count) includes some valid address, data is copied to
2104 * proper area of @buf. If there are memory holes, they'll be zero-filled.
2105 * IOREMAP area is treated as memory hole and no copy is done.
2106 *
2107 * If [addr...addr+count) doesn't includes any intersects with alive
2108 * vm_struct area, returns 0. @buf should be kernel's buffer.
2109 *
2110 * Note: In usual ops, vread() is never necessary because the caller
2111 * should know vmalloc() area is valid and can use memcpy().
2112 * This is for routines which have to access vmalloc area without
2113 * any informaion, as /dev/kmem.
2114 *
2115 * Return: number of bytes for which addr and buf should be increased
2116 * (same number as @count) or %0 if [addr...addr+count) doesn't
2117 * include any intersection with valid vmalloc area
2090 */
2091long vread(char *buf, char *addr, unsigned long count)
2092{
2093 struct vmap_area *va;
2094 struct vm_struct *vm;
2095 char *vaddr, *buf_start = buf;
2096 unsigned long buflen = count;
2097 unsigned long n;

--- 46 unchanged lines hidden (view full) ---

2144}
2145
2146/**
2147 * vwrite() - write vmalloc area in a safe way.
2148 * @buf: buffer for source data
2149 * @addr: vm address.
2150 * @count: number of bytes to be read.
2151 *
2118 */
2119long vread(char *buf, char *addr, unsigned long count)
2120{
2121 struct vmap_area *va;
2122 struct vm_struct *vm;
2123 char *vaddr, *buf_start = buf;
2124 unsigned long buflen = count;
2125 unsigned long n;

--- 46 unchanged lines hidden (view full) ---

2172}
2173
2174/**
2175 * vwrite() - write vmalloc area in a safe way.
2176 * @buf: buffer for source data
2177 * @addr: vm address.
2178 * @count: number of bytes to be read.
2179 *
2152 * Returns # of bytes which addr and buf should be incresed.
2153 * (same number to @count).
2154 * If [addr...addr+count) doesn't includes any intersect with valid
2155 * vmalloc area, returns 0.
2156 *
2157 * This function checks that addr is a valid vmalloc'ed area, and
2158 * copy data from a buffer to the given addr. If specified range of
2159 * [addr...addr+count) includes some valid address, data is copied from
2160 * proper area of @buf. If there are memory holes, no copy to hole.
2161 * IOREMAP area is treated as memory hole and no copy is done.
2162 *
2163 * If [addr...addr+count) doesn't includes any intersects with alive
2164 * vm_struct area, returns 0. @buf should be kernel's buffer.
2165 *
2166 * Note: In usual ops, vwrite() is never necessary because the caller
2167 * should know vmalloc() area is valid and can use memcpy().
2168 * This is for routines which have to access vmalloc area without
2169 * any informaion, as /dev/kmem.
2180 * This function checks that addr is a valid vmalloc'ed area, and
2181 * copy data from a buffer to the given addr. If specified range of
2182 * [addr...addr+count) includes some valid address, data is copied from
2183 * proper area of @buf. If there are memory holes, no copy to hole.
2184 * IOREMAP area is treated as memory hole and no copy is done.
2185 *
2186 * If [addr...addr+count) doesn't includes any intersects with alive
2187 * vm_struct area, returns 0. @buf should be kernel's buffer.
2188 *
2189 * Note: In usual ops, vwrite() is never necessary because the caller
2190 * should know vmalloc() area is valid and can use memcpy().
2191 * This is for routines which have to access vmalloc area without
2192 * any informaion, as /dev/kmem.
2193 *
2194 * Return: number of bytes for which addr and buf should be
2195 * increased (same number as @count) or %0 if [addr...addr+count)
2196 * doesn't include any intersection with valid vmalloc area
2170 */
2171long vwrite(char *buf, char *addr, unsigned long count)
2172{
2173 struct vmap_area *va;
2174 struct vm_struct *vm;
2175 char *vaddr;
2176 unsigned long n, buflen;
2177 int copied = 0;

--- 579 unchanged lines hidden ---
2197 */
2198long vwrite(char *buf, char *addr, unsigned long count)
2199{
2200 struct vmap_area *va;
2201 struct vm_struct *vm;
2202 char *vaddr;
2203 unsigned long n, buflen;
2204 int copied = 0;

--- 579 unchanged lines hidden ---