Pekka Enberg | 540aca0 | 2009-03-04 11:46:40 +0200 | [diff] [blame] | 1 | #include <linux/ioport.h> |
Pekka Enberg | e5b2bb5 | 2009-03-03 13:15:06 +0200 | [diff] [blame] | 2 | #include <linux/swap.h> |
Pekka Enberg | 540aca0 | 2009-03-04 11:46:40 +0200 | [diff] [blame] | 3 | |
Pekka Enberg | e5b2bb5 | 2009-03-03 13:15:06 +0200 | [diff] [blame] | 4 | #include <asm/cacheflush.h> |
Pekka Enberg | f765090 | 2009-03-05 14:55:05 +0200 | [diff] [blame] | 5 | #include <asm/e820.h> |
Pekka Enberg | 4fcb208 | 2009-03-05 14:55:08 +0200 | [diff] [blame] | 6 | #include <asm/init.h> |
Pekka Enberg | e5b2bb5 | 2009-03-03 13:15:06 +0200 | [diff] [blame] | 7 | #include <asm/page.h> |
Pekka Enberg | 540aca0 | 2009-03-04 11:46:40 +0200 | [diff] [blame] | 8 | #include <asm/page_types.h> |
Pekka Enberg | e5b2bb5 | 2009-03-03 13:15:06 +0200 | [diff] [blame] | 9 | #include <asm/sections.h> |
| 10 | #include <asm/system.h> |
Pekka Enberg | f765090 | 2009-03-05 14:55:05 +0200 | [diff] [blame] | 11 | #include <asm/tlbflush.h> |
| 12 | |
Pekka Enberg | 298af9d | 2009-03-05 14:55:06 +0200 | [diff] [blame] | 13 | unsigned long __initdata e820_table_start; |
| 14 | unsigned long __meminitdata e820_table_end; |
| 15 | unsigned long __meminitdata e820_table_top; |
Pekka Enberg | f765090 | 2009-03-05 14:55:05 +0200 | [diff] [blame] | 16 | |
| 17 | int after_bootmem; |
| 18 | |
| 19 | int direct_gbpages |
| 20 | #ifdef CONFIG_DIRECT_GBPAGES |
| 21 | = 1 |
| 22 | #endif |
| 23 | ; |
| 24 | |
Pekka Enberg | 8938891 | 2009-04-21 11:39:27 +0300 | [diff] [blame] | 25 | int nx_enabled; |
| 26 | |
| 27 | #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) |
| 28 | static int disable_nx __cpuinitdata; |
| 29 | |
| 30 | /* |
| 31 | * noexec = on|off |
| 32 | * |
| 33 | * Control non-executable mappings for processes. |
| 34 | * |
| 35 | * on Enable |
| 36 | * off Disable |
| 37 | */ |
| 38 | static int __init noexec_setup(char *str) |
| 39 | { |
| 40 | if (!str) |
| 41 | return -EINVAL; |
| 42 | if (!strncmp(str, "on", 2)) { |
| 43 | __supported_pte_mask |= _PAGE_NX; |
| 44 | disable_nx = 0; |
| 45 | } else if (!strncmp(str, "off", 3)) { |
| 46 | disable_nx = 1; |
| 47 | __supported_pte_mask &= ~_PAGE_NX; |
| 48 | } |
| 49 | return 0; |
| 50 | } |
| 51 | early_param("noexec", noexec_setup); |
| 52 | #endif |
| 53 | |
| 54 | #ifdef CONFIG_X86_PAE |
| 55 | static void __init set_nx(void) |
| 56 | { |
| 57 | unsigned int v[4], l, h; |
| 58 | |
| 59 | if (cpu_has_pae && (cpuid_eax(0x80000000) > 0x80000001)) { |
| 60 | cpuid(0x80000001, &v[0], &v[1], &v[2], &v[3]); |
| 61 | |
| 62 | if ((v[3] & (1 << 20)) && !disable_nx) { |
| 63 | rdmsr(MSR_EFER, l, h); |
| 64 | l |= EFER_NX; |
| 65 | wrmsr(MSR_EFER, l, h); |
| 66 | nx_enabled = 1; |
| 67 | __supported_pte_mask |= _PAGE_NX; |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | #else |
| 72 | static inline void set_nx(void) |
| 73 | { |
| 74 | } |
| 75 | #endif |
| 76 | |
| 77 | #ifdef CONFIG_X86_64 |
| 78 | void __cpuinit check_efer(void) |
| 79 | { |
| 80 | unsigned long efer; |
| 81 | |
| 82 | rdmsrl(MSR_EFER, efer); |
| 83 | if (!(efer & EFER_NX) || disable_nx) |
| 84 | __supported_pte_mask &= ~_PAGE_NX; |
| 85 | } |
| 86 | #endif |
| 87 | |
Pekka Enberg | f765090 | 2009-03-05 14:55:05 +0200 | [diff] [blame] | 88 | static void __init find_early_table_space(unsigned long end, int use_pse, |
| 89 | int use_gbpages) |
| 90 | { |
| 91 | unsigned long puds, pmds, ptes, tables, start; |
| 92 | |
| 93 | puds = (end + PUD_SIZE - 1) >> PUD_SHIFT; |
| 94 | tables = roundup(puds * sizeof(pud_t), PAGE_SIZE); |
| 95 | |
| 96 | if (use_gbpages) { |
| 97 | unsigned long extra; |
| 98 | |
| 99 | extra = end - ((end>>PUD_SHIFT) << PUD_SHIFT); |
| 100 | pmds = (extra + PMD_SIZE - 1) >> PMD_SHIFT; |
| 101 | } else |
| 102 | pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT; |
| 103 | |
| 104 | tables += roundup(pmds * sizeof(pmd_t), PAGE_SIZE); |
| 105 | |
| 106 | if (use_pse) { |
| 107 | unsigned long extra; |
| 108 | |
| 109 | extra = end - ((end>>PMD_SHIFT) << PMD_SHIFT); |
| 110 | #ifdef CONFIG_X86_32 |
| 111 | extra += PMD_SIZE; |
| 112 | #endif |
| 113 | ptes = (extra + PAGE_SIZE - 1) >> PAGE_SHIFT; |
| 114 | } else |
| 115 | ptes = (end + PAGE_SIZE - 1) >> PAGE_SHIFT; |
| 116 | |
| 117 | tables += roundup(ptes * sizeof(pte_t), PAGE_SIZE); |
| 118 | |
| 119 | #ifdef CONFIG_X86_32 |
| 120 | /* for fixmap */ |
| 121 | tables += roundup(__end_of_fixed_addresses * sizeof(pte_t), PAGE_SIZE); |
| 122 | #endif |
| 123 | |
| 124 | /* |
| 125 | * RED-PEN putting page tables only on node 0 could |
| 126 | * cause a hotspot and fill up ZONE_DMA. The page tables |
| 127 | * need roughly 0.5KB per GB. |
| 128 | */ |
| 129 | #ifdef CONFIG_X86_32 |
| 130 | start = 0x7000; |
Pekka Enberg | 298af9d | 2009-03-05 14:55:06 +0200 | [diff] [blame] | 131 | e820_table_start = find_e820_area(start, max_pfn_mapped<<PAGE_SHIFT, |
Pekka Enberg | f765090 | 2009-03-05 14:55:05 +0200 | [diff] [blame] | 132 | tables, PAGE_SIZE); |
| 133 | #else /* CONFIG_X86_64 */ |
| 134 | start = 0x8000; |
Pekka Enberg | 298af9d | 2009-03-05 14:55:06 +0200 | [diff] [blame] | 135 | e820_table_start = find_e820_area(start, end, tables, PAGE_SIZE); |
Pekka Enberg | f765090 | 2009-03-05 14:55:05 +0200 | [diff] [blame] | 136 | #endif |
Pekka Enberg | 298af9d | 2009-03-05 14:55:06 +0200 | [diff] [blame] | 137 | if (e820_table_start == -1UL) |
Pekka Enberg | f765090 | 2009-03-05 14:55:05 +0200 | [diff] [blame] | 138 | panic("Cannot find space for the kernel page tables"); |
| 139 | |
Pekka Enberg | 298af9d | 2009-03-05 14:55:06 +0200 | [diff] [blame] | 140 | e820_table_start >>= PAGE_SHIFT; |
| 141 | e820_table_end = e820_table_start; |
| 142 | e820_table_top = e820_table_start + (tables >> PAGE_SHIFT); |
Pekka Enberg | f765090 | 2009-03-05 14:55:05 +0200 | [diff] [blame] | 143 | |
| 144 | printk(KERN_DEBUG "kernel direct mapping tables up to %lx @ %lx-%lx\n", |
Pekka Enberg | 298af9d | 2009-03-05 14:55:06 +0200 | [diff] [blame] | 145 | end, e820_table_start << PAGE_SHIFT, e820_table_top << PAGE_SHIFT); |
Pekka Enberg | f765090 | 2009-03-05 14:55:05 +0200 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | struct map_range { |
| 149 | unsigned long start; |
| 150 | unsigned long end; |
| 151 | unsigned page_size_mask; |
| 152 | }; |
| 153 | |
| 154 | #ifdef CONFIG_X86_32 |
| 155 | #define NR_RANGE_MR 3 |
| 156 | #else /* CONFIG_X86_64 */ |
| 157 | #define NR_RANGE_MR 5 |
| 158 | #endif |
| 159 | |
Jan Beulich | dc9dd5c | 2009-03-12 12:40:06 +0000 | [diff] [blame] | 160 | static int __meminit save_mr(struct map_range *mr, int nr_range, |
| 161 | unsigned long start_pfn, unsigned long end_pfn, |
| 162 | unsigned long page_size_mask) |
Pekka Enberg | f765090 | 2009-03-05 14:55:05 +0200 | [diff] [blame] | 163 | { |
| 164 | if (start_pfn < end_pfn) { |
| 165 | if (nr_range >= NR_RANGE_MR) |
| 166 | panic("run out of range for init_memory_mapping\n"); |
| 167 | mr[nr_range].start = start_pfn<<PAGE_SHIFT; |
| 168 | mr[nr_range].end = end_pfn<<PAGE_SHIFT; |
| 169 | mr[nr_range].page_size_mask = page_size_mask; |
| 170 | nr_range++; |
| 171 | } |
| 172 | |
| 173 | return nr_range; |
| 174 | } |
| 175 | |
| 176 | #ifdef CONFIG_X86_64 |
| 177 | static void __init init_gbpages(void) |
| 178 | { |
| 179 | if (direct_gbpages && cpu_has_gbpages) |
| 180 | printk(KERN_INFO "Using GB pages for direct mapping\n"); |
| 181 | else |
| 182 | direct_gbpages = 0; |
| 183 | } |
| 184 | #else |
| 185 | static inline void init_gbpages(void) |
| 186 | { |
| 187 | } |
| 188 | #endif |
| 189 | |
| 190 | /* |
| 191 | * Setup the direct mapping of the physical memory at PAGE_OFFSET. |
| 192 | * This runs before bootmem is initialized and gets pages directly from |
| 193 | * the physical memory. To access them they are temporarily mapped. |
| 194 | */ |
| 195 | unsigned long __init_refok init_memory_mapping(unsigned long start, |
| 196 | unsigned long end) |
| 197 | { |
| 198 | unsigned long page_size_mask = 0; |
| 199 | unsigned long start_pfn, end_pfn; |
Pekka Enberg | c77a3b5 | 2009-03-05 17:04:26 +0200 | [diff] [blame] | 200 | unsigned long ret = 0; |
Pekka Enberg | f765090 | 2009-03-05 14:55:05 +0200 | [diff] [blame] | 201 | unsigned long pos; |
Pekka Enberg | f765090 | 2009-03-05 14:55:05 +0200 | [diff] [blame] | 202 | |
| 203 | struct map_range mr[NR_RANGE_MR]; |
| 204 | int nr_range, i; |
| 205 | int use_pse, use_gbpages; |
| 206 | |
| 207 | printk(KERN_INFO "init_memory_mapping: %016lx-%016lx\n", start, end); |
| 208 | |
| 209 | if (!after_bootmem) |
| 210 | init_gbpages(); |
| 211 | |
| 212 | #ifdef CONFIG_DEBUG_PAGEALLOC |
| 213 | /* |
| 214 | * For CONFIG_DEBUG_PAGEALLOC, identity mapping will use small pages. |
| 215 | * This will simplify cpa(), which otherwise needs to support splitting |
| 216 | * large pages into small in interrupt context, etc. |
| 217 | */ |
| 218 | use_pse = use_gbpages = 0; |
| 219 | #else |
| 220 | use_pse = cpu_has_pse; |
| 221 | use_gbpages = direct_gbpages; |
| 222 | #endif |
| 223 | |
Pekka Enberg | f765090 | 2009-03-05 14:55:05 +0200 | [diff] [blame] | 224 | set_nx(); |
| 225 | if (nx_enabled) |
| 226 | printk(KERN_INFO "NX (Execute Disable) protection: active\n"); |
Pekka Enberg | f765090 | 2009-03-05 14:55:05 +0200 | [diff] [blame] | 227 | |
| 228 | /* Enable PSE if available */ |
| 229 | if (cpu_has_pse) |
| 230 | set_in_cr4(X86_CR4_PSE); |
| 231 | |
| 232 | /* Enable PGE if available */ |
| 233 | if (cpu_has_pge) { |
| 234 | set_in_cr4(X86_CR4_PGE); |
| 235 | __supported_pte_mask |= _PAGE_GLOBAL; |
| 236 | } |
Pekka Enberg | f765090 | 2009-03-05 14:55:05 +0200 | [diff] [blame] | 237 | |
| 238 | if (use_gbpages) |
| 239 | page_size_mask |= 1 << PG_LEVEL_1G; |
| 240 | if (use_pse) |
| 241 | page_size_mask |= 1 << PG_LEVEL_2M; |
| 242 | |
| 243 | memset(mr, 0, sizeof(mr)); |
| 244 | nr_range = 0; |
| 245 | |
| 246 | /* head if not big page alignment ? */ |
| 247 | start_pfn = start >> PAGE_SHIFT; |
| 248 | pos = start_pfn << PAGE_SHIFT; |
| 249 | #ifdef CONFIG_X86_32 |
| 250 | /* |
| 251 | * Don't use a large page for the first 2/4MB of memory |
| 252 | * because there are often fixed size MTRRs in there |
| 253 | * and overlapping MTRRs into large pages can cause |
| 254 | * slowdowns. |
| 255 | */ |
| 256 | if (pos == 0) |
| 257 | end_pfn = 1<<(PMD_SHIFT - PAGE_SHIFT); |
| 258 | else |
| 259 | end_pfn = ((pos + (PMD_SIZE - 1))>>PMD_SHIFT) |
| 260 | << (PMD_SHIFT - PAGE_SHIFT); |
| 261 | #else /* CONFIG_X86_64 */ |
| 262 | end_pfn = ((pos + (PMD_SIZE - 1)) >> PMD_SHIFT) |
| 263 | << (PMD_SHIFT - PAGE_SHIFT); |
| 264 | #endif |
| 265 | if (end_pfn > (end >> PAGE_SHIFT)) |
| 266 | end_pfn = end >> PAGE_SHIFT; |
| 267 | if (start_pfn < end_pfn) { |
| 268 | nr_range = save_mr(mr, nr_range, start_pfn, end_pfn, 0); |
| 269 | pos = end_pfn << PAGE_SHIFT; |
| 270 | } |
| 271 | |
| 272 | /* big page (2M) range */ |
| 273 | start_pfn = ((pos + (PMD_SIZE - 1))>>PMD_SHIFT) |
| 274 | << (PMD_SHIFT - PAGE_SHIFT); |
| 275 | #ifdef CONFIG_X86_32 |
| 276 | end_pfn = (end>>PMD_SHIFT) << (PMD_SHIFT - PAGE_SHIFT); |
| 277 | #else /* CONFIG_X86_64 */ |
| 278 | end_pfn = ((pos + (PUD_SIZE - 1))>>PUD_SHIFT) |
| 279 | << (PUD_SHIFT - PAGE_SHIFT); |
| 280 | if (end_pfn > ((end>>PMD_SHIFT)<<(PMD_SHIFT - PAGE_SHIFT))) |
| 281 | end_pfn = ((end>>PMD_SHIFT)<<(PMD_SHIFT - PAGE_SHIFT)); |
| 282 | #endif |
| 283 | |
| 284 | if (start_pfn < end_pfn) { |
| 285 | nr_range = save_mr(mr, nr_range, start_pfn, end_pfn, |
| 286 | page_size_mask & (1<<PG_LEVEL_2M)); |
| 287 | pos = end_pfn << PAGE_SHIFT; |
| 288 | } |
| 289 | |
| 290 | #ifdef CONFIG_X86_64 |
| 291 | /* big page (1G) range */ |
| 292 | start_pfn = ((pos + (PUD_SIZE - 1))>>PUD_SHIFT) |
| 293 | << (PUD_SHIFT - PAGE_SHIFT); |
| 294 | end_pfn = (end >> PUD_SHIFT) << (PUD_SHIFT - PAGE_SHIFT); |
| 295 | if (start_pfn < end_pfn) { |
| 296 | nr_range = save_mr(mr, nr_range, start_pfn, end_pfn, |
| 297 | page_size_mask & |
| 298 | ((1<<PG_LEVEL_2M)|(1<<PG_LEVEL_1G))); |
| 299 | pos = end_pfn << PAGE_SHIFT; |
| 300 | } |
| 301 | |
| 302 | /* tail is not big page (1G) alignment */ |
| 303 | start_pfn = ((pos + (PMD_SIZE - 1))>>PMD_SHIFT) |
| 304 | << (PMD_SHIFT - PAGE_SHIFT); |
| 305 | end_pfn = (end >> PMD_SHIFT) << (PMD_SHIFT - PAGE_SHIFT); |
| 306 | if (start_pfn < end_pfn) { |
| 307 | nr_range = save_mr(mr, nr_range, start_pfn, end_pfn, |
| 308 | page_size_mask & (1<<PG_LEVEL_2M)); |
| 309 | pos = end_pfn << PAGE_SHIFT; |
| 310 | } |
| 311 | #endif |
| 312 | |
| 313 | /* tail is not big page (2M) alignment */ |
| 314 | start_pfn = pos>>PAGE_SHIFT; |
| 315 | end_pfn = end>>PAGE_SHIFT; |
| 316 | nr_range = save_mr(mr, nr_range, start_pfn, end_pfn, 0); |
| 317 | |
| 318 | /* try to merge same page size and continuous */ |
| 319 | for (i = 0; nr_range > 1 && i < nr_range - 1; i++) { |
| 320 | unsigned long old_start; |
| 321 | if (mr[i].end != mr[i+1].start || |
| 322 | mr[i].page_size_mask != mr[i+1].page_size_mask) |
| 323 | continue; |
| 324 | /* move it */ |
| 325 | old_start = mr[i].start; |
| 326 | memmove(&mr[i], &mr[i+1], |
| 327 | (nr_range - 1 - i) * sizeof(struct map_range)); |
| 328 | mr[i--].start = old_start; |
| 329 | nr_range--; |
| 330 | } |
| 331 | |
| 332 | for (i = 0; i < nr_range; i++) |
| 333 | printk(KERN_DEBUG " %010lx - %010lx page %s\n", |
| 334 | mr[i].start, mr[i].end, |
| 335 | (mr[i].page_size_mask & (1<<PG_LEVEL_1G))?"1G":( |
| 336 | (mr[i].page_size_mask & (1<<PG_LEVEL_2M))?"2M":"4k")); |
| 337 | |
| 338 | /* |
| 339 | * Find space for the kernel direct mapping tables. |
| 340 | * |
| 341 | * Later we should allocate these tables in the local node of the |
| 342 | * memory mapped. Unfortunately this is done currently before the |
| 343 | * nodes are discovered. |
| 344 | */ |
| 345 | if (!after_bootmem) |
| 346 | find_early_table_space(end, use_pse, use_gbpages); |
| 347 | |
| 348 | #ifdef CONFIG_X86_32 |
| 349 | for (i = 0; i < nr_range; i++) |
Pekka Enberg | e53fb04 | 2009-03-05 14:55:07 +0200 | [diff] [blame] | 350 | kernel_physical_mapping_init(mr[i].start, mr[i].end, |
| 351 | mr[i].page_size_mask); |
Pekka Enberg | f765090 | 2009-03-05 14:55:05 +0200 | [diff] [blame] | 352 | ret = end; |
| 353 | #else /* CONFIG_X86_64 */ |
| 354 | for (i = 0; i < nr_range; i++) |
| 355 | ret = kernel_physical_mapping_init(mr[i].start, mr[i].end, |
| 356 | mr[i].page_size_mask); |
| 357 | #endif |
| 358 | |
| 359 | #ifdef CONFIG_X86_32 |
| 360 | early_ioremap_page_table_range_init(); |
| 361 | |
| 362 | load_cr3(swapper_pg_dir); |
| 363 | #endif |
| 364 | |
| 365 | #ifdef CONFIG_X86_64 |
| 366 | if (!after_bootmem) |
| 367 | mmu_cr4_features = read_cr4(); |
| 368 | #endif |
| 369 | __flush_tlb_all(); |
| 370 | |
Pekka Enberg | 298af9d | 2009-03-05 14:55:06 +0200 | [diff] [blame] | 371 | if (!after_bootmem && e820_table_end > e820_table_start) |
| 372 | reserve_early(e820_table_start << PAGE_SHIFT, |
| 373 | e820_table_end << PAGE_SHIFT, "PGTABLE"); |
Pekka Enberg | f765090 | 2009-03-05 14:55:05 +0200 | [diff] [blame] | 374 | |
| 375 | if (!after_bootmem) |
| 376 | early_memtest(start, end); |
| 377 | |
| 378 | return ret >> PAGE_SHIFT; |
| 379 | } |
| 380 | |
Pekka Enberg | e5b2bb5 | 2009-03-03 13:15:06 +0200 | [diff] [blame] | 381 | |
Pekka Enberg | 540aca0 | 2009-03-04 11:46:40 +0200 | [diff] [blame] | 382 | /* |
| 383 | * devmem_is_allowed() checks to see if /dev/mem access to a certain address |
| 384 | * is valid. The argument is a physical page number. |
| 385 | * |
| 386 | * |
| 387 | * On x86, access has to be given to the first megabyte of ram because that area |
| 388 | * contains bios code and data regions used by X and dosemu and similar apps. |
| 389 | * Access has to be given to non-kernel-ram areas as well, these contain the PCI |
| 390 | * mmio resources as well as potential bios/acpi data regions. |
| 391 | */ |
| 392 | int devmem_is_allowed(unsigned long pagenr) |
| 393 | { |
| 394 | if (pagenr <= 256) |
| 395 | return 1; |
| 396 | if (iomem_is_exclusive(pagenr << PAGE_SHIFT)) |
| 397 | return 0; |
| 398 | if (!page_is_ram(pagenr)) |
| 399 | return 1; |
| 400 | return 0; |
| 401 | } |
| 402 | |
Pekka Enberg | e5b2bb5 | 2009-03-03 13:15:06 +0200 | [diff] [blame] | 403 | void free_init_pages(char *what, unsigned long begin, unsigned long end) |
| 404 | { |
| 405 | unsigned long addr = begin; |
| 406 | |
| 407 | if (addr >= end) |
| 408 | return; |
| 409 | |
| 410 | /* |
| 411 | * If debugging page accesses then do not free this memory but |
| 412 | * mark them not present - any buggy init-section access will |
| 413 | * create a kernel page fault: |
| 414 | */ |
| 415 | #ifdef CONFIG_DEBUG_PAGEALLOC |
| 416 | printk(KERN_INFO "debug: unmapping init memory %08lx..%08lx\n", |
| 417 | begin, PAGE_ALIGN(end)); |
| 418 | set_memory_np(begin, (end - begin) >> PAGE_SHIFT); |
| 419 | #else |
| 420 | /* |
| 421 | * We just marked the kernel text read only above, now that |
| 422 | * we are going to free part of that, we need to make that |
| 423 | * writeable first. |
| 424 | */ |
| 425 | set_memory_rw(begin, (end - begin) >> PAGE_SHIFT); |
| 426 | |
| 427 | printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10); |
| 428 | |
| 429 | for (; addr < end; addr += PAGE_SIZE) { |
| 430 | ClearPageReserved(virt_to_page(addr)); |
| 431 | init_page_count(virt_to_page(addr)); |
| 432 | memset((void *)(addr & ~(PAGE_SIZE-1)), |
| 433 | POISON_FREE_INITMEM, PAGE_SIZE); |
| 434 | free_page(addr); |
| 435 | totalram_pages++; |
| 436 | } |
| 437 | #endif |
| 438 | } |
| 439 | |
| 440 | void free_initmem(void) |
| 441 | { |
| 442 | free_init_pages("unused kernel memory", |
| 443 | (unsigned long)(&__init_begin), |
| 444 | (unsigned long)(&__init_end)); |
| 445 | } |
Pekka Enberg | 731ddea | 2009-03-04 11:13:40 +0200 | [diff] [blame] | 446 | |
| 447 | #ifdef CONFIG_BLK_DEV_INITRD |
| 448 | void free_initrd_mem(unsigned long start, unsigned long end) |
| 449 | { |
| 450 | free_init_pages("initrd memory", start, end); |
| 451 | } |
| 452 | #endif |