init_64.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245
  1. /*
  2. * linux/arch/x86_64/mm/init.c
  3. *
  4. * Copyright (C) 1995 Linus Torvalds
  5. * Copyright (C) 2000 Pavel Machek <pavel@suse.cz>
  6. * Copyright (C) 2002,2003 Andi Kleen <ak@suse.de>
  7. */
  8. #include <linux/signal.h>
  9. #include <linux/sched.h>
  10. #include <linux/kernel.h>
  11. #include <linux/errno.h>
  12. #include <linux/string.h>
  13. #include <linux/types.h>
  14. #include <linux/ptrace.h>
  15. #include <linux/mman.h>
  16. #include <linux/mm.h>
  17. #include <linux/swap.h>
  18. #include <linux/smp.h>
  19. #include <linux/init.h>
  20. #include <linux/initrd.h>
  21. #include <linux/pagemap.h>
  22. #include <linux/bootmem.h>
  23. #include <linux/proc_fs.h>
  24. #include <linux/pci.h>
  25. #include <linux/pfn.h>
  26. #include <linux/poison.h>
  27. #include <linux/dma-mapping.h>
  28. #include <linux/module.h>
  29. #include <linux/memory_hotplug.h>
  30. #include <linux/nmi.h>
  31. #include <asm/processor.h>
  32. #include <asm/bios_ebda.h>
  33. #include <asm/system.h>
  34. #include <asm/uaccess.h>
  35. #include <asm/pgtable.h>
  36. #include <asm/pgalloc.h>
  37. #include <asm/dma.h>
  38. #include <asm/fixmap.h>
  39. #include <asm/e820.h>
  40. #include <asm/apic.h>
  41. #include <asm/tlb.h>
  42. #include <asm/mmu_context.h>
  43. #include <asm/proto.h>
  44. #include <asm/smp.h>
  45. #include <asm/sections.h>
  46. #include <asm/kdebug.h>
  47. #include <asm/numa.h>
  48. #include <asm/cacheflush.h>
  49. /*
  50. * end_pfn only includes RAM, while max_pfn_mapped includes all e820 entries.
  51. * The direct mapping extends to max_pfn_mapped, so that we can directly access
  52. * apertures, ACPI and other tables without having to play with fixmaps.
  53. */
  54. unsigned long max_low_pfn_mapped;
  55. unsigned long max_pfn_mapped;
  56. static unsigned long dma_reserve __initdata;
  57. DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
  58. int direct_gbpages
  59. #ifdef CONFIG_DIRECT_GBPAGES
  60. = 1
  61. #endif
  62. ;
  63. static int __init parse_direct_gbpages_off(char *arg)
  64. {
  65. direct_gbpages = 0;
  66. return 0;
  67. }
  68. early_param("nogbpages", parse_direct_gbpages_off);
  69. static int __init parse_direct_gbpages_on(char *arg)
  70. {
  71. direct_gbpages = 1;
  72. return 0;
  73. }
  74. early_param("gbpages", parse_direct_gbpages_on);
  75. /*
  76. * NOTE: pagetable_init alloc all the fixmap pagetables contiguous on the
  77. * physical space so we can cache the place of the first one and move
  78. * around without checking the pgd every time.
  79. */
  80. int after_bootmem;
  81. pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
  82. EXPORT_SYMBOL_GPL(__supported_pte_mask);
  83. static int do_not_nx __cpuinitdata;
  84. /*
  85. * noexec=on|off
  86. * Control non-executable mappings for 64-bit processes.
  87. *
  88. * on Enable (default)
  89. * off Disable
  90. */
  91. static int __init nonx_setup(char *str)
  92. {
  93. if (!str)
  94. return -EINVAL;
  95. if (!strncmp(str, "on", 2)) {
  96. __supported_pte_mask |= _PAGE_NX;
  97. do_not_nx = 0;
  98. } else if (!strncmp(str, "off", 3)) {
  99. do_not_nx = 1;
  100. __supported_pte_mask &= ~_PAGE_NX;
  101. }
  102. return 0;
  103. }
  104. early_param("noexec", nonx_setup);
  105. void __cpuinit check_efer(void)
  106. {
  107. unsigned long efer;
  108. rdmsrl(MSR_EFER, efer);
  109. if (!(efer & EFER_NX) || do_not_nx)
  110. __supported_pte_mask &= ~_PAGE_NX;
  111. }
  112. int force_personality32;
  113. /*
  114. * noexec32=on|off
  115. * Control non executable heap for 32bit processes.
  116. * To control the stack too use noexec=off
  117. *
  118. * on PROT_READ does not imply PROT_EXEC for 32-bit processes (default)
  119. * off PROT_READ implies PROT_EXEC
  120. */
  121. static int __init nonx32_setup(char *str)
  122. {
  123. if (!strcmp(str, "on"))
  124. force_personality32 &= ~READ_IMPLIES_EXEC;
  125. else if (!strcmp(str, "off"))
  126. force_personality32 |= READ_IMPLIES_EXEC;
  127. return 1;
  128. }
  129. __setup("noexec32=", nonx32_setup);
  130. /*
  131. * NOTE: This function is marked __ref because it calls __init function
  132. * (alloc_bootmem_pages). It's safe to do it ONLY when after_bootmem == 0.
  133. */
  134. static __ref void *spp_getpage(void)
  135. {
  136. void *ptr;
  137. if (after_bootmem)
  138. ptr = (void *) get_zeroed_page(GFP_ATOMIC);
  139. else
  140. ptr = alloc_bootmem_pages(PAGE_SIZE);
  141. if (!ptr || ((unsigned long)ptr & ~PAGE_MASK)) {
  142. panic("set_pte_phys: cannot allocate page data %s\n",
  143. after_bootmem ? "after bootmem" : "");
  144. }
  145. pr_debug("spp_getpage %p\n", ptr);
  146. return ptr;
  147. }
  148. void
  149. set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
  150. {
  151. pud_t *pud;
  152. pmd_t *pmd;
  153. pte_t *pte;
  154. pud = pud_page + pud_index(vaddr);
  155. if (pud_none(*pud)) {
  156. pmd = (pmd_t *) spp_getpage();
  157. pud_populate(&init_mm, pud, pmd);
  158. if (pmd != pmd_offset(pud, 0)) {
  159. printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
  160. pmd, pmd_offset(pud, 0));
  161. return;
  162. }
  163. }
  164. pmd = pmd_offset(pud, vaddr);
  165. if (pmd_none(*pmd)) {
  166. pte = (pte_t *) spp_getpage();
  167. pmd_populate_kernel(&init_mm, pmd, pte);
  168. if (pte != pte_offset_kernel(pmd, 0)) {
  169. printk(KERN_ERR "PAGETABLE BUG #02!\n");
  170. return;
  171. }
  172. }
  173. pte = pte_offset_kernel(pmd, vaddr);
  174. set_pte(pte, new_pte);
  175. /*
  176. * It's enough to flush this one mapping.
  177. * (PGE mappings get flushed as well)
  178. */
  179. __flush_tlb_one(vaddr);
  180. }
  181. void
  182. set_pte_vaddr(unsigned long vaddr, pte_t pteval)
  183. {
  184. pgd_t *pgd;
  185. pud_t *pud_page;
  186. pr_debug("set_pte_vaddr %lx to %lx\n", vaddr, native_pte_val(pteval));
  187. pgd = pgd_offset_k(vaddr);
  188. if (pgd_none(*pgd)) {
  189. printk(KERN_ERR
  190. "PGD FIXMAP MISSING, it should be setup in head.S!\n");
  191. return;
  192. }
  193. pud_page = (pud_t*)pgd_page_vaddr(*pgd);
  194. set_pte_vaddr_pud(pud_page, vaddr, pteval);
  195. }
  196. /*
  197. * Create large page table mappings for a range of physical addresses.
  198. */
  199. static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
  200. pgprot_t prot)
  201. {
  202. pgd_t *pgd;
  203. pud_t *pud;
  204. pmd_t *pmd;
  205. BUG_ON((phys & ~PMD_MASK) || (size & ~PMD_MASK));
  206. for (; size; phys += PMD_SIZE, size -= PMD_SIZE) {
  207. pgd = pgd_offset_k((unsigned long)__va(phys));
  208. if (pgd_none(*pgd)) {
  209. pud = (pud_t *) spp_getpage();
  210. set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
  211. _PAGE_USER));
  212. }
  213. pud = pud_offset(pgd, (unsigned long)__va(phys));
  214. if (pud_none(*pud)) {
  215. pmd = (pmd_t *) spp_getpage();
  216. set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
  217. _PAGE_USER));
  218. }
  219. pmd = pmd_offset(pud, phys);
  220. BUG_ON(!pmd_none(*pmd));
  221. set_pmd(pmd, __pmd(phys | pgprot_val(prot)));
  222. }
  223. }
  224. void __init init_extra_mapping_wb(unsigned long phys, unsigned long size)
  225. {
  226. __init_extra_mapping(phys, size, PAGE_KERNEL_LARGE);
  227. }
  228. void __init init_extra_mapping_uc(unsigned long phys, unsigned long size)
  229. {
  230. __init_extra_mapping(phys, size, PAGE_KERNEL_LARGE_NOCACHE);
  231. }
  232. /*
  233. * The head.S code sets up the kernel high mapping:
  234. *
  235. * from __START_KERNEL_map to __START_KERNEL_map + size (== _end-_text)
  236. *
  237. * phys_addr holds the negative offset to the kernel, which is added
  238. * to the compile time generated pmds. This results in invalid pmds up
  239. * to the point where we hit the physaddr 0 mapping.
  240. *
  241. * We limit the mappings to the region from _text to _end. _end is
  242. * rounded up to the 2MB boundary. This catches the invalid pmds as
  243. * well, as they are located before _text:
  244. */
  245. void __init cleanup_highmap(void)
  246. {
  247. unsigned long vaddr = __START_KERNEL_map;
  248. unsigned long end = roundup((unsigned long)_end, PMD_SIZE) - 1;
  249. pmd_t *pmd = level2_kernel_pgt;
  250. pmd_t *last_pmd = pmd + PTRS_PER_PMD;
  251. for (; pmd < last_pmd; pmd++, vaddr += PMD_SIZE) {
  252. if (pmd_none(*pmd))
  253. continue;
  254. if (vaddr < (unsigned long) _text || vaddr > end)
  255. set_pmd(pmd, __pmd(0));
  256. }
  257. }
  258. static unsigned long __initdata table_start;
  259. static unsigned long __meminitdata table_end;
  260. static unsigned long __meminitdata table_top;
  261. static __ref void *alloc_low_page(unsigned long *phys)
  262. {
  263. unsigned long pfn = table_end++;
  264. void *adr;
  265. if (after_bootmem) {
  266. adr = (void *)get_zeroed_page(GFP_ATOMIC);
  267. *phys = __pa(adr);
  268. return adr;
  269. }
  270. if (pfn >= table_top)
  271. panic("alloc_low_page: ran out of memory");
  272. adr = early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
  273. memset(adr, 0, PAGE_SIZE);
  274. *phys = pfn * PAGE_SIZE;
  275. return adr;
  276. }
  277. static __ref void unmap_low_page(void *adr)
  278. {
  279. if (after_bootmem)
  280. return;
  281. early_iounmap(adr, PAGE_SIZE);
  282. }
  283. static unsigned long __meminit
  284. phys_pte_init(pte_t *pte_page, unsigned long addr, unsigned long end,
  285. pgprot_t prot)
  286. {
  287. unsigned pages = 0;
  288. unsigned long last_map_addr = end;
  289. int i;
  290. pte_t *pte = pte_page + pte_index(addr);
  291. for(i = pte_index(addr); i < PTRS_PER_PTE; i++, addr += PAGE_SIZE, pte++) {
  292. if (addr >= end) {
  293. if (!after_bootmem) {
  294. for(; i < PTRS_PER_PTE; i++, pte++)
  295. set_pte(pte, __pte(0));
  296. }
  297. break;
  298. }
  299. /*
  300. * We will re-use the existing mapping.
  301. * Xen for example has some special requirements, like mapping
  302. * pagetable pages as RO. So assume someone who pre-setup
  303. * these mappings are more intelligent.
  304. */
  305. if (pte_val(*pte)) {
  306. pages++;
  307. continue;
  308. }
  309. if (0)
  310. printk(" pte=%p addr=%lx pte=%016lx\n",
  311. pte, addr, pfn_pte(addr >> PAGE_SHIFT, PAGE_KERNEL).pte);
  312. pages++;
  313. set_pte(pte, pfn_pte(addr >> PAGE_SHIFT, prot));
  314. last_map_addr = (addr & PAGE_MASK) + PAGE_SIZE;
  315. }
  316. update_page_count(PG_LEVEL_4K, pages);
  317. return last_map_addr;
  318. }
  319. static unsigned long __meminit
  320. phys_pte_update(pmd_t *pmd, unsigned long address, unsigned long end,
  321. pgprot_t prot)
  322. {
  323. pte_t *pte = (pte_t *)pmd_page_vaddr(*pmd);
  324. return phys_pte_init(pte, address, end, prot);
  325. }
  326. static unsigned long __meminit
  327. phys_pmd_init(pmd_t *pmd_page, unsigned long address, unsigned long end,
  328. unsigned long page_size_mask, pgprot_t prot)
  329. {
  330. unsigned long pages = 0;
  331. unsigned long last_map_addr = end;
  332. int i = pmd_index(address);
  333. for (; i < PTRS_PER_PMD; i++, address += PMD_SIZE) {
  334. unsigned long pte_phys;
  335. pmd_t *pmd = pmd_page + pmd_index(address);
  336. pte_t *pte;
  337. pgprot_t new_prot = prot;
  338. if (address >= end) {
  339. if (!after_bootmem) {
  340. for (; i < PTRS_PER_PMD; i++, pmd++)
  341. set_pmd(pmd, __pmd(0));
  342. }
  343. break;
  344. }
  345. if (pmd_val(*pmd)) {
  346. if (!pmd_large(*pmd)) {
  347. spin_lock(&init_mm.page_table_lock);
  348. last_map_addr = phys_pte_update(pmd, address,
  349. end, prot);
  350. spin_unlock(&init_mm.page_table_lock);
  351. continue;
  352. }
  353. /*
  354. * If we are ok with PG_LEVEL_2M mapping, then we will
  355. * use the existing mapping,
  356. *
  357. * Otherwise, we will split the large page mapping but
  358. * use the same existing protection bits except for
  359. * large page, so that we don't violate Intel's TLB
  360. * Application note (317080) which says, while changing
  361. * the page sizes, new and old translations should
  362. * not differ with respect to page frame and
  363. * attributes.
  364. */
  365. if (page_size_mask & (1 << PG_LEVEL_2M)) {
  366. pages++;
  367. continue;
  368. }
  369. new_prot = pte_pgprot(pte_clrhuge(*(pte_t *)pmd));
  370. }
  371. if (page_size_mask & (1<<PG_LEVEL_2M)) {
  372. pages++;
  373. spin_lock(&init_mm.page_table_lock);
  374. set_pte((pte_t *)pmd,
  375. pfn_pte(address >> PAGE_SHIFT,
  376. __pgprot(pgprot_val(prot) | _PAGE_PSE)));
  377. spin_unlock(&init_mm.page_table_lock);
  378. last_map_addr = (address & PMD_MASK) + PMD_SIZE;
  379. continue;
  380. }
  381. pte = alloc_low_page(&pte_phys);
  382. last_map_addr = phys_pte_init(pte, address, end, new_prot);
  383. unmap_low_page(pte);
  384. spin_lock(&init_mm.page_table_lock);
  385. pmd_populate_kernel(&init_mm, pmd, __va(pte_phys));
  386. spin_unlock(&init_mm.page_table_lock);
  387. }
  388. update_page_count(PG_LEVEL_2M, pages);
  389. return last_map_addr;
  390. }
  391. static unsigned long __meminit
  392. phys_pmd_update(pud_t *pud, unsigned long address, unsigned long end,
  393. unsigned long page_size_mask, pgprot_t prot)
  394. {
  395. pmd_t *pmd = pmd_offset(pud, 0);
  396. unsigned long last_map_addr;
  397. last_map_addr = phys_pmd_init(pmd, address, end, page_size_mask, prot);
  398. __flush_tlb_all();
  399. return last_map_addr;
  400. }
  401. static unsigned long __meminit
  402. phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
  403. unsigned long page_size_mask)
  404. {
  405. unsigned long pages = 0;
  406. unsigned long last_map_addr = end;
  407. int i = pud_index(addr);
  408. for (; i < PTRS_PER_PUD; i++, addr = (addr & PUD_MASK) + PUD_SIZE) {
  409. unsigned long pmd_phys;
  410. pud_t *pud = pud_page + pud_index(addr);
  411. pmd_t *pmd;
  412. pgprot_t prot = PAGE_KERNEL;
  413. if (addr >= end)
  414. break;
  415. if (!after_bootmem &&
  416. !e820_any_mapped(addr, addr+PUD_SIZE, 0)) {
  417. set_pud(pud, __pud(0));
  418. continue;
  419. }
  420. if (pud_val(*pud)) {
  421. if (!pud_large(*pud)) {
  422. last_map_addr = phys_pmd_update(pud, addr, end,
  423. page_size_mask, prot);
  424. continue;
  425. }
  426. /*
  427. * If we are ok with PG_LEVEL_1G mapping, then we will
  428. * use the existing mapping.
  429. *
  430. * Otherwise, we will split the gbpage mapping but use
  431. * the same existing protection bits except for large
  432. * page, so that we don't violate Intel's TLB
  433. * Application note (317080) which says, while changing
  434. * the page sizes, new and old translations should
  435. * not differ with respect to page frame and
  436. * attributes.
  437. */
  438. if (page_size_mask & (1 << PG_LEVEL_1G)) {
  439. pages++;
  440. continue;
  441. }
  442. prot = pte_pgprot(pte_clrhuge(*(pte_t *)pud));
  443. }
  444. if (page_size_mask & (1<<PG_LEVEL_1G)) {
  445. pages++;
  446. spin_lock(&init_mm.page_table_lock);
  447. set_pte((pte_t *)pud,
  448. pfn_pte(addr >> PAGE_SHIFT, PAGE_KERNEL_LARGE));
  449. spin_unlock(&init_mm.page_table_lock);
  450. last_map_addr = (addr & PUD_MASK) + PUD_SIZE;
  451. continue;
  452. }
  453. pmd = alloc_low_page(&pmd_phys);
  454. last_map_addr = phys_pmd_init(pmd, addr, end, page_size_mask,
  455. prot);
  456. unmap_low_page(pmd);
  457. spin_lock(&init_mm.page_table_lock);
  458. pud_populate(&init_mm, pud, __va(pmd_phys));
  459. spin_unlock(&init_mm.page_table_lock);
  460. }
  461. __flush_tlb_all();
  462. update_page_count(PG_LEVEL_1G, pages);
  463. return last_map_addr;
  464. }
  465. static unsigned long __meminit
  466. phys_pud_update(pgd_t *pgd, unsigned long addr, unsigned long end,
  467. unsigned long page_size_mask)
  468. {
  469. pud_t *pud;
  470. pud = (pud_t *)pgd_page_vaddr(*pgd);
  471. return phys_pud_init(pud, addr, end, page_size_mask);
  472. }
  473. static void __init find_early_table_space(unsigned long end, int use_pse,
  474. int use_gbpages)
  475. {
  476. unsigned long puds, pmds, ptes, tables, start;
  477. puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
  478. tables = roundup(puds * sizeof(pud_t), PAGE_SIZE);
  479. if (use_gbpages) {
  480. unsigned long extra;
  481. extra = end - ((end>>PUD_SHIFT) << PUD_SHIFT);
  482. pmds = (extra + PMD_SIZE - 1) >> PMD_SHIFT;
  483. } else
  484. pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
  485. tables += roundup(pmds * sizeof(pmd_t), PAGE_SIZE);
  486. if (use_pse) {
  487. unsigned long extra;
  488. extra = end - ((end>>PMD_SHIFT) << PMD_SHIFT);
  489. ptes = (extra + PAGE_SIZE - 1) >> PAGE_SHIFT;
  490. } else
  491. ptes = (end + PAGE_SIZE - 1) >> PAGE_SHIFT;
  492. tables += roundup(ptes * sizeof(pte_t), PAGE_SIZE);
  493. /*
  494. * RED-PEN putting page tables only on node 0 could
  495. * cause a hotspot and fill up ZONE_DMA. The page tables
  496. * need roughly 0.5KB per GB.
  497. */
  498. start = 0x8000;
  499. table_start = find_e820_area(start, end, tables, PAGE_SIZE);
  500. if (table_start == -1UL)
  501. panic("Cannot find space for the kernel page tables");
  502. table_start >>= PAGE_SHIFT;
  503. table_end = table_start;
  504. table_top = table_start + (tables >> PAGE_SHIFT);
  505. printk(KERN_DEBUG "kernel direct mapping tables up to %lx @ %lx-%lx\n",
  506. end, table_start << PAGE_SHIFT, table_top << PAGE_SHIFT);
  507. }
  508. static void __init init_gbpages(void)
  509. {
  510. if (direct_gbpages && cpu_has_gbpages)
  511. printk(KERN_INFO "Using GB pages for direct mapping\n");
  512. else
  513. direct_gbpages = 0;
  514. }
  515. static unsigned long __init kernel_physical_mapping_init(unsigned long start,
  516. unsigned long end,
  517. unsigned long page_size_mask)
  518. {
  519. unsigned long next, last_map_addr = end;
  520. start = (unsigned long)__va(start);
  521. end = (unsigned long)__va(end);
  522. for (; start < end; start = next) {
  523. pgd_t *pgd = pgd_offset_k(start);
  524. unsigned long pud_phys;
  525. pud_t *pud;
  526. next = (start + PGDIR_SIZE) & PGDIR_MASK;
  527. if (next > end)
  528. next = end;
  529. if (pgd_val(*pgd)) {
  530. last_map_addr = phys_pud_update(pgd, __pa(start),
  531. __pa(end), page_size_mask);
  532. continue;
  533. }
  534. pud = alloc_low_page(&pud_phys);
  535. last_map_addr = phys_pud_init(pud, __pa(start), __pa(next),
  536. page_size_mask);
  537. unmap_low_page(pud);
  538. spin_lock(&init_mm.page_table_lock);
  539. pgd_populate(&init_mm, pgd, __va(pud_phys));
  540. spin_unlock(&init_mm.page_table_lock);
  541. }
  542. __flush_tlb_all();
  543. return last_map_addr;
  544. }
  545. struct map_range {
  546. unsigned long start;
  547. unsigned long end;
  548. unsigned page_size_mask;
  549. };
  550. #define NR_RANGE_MR 5
  551. static int save_mr(struct map_range *mr, int nr_range,
  552. unsigned long start_pfn, unsigned long end_pfn,
  553. unsigned long page_size_mask)
  554. {
  555. if (start_pfn < end_pfn) {
  556. if (nr_range >= NR_RANGE_MR)
  557. panic("run out of range for init_memory_mapping\n");
  558. mr[nr_range].start = start_pfn<<PAGE_SHIFT;
  559. mr[nr_range].end = end_pfn<<PAGE_SHIFT;
  560. mr[nr_range].page_size_mask = page_size_mask;
  561. nr_range++;
  562. }
  563. return nr_range;
  564. }
  565. /*
  566. * Setup the direct mapping of the physical memory at PAGE_OFFSET.
  567. * This runs before bootmem is initialized and gets pages directly from
  568. * the physical memory. To access them they are temporarily mapped.
  569. */
  570. unsigned long __init_refok init_memory_mapping(unsigned long start,
  571. unsigned long end)
  572. {
  573. unsigned long last_map_addr = 0;
  574. unsigned long page_size_mask = 0;
  575. unsigned long start_pfn, end_pfn;
  576. unsigned long pos;
  577. struct map_range mr[NR_RANGE_MR];
  578. int nr_range, i;
  579. int use_pse, use_gbpages;
  580. printk(KERN_INFO "init_memory_mapping: %016lx-%016lx\n", start, end);
  581. /*
  582. * Find space for the kernel direct mapping tables.
  583. *
  584. * Later we should allocate these tables in the local node of the
  585. * memory mapped. Unfortunately this is done currently before the
  586. * nodes are discovered.
  587. */
  588. if (!after_bootmem)
  589. init_gbpages();
  590. #ifdef CONFIG_DEBUG_PAGEALLOC
  591. /*
  592. * For CONFIG_DEBUG_PAGEALLOC, identity mapping will use small pages.
  593. * This will simplify cpa(), which otherwise needs to support splitting
  594. * large pages into small in interrupt context, etc.
  595. */
  596. use_pse = use_gbpages = 0;
  597. #else
  598. use_pse = cpu_has_pse;
  599. use_gbpages = direct_gbpages;
  600. #endif
  601. if (use_gbpages)
  602. page_size_mask |= 1 << PG_LEVEL_1G;
  603. if (use_pse)
  604. page_size_mask |= 1 << PG_LEVEL_2M;
  605. memset(mr, 0, sizeof(mr));
  606. nr_range = 0;
  607. /* head if not big page alignment ?*/
  608. start_pfn = start >> PAGE_SHIFT;
  609. pos = start_pfn << PAGE_SHIFT;
  610. end_pfn = ((pos + (PMD_SIZE - 1)) >> PMD_SHIFT)
  611. << (PMD_SHIFT - PAGE_SHIFT);
  612. if (start_pfn < end_pfn) {
  613. nr_range = save_mr(mr, nr_range, start_pfn, end_pfn, 0);
  614. pos = end_pfn << PAGE_SHIFT;
  615. }
  616. /* big page (2M) range*/
  617. start_pfn = ((pos + (PMD_SIZE - 1))>>PMD_SHIFT)
  618. << (PMD_SHIFT - PAGE_SHIFT);
  619. end_pfn = ((pos + (PUD_SIZE - 1))>>PUD_SHIFT)
  620. << (PUD_SHIFT - PAGE_SHIFT);
  621. if (end_pfn > ((end>>PMD_SHIFT)<<(PMD_SHIFT - PAGE_SHIFT)))
  622. end_pfn = ((end>>PMD_SHIFT)<<(PMD_SHIFT - PAGE_SHIFT));
  623. if (start_pfn < end_pfn) {
  624. nr_range = save_mr(mr, nr_range, start_pfn, end_pfn,
  625. page_size_mask & (1<<PG_LEVEL_2M));
  626. pos = end_pfn << PAGE_SHIFT;
  627. }
  628. /* big page (1G) range */
  629. start_pfn = ((pos + (PUD_SIZE - 1))>>PUD_SHIFT)
  630. << (PUD_SHIFT - PAGE_SHIFT);
  631. end_pfn = (end >> PUD_SHIFT) << (PUD_SHIFT - PAGE_SHIFT);
  632. if (start_pfn < end_pfn) {
  633. nr_range = save_mr(mr, nr_range, start_pfn, end_pfn,
  634. page_size_mask &
  635. ((1<<PG_LEVEL_2M)|(1<<PG_LEVEL_1G)));
  636. pos = end_pfn << PAGE_SHIFT;
  637. }
  638. /* tail is not big page (1G) alignment */
  639. start_pfn = ((pos + (PMD_SIZE - 1))>>PMD_SHIFT)
  640. << (PMD_SHIFT - PAGE_SHIFT);
  641. end_pfn = (end >> PMD_SHIFT) << (PMD_SHIFT - PAGE_SHIFT);
  642. if (start_pfn < end_pfn) {
  643. nr_range = save_mr(mr, nr_range, start_pfn, end_pfn,
  644. page_size_mask & (1<<PG_LEVEL_2M));
  645. pos = end_pfn << PAGE_SHIFT;
  646. }
  647. /* tail is not big page (2M) alignment */
  648. start_pfn = pos>>PAGE_SHIFT;
  649. end_pfn = end>>PAGE_SHIFT;
  650. nr_range = save_mr(mr, nr_range, start_pfn, end_pfn, 0);
  651. /* try to merge same page size and continuous */
  652. for (i = 0; nr_range > 1 && i < nr_range - 1; i++) {
  653. unsigned long old_start;
  654. if (mr[i].end != mr[i+1].start ||
  655. mr[i].page_size_mask != mr[i+1].page_size_mask)
  656. continue;
  657. /* move it */
  658. old_start = mr[i].start;
  659. memmove(&mr[i], &mr[i+1],
  660. (nr_range - 1 - i) * sizeof (struct map_range));
  661. mr[i--].start = old_start;
  662. nr_range--;
  663. }
  664. for (i = 0; i < nr_range; i++)
  665. printk(KERN_DEBUG " %010lx - %010lx page %s\n",
  666. mr[i].start, mr[i].end,
  667. (mr[i].page_size_mask & (1<<PG_LEVEL_1G))?"1G":(
  668. (mr[i].page_size_mask & (1<<PG_LEVEL_2M))?"2M":"4k"));
  669. if (!after_bootmem)
  670. find_early_table_space(end, use_pse, use_gbpages);
  671. for (i = 0; i < nr_range; i++)
  672. last_map_addr = kernel_physical_mapping_init(
  673. mr[i].start, mr[i].end,
  674. mr[i].page_size_mask);
  675. if (!after_bootmem)
  676. mmu_cr4_features = read_cr4();
  677. __flush_tlb_all();
  678. if (!after_bootmem && table_end > table_start)
  679. reserve_early(table_start << PAGE_SHIFT,
  680. table_end << PAGE_SHIFT, "PGTABLE");
  681. printk(KERN_INFO "last_map_addr: %lx end: %lx\n",
  682. last_map_addr, end);
  683. if (!after_bootmem)
  684. early_memtest(start, end);
  685. return last_map_addr >> PAGE_SHIFT;
  686. }
  687. #ifndef CONFIG_NUMA
  688. void __init initmem_init(unsigned long start_pfn, unsigned long end_pfn)
  689. {
  690. unsigned long bootmap_size, bootmap;
  691. bootmap_size = bootmem_bootmap_pages(end_pfn)<<PAGE_SHIFT;
  692. bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT, bootmap_size,
  693. PAGE_SIZE);
  694. if (bootmap == -1L)
  695. panic("Cannot find bootmem map of size %ld\n", bootmap_size);
  696. /* don't touch min_low_pfn */
  697. bootmap_size = init_bootmem_node(NODE_DATA(0), bootmap >> PAGE_SHIFT,
  698. 0, end_pfn);
  699. e820_register_active_regions(0, start_pfn, end_pfn);
  700. free_bootmem_with_active_regions(0, end_pfn);
  701. early_res_to_bootmem(0, end_pfn<<PAGE_SHIFT);
  702. reserve_bootmem(bootmap, bootmap_size, BOOTMEM_DEFAULT);
  703. }
  704. void __init paging_init(void)
  705. {
  706. unsigned long max_zone_pfns[MAX_NR_ZONES];
  707. memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
  708. max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN;
  709. max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN;
  710. max_zone_pfns[ZONE_NORMAL] = max_pfn;
  711. memory_present(0, 0, max_pfn);
  712. sparse_init();
  713. free_area_init_nodes(max_zone_pfns);
  714. }
  715. #endif
  716. /*
  717. * Memory hotplug specific functions
  718. */
  719. #ifdef CONFIG_MEMORY_HOTPLUG
  720. /*
  721. * Memory is added always to NORMAL zone. This means you will never get
  722. * additional DMA/DMA32 memory.
  723. */
  724. int arch_add_memory(int nid, u64 start, u64 size)
  725. {
  726. struct pglist_data *pgdat = NODE_DATA(nid);
  727. struct zone *zone = pgdat->node_zones + ZONE_NORMAL;
  728. unsigned long last_mapped_pfn, start_pfn = start >> PAGE_SHIFT;
  729. unsigned long nr_pages = size >> PAGE_SHIFT;
  730. int ret;
  731. last_mapped_pfn = init_memory_mapping(start, start + size);
  732. if (last_mapped_pfn > max_pfn_mapped)
  733. max_pfn_mapped = last_mapped_pfn;
  734. ret = __add_pages(nid, zone, start_pfn, nr_pages);
  735. WARN_ON_ONCE(ret);
  736. return ret;
  737. }
  738. EXPORT_SYMBOL_GPL(arch_add_memory);
  739. #if !defined(CONFIG_ACPI_NUMA) && defined(CONFIG_NUMA)
  740. int memory_add_physaddr_to_nid(u64 start)
  741. {
  742. return 0;
  743. }
  744. EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
  745. #endif
  746. #endif /* CONFIG_MEMORY_HOTPLUG */
  747. /*
  748. * devmem_is_allowed() checks to see if /dev/mem access to a certain address
  749. * is valid. The argument is a physical page number.
  750. *
  751. *
  752. * On x86, access has to be given to the first megabyte of ram because that area
  753. * contains bios code and data regions used by X and dosemu and similar apps.
  754. * Access has to be given to non-kernel-ram areas as well, these contain the PCI
  755. * mmio resources as well as potential bios/acpi data regions.
  756. */
  757. int devmem_is_allowed(unsigned long pagenr)
  758. {
  759. if (pagenr <= 256)
  760. return 1;
  761. if (!page_is_ram(pagenr))
  762. return 1;
  763. return 0;
  764. }
  765. static struct kcore_list kcore_mem, kcore_vmalloc, kcore_kernel,
  766. kcore_modules, kcore_vsyscall;
  767. void __init mem_init(void)
  768. {
  769. long codesize, reservedpages, datasize, initsize;
  770. unsigned long absent_pages;
  771. pci_iommu_alloc();
  772. /* clear_bss() already clear the empty_zero_page */
  773. reservedpages = 0;
  774. /* this will put all low memory onto the freelists */
  775. #ifdef CONFIG_NUMA
  776. totalram_pages = numa_free_all_bootmem();
  777. #else
  778. totalram_pages = free_all_bootmem();
  779. #endif
  780. absent_pages = absent_pages_in_range(0, max_pfn);
  781. reservedpages = max_pfn - totalram_pages - absent_pages;
  782. after_bootmem = 1;
  783. codesize = (unsigned long) &_etext - (unsigned long) &_text;
  784. datasize = (unsigned long) &_edata - (unsigned long) &_etext;
  785. initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
  786. /* Register memory areas for /proc/kcore */
  787. kclist_add(&kcore_mem, __va(0), max_low_pfn << PAGE_SHIFT);
  788. kclist_add(&kcore_vmalloc, (void *)VMALLOC_START,
  789. VMALLOC_END-VMALLOC_START);
  790. kclist_add(&kcore_kernel, &_stext, _end - _stext);
  791. kclist_add(&kcore_modules, (void *)MODULES_VADDR, MODULES_LEN);
  792. kclist_add(&kcore_vsyscall, (void *)VSYSCALL_START,
  793. VSYSCALL_END - VSYSCALL_START);
  794. printk(KERN_INFO "Memory: %luk/%luk available (%ldk kernel code, "
  795. "%ldk absent, %ldk reserved, %ldk data, %ldk init)\n",
  796. (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
  797. max_pfn << (PAGE_SHIFT-10),
  798. codesize >> 10,
  799. absent_pages << (PAGE_SHIFT-10),
  800. reservedpages << (PAGE_SHIFT-10),
  801. datasize >> 10,
  802. initsize >> 10);
  803. }
  804. void free_init_pages(char *what, unsigned long begin, unsigned long end)
  805. {
  806. unsigned long addr = begin;
  807. if (addr >= end)
  808. return;
  809. /*
  810. * If debugging page accesses then do not free this memory but
  811. * mark them not present - any buggy init-section access will
  812. * create a kernel page fault:
  813. */
  814. #ifdef CONFIG_DEBUG_PAGEALLOC
  815. printk(KERN_INFO "debug: unmapping init memory %08lx..%08lx\n",
  816. begin, PAGE_ALIGN(end));
  817. set_memory_np(begin, (end - begin) >> PAGE_SHIFT);
  818. #else
  819. printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);
  820. for (; addr < end; addr += PAGE_SIZE) {
  821. ClearPageReserved(virt_to_page(addr));
  822. init_page_count(virt_to_page(addr));
  823. memset((void *)(addr & ~(PAGE_SIZE-1)),
  824. POISON_FREE_INITMEM, PAGE_SIZE);
  825. free_page(addr);
  826. totalram_pages++;
  827. }
  828. #endif
  829. }
  830. void free_initmem(void)
  831. {
  832. free_init_pages("unused kernel memory",
  833. (unsigned long)(&__init_begin),
  834. (unsigned long)(&__init_end));
  835. }
  836. #ifdef CONFIG_DEBUG_RODATA
  837. const int rodata_test_data = 0xC3;
  838. EXPORT_SYMBOL_GPL(rodata_test_data);
  839. void mark_rodata_ro(void)
  840. {
  841. unsigned long start = PFN_ALIGN(_stext), end = PFN_ALIGN(__end_rodata);
  842. unsigned long rodata_start =
  843. ((unsigned long)__start_rodata + PAGE_SIZE - 1) & PAGE_MASK;
  844. #ifdef CONFIG_DYNAMIC_FTRACE
  845. /* Dynamic tracing modifies the kernel text section */
  846. start = rodata_start;
  847. #endif
  848. printk(KERN_INFO "Write protecting the kernel read-only data: %luk\n",
  849. (end - start) >> 10);
  850. set_memory_ro(start, (end - start) >> PAGE_SHIFT);
  851. /*
  852. * The rodata section (but not the kernel text!) should also be
  853. * not-executable.
  854. */
  855. set_memory_nx(rodata_start, (end - rodata_start) >> PAGE_SHIFT);
  856. rodata_test();
  857. #ifdef CONFIG_CPA_DEBUG
  858. printk(KERN_INFO "Testing CPA: undo %lx-%lx\n", start, end);
  859. set_memory_rw(start, (end-start) >> PAGE_SHIFT);
  860. printk(KERN_INFO "Testing CPA: again\n");
  861. set_memory_ro(start, (end-start) >> PAGE_SHIFT);
  862. #endif
  863. }
  864. #endif
  865. #ifdef CONFIG_BLK_DEV_INITRD
  866. void free_initrd_mem(unsigned long start, unsigned long end)
  867. {
  868. free_init_pages("initrd memory", start, end);
  869. }
  870. #endif
  871. int __init reserve_bootmem_generic(unsigned long phys, unsigned long len,
  872. int flags)
  873. {
  874. #ifdef CONFIG_NUMA
  875. int nid, next_nid;
  876. int ret;
  877. #endif
  878. unsigned long pfn = phys >> PAGE_SHIFT;
  879. if (pfn >= max_pfn) {
  880. /*
  881. * This can happen with kdump kernels when accessing
  882. * firmware tables:
  883. */
  884. if (pfn < max_pfn_mapped)
  885. return -EFAULT;
  886. printk(KERN_ERR "reserve_bootmem: illegal reserve %lx %lu\n",
  887. phys, len);
  888. return -EFAULT;
  889. }
  890. /* Should check here against the e820 map to avoid double free */
  891. #ifdef CONFIG_NUMA
  892. nid = phys_to_nid(phys);
  893. next_nid = phys_to_nid(phys + len - 1);
  894. if (nid == next_nid)
  895. ret = reserve_bootmem_node(NODE_DATA(nid), phys, len, flags);
  896. else
  897. ret = reserve_bootmem(phys, len, flags);
  898. if (ret != 0)
  899. return ret;
  900. #else
  901. reserve_bootmem(phys, len, BOOTMEM_DEFAULT);
  902. #endif
  903. if (phys+len <= MAX_DMA_PFN*PAGE_SIZE) {
  904. dma_reserve += len / PAGE_SIZE;
  905. set_dma_reserve(dma_reserve);
  906. }
  907. return 0;
  908. }
  909. int kern_addr_valid(unsigned long addr)
  910. {
  911. unsigned long above = ((long)addr) >> __VIRTUAL_MASK_SHIFT;
  912. pgd_t *pgd;
  913. pud_t *pud;
  914. pmd_t *pmd;
  915. pte_t *pte;
  916. if (above != 0 && above != -1UL)
  917. return 0;
  918. pgd = pgd_offset_k(addr);
  919. if (pgd_none(*pgd))
  920. return 0;
  921. pud = pud_offset(pgd, addr);
  922. if (pud_none(*pud))
  923. return 0;
  924. pmd = pmd_offset(pud, addr);
  925. if (pmd_none(*pmd))
  926. return 0;
  927. if (pmd_large(*pmd))
  928. return pfn_valid(pmd_pfn(*pmd));
  929. pte = pte_offset_kernel(pmd, addr);
  930. if (pte_none(*pte))
  931. return 0;
  932. return pfn_valid(pte_pfn(*pte));
  933. }
  934. /*
  935. * A pseudo VMA to allow ptrace access for the vsyscall page. This only
  936. * covers the 64bit vsyscall page now. 32bit has a real VMA now and does
  937. * not need special handling anymore:
  938. */
  939. static struct vm_area_struct gate_vma = {
  940. .vm_start = VSYSCALL_START,
  941. .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
  942. .vm_page_prot = PAGE_READONLY_EXEC,
  943. .vm_flags = VM_READ | VM_EXEC
  944. };
  945. struct vm_area_struct *get_gate_vma(struct task_struct *tsk)
  946. {
  947. #ifdef CONFIG_IA32_EMULATION
  948. if (test_tsk_thread_flag(tsk, TIF_IA32))
  949. return NULL;
  950. #endif
  951. return &gate_vma;
  952. }
  953. int in_gate_area(struct task_struct *task, unsigned long addr)
  954. {
  955. struct vm_area_struct *vma = get_gate_vma(task);
  956. if (!vma)
  957. return 0;
  958. return (addr >= vma->vm_start) && (addr < vma->vm_end);
  959. }
  960. /*
  961. * Use this when you have no reliable task/vma, typically from interrupt
  962. * context. It is less reliable than using the task's vma and may give
  963. * false positives:
  964. */
  965. int in_gate_area_no_task(unsigned long addr)
  966. {
  967. return (addr >= VSYSCALL_START) && (addr < VSYSCALL_END);
  968. }
  969. const char *arch_vma_name(struct vm_area_struct *vma)
  970. {
  971. if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
  972. return "[vdso]";
  973. if (vma == &gate_vma)
  974. return "[vsyscall]";
  975. return NULL;
  976. }
  977. #ifdef CONFIG_SPARSEMEM_VMEMMAP
  978. /*
  979. * Initialise the sparsemem vmemmap using huge-pages at the PMD level.
  980. */
  981. static long __meminitdata addr_start, addr_end;
  982. static void __meminitdata *p_start, *p_end;
  983. static int __meminitdata node_start;
  984. int __meminit
  985. vmemmap_populate(struct page *start_page, unsigned long size, int node)
  986. {
  987. unsigned long addr = (unsigned long)start_page;
  988. unsigned long end = (unsigned long)(start_page + size);
  989. unsigned long next;
  990. pgd_t *pgd;
  991. pud_t *pud;
  992. pmd_t *pmd;
  993. for (; addr < end; addr = next) {
  994. void *p = NULL;
  995. pgd = vmemmap_pgd_populate(addr, node);
  996. if (!pgd)
  997. return -ENOMEM;
  998. pud = vmemmap_pud_populate(pgd, addr, node);
  999. if (!pud)
  1000. return -ENOMEM;
  1001. if (!cpu_has_pse) {
  1002. next = (addr + PAGE_SIZE) & PAGE_MASK;
  1003. pmd = vmemmap_pmd_populate(pud, addr, node);
  1004. if (!pmd)
  1005. return -ENOMEM;
  1006. p = vmemmap_pte_populate(pmd, addr, node);
  1007. if (!p)
  1008. return -ENOMEM;
  1009. addr_end = addr + PAGE_SIZE;
  1010. p_end = p + PAGE_SIZE;
  1011. } else {
  1012. next = pmd_addr_end(addr, end);
  1013. pmd = pmd_offset(pud, addr);
  1014. if (pmd_none(*pmd)) {
  1015. pte_t entry;
  1016. p = vmemmap_alloc_block(PMD_SIZE, node);
  1017. if (!p)
  1018. return -ENOMEM;
  1019. entry = pfn_pte(__pa(p) >> PAGE_SHIFT,
  1020. PAGE_KERNEL_LARGE);
  1021. set_pmd(pmd, __pmd(pte_val(entry)));
  1022. /* check to see if we have contiguous blocks */
  1023. if (p_end != p || node_start != node) {
  1024. if (p_start)
  1025. printk(KERN_DEBUG " [%lx-%lx] PMD -> [%p-%p] on node %d\n",
  1026. addr_start, addr_end-1, p_start, p_end-1, node_start);
  1027. addr_start = addr;
  1028. node_start = node;
  1029. p_start = p;
  1030. }
  1031. addr_end = addr + PMD_SIZE;
  1032. p_end = p + PMD_SIZE;
  1033. } else
  1034. vmemmap_verify((pte_t *)pmd, node, addr, next);
  1035. }
  1036. }
  1037. return 0;
  1038. }
  1039. void __meminit vmemmap_populate_print_last(void)
  1040. {
  1041. if (p_start) {
  1042. printk(KERN_DEBUG " [%lx-%lx] PMD -> [%p-%p] on node %d\n",
  1043. addr_start, addr_end-1, p_start, p_end-1, node_start);
  1044. p_start = NULL;
  1045. p_end = NULL;
  1046. node_start = 0;
  1047. }
  1048. }
  1049. #endif