blob: 00168e65688a47461cf382a0503c8aefb74cda83 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/i386/mm/init.c
3 *
4 * Copyright (C) 1995 Linus Torvalds
5 *
6 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
7 */
8
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include <linux/module.h>
10#include <linux/signal.h>
11#include <linux/sched.h>
12#include <linux/kernel.h>
13#include <linux/errno.h>
14#include <linux/string.h>
15#include <linux/types.h>
16#include <linux/ptrace.h>
17#include <linux/mman.h>
18#include <linux/mm.h>
19#include <linux/hugetlb.h>
20#include <linux/swap.h>
21#include <linux/smp.h>
22#include <linux/init.h>
23#include <linux/highmem.h>
24#include <linux/pagemap.h>
Jan Beulich6fb14752007-05-02 19:27:10 +020025#include <linux/pfn.h>
Randy Dunlapc9cf5522006-06-27 02:53:52 -070026#include <linux/poison.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <linux/bootmem.h>
28#include <linux/slab.h>
29#include <linux/proc_fs.h>
Dave Hansen05039b92005-10-29 18:16:57 -070030#include <linux/memory_hotplug.h>
Adrian Bunk27d99f72005-11-13 16:06:51 -080031#include <linux/initrd.h>
Shaohua Li55b23552006-06-23 02:04:49 -070032#include <linux/cpumask.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
H. Peter Anvinf832ff12008-02-04 16:47:58 +010034#include <asm/asm.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#include <asm/processor.h>
36#include <asm/system.h>
37#include <asm/uaccess.h>
38#include <asm/pgtable.h>
39#include <asm/dma.h>
40#include <asm/fixmap.h>
41#include <asm/e820.h>
42#include <asm/apic.h>
Ingo Molnar8550eb92008-01-30 13:34:10 +010043#include <asm/bugs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <asm/tlb.h>
45#include <asm/tlbflush.h>
Jeremy Fitzhardingea5a19c62008-01-30 13:33:39 +010046#include <asm/pgalloc.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#include <asm/sections.h>
Jeremy Fitzhardingeb239fb22007-05-02 19:27:13 +020048#include <asm/paravirt.h>
Ian Campbell551889a2008-02-09 23:24:09 +010049#include <asm/setup.h>
Harvey Harrison7bfeab92008-02-12 12:12:01 -080050#include <asm/cacheflush.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52unsigned int __VMALLOC_RESERVE = 128 << 20;
53
54DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
55unsigned long highstart_pfn, highend_pfn;
56
Ingo Molnar8550eb92008-01-30 13:34:10 +010057static noinline int do_test_wp_bit(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
59/*
60 * Creates a middle page table and puts a pointer to it in the
61 * given global directory entry. This only returns the gd entry
62 * in non-PAE compilation mode, since the middle layer is folded.
63 */
64static pmd_t * __init one_md_table_init(pgd_t *pgd)
65{
66 pud_t *pud;
67 pmd_t *pmd_table;
Ingo Molnar8550eb92008-01-30 13:34:10 +010068
Linus Torvalds1da177e2005-04-16 15:20:36 -070069#ifdef CONFIG_X86_PAE
Jeremy Fitzhardingeb239fb22007-05-02 19:27:13 +020070 if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
71 pmd_table = (pmd_t *) alloc_bootmem_low_pages(PAGE_SIZE);
72
Jeremy Fitzhardinge6c435452008-01-30 13:33:39 +010073 paravirt_alloc_pd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
Jeremy Fitzhardingeb239fb22007-05-02 19:27:13 +020074 set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
75 pud = pud_offset(pgd, 0);
Ingo Molnar8550eb92008-01-30 13:34:10 +010076 BUG_ON(pmd_table != pmd_offset(pud, 0));
Jeremy Fitzhardingeb239fb22007-05-02 19:27:13 +020077 }
78#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 pud = pud_offset(pgd, 0);
80 pmd_table = pmd_offset(pud, 0);
Ingo Molnar8550eb92008-01-30 13:34:10 +010081
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 return pmd_table;
83}
84
85/*
86 * Create a page table and place a pointer to it in a middle page
Ingo Molnar8550eb92008-01-30 13:34:10 +010087 * directory entry:
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 */
89static pte_t * __init one_page_table_init(pmd_t *pmd)
90{
Jeremy Fitzhardingeb239fb22007-05-02 19:27:13 +020091 if (!(pmd_val(*pmd) & _PAGE_PRESENT)) {
Ingo Molnar509a80c2007-10-17 18:04:34 +020092 pte_t *page_table = NULL;
93
94#ifdef CONFIG_DEBUG_PAGEALLOC
95 page_table = (pte_t *) alloc_bootmem_pages(PAGE_SIZE);
96#endif
Ingo Molnar8550eb92008-01-30 13:34:10 +010097 if (!page_table) {
Ingo Molnar509a80c2007-10-17 18:04:34 +020098 page_table =
99 (pte_t *)alloc_bootmem_low_pages(PAGE_SIZE);
Ingo Molnar8550eb92008-01-30 13:34:10 +0100100 }
Jeremy Fitzhardingeb239fb22007-05-02 19:27:13 +0200101
Jeremy Fitzhardingefdb4c332007-07-17 18:37:03 -0700102 paravirt_alloc_pt(&init_mm, __pa(page_table) >> PAGE_SHIFT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
Jeremy Fitzhardingeb239fb22007-05-02 19:27:13 +0200104 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 }
Ingo Molnar509a80c2007-10-17 18:04:34 +0200106
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 return pte_offset_kernel(pmd, 0);
108}
109
110/*
Ingo Molnar8550eb92008-01-30 13:34:10 +0100111 * This function initializes a certain range of kernel virtual memory
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 * with new bootmem page tables, everywhere page tables are missing in
113 * the given range.
Ingo Molnar8550eb92008-01-30 13:34:10 +0100114 *
115 * NOTE: The pagetables are allocated contiguous on the physical space
116 * so we can cache the place of the first one and move around without
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 * checking the pgd every time.
118 */
Ingo Molnar8550eb92008-01-30 13:34:10 +0100119static void __init
120page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 int pgd_idx, pmd_idx;
123 unsigned long vaddr;
Ingo Molnar8550eb92008-01-30 13:34:10 +0100124 pgd_t *pgd;
125 pmd_t *pmd;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126
127 vaddr = start;
128 pgd_idx = pgd_index(vaddr);
129 pmd_idx = pmd_index(vaddr);
130 pgd = pgd_base + pgd_idx;
131
132 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
Jeremy Fitzhardingeb239fb22007-05-02 19:27:13 +0200133 pmd = one_md_table_init(pgd);
134 pmd = pmd + pmd_index(vaddr);
Ingo Molnar8550eb92008-01-30 13:34:10 +0100135 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
136 pmd++, pmd_idx++) {
Jeremy Fitzhardingeb239fb22007-05-02 19:27:13 +0200137 one_page_table_init(pmd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138
139 vaddr += PMD_SIZE;
140 }
141 pmd_idx = 0;
142 }
143}
144
145static inline int is_kernel_text(unsigned long addr)
146{
147 if (addr >= PAGE_OFFSET && addr <= (unsigned long)__init_end)
148 return 1;
149 return 0;
150}
151
152/*
Ingo Molnar8550eb92008-01-30 13:34:10 +0100153 * This maps the physical memory to kernel virtual address space, a total
154 * of max_low_pfn pages, by creating page tables starting from address
155 * PAGE_OFFSET:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 */
157static void __init kernel_physical_mapping_init(pgd_t *pgd_base)
158{
Ingo Molnar8550eb92008-01-30 13:34:10 +0100159 int pgd_idx, pmd_idx, pte_ofs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 unsigned long pfn;
161 pgd_t *pgd;
162 pmd_t *pmd;
163 pte_t *pte;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164
165 pgd_idx = pgd_index(PAGE_OFFSET);
166 pgd = pgd_base + pgd_idx;
167 pfn = 0;
168
169 for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
170 pmd = one_md_table_init(pgd);
171 if (pfn >= max_low_pfn)
172 continue;
Ingo Molnar8550eb92008-01-30 13:34:10 +0100173
Jeremy Fitzhardingef3f20de2008-01-30 13:31:09 +0100174 for (pmd_idx = 0;
175 pmd_idx < PTRS_PER_PMD && pfn < max_low_pfn;
176 pmd++, pmd_idx++) {
Ingo Molnar8550eb92008-01-30 13:34:10 +0100177 unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178
Ingo Molnar8550eb92008-01-30 13:34:10 +0100179 /*
180 * Map with big pages if possible, otherwise
181 * create normal page tables:
182 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 if (cpu_has_pse) {
Ingo Molnar8550eb92008-01-30 13:34:10 +0100184 unsigned int addr2;
Jeremy Fitzhardingef3f20de2008-01-30 13:31:09 +0100185 pgprot_t prot = PAGE_KERNEL_LARGE;
186
Ingo Molnar8550eb92008-01-30 13:34:10 +0100187 addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
Jeremy Fitzhardingef3f20de2008-01-30 13:31:09 +0100188 PAGE_OFFSET + PAGE_SIZE-1;
189
Ingo Molnar8550eb92008-01-30 13:34:10 +0100190 if (is_kernel_text(addr) ||
191 is_kernel_text(addr2))
Jeremy Fitzhardingef3f20de2008-01-30 13:31:09 +0100192 prot = PAGE_KERNEL_LARGE_EXEC;
193
194 set_pmd(pmd, pfn_pmd(pfn, prot));
Jeremy Fitzhardingeb239fb22007-05-02 19:27:13 +0200195
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 pfn += PTRS_PER_PTE;
Ingo Molnar8550eb92008-01-30 13:34:10 +0100197 continue;
198 }
199 pte = one_page_table_init(pmd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200
Ingo Molnar8550eb92008-01-30 13:34:10 +0100201 for (pte_ofs = 0;
202 pte_ofs < PTRS_PER_PTE && pfn < max_low_pfn;
203 pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
204 pgprot_t prot = PAGE_KERNEL;
Jeremy Fitzhardingef3f20de2008-01-30 13:31:09 +0100205
Ingo Molnar8550eb92008-01-30 13:34:10 +0100206 if (is_kernel_text(addr))
207 prot = PAGE_KERNEL_EXEC;
Jeremy Fitzhardingef3f20de2008-01-30 13:31:09 +0100208
Ingo Molnar8550eb92008-01-30 13:34:10 +0100209 set_pte(pte, pfn_pte(pfn, prot));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 }
211 }
212 }
213}
214
215static inline int page_kills_ppro(unsigned long pagenr)
216{
217 if (pagenr >= 0x70000 && pagenr <= 0x7003F)
218 return 1;
219 return 0;
220}
221
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222#ifdef CONFIG_HIGHMEM
223pte_t *kmap_pte;
224pgprot_t kmap_prot;
225
Ingo Molnar8550eb92008-01-30 13:34:10 +0100226static inline pte_t *kmap_get_fixmap_pte(unsigned long vaddr)
227{
228 return pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k(vaddr),
229 vaddr), vaddr), vaddr);
230}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231
232static void __init kmap_init(void)
233{
234 unsigned long kmap_vstart;
235
Ingo Molnar8550eb92008-01-30 13:34:10 +0100236 /*
237 * Cache the first kmap pte:
238 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 kmap_vstart = __fix_to_virt(FIX_KMAP_BEGIN);
240 kmap_pte = kmap_get_fixmap_pte(kmap_vstart);
241
242 kmap_prot = PAGE_KERNEL;
243}
244
245static void __init permanent_kmaps_init(pgd_t *pgd_base)
246{
Ingo Molnar8550eb92008-01-30 13:34:10 +0100247 unsigned long vaddr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 pgd_t *pgd;
249 pud_t *pud;
250 pmd_t *pmd;
251 pte_t *pte;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252
253 vaddr = PKMAP_BASE;
254 page_table_range_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, pgd_base);
255
256 pgd = swapper_pg_dir + pgd_index(vaddr);
257 pud = pud_offset(pgd, vaddr);
258 pmd = pmd_offset(pud, vaddr);
259 pte = pte_offset_kernel(pmd, vaddr);
Ingo Molnar8550eb92008-01-30 13:34:10 +0100260 pkmap_page_table = pte;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261}
262
Matt Tolentinoc09b4242006-01-17 07:03:44 +0100263static void __meminit free_new_highpage(struct page *page)
Dave Hansen05039b92005-10-29 18:16:57 -0700264{
Nick Piggin7835e982006-03-22 00:08:40 -0800265 init_page_count(page);
Dave Hansen05039b92005-10-29 18:16:57 -0700266 __free_page(page);
267 totalhigh_pages++;
268}
269
270void __init add_one_highpage_init(struct page *page, int pfn, int bad_ppro)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271{
272 if (page_is_ram(pfn) && !(bad_ppro && page_kills_ppro(pfn))) {
273 ClearPageReserved(page);
Dave Hansen05039b92005-10-29 18:16:57 -0700274 free_new_highpage(page);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275 } else
276 SetPageReserved(page);
277}
278
Ingo Molnar8550eb92008-01-30 13:34:10 +0100279static int __meminit
280add_one_highpage_hotplug(struct page *page, unsigned long pfn)
Dave Hansen05039b92005-10-29 18:16:57 -0700281{
282 free_new_highpage(page);
283 totalram_pages++;
284#ifdef CONFIG_FLATMEM
285 max_mapnr = max(pfn, max_mapnr);
286#endif
287 num_physpages++;
Ingo Molnar8550eb92008-01-30 13:34:10 +0100288
Dave Hansen05039b92005-10-29 18:16:57 -0700289 return 0;
290}
291
292/*
293 * Not currently handling the NUMA case.
294 * Assuming single node and all memory that
295 * has been added dynamically that would be
Ingo Molnar8550eb92008-01-30 13:34:10 +0100296 * onlined here is in HIGHMEM.
Dave Hansen05039b92005-10-29 18:16:57 -0700297 */
Vivek Goyal0e0be252007-01-11 01:52:44 +0100298void __meminit online_page(struct page *page)
Dave Hansen05039b92005-10-29 18:16:57 -0700299{
300 ClearPageReserved(page);
301 add_one_highpage_hotplug(page, page_to_pfn(page));
302}
303
Ingo Molnar8550eb92008-01-30 13:34:10 +0100304#ifndef CONFIG_NUMA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305static void __init set_highmem_pages_init(int bad_ppro)
306{
307 int pfn;
Ingo Molnar8550eb92008-01-30 13:34:10 +0100308
Ingo Molnar23be8c72008-01-15 16:44:37 +0100309 for (pfn = highstart_pfn; pfn < highend_pfn; pfn++) {
310 /*
311 * Holes under sparsemem might not have no mem_map[]:
312 */
313 if (pfn_valid(pfn))
314 add_one_highpage_init(pfn_to_page(pfn), pfn, bad_ppro);
315 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 totalram_pages += totalhigh_pages;
317}
Ingo Molnar8550eb92008-01-30 13:34:10 +0100318#endif /* !CONFIG_NUMA */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319
320#else
Ingo Molnar8550eb92008-01-30 13:34:10 +0100321# define kmap_init() do { } while (0)
322# define permanent_kmaps_init(pgd_base) do { } while (0)
323# define set_highmem_pages_init(bad_ppro) do { } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324#endif /* CONFIG_HIGHMEM */
325
Andi Kleenc93c82b2008-01-30 13:33:50 +0100326pteval_t __PAGE_KERNEL = _PAGE_KERNEL;
Alexey Dobriyan129f6942005-06-23 00:08:33 -0700327EXPORT_SYMBOL(__PAGE_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328
Ingo Molnar8550eb92008-01-30 13:34:10 +0100329pteval_t __PAGE_KERNEL_EXEC = _PAGE_KERNEL_EXEC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330
Jeremy Fitzhardingeb239fb22007-05-02 19:27:13 +0200331void __init native_pagetable_setup_start(pgd_t *base)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332{
Ian Campbell551889a2008-02-09 23:24:09 +0100333 unsigned long pfn, va;
334 pgd_t *pgd;
335 pud_t *pud;
336 pmd_t *pmd;
337 pte_t *pte;
Jeremy Fitzhardingeb239fb22007-05-02 19:27:13 +0200338
339 /*
Ian Campbell551889a2008-02-09 23:24:09 +0100340 * Remove any mappings which extend past the end of physical
341 * memory from the boot time page table:
Jeremy Fitzhardingeb239fb22007-05-02 19:27:13 +0200342 */
Ian Campbell551889a2008-02-09 23:24:09 +0100343 for (pfn = max_low_pfn + 1; pfn < 1<<(32-PAGE_SHIFT); pfn++) {
344 va = PAGE_OFFSET + (pfn<<PAGE_SHIFT);
345 pgd = base + pgd_index(va);
346 if (!pgd_present(*pgd))
347 break;
Jeremy Fitzhardingeb239fb22007-05-02 19:27:13 +0200348
Ian Campbell551889a2008-02-09 23:24:09 +0100349 pud = pud_offset(pgd, va);
350 pmd = pmd_offset(pud, va);
351 if (!pmd_present(*pmd))
352 break;
353
354 pte = pte_offset_kernel(pmd, va);
355 if (!pte_present(*pte))
356 break;
357
358 pte_clear(NULL, va, pte);
359 }
Jeremy Fitzhardinge6c435452008-01-30 13:33:39 +0100360 paravirt_alloc_pd(&init_mm, __pa(base) >> PAGE_SHIFT);
Jeremy Fitzhardingeb239fb22007-05-02 19:27:13 +0200361}
362
363void __init native_pagetable_setup_done(pgd_t *base)
364{
Jeremy Fitzhardingeb239fb22007-05-02 19:27:13 +0200365}
366
367/*
368 * Build a proper pagetable for the kernel mappings. Up until this
369 * point, we've been running on some set of pagetables constructed by
370 * the boot process.
371 *
372 * If we're booting on native hardware, this will be a pagetable
Ian Campbell551889a2008-02-09 23:24:09 +0100373 * constructed in arch/x86/kernel/head_32.S. The root of the
374 * pagetable will be swapper_pg_dir.
Jeremy Fitzhardingeb239fb22007-05-02 19:27:13 +0200375 *
376 * If we're booting paravirtualized under a hypervisor, then there are
377 * more options: we may already be running PAE, and the pagetable may
378 * or may not be based in swapper_pg_dir. In any case,
379 * paravirt_pagetable_setup_start() will set up swapper_pg_dir
380 * appropriately for the rest of the initialization to work.
381 *
382 * In general, pagetable_init() assumes that the pagetable may already
383 * be partially populated, and so it avoids stomping on any existing
384 * mappings.
385 */
Ingo Molnar8550eb92008-01-30 13:34:10 +0100386static void __init pagetable_init(void)
Jeremy Fitzhardingeb239fb22007-05-02 19:27:13 +0200387{
Jeremy Fitzhardingeb239fb22007-05-02 19:27:13 +0200388 pgd_t *pgd_base = swapper_pg_dir;
Ingo Molnar8550eb92008-01-30 13:34:10 +0100389 unsigned long vaddr, end;
Jeremy Fitzhardingeb239fb22007-05-02 19:27:13 +0200390
391 paravirt_pagetable_setup_start(pgd_base);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392
393 /* Enable PSE if available */
Jeremy Fitzhardingeb239fb22007-05-02 19:27:13 +0200394 if (cpu_has_pse)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 set_in_cr4(X86_CR4_PSE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396
397 /* Enable PGE if available */
398 if (cpu_has_pge) {
399 set_in_cr4(X86_CR4_PGE);
400 __PAGE_KERNEL |= _PAGE_GLOBAL;
401 __PAGE_KERNEL_EXEC |= _PAGE_GLOBAL;
402 }
403
404 kernel_physical_mapping_init(pgd_base);
405 remap_numa_kva();
406
407 /*
408 * Fixed mappings, only the page table structure has to be
409 * created - mappings will be set by set_fixmap():
410 */
Huang, Yingbeacfaa2008-01-30 13:33:44 +0100411 early_ioremap_clear();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK;
Jeremy Fitzhardingeb239fb22007-05-02 19:27:13 +0200413 end = (FIXADDR_TOP + PMD_SIZE - 1) & PMD_MASK;
414 page_table_range_init(vaddr, end, pgd_base);
Huang, Yingbeacfaa2008-01-30 13:33:44 +0100415 early_ioremap_reset();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416
417 permanent_kmaps_init(pgd_base);
418
Jeremy Fitzhardingeb239fb22007-05-02 19:27:13 +0200419 paravirt_pagetable_setup_done(pgd_base);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420}
421
Rafael J. Wysockia6eb84b2008-02-01 15:28:16 +0100422#ifdef CONFIG_ACPI_SLEEP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423/*
Rafael J. Wysockia6eb84b2008-02-01 15:28:16 +0100424 * ACPI suspend needs this for resume, because things like the intel-agp
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 * driver might have split up a kernel 4MB mapping.
426 */
Rafael J. Wysockia6eb84b2008-02-01 15:28:16 +0100427char swsusp_pg_dir[PAGE_SIZE]
Ingo Molnar8550eb92008-01-30 13:34:10 +0100428 __attribute__ ((aligned(PAGE_SIZE)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429
430static inline void save_pg_dir(void)
431{
432 memcpy(swsusp_pg_dir, swapper_pg_dir, PAGE_SIZE);
433}
Rafael J. Wysockia6eb84b2008-02-01 15:28:16 +0100434#else /* !CONFIG_ACPI_SLEEP */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435static inline void save_pg_dir(void)
436{
437}
Rafael J. Wysockia6eb84b2008-02-01 15:28:16 +0100438#endif /* !CONFIG_ACPI_SLEEP */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439
Ingo Molnar8550eb92008-01-30 13:34:10 +0100440void zap_low_mappings(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441{
442 int i;
443
444 save_pg_dir();
445
446 /*
447 * Zap initial low-memory mappings.
448 *
449 * Note that "pgd_clear()" doesn't do it for
450 * us, because pgd_clear() is a no-op on i386.
451 */
Ingo Molnar8550eb92008-01-30 13:34:10 +0100452 for (i = 0; i < USER_PTRS_PER_PGD; i++) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453#ifdef CONFIG_X86_PAE
454 set_pgd(swapper_pg_dir+i, __pgd(1 + __pa(empty_zero_page)));
455#else
456 set_pgd(swapper_pg_dir+i, __pgd(0));
457#endif
Ingo Molnar8550eb92008-01-30 13:34:10 +0100458 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 flush_tlb_all();
460}
461
Ingo Molnar8550eb92008-01-30 13:34:10 +0100462int nx_enabled;
Jan Beulichd5321ab2007-07-21 17:10:26 +0200463
Jeremy Fitzhardinge6fdc05d2008-01-30 13:32:57 +0100464pteval_t __supported_pte_mask __read_mostly = ~_PAGE_NX;
465EXPORT_SYMBOL_GPL(__supported_pte_mask);
466
Jan Beulichd5321ab2007-07-21 17:10:26 +0200467#ifdef CONFIG_X86_PAE
468
Ingo Molnar8550eb92008-01-30 13:34:10 +0100469static int disable_nx __initdata;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470
471/*
472 * noexec = on|off
473 *
474 * Control non executable mappings.
475 *
476 * on Enable
477 * off Disable
478 */
Rusty Russell1a3f2392006-09-26 10:52:32 +0200479static int __init noexec_setup(char *str)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480{
Rusty Russell1a3f2392006-09-26 10:52:32 +0200481 if (!str || !strcmp(str, "on")) {
482 if (cpu_has_nx) {
483 __supported_pte_mask |= _PAGE_NX;
484 disable_nx = 0;
485 }
Ingo Molnar8550eb92008-01-30 13:34:10 +0100486 } else {
487 if (!strcmp(str, "off")) {
488 disable_nx = 1;
489 __supported_pte_mask &= ~_PAGE_NX;
490 } else {
491 return -EINVAL;
492 }
493 }
Rusty Russell1a3f2392006-09-26 10:52:32 +0200494
495 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496}
Rusty Russell1a3f2392006-09-26 10:52:32 +0200497early_param("noexec", noexec_setup);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499static void __init set_nx(void)
500{
501 unsigned int v[4], l, h;
502
503 if (cpu_has_pae && (cpuid_eax(0x80000000) > 0x80000001)) {
504 cpuid(0x80000001, &v[0], &v[1], &v[2], &v[3]);
Ingo Molnar8550eb92008-01-30 13:34:10 +0100505
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 if ((v[3] & (1 << 20)) && !disable_nx) {
507 rdmsr(MSR_EFER, l, h);
508 l |= EFER_NX;
509 wrmsr(MSR_EFER, l, h);
510 nx_enabled = 1;
511 __supported_pte_mask |= _PAGE_NX;
512 }
513 }
514}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515#endif
516
517/*
518 * paging_init() sets up the page tables - note that the first 8MB are
519 * already mapped by head.S.
520 *
521 * This routines also unmaps the page at virtual kernel address 0, so
522 * that we can trap those pesky NULL-reference errors in the kernel.
523 */
524void __init paging_init(void)
525{
526#ifdef CONFIG_X86_PAE
527 set_nx();
528 if (nx_enabled)
Ingo Molnard7d119d2008-01-30 13:34:10 +0100529 printk(KERN_INFO "NX (Execute Disable) protection: active\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 pagetable_init();
532
533 load_cr3(swapper_pg_dir);
534
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 __flush_tlb_all();
536
537 kmap_init();
538}
539
540/*
541 * Test if the WP bit works in supervisor mode. It isn't supported on 386's
542 * and also on some strange 486's (NexGen etc.). All 586+'s are OK. This
543 * used to involve black magic jumps to work around some nasty CPU bugs,
544 * but fortunately the switch to using exceptions got rid of all that.
545 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546static void __init test_wp_bit(void)
547{
Ingo Molnard7d119d2008-01-30 13:34:10 +0100548 printk(KERN_INFO
549 "Checking if this processor honours the WP bit even in supervisor mode...");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550
551 /* Any page-aligned address will do, the test is non-destructive */
552 __set_fixmap(FIX_WP_TEST, __pa(&swapper_pg_dir), PAGE_READONLY);
553 boot_cpu_data.wp_works_ok = do_test_wp_bit();
554 clear_fixmap(FIX_WP_TEST);
555
556 if (!boot_cpu_data.wp_works_ok) {
Ingo Molnard7d119d2008-01-30 13:34:10 +0100557 printk(KERN_CONT "No.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558#ifdef CONFIG_X86_WP_WORKS_OK
Ingo Molnard7d119d2008-01-30 13:34:10 +0100559 panic(
560 "This kernel doesn't support CPU's with broken WP. Recompile it for a 386!");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561#endif
562 } else {
Ingo Molnard7d119d2008-01-30 13:34:10 +0100563 printk(KERN_CONT "Ok.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 }
565}
566
Ingo Molnar8550eb92008-01-30 13:34:10 +0100567static struct kcore_list kcore_mem, kcore_vmalloc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568
569void __init mem_init(void)
570{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 int codesize, reservedpages, datasize, initsize;
Ingo Molnar8550eb92008-01-30 13:34:10 +0100572 int tmp, bad_ppro;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573
Andy Whitcroft05b79bd2005-06-23 00:07:57 -0700574#ifdef CONFIG_FLATMEM
Eric Sesterhenn8d8f3cb2006-10-03 23:34:58 +0200575 BUG_ON(!mem_map);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 bad_ppro = ppro_with_ram_bug();
578
579#ifdef CONFIG_HIGHMEM
580 /* check that fixmap and pkmap do not overlap */
Ingo Molnard7d119d2008-01-30 13:34:10 +0100581 if (PKMAP_BASE + LAST_PKMAP*PAGE_SIZE >= FIXADDR_START) {
582 printk(KERN_ERR
583 "fixmap and kmap areas overlap - this will crash\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 printk(KERN_ERR "pkstart: %lxh pkend: %lxh fixstart %lxh\n",
Ingo Molnard7d119d2008-01-30 13:34:10 +0100585 PKMAP_BASE, PKMAP_BASE + LAST_PKMAP*PAGE_SIZE,
586 FIXADDR_START);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 BUG();
588 }
589#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 /* this will put all low memory onto the freelists */
591 totalram_pages += free_all_bootmem();
592
593 reservedpages = 0;
594 for (tmp = 0; tmp < max_low_pfn; tmp++)
595 /*
Ingo Molnar8550eb92008-01-30 13:34:10 +0100596 * Only count reserved RAM pages:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 */
598 if (page_is_ram(tmp) && PageReserved(pfn_to_page(tmp)))
599 reservedpages++;
600
601 set_highmem_pages_init(bad_ppro);
602
603 codesize = (unsigned long) &_etext - (unsigned long) &_text;
604 datasize = (unsigned long) &_edata - (unsigned long) &_etext;
605 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
606
Ingo Molnar8550eb92008-01-30 13:34:10 +0100607 kclist_add(&kcore_mem, __va(0), max_low_pfn << PAGE_SHIFT);
608 kclist_add(&kcore_vmalloc, (void *)VMALLOC_START,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609 VMALLOC_END-VMALLOC_START);
610
Ingo Molnar8550eb92008-01-30 13:34:10 +0100611 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
612 "%dk reserved, %dk data, %dk init, %ldk highmem)\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
614 num_physpages << (PAGE_SHIFT-10),
615 codesize >> 10,
616 reservedpages << (PAGE_SHIFT-10),
617 datasize >> 10,
618 initsize >> 10,
619 (unsigned long) (totalhigh_pages << (PAGE_SHIFT-10))
620 );
621
Jeremy Fitzhardinge052e7992006-09-25 23:32:25 -0700622#if 1 /* double-sanity-check paranoia */
Ingo Molnard7d119d2008-01-30 13:34:10 +0100623 printk(KERN_INFO "virtual kernel memory layout:\n"
Ingo Molnar8550eb92008-01-30 13:34:10 +0100624 " fixmap : 0x%08lx - 0x%08lx (%4ld kB)\n"
Jeremy Fitzhardinge052e7992006-09-25 23:32:25 -0700625#ifdef CONFIG_HIGHMEM
Ingo Molnar8550eb92008-01-30 13:34:10 +0100626 " pkmap : 0x%08lx - 0x%08lx (%4ld kB)\n"
Jeremy Fitzhardinge052e7992006-09-25 23:32:25 -0700627#endif
Ingo Molnar8550eb92008-01-30 13:34:10 +0100628 " vmalloc : 0x%08lx - 0x%08lx (%4ld MB)\n"
629 " lowmem : 0x%08lx - 0x%08lx (%4ld MB)\n"
630 " .init : 0x%08lx - 0x%08lx (%4ld kB)\n"
631 " .data : 0x%08lx - 0x%08lx (%4ld kB)\n"
632 " .text : 0x%08lx - 0x%08lx (%4ld kB)\n",
633 FIXADDR_START, FIXADDR_TOP,
634 (FIXADDR_TOP - FIXADDR_START) >> 10,
Jeremy Fitzhardinge052e7992006-09-25 23:32:25 -0700635
636#ifdef CONFIG_HIGHMEM
Ingo Molnar8550eb92008-01-30 13:34:10 +0100637 PKMAP_BASE, PKMAP_BASE+LAST_PKMAP*PAGE_SIZE,
638 (LAST_PKMAP*PAGE_SIZE) >> 10,
Jeremy Fitzhardinge052e7992006-09-25 23:32:25 -0700639#endif
640
Ingo Molnar8550eb92008-01-30 13:34:10 +0100641 VMALLOC_START, VMALLOC_END,
642 (VMALLOC_END - VMALLOC_START) >> 20,
Jeremy Fitzhardinge052e7992006-09-25 23:32:25 -0700643
Ingo Molnar8550eb92008-01-30 13:34:10 +0100644 (unsigned long)__va(0), (unsigned long)high_memory,
645 ((unsigned long)high_memory - (unsigned long)__va(0)) >> 20,
Jeremy Fitzhardinge052e7992006-09-25 23:32:25 -0700646
Ingo Molnar8550eb92008-01-30 13:34:10 +0100647 (unsigned long)&__init_begin, (unsigned long)&__init_end,
648 ((unsigned long)&__init_end -
649 (unsigned long)&__init_begin) >> 10,
Jeremy Fitzhardinge052e7992006-09-25 23:32:25 -0700650
Ingo Molnar8550eb92008-01-30 13:34:10 +0100651 (unsigned long)&_etext, (unsigned long)&_edata,
652 ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
Jeremy Fitzhardinge052e7992006-09-25 23:32:25 -0700653
Ingo Molnar8550eb92008-01-30 13:34:10 +0100654 (unsigned long)&_text, (unsigned long)&_etext,
655 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
Jeremy Fitzhardinge052e7992006-09-25 23:32:25 -0700656
657#ifdef CONFIG_HIGHMEM
Ingo Molnar8550eb92008-01-30 13:34:10 +0100658 BUG_ON(PKMAP_BASE + LAST_PKMAP*PAGE_SIZE > FIXADDR_START);
659 BUG_ON(VMALLOC_END > PKMAP_BASE);
Jeremy Fitzhardinge052e7992006-09-25 23:32:25 -0700660#endif
Ingo Molnar8550eb92008-01-30 13:34:10 +0100661 BUG_ON(VMALLOC_START > VMALLOC_END);
662 BUG_ON((unsigned long)high_memory > VMALLOC_START);
Jeremy Fitzhardinge052e7992006-09-25 23:32:25 -0700663#endif /* double-sanity-check paranoia */
664
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 if (boot_cpu_data.wp_works_ok < 0)
666 test_wp_bit();
667
Thomas Gleixner76ebd052008-02-09 23:24:09 +0100668 cpa_init();
669
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 /*
671 * Subtle. SMP is doing it's boot stuff late (because it has to
672 * fork idle threads) - but it also needs low mappings for the
673 * protected-mode entry to work. We zap these entries only after
674 * the WP-bit has been tested.
675 */
676#ifndef CONFIG_SMP
677 zap_low_mappings();
678#endif
679}
680
KAMEZAWA Hiroyukiad8f5792006-05-20 15:00:03 -0700681#ifdef CONFIG_MEMORY_HOTPLUG
Yasunori Gotobc02af92006-06-27 02:53:30 -0700682int arch_add_memory(int nid, u64 start, u64 size)
Dave Hansen05039b92005-10-29 18:16:57 -0700683{
Yasunori Goto7c7e9422006-12-22 01:11:13 -0800684 struct pglist_data *pgdata = NODE_DATA(nid);
Christoph Lameter776ed982006-09-25 23:31:09 -0700685 struct zone *zone = pgdata->node_zones + ZONE_HIGHMEM;
Dave Hansen05039b92005-10-29 18:16:57 -0700686 unsigned long start_pfn = start >> PAGE_SHIFT;
687 unsigned long nr_pages = size >> PAGE_SHIFT;
688
689 return __add_pages(zone, start_pfn, nr_pages);
690}
Andi Kleen9d99aaa2006-04-07 19:49:15 +0200691#endif
Dave Hansen05039b92005-10-29 18:16:57 -0700692
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693/*
694 * This function cannot be __init, since exceptions don't work in that
695 * section. Put this after the callers, so that it cannot be inlined.
696 */
Ingo Molnar8550eb92008-01-30 13:34:10 +0100697static noinline int do_test_wp_bit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698{
699 char tmp_reg;
700 int flag;
701
702 __asm__ __volatile__(
Ingo Molnar8550eb92008-01-30 13:34:10 +0100703 " movb %0, %1 \n"
704 "1: movb %1, %0 \n"
705 " xorl %2, %2 \n"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 "2: \n"
H. Peter Anvinf832ff12008-02-04 16:47:58 +0100707 _ASM_EXTABLE(1b,2b)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 :"=m" (*(char *)fix_to_virt(FIX_WP_TEST)),
709 "=q" (tmp_reg),
710 "=r" (flag)
711 :"2" (1)
712 :"memory");
Ingo Molnar8550eb92008-01-30 13:34:10 +0100713
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 return flag;
715}
716
Arjan van de Ven63aaf302006-01-06 00:12:02 -0800717#ifdef CONFIG_DEBUG_RODATA
Arjan van de Venedeed302008-01-30 13:34:08 +0100718const int rodata_test_data = 0xC3;
719EXPORT_SYMBOL_GPL(rodata_test_data);
Arjan van de Ven63aaf302006-01-06 00:12:02 -0800720
Arjan van de Ven63aaf302006-01-06 00:12:02 -0800721void mark_rodata_ro(void)
722{
Jan Beulich6fb14752007-05-02 19:27:10 +0200723 unsigned long start = PFN_ALIGN(_text);
724 unsigned long size = PFN_ALIGN(_etext) - start;
Arjan van de Ven63aaf302006-01-06 00:12:02 -0800725
Mathieu Desnoyers4e4eee02008-02-02 15:42:20 -0500726 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
727 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
728 size >> 10);
Andi Kleen0c42f392008-01-30 13:33:42 +0100729
730#ifdef CONFIG_CPA_DEBUG
Mathieu Desnoyers4e4eee02008-02-02 15:42:20 -0500731 printk(KERN_INFO "Testing CPA: Reverting %lx-%lx\n",
732 start, start+size);
733 set_pages_rw(virt_to_page(start), size>>PAGE_SHIFT);
Andi Kleen0c42f392008-01-30 13:33:42 +0100734
Mathieu Desnoyers4e4eee02008-02-02 15:42:20 -0500735 printk(KERN_INFO "Testing CPA: write protecting again\n");
736 set_pages_ro(virt_to_page(start), size>>PAGE_SHIFT);
Linus Torvalds602033e2007-07-26 12:07:21 -0700737#endif
Jan Beulich6fb14752007-05-02 19:27:10 +0200738 start += size;
739 size = (unsigned long)__end_rodata - start;
Arjan van de Ven6d238cc2008-01-30 13:34:06 +0100740 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
Ingo Molnard7d119d2008-01-30 13:34:10 +0100741 printk(KERN_INFO "Write protecting the kernel read-only data: %luk\n",
742 size >> 10);
Arjan van de Venedeed302008-01-30 13:34:08 +0100743 rodata_test();
Arjan van de Ven63aaf302006-01-06 00:12:02 -0800744
Andi Kleen0c42f392008-01-30 13:33:42 +0100745#ifdef CONFIG_CPA_DEBUG
Ingo Molnard7d119d2008-01-30 13:34:10 +0100746 printk(KERN_INFO "Testing CPA: undo %lx-%lx\n", start, start + size);
Arjan van de Ven6d238cc2008-01-30 13:34:06 +0100747 set_pages_rw(virt_to_page(start), size >> PAGE_SHIFT);
Andi Kleen0c42f392008-01-30 13:33:42 +0100748
Ingo Molnard7d119d2008-01-30 13:34:10 +0100749 printk(KERN_INFO "Testing CPA: write protecting again\n");
Arjan van de Ven6d238cc2008-01-30 13:34:06 +0100750 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
Andi Kleen0c42f392008-01-30 13:33:42 +0100751#endif
Arjan van de Ven63aaf302006-01-06 00:12:02 -0800752}
753#endif
754
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800755void free_init_pages(char *what, unsigned long begin, unsigned long end)
756{
Ingo Molnaree01f112008-01-30 13:34:09 +0100757#ifdef CONFIG_DEBUG_PAGEALLOC
758 /*
759 * If debugging page accesses then do not free this memory but
760 * mark them not present - any buggy init-section access will
761 * create a kernel page fault:
762 */
763 printk(KERN_INFO "debug: unmapping init memory %08lx..%08lx\n",
764 begin, PAGE_ALIGN(end));
765 set_memory_np(begin, (end - begin) >> PAGE_SHIFT);
766#else
Ingo Molnar86f03982008-01-30 13:34:09 +0100767 unsigned long addr;
768
Arjan van de Ven3c1df682008-01-30 13:34:07 +0100769 /*
770 * We just marked the kernel text read only above, now that
771 * we are going to free part of that, we need to make that
772 * writeable first.
773 */
774 set_memory_rw(begin, (end - begin) >> PAGE_SHIFT);
775
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800776 for (addr = begin; addr < end; addr += PAGE_SIZE) {
Linus Torvaldse3ebadd2007-05-07 08:44:24 -0700777 ClearPageReserved(virt_to_page(addr));
778 init_page_count(virt_to_page(addr));
779 memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
780 free_page(addr);
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800781 totalram_pages++;
782 }
Jan Beulich6fb14752007-05-02 19:27:10 +0200783 printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);
Ingo Molnaree01f112008-01-30 13:34:09 +0100784#endif
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800785}
786
787void free_initmem(void)
788{
789 free_init_pages("unused kernel memory",
Linus Torvaldse3ebadd2007-05-07 08:44:24 -0700790 (unsigned long)(&__init_begin),
791 (unsigned long)(&__init_end));
Gerd Hoffmann9a0b5812006-03-23 02:59:32 -0800792}
Arjan van de Ven63aaf302006-01-06 00:12:02 -0800793
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794#ifdef CONFIG_BLK_DEV_INITRD
795void free_initrd_mem(unsigned long start, unsigned long end)
796{
Linus Torvaldse3ebadd2007-05-07 08:44:24 -0700797 free_init_pages("initrd memory", start, end);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798}
799#endif