11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * linux/arch/arm/mm/init.c 31da177e4SLinus Torvalds * 490072059SRussell King * Copyright (C) 1995-2005 Russell King 51da177e4SLinus Torvalds * 61da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or modify 71da177e4SLinus Torvalds * it under the terms of the GNU General Public License version 2 as 81da177e4SLinus Torvalds * published by the Free Software Foundation. 91da177e4SLinus Torvalds */ 101da177e4SLinus Torvalds #include <linux/kernel.h> 111da177e4SLinus Torvalds #include <linux/errno.h> 121da177e4SLinus Torvalds #include <linux/swap.h> 131da177e4SLinus Torvalds #include <linux/init.h> 141da177e4SLinus Torvalds #include <linux/bootmem.h> 151da177e4SLinus Torvalds #include <linux/mman.h> 16dc28094bSPaul Gortmaker #include <linux/export.h> 171da177e4SLinus Torvalds #include <linux/nodemask.h> 181da177e4SLinus Torvalds #include <linux/initrd.h> 199eb8f674SGrant Likely #include <linux/of_fdt.h> 203835f6cbSNicolas Pitre #include <linux/highmem.h> 215a0e3ad6STejun Heo #include <linux/gfp.h> 222778f620SRussell King #include <linux/memblock.h> 23c7909509SMarek Szyprowski #include <linux/dma-contiguous.h> 24158e8bfeSAlessandro Rubini #include <linux/sizes.h> 251da177e4SLinus Torvalds 26b4b20ad8SRussell King #include <asm/cp15.h> 271da177e4SLinus Torvalds #include <asm/mach-types.h> 28716a3dc2SRussell King #include <asm/memblock.h> 2993c02ab4SGrant Likely #include <asm/prom.h> 3037efe642SRussell King #include <asm/sections.h> 311da177e4SLinus Torvalds #include <asm/setup.h> 321e6b4811SKees Cook #include <asm/system_info.h> 331da177e4SLinus Torvalds #include <asm/tlb.h> 34db9ef1afSFenkart/Bostandzhyan #include <asm/fixmap.h> 351da177e4SLinus Torvalds 361da177e4SLinus Torvalds #include <asm/mach/arch.h> 371da177e4SLinus Torvalds #include <asm/mach/map.h> 381da177e4SLinus Torvalds 391b2e2b73SRussell King #include "mm.h" 401b2e2b73SRussell King 41b4b20ad8SRussell King #ifdef CONFIG_CPU_CP15_MMU 42b4b20ad8SRussell King unsigned long __init __clear_cr(unsigned long mask) 43b4b20ad8SRussell King { 44b4b20ad8SRussell King cr_alignment = cr_alignment & ~mask; 45b4b20ad8SRussell King return cr_alignment; 46b4b20ad8SRussell King } 47b4b20ad8SRussell King #endif 48b4b20ad8SRussell King 49de22cc6eSVitaly Andrianov static phys_addr_t phys_initrd_start __initdata = 0; 50012d1f4aSRussell King static unsigned long phys_initrd_size __initdata = 0; 51012d1f4aSRussell King 522b0d8c25SJeremy Kerr static int __init early_initrd(char *p) 53012d1f4aSRussell King { 54de22cc6eSVitaly Andrianov phys_addr_t start; 55de22cc6eSVitaly Andrianov unsigned long size; 562b0d8c25SJeremy Kerr char *endp; 57012d1f4aSRussell King 582b0d8c25SJeremy Kerr start = memparse(p, &endp); 592b0d8c25SJeremy Kerr if (*endp == ',') { 602b0d8c25SJeremy Kerr size = memparse(endp + 1, NULL); 61012d1f4aSRussell King 62012d1f4aSRussell King phys_initrd_start = start; 63012d1f4aSRussell King phys_initrd_size = size; 64012d1f4aSRussell King } 652b0d8c25SJeremy Kerr return 0; 66012d1f4aSRussell King } 672b0d8c25SJeremy Kerr early_param("initrd", early_initrd); 68012d1f4aSRussell King 69012d1f4aSRussell King static int __init parse_tag_initrd(const struct tag *tag) 70012d1f4aSRussell King { 714ed89f22SRussell King pr_warn("ATAG_INITRD is deprecated; " 72012d1f4aSRussell King "please update your bootloader.\n"); 73012d1f4aSRussell King phys_initrd_start = __virt_to_phys(tag->u.initrd.start); 74012d1f4aSRussell King phys_initrd_size = tag->u.initrd.size; 75012d1f4aSRussell King return 0; 76012d1f4aSRussell King } 77012d1f4aSRussell King 78012d1f4aSRussell King __tagtable(ATAG_INITRD, parse_tag_initrd); 79012d1f4aSRussell King 80012d1f4aSRussell King static int __init parse_tag_initrd2(const struct tag *tag) 81012d1f4aSRussell King { 82012d1f4aSRussell King phys_initrd_start = tag->u.initrd.start; 83012d1f4aSRussell King phys_initrd_size = tag->u.initrd.size; 84012d1f4aSRussell King return 0; 85012d1f4aSRussell King } 86012d1f4aSRussell King 87012d1f4aSRussell King __tagtable(ATAG_INITRD2, parse_tag_initrd2); 881da177e4SLinus Torvalds 891da177e4SLinus Torvalds /* 904b5f32ceSNicolas Pitre * This keeps memory configuration data used by a couple memory 914b5f32ceSNicolas Pitre * initialization functions, as well as show_mem() for the skipping 924b5f32ceSNicolas Pitre * of holes in the memory map. It is populated by arm_add_memory(). 931da177e4SLinus Torvalds */ 94b2b755b5SDavid Rientjes void show_mem(unsigned int filter) 951da177e4SLinus Torvalds { 961da177e4SLinus Torvalds int free = 0, total = 0, reserved = 0; 971c2f87c2SLaura Abbott int shared = 0, cached = 0, slab = 0; 981c2f87c2SLaura Abbott struct memblock_region *reg; 991da177e4SLinus Torvalds 1001da177e4SLinus Torvalds printk("Mem-info:\n"); 1017bf02ea2SDavid Rientjes show_free_areas(filter); 102be370302SRussell King 1031c2f87c2SLaura Abbott for_each_memblock (memory, reg) { 1045e709827SRay Lehtiniemi unsigned int pfn1, pfn2; 1051da177e4SLinus Torvalds struct page *page, *end; 1061da177e4SLinus Torvalds 1071c2f87c2SLaura Abbott pfn1 = memblock_region_memory_base_pfn(reg); 1081c2f87c2SLaura Abbott pfn2 = memblock_region_memory_end_pfn(reg); 1095e709827SRay Lehtiniemi 110ea056df7SCatalin Marinas page = pfn_to_page(pfn1); 111ea056df7SCatalin Marinas end = pfn_to_page(pfn2 - 1) + 1; 1121da177e4SLinus Torvalds 1131da177e4SLinus Torvalds do { 1141da177e4SLinus Torvalds total++; 1151da177e4SLinus Torvalds if (PageReserved(page)) 1161da177e4SLinus Torvalds reserved++; 1171da177e4SLinus Torvalds else if (PageSwapCache(page)) 1181da177e4SLinus Torvalds cached++; 1191da177e4SLinus Torvalds else if (PageSlab(page)) 1201da177e4SLinus Torvalds slab++; 1211da177e4SLinus Torvalds else if (!page_count(page)) 1221da177e4SLinus Torvalds free++; 1231da177e4SLinus Torvalds else 1241da177e4SLinus Torvalds shared += page_count(page) - 1; 1251c2f87c2SLaura Abbott pfn1++; 1261c2f87c2SLaura Abbott page = pfn_to_page(pfn1); 1271c2f87c2SLaura Abbott } while (pfn1 < pfn2); 1281da177e4SLinus Torvalds } 1291da177e4SLinus Torvalds 1301da177e4SLinus Torvalds printk("%d pages of RAM\n", total); 1311da177e4SLinus Torvalds printk("%d free pages\n", free); 1321da177e4SLinus Torvalds printk("%d reserved pages\n", reserved); 1331da177e4SLinus Torvalds printk("%d slab pages\n", slab); 1341da177e4SLinus Torvalds printk("%d pages shared\n", shared); 1351da177e4SLinus Torvalds printk("%d pages swap cached\n", cached); 1361da177e4SLinus Torvalds } 1371da177e4SLinus Torvalds 138f25b4b4cSRussell King static void __init find_limits(unsigned long *min, unsigned long *max_low, 139f25b4b4cSRussell King unsigned long *max_high) 140dde5828fSRussell King { 1411c2f87c2SLaura Abbott *max_low = PFN_DOWN(memblock_get_current_limit()); 1421c2f87c2SLaura Abbott *min = PFN_UP(memblock_start_of_DRAM()); 1431c2f87c2SLaura Abbott *max_high = PFN_DOWN(memblock_end_of_DRAM()); 144dde5828fSRussell King } 145dde5828fSRussell King 146be20902bSRussell King #ifdef CONFIG_ZONE_DMA 14765032018SNicolas Pitre 148364230b9SRob Herring phys_addr_t arm_dma_zone_size __read_mostly; 14965032018SNicolas Pitre EXPORT_SYMBOL(arm_dma_zone_size); 15065032018SNicolas Pitre 151022ae537SRussell King /* 152022ae537SRussell King * The DMA mask corresponding to the maximum bus address allocatable 153022ae537SRussell King * using GFP_DMA. The default here places no restriction on DMA 154022ae537SRussell King * allocations. This must be the smallest DMA mask in the system, 155022ae537SRussell King * so a successful GFP_DMA allocation will always satisfy this. 156022ae537SRussell King */ 1574986e5c7SMarek Szyprowski phys_addr_t arm_dma_limit; 1584dcfa600SRussell King unsigned long arm_dma_pfn_limit; 159022ae537SRussell King 160be20902bSRussell King static void __init arm_adjust_dma_zone(unsigned long *size, unsigned long *hole, 161be20902bSRussell King unsigned long dma_size) 162be20902bSRussell King { 163be20902bSRussell King if (size[0] <= dma_size) 164be20902bSRussell King return; 165be20902bSRussell King 166be20902bSRussell King size[ZONE_NORMAL] = size[0] - dma_size; 167be20902bSRussell King size[ZONE_DMA] = dma_size; 168be20902bSRussell King hole[ZONE_NORMAL] = hole[0]; 169be20902bSRussell King hole[ZONE_DMA] = 0; 170be20902bSRussell King } 171be20902bSRussell King #endif 172be20902bSRussell King 173ff69a4c8SRussell King void __init setup_dma_zone(const struct machine_desc *mdesc) 174c7909509SMarek Szyprowski { 175c7909509SMarek Szyprowski #ifdef CONFIG_ZONE_DMA 176c7909509SMarek Szyprowski if (mdesc->dma_zone_size) { 177c7909509SMarek Szyprowski arm_dma_zone_size = mdesc->dma_zone_size; 1786bcac805SRussell King arm_dma_limit = PHYS_OFFSET + arm_dma_zone_size - 1; 179c7909509SMarek Szyprowski } else 180c7909509SMarek Szyprowski arm_dma_limit = 0xffffffff; 1814dcfa600SRussell King arm_dma_pfn_limit = arm_dma_limit >> PAGE_SHIFT; 182c7909509SMarek Szyprowski #endif 183c7909509SMarek Szyprowski } 184c7909509SMarek Szyprowski 18584f452b1SSantosh Shilimkar static void __init zone_sizes_init(unsigned long min, unsigned long max_low, 186a2c54d2aSRussell King unsigned long max_high) 187b7a69ac3SRussell King { 188b7a69ac3SRussell King unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES]; 189a2c54d2aSRussell King struct memblock_region *reg; 190b7a69ac3SRussell King 19190072059SRussell King /* 192be370302SRussell King * initialise the zones. 19390072059SRussell King */ 19490072059SRussell King memset(zone_size, 0, sizeof(zone_size)); 19590072059SRussell King 19690072059SRussell King /* 197be370302SRussell King * The memory size has already been determined. If we need 198be370302SRussell King * to do anything fancy with the allocation of this memory 199be370302SRussell King * to the zones, now is the time to do it. 20090072059SRussell King */ 201dde5828fSRussell King zone_size[0] = max_low - min; 202dde5828fSRussell King #ifdef CONFIG_HIGHMEM 203dde5828fSRussell King zone_size[ZONE_HIGHMEM] = max_high - max_low; 204dde5828fSRussell King #endif 20590072059SRussell King 20690072059SRussell King /* 207be370302SRussell King * Calculate the size of the holes. 208be370302SRussell King * holes = node_size - sum(bank_sizes) 20990072059SRussell King */ 210dde5828fSRussell King memcpy(zhole_size, zone_size, sizeof(zhole_size)); 211a2c54d2aSRussell King for_each_memblock(memory, reg) { 212a2c54d2aSRussell King unsigned long start = memblock_region_memory_base_pfn(reg); 213a2c54d2aSRussell King unsigned long end = memblock_region_memory_end_pfn(reg); 214a2c54d2aSRussell King 215a2c54d2aSRussell King if (start < max_low) { 216a2c54d2aSRussell King unsigned long low_end = min(end, max_low); 217a2c54d2aSRussell King zhole_size[0] -= low_end - start; 218a2c54d2aSRussell King } 219dde5828fSRussell King #ifdef CONFIG_HIGHMEM 220a2c54d2aSRussell King if (end > max_low) { 221a2c54d2aSRussell King unsigned long high_start = max(start, max_low); 222a2c54d2aSRussell King zhole_size[ZONE_HIGHMEM] -= end - high_start; 223a2c54d2aSRussell King } 224dde5828fSRussell King #endif 225dde5828fSRussell King } 22690072059SRussell King 22765032018SNicolas Pitre #ifdef CONFIG_ZONE_DMA 22890072059SRussell King /* 22990072059SRussell King * Adjust the sizes according to any special requirements for 23090072059SRussell King * this machine type. 23190072059SRussell King */ 232c7909509SMarek Szyprowski if (arm_dma_zone_size) 233be20902bSRussell King arm_adjust_dma_zone(zone_size, zhole_size, 23465032018SNicolas Pitre arm_dma_zone_size >> PAGE_SHIFT); 235be20902bSRussell King #endif 23690072059SRussell King 237be370302SRussell King free_area_init_node(0, zone_size, min, zhole_size); 23890072059SRussell King } 23990072059SRussell King 2407b7bf499SWill Deacon #ifdef CONFIG_HAVE_ARCH_PFN_VALID 241b7cfda9fSRussell King int pfn_valid(unsigned long pfn) 242b7cfda9fSRussell King { 243fb492c91SMark Rutland return memblock_is_memory(__pfn_to_phys(pfn)); 244b7cfda9fSRussell King } 245b7cfda9fSRussell King EXPORT_SYMBOL(pfn_valid); 2467b7bf499SWill Deacon #endif 247657e12fdSRussell King 2487b7bf499SWill Deacon #ifndef CONFIG_SPARSEMEM 24914904927SStephen Boyd static void __init arm_memory_present(void) 250657e12fdSRussell King { 251657e12fdSRussell King } 252657e12fdSRussell King #else 25314904927SStephen Boyd static void __init arm_memory_present(void) 254657e12fdSRussell King { 255719c1514SBenjamin Herrenschmidt struct memblock_region *reg; 256719c1514SBenjamin Herrenschmidt 2577c996361SYinghai Lu for_each_memblock(memory, reg) 258c7fc2de0SYinghai Lu memory_present(0, memblock_region_memory_base_pfn(reg), 259c7fc2de0SYinghai Lu memblock_region_memory_end_pfn(reg)); 260657e12fdSRussell King } 261b7cfda9fSRussell King #endif 262b7cfda9fSRussell King 263716a3dc2SRussell King static bool arm_memblock_steal_permitted = true; 264716a3dc2SRussell King 265bc2827d0SRussell King phys_addr_t __init arm_memblock_steal(phys_addr_t size, phys_addr_t align) 266716a3dc2SRussell King { 267716a3dc2SRussell King phys_addr_t phys; 268716a3dc2SRussell King 269716a3dc2SRussell King BUG_ON(!arm_memblock_steal_permitted); 270716a3dc2SRussell King 2717ac68a4cSRussell King phys = memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ANYWHERE); 272716a3dc2SRussell King memblock_free(phys, size); 273716a3dc2SRussell King memblock_remove(phys, size); 274716a3dc2SRussell King 275716a3dc2SRussell King return phys; 276716a3dc2SRussell King } 277716a3dc2SRussell King 2781c2f87c2SLaura Abbott void __init arm_memblock_init(const struct machine_desc *mdesc) 2792778f620SRussell King { 2802778f620SRussell King /* Register the kernel text, kernel data and initrd with memblock. */ 2812778f620SRussell King #ifdef CONFIG_XIP_KERNEL 282842eab40SRussell King memblock_reserve(__pa(_sdata), _end - _sdata); 2832778f620SRussell King #else 2842778f620SRussell King memblock_reserve(__pa(_stext), _end - _stext); 2852778f620SRussell King #endif 2862778f620SRussell King #ifdef CONFIG_BLK_DEV_INITRD 28765939301SRob Herring /* FDT scan will populate initrd_start */ 2884c235cb9SBen Peddell if (initrd_start && !phys_initrd_size) { 28965939301SRob Herring phys_initrd_start = __virt_to_phys(initrd_start); 29065939301SRob Herring phys_initrd_size = initrd_end - initrd_start; 29165939301SRob Herring } 2924c235cb9SBen Peddell initrd_start = initrd_end = 0; 293b0a2679dSRussell King if (phys_initrd_size && 2948f4b8c76SRussell King !memblock_is_region_memory(phys_initrd_start, phys_initrd_size)) { 295de22cc6eSVitaly Andrianov pr_err("INITRD: 0x%08llx+0x%08lx is not a memory region - disabling initrd\n", 296de22cc6eSVitaly Andrianov (u64)phys_initrd_start, phys_initrd_size); 2978f4b8c76SRussell King phys_initrd_start = phys_initrd_size = 0; 2988f4b8c76SRussell King } 2998f4b8c76SRussell King if (phys_initrd_size && 300b0a2679dSRussell King memblock_is_region_reserved(phys_initrd_start, phys_initrd_size)) { 301de22cc6eSVitaly Andrianov pr_err("INITRD: 0x%08llx+0x%08lx overlaps in-use memory region - disabling initrd\n", 302de22cc6eSVitaly Andrianov (u64)phys_initrd_start, phys_initrd_size); 303b0a2679dSRussell King phys_initrd_start = phys_initrd_size = 0; 304b0a2679dSRussell King } 3052778f620SRussell King if (phys_initrd_size) { 3062778f620SRussell King memblock_reserve(phys_initrd_start, phys_initrd_size); 3072778f620SRussell King 3082778f620SRussell King /* Now convert initrd to virtual addresses */ 3092778f620SRussell King initrd_start = __phys_to_virt(phys_initrd_start); 3102778f620SRussell King initrd_end = initrd_start + phys_initrd_size; 3112778f620SRussell King } 3122778f620SRussell King #endif 3132778f620SRussell King 3142778f620SRussell King arm_mm_memblock_reserve(); 3152778f620SRussell King 3168d717a52SRussell King /* reserve any platform specific memblock areas */ 3178d717a52SRussell King if (mdesc->reserve) 3188d717a52SRussell King mdesc->reserve(); 3198d717a52SRussell King 320bcedb5f9SMarek Szyprowski early_init_fdt_scan_reserved_mem(); 321bcedb5f9SMarek Szyprowski 322c7909509SMarek Szyprowski /* 323c7909509SMarek Szyprowski * reserve memory for DMA contigouos allocations, 324c7909509SMarek Szyprowski * must come from DMA area inside low memory 325c7909509SMarek Szyprowski */ 32695b0e655SMarek Szyprowski dma_contiguous_reserve(arm_dma_limit); 327c7909509SMarek Szyprowski 328716a3dc2SRussell King arm_memblock_steal_permitted = false; 3292778f620SRussell King memblock_dump_all(); 3302778f620SRussell King } 3312778f620SRussell King 3328d717a52SRussell King void __init bootmem_init(void) 33390072059SRussell King { 334dde5828fSRussell King unsigned long min, max_low, max_high; 33590072059SRussell King 3368e58caefSGrygorii Strashko memblock_allow_resize(); 337dde5828fSRussell King max_low = max_high = 0; 338dde5828fSRussell King 339f25b4b4cSRussell King find_limits(&min, &max_low, &max_high); 340dde5828fSRussell King 341b7a69ac3SRussell King /* 342657e12fdSRussell King * Sparsemem tries to allocate bootmem in memory_present(), 343657e12fdSRussell King * so must be done after the fixed reservations 344657e12fdSRussell King */ 345eda2e5dcSRussell King arm_memory_present(); 34690072059SRussell King 347b7a69ac3SRussell King /* 348b7a69ac3SRussell King * sparse_init() needs the bootmem allocator up and running. 349b7a69ac3SRussell King */ 350b7a69ac3SRussell King sparse_init(); 351b7a69ac3SRussell King 352b7a69ac3SRussell King /* 353be370302SRussell King * Now free the memory - free_area_init_node needs 354b7a69ac3SRussell King * the sparse mem_map arrays initialized by sparse_init() 355b7a69ac3SRussell King * for memmap_init_zone(), otherwise all PFNs are invalid. 356b7a69ac3SRussell King */ 35784f452b1SSantosh Shilimkar zone_sizes_init(min, max_low, max_high); 358b7a69ac3SRussell King 35990072059SRussell King /* 36090072059SRussell King * This doesn't seem to be used by the Linux memory manager any 36190072059SRussell King * more, but is used by ll_rw_block. If we can get rid of it, we 36290072059SRussell King * also get rid of some of the stuff above as well. 36390072059SRussell King */ 36426ba47b1SSantosh Shilimkar min_low_pfn = min; 36526ba47b1SSantosh Shilimkar max_low_pfn = max_low; 36626ba47b1SSantosh Shilimkar max_pfn = max_high; 36790072059SRussell King } 36890072059SRussell King 36954d52573SStephen Boyd /* 37054d52573SStephen Boyd * Poison init memory with an undefined instruction (ARM) or a branch to an 37154d52573SStephen Boyd * undefined instruction (Thumb). 37254d52573SStephen Boyd */ 37354d52573SStephen Boyd static inline void poison_init_mem(void *s, size_t count) 37454d52573SStephen Boyd { 37554d52573SStephen Boyd u32 *p = (u32 *)s; 376bf912d99SJamie Iles for (; count != 0; count -= 4) 37754d52573SStephen Boyd *p++ = 0xe7fddef0; 37854d52573SStephen Boyd } 37954d52573SStephen Boyd 380a013053dSRussell King static inline void 381be370302SRussell King free_memmap(unsigned long start_pfn, unsigned long end_pfn) 382a013053dSRussell King { 383a013053dSRussell King struct page *start_pg, *end_pg; 38456bc6286SVitaly Andrianov phys_addr_t pg, pgend; 385a013053dSRussell King 386a013053dSRussell King /* 387a013053dSRussell King * Convert start_pfn/end_pfn to a struct page pointer. 388a013053dSRussell King */ 3893257f43dSCatalin Marinas start_pg = pfn_to_page(start_pfn - 1) + 1; 3909af386c8SWill Deacon end_pg = pfn_to_page(end_pfn - 1) + 1; 391a013053dSRussell King 392a013053dSRussell King /* 393a013053dSRussell King * Convert to physical addresses, and 394a013053dSRussell King * round start upwards and end downwards. 395a013053dSRussell King */ 39656bc6286SVitaly Andrianov pg = PAGE_ALIGN(__pa(start_pg)); 39756bc6286SVitaly Andrianov pgend = __pa(end_pg) & PAGE_MASK; 398a013053dSRussell King 399a013053dSRussell King /* 400a013053dSRussell King * If there are free pages between these, 401a013053dSRussell King * free the section of the memmap array. 402a013053dSRussell King */ 403a013053dSRussell King if (pg < pgend) 404cfb66586SSantosh Shilimkar memblock_free_early(pg, pgend - pg); 405a013053dSRussell King } 406a013053dSRussell King 407a013053dSRussell King /* 408a013053dSRussell King * The mem_map array can get very big. Free the unused area of the memory map. 409a013053dSRussell King */ 4101c2f87c2SLaura Abbott static void __init free_unused_memmap(void) 411a013053dSRussell King { 4121c2f87c2SLaura Abbott unsigned long start, prev_end = 0; 4131c2f87c2SLaura Abbott struct memblock_region *reg; 414a013053dSRussell King 415a013053dSRussell King /* 4163260e529SMichael Bohan * This relies on each bank being in address order. 4173260e529SMichael Bohan * The banks are sorted previously in bootmem_init(). 418a013053dSRussell King */ 4191c2f87c2SLaura Abbott for_each_memblock(memory, reg) { 4201c2f87c2SLaura Abbott start = memblock_region_memory_base_pfn(reg); 421a013053dSRussell King 4229af386c8SWill Deacon #ifdef CONFIG_SPARSEMEM 4239af386c8SWill Deacon /* 4249af386c8SWill Deacon * Take care not to free memmap entries that don't exist 4259af386c8SWill Deacon * due to SPARSEMEM sections which aren't present. 4269af386c8SWill Deacon */ 4271c2f87c2SLaura Abbott start = min(start, 4281c2f87c2SLaura Abbott ALIGN(prev_end, PAGES_PER_SECTION)); 429002ea9eeSLinus Walleij #else 430002ea9eeSLinus Walleij /* 431002ea9eeSLinus Walleij * Align down here since the VM subsystem insists that the 432002ea9eeSLinus Walleij * memmap entries are valid from the bank start aligned to 433002ea9eeSLinus Walleij * MAX_ORDER_NR_PAGES. 434002ea9eeSLinus Walleij */ 4351c2f87c2SLaura Abbott start = round_down(start, MAX_ORDER_NR_PAGES); 4369af386c8SWill Deacon #endif 437a013053dSRussell King /* 438a013053dSRussell King * If we had a previous bank, and there is a space 439a013053dSRussell King * between the current bank and the previous, free it. 440a013053dSRussell King */ 4411c2f87c2SLaura Abbott if (prev_end && prev_end < start) 4421c2f87c2SLaura Abbott free_memmap(prev_end, start); 443a013053dSRussell King 4443260e529SMichael Bohan /* 4453260e529SMichael Bohan * Align up here since the VM subsystem insists that the 4463260e529SMichael Bohan * memmap entries are valid from the bank end aligned to 4473260e529SMichael Bohan * MAX_ORDER_NR_PAGES. 4483260e529SMichael Bohan */ 4491c2f87c2SLaura Abbott prev_end = ALIGN(memblock_region_memory_end_pfn(reg), 4501c2f87c2SLaura Abbott MAX_ORDER_NR_PAGES); 451a013053dSRussell King } 4529af386c8SWill Deacon 4539af386c8SWill Deacon #ifdef CONFIG_SPARSEMEM 4541c2f87c2SLaura Abbott if (!IS_ALIGNED(prev_end, PAGES_PER_SECTION)) 4551c2f87c2SLaura Abbott free_memmap(prev_end, 4561c2f87c2SLaura Abbott ALIGN(prev_end, PAGES_PER_SECTION)); 4579af386c8SWill Deacon #endif 458a013053dSRussell King } 459a013053dSRussell King 46083db0384SJiang Liu #ifdef CONFIG_HIGHMEM 46183db0384SJiang Liu static inline void free_area_high(unsigned long pfn, unsigned long end) 46283db0384SJiang Liu { 463dd6911efSJiang Liu for (; pfn < end; pfn++) 464dd6911efSJiang Liu free_highmem_page(pfn_to_page(pfn)); 46583db0384SJiang Liu } 46683db0384SJiang Liu #endif 46783db0384SJiang Liu 468d0e775afSRussell King static void __init free_highpages(void) 469d0e775afSRussell King { 470d0e775afSRussell King #ifdef CONFIG_HIGHMEM 47126ba47b1SSantosh Shilimkar unsigned long max_low = max_low_pfn; 472df4f14c7SRussell King struct memblock_region *mem, *res; 473d0e775afSRussell King 474d0e775afSRussell King /* set highmem page free */ 475df4f14c7SRussell King for_each_memblock(memory, mem) { 476df4f14c7SRussell King unsigned long start = memblock_region_memory_base_pfn(mem); 477df4f14c7SRussell King unsigned long end = memblock_region_memory_end_pfn(mem); 478df4f14c7SRussell King 479df4f14c7SRussell King /* Ignore complete lowmem entries */ 480df4f14c7SRussell King if (end <= max_low) 481df4f14c7SRussell King continue; 482df4f14c7SRussell King 483df4f14c7SRussell King /* Truncate partial highmem entries */ 484df4f14c7SRussell King if (start < max_low) 485df4f14c7SRussell King start = max_low; 486df4f14c7SRussell King 487df4f14c7SRussell King /* Find and exclude any reserved regions */ 488df4f14c7SRussell King for_each_memblock(reserved, res) { 489df4f14c7SRussell King unsigned long res_start, res_end; 490df4f14c7SRussell King 491df4f14c7SRussell King res_start = memblock_region_reserved_base_pfn(res); 492df4f14c7SRussell King res_end = memblock_region_reserved_end_pfn(res); 493df4f14c7SRussell King 494df4f14c7SRussell King if (res_end < start) 495df4f14c7SRussell King continue; 496df4f14c7SRussell King if (res_start < start) 497df4f14c7SRussell King res_start = start; 498df4f14c7SRussell King if (res_start > end) 499df4f14c7SRussell King res_start = end; 500df4f14c7SRussell King if (res_end > end) 501df4f14c7SRussell King res_end = end; 502df4f14c7SRussell King if (res_start != start) 50383db0384SJiang Liu free_area_high(start, res_start); 504df4f14c7SRussell King start = res_end; 505df4f14c7SRussell King if (start == end) 506df4f14c7SRussell King break; 507df4f14c7SRussell King } 508df4f14c7SRussell King 509df4f14c7SRussell King /* And now free anything which remains */ 510df4f14c7SRussell King if (start < end) 51183db0384SJiang Liu free_area_high(start, end); 512d0e775afSRussell King } 513d0e775afSRussell King #endif 514d0e775afSRussell King } 515d0e775afSRussell King 5161da177e4SLinus Torvalds /* 5171da177e4SLinus Torvalds * mem_init() marks the free areas in the mem_map and tells us how much 5181da177e4SLinus Torvalds * memory is free. This is done after various parts of the system have 5191da177e4SLinus Torvalds * claimed their memory after the kernel image. 5201da177e4SLinus Torvalds */ 5211da177e4SLinus Torvalds void __init mem_init(void) 5221da177e4SLinus Torvalds { 5231dbd30e9SLinus Walleij #ifdef CONFIG_HAVE_TCM 5241dbd30e9SLinus Walleij /* These pointers are filled in on TCM detection */ 5251dbd30e9SLinus Walleij extern u32 dtcm_end; 5261dbd30e9SLinus Walleij extern u32 itcm_end; 5271dbd30e9SLinus Walleij #endif 5281da177e4SLinus Torvalds 529b3ba41f2SSantosh Shilimkar set_max_mapnr(pfn_to_page(max_pfn) - mem_map); 5301da177e4SLinus Torvalds 5311da177e4SLinus Torvalds /* this will put all unused low memory onto the freelists */ 5321c2f87c2SLaura Abbott free_unused_memmap(); 5330c988534SJiang Liu free_all_bootmem(); 5341da177e4SLinus Torvalds 5351da177e4SLinus Torvalds #ifdef CONFIG_SA1111 5361da177e4SLinus Torvalds /* now that our DMA memory is actually so designated, we can free it */ 537bfd65dd9SLinus Torvalds free_reserved_area(__va(PHYS_OFFSET), swapper_pg_dir, -1, NULL); 5381da177e4SLinus Torvalds #endif 5391da177e4SLinus Torvalds 540d0e775afSRussell King free_highpages(); 5413835f6cbSNicolas Pitre 5422450c973SJiang Liu mem_init_print_info(NULL); 5431da177e4SLinus Torvalds 544db9ef1afSFenkart/Bostandzhyan #define MLK(b, t) b, t, ((t) - (b)) >> 10 545db9ef1afSFenkart/Bostandzhyan #define MLM(b, t) b, t, ((t) - (b)) >> 20 546db9ef1afSFenkart/Bostandzhyan #define MLK_ROUNDUP(b, t) b, t, DIV_ROUND_UP(((t) - (b)), SZ_1K) 547db9ef1afSFenkart/Bostandzhyan 5484ed89f22SRussell King pr_notice("Virtual kernel memory layout:\n" 549db9ef1afSFenkart/Bostandzhyan " vector : 0x%08lx - 0x%08lx (%4ld kB)\n" 55007d2a5c7SLinus Walleij #ifdef CONFIG_HAVE_TCM 55107d2a5c7SLinus Walleij " DTCM : 0x%08lx - 0x%08lx (%4ld kB)\n" 55207d2a5c7SLinus Walleij " ITCM : 0x%08lx - 0x%08lx (%4ld kB)\n" 55307d2a5c7SLinus Walleij #endif 554db9ef1afSFenkart/Bostandzhyan " fixmap : 0x%08lx - 0x%08lx (%4ld kB)\n" 555db9ef1afSFenkart/Bostandzhyan " vmalloc : 0x%08lx - 0x%08lx (%4ld MB)\n" 556db9ef1afSFenkart/Bostandzhyan " lowmem : 0x%08lx - 0x%08lx (%4ld MB)\n" 557db9ef1afSFenkart/Bostandzhyan #ifdef CONFIG_HIGHMEM 558db9ef1afSFenkart/Bostandzhyan " pkmap : 0x%08lx - 0x%08lx (%4ld MB)\n" 559db9ef1afSFenkart/Bostandzhyan #endif 560d9277d51SUwe Kleine-König #ifdef CONFIG_MODULES 561db9ef1afSFenkart/Bostandzhyan " modules : 0x%08lx - 0x%08lx (%4ld MB)\n" 562d9277d51SUwe Kleine-König #endif 563178c3dfeSRussell King " .text : 0x%p" " - 0x%p" " (%4td kB)\n" 564178c3dfeSRussell King " .init : 0x%p" " - 0x%p" " (%4td kB)\n" 565178c3dfeSRussell King " .data : 0x%p" " - 0x%p" " (%4td kB)\n" 566178c3dfeSRussell King " .bss : 0x%p" " - 0x%p" " (%4td kB)\n", 567db9ef1afSFenkart/Bostandzhyan 568db9ef1afSFenkart/Bostandzhyan MLK(UL(CONFIG_VECTORS_BASE), UL(CONFIG_VECTORS_BASE) + 569db9ef1afSFenkart/Bostandzhyan (PAGE_SIZE)), 57007d2a5c7SLinus Walleij #ifdef CONFIG_HAVE_TCM 5711dbd30e9SLinus Walleij MLK(DTCM_OFFSET, (unsigned long) dtcm_end), 5721dbd30e9SLinus Walleij MLK(ITCM_OFFSET, (unsigned long) itcm_end), 57307d2a5c7SLinus Walleij #endif 574b615bbbfSMark Salter MLK(FIXADDR_START, FIXADDR_END), 575c931b4f6SFenkart/Bostandzhyan MLM(VMALLOC_START, VMALLOC_END), 576db9ef1afSFenkart/Bostandzhyan MLM(PAGE_OFFSET, (unsigned long)high_memory), 577db9ef1afSFenkart/Bostandzhyan #ifdef CONFIG_HIGHMEM 578db9ef1afSFenkart/Bostandzhyan MLM(PKMAP_BASE, (PKMAP_BASE) + (LAST_PKMAP) * 579db9ef1afSFenkart/Bostandzhyan (PAGE_SIZE)), 580db9ef1afSFenkart/Bostandzhyan #endif 581d9277d51SUwe Kleine-König #ifdef CONFIG_MODULES 582db9ef1afSFenkart/Bostandzhyan MLM(MODULES_VADDR, MODULES_END), 583d9277d51SUwe Kleine-König #endif 584db9ef1afSFenkart/Bostandzhyan 585db9ef1afSFenkart/Bostandzhyan MLK_ROUNDUP(_text, _etext), 5863835d69aSRussell King MLK_ROUNDUP(__init_begin, __init_end), 58745f6d7e0SRabin Vincent MLK_ROUNDUP(_sdata, _edata), 58845f6d7e0SRabin Vincent MLK_ROUNDUP(__bss_start, __bss_stop)); 589db9ef1afSFenkart/Bostandzhyan 590db9ef1afSFenkart/Bostandzhyan #undef MLK 591db9ef1afSFenkart/Bostandzhyan #undef MLM 592db9ef1afSFenkart/Bostandzhyan #undef MLK_ROUNDUP 593db9ef1afSFenkart/Bostandzhyan 594a1839272SFenkart/Bostandzhyan /* 595a1839272SFenkart/Bostandzhyan * Check boundaries twice: Some fundamental inconsistencies can 596a1839272SFenkart/Bostandzhyan * be detected at build time already. 597a1839272SFenkart/Bostandzhyan */ 598a1839272SFenkart/Bostandzhyan #ifdef CONFIG_MMU 599a1839272SFenkart/Bostandzhyan BUILD_BUG_ON(TASK_SIZE > MODULES_VADDR); 600a1839272SFenkart/Bostandzhyan BUG_ON(TASK_SIZE > MODULES_VADDR); 601a1839272SFenkart/Bostandzhyan #endif 602a1839272SFenkart/Bostandzhyan 603a1839272SFenkart/Bostandzhyan #ifdef CONFIG_HIGHMEM 604a1839272SFenkart/Bostandzhyan BUILD_BUG_ON(PKMAP_BASE + LAST_PKMAP * PAGE_SIZE > PAGE_OFFSET); 605a1839272SFenkart/Bostandzhyan BUG_ON(PKMAP_BASE + LAST_PKMAP * PAGE_SIZE > PAGE_OFFSET); 606a1839272SFenkart/Bostandzhyan #endif 607a1839272SFenkart/Bostandzhyan 6082450c973SJiang Liu if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) { 6091da177e4SLinus Torvalds extern int sysctl_overcommit_memory; 6101da177e4SLinus Torvalds /* 6111da177e4SLinus Torvalds * On a machine this small we won't get 6121da177e4SLinus Torvalds * anywhere without overcommit, so turn 6131da177e4SLinus Torvalds * it on by default. 6141da177e4SLinus Torvalds */ 6151da177e4SLinus Torvalds sysctl_overcommit_memory = OVERCOMMIT_ALWAYS; 6161da177e4SLinus Torvalds } 6171da177e4SLinus Torvalds } 6181da177e4SLinus Torvalds 6191e6b4811SKees Cook #ifdef CONFIG_ARM_KERNMEM_PERMS 6201e6b4811SKees Cook struct section_perm { 6211e6b4811SKees Cook unsigned long start; 6221e6b4811SKees Cook unsigned long end; 6231e6b4811SKees Cook pmdval_t mask; 6241e6b4811SKees Cook pmdval_t prot; 62580d6b0c2SKees Cook pmdval_t clear; 6261e6b4811SKees Cook }; 6271e6b4811SKees Cook 62880d6b0c2SKees Cook static struct section_perm nx_perms[] = { 6291e6b4811SKees Cook /* Make pages tables, etc before _stext RW (set NX). */ 6301e6b4811SKees Cook { 6311e6b4811SKees Cook .start = PAGE_OFFSET, 6321e6b4811SKees Cook .end = (unsigned long)_stext, 6331e6b4811SKees Cook .mask = ~PMD_SECT_XN, 6341e6b4811SKees Cook .prot = PMD_SECT_XN, 6351e6b4811SKees Cook }, 6361e6b4811SKees Cook /* Make init RW (set NX). */ 6371e6b4811SKees Cook { 6381e6b4811SKees Cook .start = (unsigned long)__init_begin, 6391e6b4811SKees Cook .end = (unsigned long)_sdata, 6401e6b4811SKees Cook .mask = ~PMD_SECT_XN, 6411e6b4811SKees Cook .prot = PMD_SECT_XN, 6421e6b4811SKees Cook }, 64380d6b0c2SKees Cook #ifdef CONFIG_DEBUG_RODATA 64480d6b0c2SKees Cook /* Make rodata NX (set RO in ro_perms below). */ 64580d6b0c2SKees Cook { 64680d6b0c2SKees Cook .start = (unsigned long)__start_rodata, 64780d6b0c2SKees Cook .end = (unsigned long)__init_begin, 64880d6b0c2SKees Cook .mask = ~PMD_SECT_XN, 64980d6b0c2SKees Cook .prot = PMD_SECT_XN, 65080d6b0c2SKees Cook }, 65180d6b0c2SKees Cook #endif 6521e6b4811SKees Cook }; 6531e6b4811SKees Cook 65480d6b0c2SKees Cook #ifdef CONFIG_DEBUG_RODATA 65580d6b0c2SKees Cook static struct section_perm ro_perms[] = { 65680d6b0c2SKees Cook /* Make kernel code and rodata RX (set RO). */ 65780d6b0c2SKees Cook { 65880d6b0c2SKees Cook .start = (unsigned long)_stext, 65980d6b0c2SKees Cook .end = (unsigned long)__init_begin, 66080d6b0c2SKees Cook #ifdef CONFIG_ARM_LPAE 661*1e347922SVictor Kamensky .mask = ~L_PMD_SECT_RDONLY, 662*1e347922SVictor Kamensky .prot = L_PMD_SECT_RDONLY, 66380d6b0c2SKees Cook #else 66480d6b0c2SKees Cook .mask = ~(PMD_SECT_APX | PMD_SECT_AP_WRITE), 66580d6b0c2SKees Cook .prot = PMD_SECT_APX | PMD_SECT_AP_WRITE, 66680d6b0c2SKees Cook .clear = PMD_SECT_AP_WRITE, 66780d6b0c2SKees Cook #endif 66880d6b0c2SKees Cook }, 66980d6b0c2SKees Cook }; 67080d6b0c2SKees Cook #endif 67180d6b0c2SKees Cook 6721e6b4811SKees Cook /* 6731e6b4811SKees Cook * Updates section permissions only for the current mm (sections are 6741e6b4811SKees Cook * copied into each mm). During startup, this is the init_mm. Is only 6751e6b4811SKees Cook * safe to be called with preemption disabled, as under stop_machine(). 6761e6b4811SKees Cook */ 6771e6b4811SKees Cook static inline void section_update(unsigned long addr, pmdval_t mask, 6781e6b4811SKees Cook pmdval_t prot) 6791e6b4811SKees Cook { 6801e6b4811SKees Cook struct mm_struct *mm; 6811e6b4811SKees Cook pmd_t *pmd; 6821e6b4811SKees Cook 6831e6b4811SKees Cook mm = current->active_mm; 6841e6b4811SKees Cook pmd = pmd_offset(pud_offset(pgd_offset(mm, addr), addr), addr); 6851e6b4811SKees Cook 6861e6b4811SKees Cook #ifdef CONFIG_ARM_LPAE 6871e6b4811SKees Cook pmd[0] = __pmd((pmd_val(pmd[0]) & mask) | prot); 6881e6b4811SKees Cook #else 6891e6b4811SKees Cook if (addr & SECTION_SIZE) 6901e6b4811SKees Cook pmd[1] = __pmd((pmd_val(pmd[1]) & mask) | prot); 6911e6b4811SKees Cook else 6921e6b4811SKees Cook pmd[0] = __pmd((pmd_val(pmd[0]) & mask) | prot); 6931e6b4811SKees Cook #endif 6941e6b4811SKees Cook flush_pmd_entry(pmd); 6951e6b4811SKees Cook local_flush_tlb_kernel_range(addr, addr + SECTION_SIZE); 6961e6b4811SKees Cook } 6971e6b4811SKees Cook 6981e6b4811SKees Cook /* Make sure extended page tables are in use. */ 6991e6b4811SKees Cook static inline bool arch_has_strict_perms(void) 7001e6b4811SKees Cook { 7011e6b4811SKees Cook if (cpu_architecture() < CPU_ARCH_ARMv6) 7021e6b4811SKees Cook return false; 7031e6b4811SKees Cook 7041e6b4811SKees Cook return !!(get_cr() & CR_XP); 7051e6b4811SKees Cook } 7061e6b4811SKees Cook 7071e6b4811SKees Cook #define set_section_perms(perms, field) { \ 7081e6b4811SKees Cook size_t i; \ 7091e6b4811SKees Cook unsigned long addr; \ 7101e6b4811SKees Cook \ 7111e6b4811SKees Cook if (!arch_has_strict_perms()) \ 7121e6b4811SKees Cook return; \ 7131e6b4811SKees Cook \ 7141e6b4811SKees Cook for (i = 0; i < ARRAY_SIZE(perms); i++) { \ 7151e6b4811SKees Cook if (!IS_ALIGNED(perms[i].start, SECTION_SIZE) || \ 7161e6b4811SKees Cook !IS_ALIGNED(perms[i].end, SECTION_SIZE)) { \ 7171e6b4811SKees Cook pr_err("BUG: section %lx-%lx not aligned to %lx\n", \ 7181e6b4811SKees Cook perms[i].start, perms[i].end, \ 7191e6b4811SKees Cook SECTION_SIZE); \ 7201e6b4811SKees Cook continue; \ 7211e6b4811SKees Cook } \ 7221e6b4811SKees Cook \ 7231e6b4811SKees Cook for (addr = perms[i].start; \ 7241e6b4811SKees Cook addr < perms[i].end; \ 7251e6b4811SKees Cook addr += SECTION_SIZE) \ 7261e6b4811SKees Cook section_update(addr, perms[i].mask, \ 7271e6b4811SKees Cook perms[i].field); \ 7281e6b4811SKees Cook } \ 7291e6b4811SKees Cook } 7301e6b4811SKees Cook 7311e6b4811SKees Cook static inline void fix_kernmem_perms(void) 7321e6b4811SKees Cook { 7331e6b4811SKees Cook set_section_perms(nx_perms, prot); 7341e6b4811SKees Cook } 73580d6b0c2SKees Cook 73680d6b0c2SKees Cook #ifdef CONFIG_DEBUG_RODATA 73780d6b0c2SKees Cook void mark_rodata_ro(void) 73880d6b0c2SKees Cook { 73980d6b0c2SKees Cook set_section_perms(ro_perms, prot); 74080d6b0c2SKees Cook } 74180d6b0c2SKees Cook 74280d6b0c2SKees Cook void set_kernel_text_rw(void) 74380d6b0c2SKees Cook { 74480d6b0c2SKees Cook set_section_perms(ro_perms, clear); 74580d6b0c2SKees Cook } 74680d6b0c2SKees Cook 74780d6b0c2SKees Cook void set_kernel_text_ro(void) 74880d6b0c2SKees Cook { 74980d6b0c2SKees Cook set_section_perms(ro_perms, prot); 75080d6b0c2SKees Cook } 75180d6b0c2SKees Cook #endif /* CONFIG_DEBUG_RODATA */ 75280d6b0c2SKees Cook 7531e6b4811SKees Cook #else 7541e6b4811SKees Cook static inline void fix_kernmem_perms(void) { } 7551e6b4811SKees Cook #endif /* CONFIG_ARM_KERNMEM_PERMS */ 7561e6b4811SKees Cook 7571e6b4811SKees Cook void free_tcmmem(void) 7581da177e4SLinus Torvalds { 759bc581770SLinus Walleij #ifdef CONFIG_HAVE_TCM 760ea208f64SLinus Walleij extern char __tcm_start, __tcm_end; 761bc581770SLinus Walleij 76254d52573SStephen Boyd poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start); 763dbe67df4SJiang Liu free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link"); 764bc581770SLinus Walleij #endif 7651e6b4811SKees Cook } 7661e6b4811SKees Cook 7671e6b4811SKees Cook void free_initmem(void) 7681e6b4811SKees Cook { 7691e6b4811SKees Cook fix_kernmem_perms(); 7701e6b4811SKees Cook free_tcmmem(); 771bc581770SLinus Walleij 77254d52573SStephen Boyd poison_init_mem(__init_begin, __init_end - __init_begin); 7736db015e4SNicolas Pitre if (!machine_is_integrator() && !machine_is_cintegrator()) 774dbe67df4SJiang Liu free_initmem_default(-1); 7751da177e4SLinus Torvalds } 7761da177e4SLinus Torvalds 7771da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD 7781da177e4SLinus Torvalds 7791da177e4SLinus Torvalds static int keep_initrd; 7801da177e4SLinus Torvalds 7811da177e4SLinus Torvalds void free_initrd_mem(unsigned long start, unsigned long end) 7821da177e4SLinus Torvalds { 78354d52573SStephen Boyd if (!keep_initrd) { 784421520baSYalin Wang if (start == initrd_start) 785421520baSYalin Wang start = round_down(start, PAGE_SIZE); 786421520baSYalin Wang if (end == initrd_end) 787421520baSYalin Wang end = round_up(end, PAGE_SIZE); 788421520baSYalin Wang 78954d52573SStephen Boyd poison_init_mem((void *)start, PAGE_ALIGN(end) - start); 790dbe67df4SJiang Liu free_reserved_area((void *)start, (void *)end, -1, "initrd"); 7911da177e4SLinus Torvalds } 79254d52573SStephen Boyd } 7931da177e4SLinus Torvalds 7941da177e4SLinus Torvalds static int __init keepinitrd_setup(char *__unused) 7951da177e4SLinus Torvalds { 7961da177e4SLinus Torvalds keep_initrd = 1; 7971da177e4SLinus Torvalds return 1; 7981da177e4SLinus Torvalds } 7991da177e4SLinus Torvalds 8001da177e4SLinus Torvalds __setup("keepinitrd", keepinitrd_setup); 8011da177e4SLinus Torvalds #endif 802