init_64.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253
  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. #ifdef CONFIG_X86_32
  490. extra += PMD_SIZE;
  491. #endif
  492. ptes = (extra + PAGE_SIZE - 1) >> PAGE_SHIFT;
  493. } else
  494. ptes = (end + PAGE_SIZE - 1) >> PAGE_SHIFT;
  495. tables += roundup(ptes * sizeof(pte_t), PAGE_SIZE);
  496. #ifdef CONFIG_X86_32
  497. /* for fixmap */
  498. tables += roundup(__end_of_fixed_addresses * sizeof(pte_t), PAGE_SIZE);
  499. #endif
  500. /*
  501. * RED-PEN putting page tables only on node 0 could
  502. * cause a hotspot and fill up ZONE_DMA. The page tables
  503. * need roughly 0.5KB per GB.
  504. */
  505. #ifdef CONFIG_X86_32
  506. start = 0x7000;
  507. table_start = find_e820_area(start, max_pfn_mapped<<PAGE_SHIFT,
  508. tables, PAGE_SIZE);
  509. #else /* CONFIG_X86_64 */
  510. start = 0x8000;
  511. table_start = find_e820_area(start, end, tables, PAGE_SIZE);
  512. #endif
  513. if (table_start == -1UL)
  514. panic("Cannot find space for the kernel page tables");
  515. table_start >>= PAGE_SHIFT;
  516. table_end = table_start;
  517. table_top = table_start + (tables >> PAGE_SHIFT);
  518. printk(KERN_DEBUG "kernel direct mapping tables up to %lx @ %lx-%lx\n",
  519. end, table_start << PAGE_SHIFT, table_top << PAGE_SHIFT);
  520. }
  521. static void __init init_gbpages(void)
  522. {
  523. if (direct_gbpages && cpu_has_gbpages)
  524. printk(KERN_INFO "Using GB pages for direct mapping\n");
  525. else
  526. direct_gbpages = 0;
  527. }
  528. static unsigned long __meminit kernel_physical_mapping_init(unsigned long start,
  529. unsigned long end,
  530. unsigned long page_size_mask)
  531. {
  532. unsigned long next, last_map_addr = end;
  533. start = (unsigned long)__va(start);
  534. end = (unsigned long)__va(end);
  535. for (; start < end; start = next) {
  536. pgd_t *pgd = pgd_offset_k(start);
  537. unsigned long pud_phys;
  538. pud_t *pud;
  539. next = (start + PGDIR_SIZE) & PGDIR_MASK;
  540. if (next > end)
  541. next = end;
  542. if (pgd_val(*pgd)) {
  543. last_map_addr = phys_pud_update(pgd, __pa(start),
  544. __pa(end), page_size_mask);
  545. continue;
  546. }
  547. pud = alloc_low_page(&pud_phys);
  548. last_map_addr = phys_pud_init(pud, __pa(start), __pa(next),
  549. page_size_mask);
  550. unmap_low_page(pud);
  551. spin_lock(&init_mm.page_table_lock);
  552. pgd_populate(&init_mm, pgd, __va(pud_phys));
  553. spin_unlock(&init_mm.page_table_lock);
  554. }
  555. __flush_tlb_all();
  556. return last_map_addr;
  557. }
  558. struct map_range {
  559. unsigned long start;
  560. unsigned long end;
  561. unsigned page_size_mask;
  562. };
  563. #define NR_RANGE_MR 5
  564. static int save_mr(struct map_range *mr, int nr_range,
  565. unsigned long start_pfn, unsigned long end_pfn,
  566. unsigned long page_size_mask)
  567. {
  568. if (start_pfn < end_pfn) {
  569. if (nr_range >= NR_RANGE_MR)
  570. panic("run out of range for init_memory_mapping\n");
  571. mr[nr_range].start = start_pfn<<PAGE_SHIFT;
  572. mr[nr_range].end = end_pfn<<PAGE_SHIFT;
  573. mr[nr_range].page_size_mask = page_size_mask;
  574. nr_range++;
  575. }
  576. return nr_range;
  577. }
  578. /*
  579. * Setup the direct mapping of the physical memory at PAGE_OFFSET.
  580. * This runs before bootmem is initialized and gets pages directly from
  581. * the physical memory. To access them they are temporarily mapped.
  582. */
  583. unsigned long __init_refok init_memory_mapping(unsigned long start,
  584. unsigned long end)
  585. {
  586. unsigned long page_size_mask = 0;
  587. unsigned long start_pfn, end_pfn;
  588. unsigned long pos;
  589. unsigned long ret;
  590. struct map_range mr[NR_RANGE_MR];
  591. int nr_range, i;
  592. int use_pse, use_gbpages;
  593. printk(KERN_INFO "init_memory_mapping: %016lx-%016lx\n", start, end);
  594. if (!after_bootmem)
  595. init_gbpages();
  596. #ifdef CONFIG_DEBUG_PAGEALLOC
  597. /*
  598. * For CONFIG_DEBUG_PAGEALLOC, identity mapping will use small pages.
  599. * This will simplify cpa(), which otherwise needs to support splitting
  600. * large pages into small in interrupt context, etc.
  601. */
  602. use_pse = use_gbpages = 0;
  603. #else
  604. use_pse = cpu_has_pse;
  605. use_gbpages = direct_gbpages;
  606. #endif
  607. #ifdef CONFIG_X86_32
  608. #ifdef CONFIG_X86_PAE
  609. set_nx();
  610. if (nx_enabled)
  611. printk(KERN_INFO "NX (Execute Disable) protection: active\n");
  612. #endif
  613. /* Enable PSE if available */
  614. if (cpu_has_pse)
  615. set_in_cr4(X86_CR4_PSE);
  616. /* Enable PGE if available */
  617. if (cpu_has_pge) {
  618. set_in_cr4(X86_CR4_PGE);
  619. __supported_pte_mask |= _PAGE_GLOBAL;
  620. }
  621. #endif
  622. if (use_gbpages)
  623. page_size_mask |= 1 << PG_LEVEL_1G;
  624. if (use_pse)
  625. page_size_mask |= 1 << PG_LEVEL_2M;
  626. memset(mr, 0, sizeof(mr));
  627. nr_range = 0;
  628. /* head if not big page alignment ? */
  629. start_pfn = start >> PAGE_SHIFT;
  630. pos = start_pfn << PAGE_SHIFT;
  631. #ifdef CONFIG_X86_32
  632. /*
  633. * Don't use a large page for the first 2/4MB of memory
  634. * because there are often fixed size MTRRs in there
  635. * and overlapping MTRRs into large pages can cause
  636. * slowdowns.
  637. */
  638. if (pos == 0)
  639. end_pfn = 1<<(PMD_SHIFT - PAGE_SHIFT);
  640. else
  641. end_pfn = ((pos + (PMD_SIZE - 1))>>PMD_SHIFT)
  642. << (PMD_SHIFT - PAGE_SHIFT);
  643. #else /* CONFIG_X86_64 */
  644. end_pfn = ((pos + (PMD_SIZE - 1)) >> PMD_SHIFT)
  645. << (PMD_SHIFT - PAGE_SHIFT);
  646. #endif
  647. if (end_pfn > (end >> PAGE_SHIFT))
  648. end_pfn = end >> PAGE_SHIFT;
  649. if (start_pfn < end_pfn) {
  650. nr_range = save_mr(mr, nr_range, start_pfn, end_pfn, 0);
  651. pos = end_pfn << PAGE_SHIFT;
  652. }
  653. /* big page (2M) range */
  654. start_pfn = ((pos + (PMD_SIZE - 1))>>PMD_SHIFT)
  655. << (PMD_SHIFT - PAGE_SHIFT);
  656. #ifdef CONFIG_X86_32
  657. end_pfn = (end>>PMD_SHIFT) << (PMD_SHIFT - PAGE_SHIFT);
  658. #else /* CONFIG_X86_64 */
  659. end_pfn = ((pos + (PUD_SIZE - 1))>>PUD_SHIFT)
  660. << (PUD_SHIFT - PAGE_SHIFT);
  661. if (end_pfn > ((end>>PMD_SHIFT)<<(PMD_SHIFT - PAGE_SHIFT)))
  662. end_pfn = ((end>>PMD_SHIFT)<<(PMD_SHIFT - PAGE_SHIFT));
  663. #endif
  664. if (start_pfn < end_pfn) {
  665. nr_range = save_mr(mr, nr_range, start_pfn, end_pfn,
  666. page_size_mask & (1<<PG_LEVEL_2M));
  667. pos = end_pfn << PAGE_SHIFT;
  668. }
  669. #ifdef CONFIG_X86_64
  670. /* big page (1G) range */
  671. start_pfn = ((pos + (PUD_SIZE - 1))>>PUD_SHIFT)
  672. << (PUD_SHIFT - PAGE_SHIFT);
  673. end_pfn = (end >> PUD_SHIFT) << (PUD_SHIFT - PAGE_SHIFT);
  674. if (start_pfn < end_pfn) {
  675. nr_range = save_mr(mr, nr_range, start_pfn, end_pfn,
  676. page_size_mask &
  677. ((1<<PG_LEVEL_2M)|(1<<PG_LEVEL_1G)));
  678. pos = end_pfn << PAGE_SHIFT;
  679. }
  680. /* tail is not big page (1G) alignment */
  681. start_pfn = ((pos + (PMD_SIZE - 1))>>PMD_SHIFT)
  682. << (PMD_SHIFT - PAGE_SHIFT);
  683. end_pfn = (end >> PMD_SHIFT) << (PMD_SHIFT - PAGE_SHIFT);
  684. if (start_pfn < end_pfn) {
  685. nr_range = save_mr(mr, nr_range, start_pfn, end_pfn,
  686. page_size_mask & (1<<PG_LEVEL_2M));
  687. pos = end_pfn << PAGE_SHIFT;
  688. }
  689. #endif
  690. /* tail is not big page (2M) alignment */
  691. start_pfn = pos>>PAGE_SHIFT;
  692. end_pfn = end>>PAGE_SHIFT;
  693. nr_range = save_mr(mr, nr_range, start_pfn, end_pfn, 0);
  694. /* try to merge same page size and continuous */
  695. for (i = 0; nr_range > 1 && i < nr_range - 1; i++) {
  696. unsigned long old_start;
  697. if (mr[i].end != mr[i+1].start ||
  698. mr[i].page_size_mask != mr[i+1].page_size_mask)
  699. continue;
  700. /* move it */
  701. old_start = mr[i].start;
  702. memmove(&mr[i], &mr[i+1],
  703. (nr_range - 1 - i) * sizeof(struct map_range));
  704. mr[i--].start = old_start;
  705. nr_range--;
  706. }
  707. for (i = 0; i < nr_range; i++)
  708. printk(KERN_DEBUG " %010lx - %010lx page %s\n",
  709. mr[i].start, mr[i].end,
  710. (mr[i].page_size_mask & (1<<PG_LEVEL_1G))?"1G":(
  711. (mr[i].page_size_mask & (1<<PG_LEVEL_2M))?"2M":"4k"));
  712. /*
  713. * Find space for the kernel direct mapping tables.
  714. *
  715. * Later we should allocate these tables in the local node of the
  716. * memory mapped. Unfortunately this is done currently before the
  717. * nodes are discovered.
  718. */
  719. if (!after_bootmem)
  720. find_early_table_space(end, use_pse, use_gbpages);
  721. #ifdef CONFIG_X86_32
  722. for (i = 0; i < nr_range; i++)
  723. kernel_physical_mapping_init(
  724. mr[i].start >> PAGE_SHIFT,
  725. mr[i].end >> PAGE_SHIFT,
  726. mr[i].page_size_mask == (1<<PG_LEVEL_2M));
  727. ret = end;
  728. #else /* CONFIG_X86_64 */
  729. for (i = 0; i < nr_range; i++)
  730. ret = kernel_physical_mapping_init(mr[i].start, mr[i].end,
  731. mr[i].page_size_mask);
  732. #endif
  733. #ifdef CONFIG_X86_32
  734. early_ioremap_page_table_range_init();
  735. load_cr3(swapper_pg_dir);
  736. #endif
  737. #ifdef CONFIG_X86_64
  738. if (!after_bootmem)
  739. mmu_cr4_features = read_cr4();
  740. #endif
  741. __flush_tlb_all();
  742. if (!after_bootmem && table_end > table_start)
  743. reserve_early(table_start << PAGE_SHIFT,
  744. table_end << PAGE_SHIFT, "PGTABLE");
  745. if (!after_bootmem)
  746. early_memtest(start, end);
  747. return ret >> PAGE_SHIFT;
  748. }
  749. #ifndef CONFIG_NUMA
  750. void __init initmem_init(unsigned long start_pfn, unsigned long end_pfn)
  751. {
  752. unsigned long bootmap_size, bootmap;
  753. bootmap_size = bootmem_bootmap_pages(end_pfn)<<PAGE_SHIFT;
  754. bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT, bootmap_size,
  755. PAGE_SIZE);
  756. if (bootmap == -1L)
  757. panic("Cannot find bootmem map of size %ld\n", bootmap_size);
  758. /* don't touch min_low_pfn */
  759. bootmap_size = init_bootmem_node(NODE_DATA(0), bootmap >> PAGE_SHIFT,
  760. 0, end_pfn);
  761. e820_register_active_regions(0, start_pfn, end_pfn);
  762. free_bootmem_with_active_regions(0, end_pfn);
  763. early_res_to_bootmem(0, end_pfn<<PAGE_SHIFT);
  764. reserve_bootmem(bootmap, bootmap_size, BOOTMEM_DEFAULT);
  765. }
  766. void __init paging_init(void)
  767. {
  768. unsigned long max_zone_pfns[MAX_NR_ZONES];
  769. memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
  770. max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN;
  771. max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN;
  772. max_zone_pfns[ZONE_NORMAL] = max_pfn;
  773. memory_present(0, 0, max_pfn);
  774. sparse_init();
  775. free_area_init_nodes(max_zone_pfns);
  776. }
  777. #endif
  778. /*
  779. * Memory hotplug specific functions
  780. */
  781. #ifdef CONFIG_MEMORY_HOTPLUG
  782. /*
  783. * Memory is added always to NORMAL zone. This means you will never get
  784. * additional DMA/DMA32 memory.
  785. */
  786. int arch_add_memory(int nid, u64 start, u64 size)
  787. {
  788. struct pglist_data *pgdat = NODE_DATA(nid);
  789. struct zone *zone = pgdat->node_zones + ZONE_NORMAL;
  790. unsigned long last_mapped_pfn, start_pfn = start >> PAGE_SHIFT;
  791. unsigned long nr_pages = size >> PAGE_SHIFT;
  792. int ret;
  793. last_mapped_pfn = init_memory_mapping(start, start + size);
  794. if (last_mapped_pfn > max_pfn_mapped)
  795. max_pfn_mapped = last_mapped_pfn;
  796. ret = __add_pages(nid, zone, start_pfn, nr_pages);
  797. WARN_ON_ONCE(ret);
  798. return ret;
  799. }
  800. EXPORT_SYMBOL_GPL(arch_add_memory);
  801. #if !defined(CONFIG_ACPI_NUMA) && defined(CONFIG_NUMA)
  802. int memory_add_physaddr_to_nid(u64 start)
  803. {
  804. return 0;
  805. }
  806. EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
  807. #endif
  808. #endif /* CONFIG_MEMORY_HOTPLUG */
  809. static struct kcore_list kcore_mem, kcore_vmalloc, kcore_kernel,
  810. kcore_modules, kcore_vsyscall;
  811. void __init mem_init(void)
  812. {
  813. long codesize, reservedpages, datasize, initsize;
  814. unsigned long absent_pages;
  815. pci_iommu_alloc();
  816. /* clear_bss() already clear the empty_zero_page */
  817. reservedpages = 0;
  818. /* this will put all low memory onto the freelists */
  819. #ifdef CONFIG_NUMA
  820. totalram_pages = numa_free_all_bootmem();
  821. #else
  822. totalram_pages = free_all_bootmem();
  823. #endif
  824. absent_pages = absent_pages_in_range(0, max_pfn);
  825. reservedpages = max_pfn - totalram_pages - absent_pages;
  826. after_bootmem = 1;
  827. codesize = (unsigned long) &_etext - (unsigned long) &_text;
  828. datasize = (unsigned long) &_edata - (unsigned long) &_etext;
  829. initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
  830. /* Register memory areas for /proc/kcore */
  831. kclist_add(&kcore_mem, __va(0), max_low_pfn << PAGE_SHIFT);
  832. kclist_add(&kcore_vmalloc, (void *)VMALLOC_START,
  833. VMALLOC_END-VMALLOC_START);
  834. kclist_add(&kcore_kernel, &_stext, _end - _stext);
  835. kclist_add(&kcore_modules, (void *)MODULES_VADDR, MODULES_LEN);
  836. kclist_add(&kcore_vsyscall, (void *)VSYSCALL_START,
  837. VSYSCALL_END - VSYSCALL_START);
  838. printk(KERN_INFO "Memory: %luk/%luk available (%ldk kernel code, "
  839. "%ldk absent, %ldk reserved, %ldk data, %ldk init)\n",
  840. (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
  841. max_pfn << (PAGE_SHIFT-10),
  842. codesize >> 10,
  843. absent_pages << (PAGE_SHIFT-10),
  844. reservedpages << (PAGE_SHIFT-10),
  845. datasize >> 10,
  846. initsize >> 10);
  847. }
  848. #ifdef CONFIG_DEBUG_RODATA
  849. const int rodata_test_data = 0xC3;
  850. EXPORT_SYMBOL_GPL(rodata_test_data);
  851. void mark_rodata_ro(void)
  852. {
  853. unsigned long start = PFN_ALIGN(_stext), end = PFN_ALIGN(__end_rodata);
  854. unsigned long rodata_start =
  855. ((unsigned long)__start_rodata + PAGE_SIZE - 1) & PAGE_MASK;
  856. #ifdef CONFIG_DYNAMIC_FTRACE
  857. /* Dynamic tracing modifies the kernel text section */
  858. start = rodata_start;
  859. #endif
  860. printk(KERN_INFO "Write protecting the kernel read-only data: %luk\n",
  861. (end - start) >> 10);
  862. set_memory_ro(start, (end - start) >> PAGE_SHIFT);
  863. /*
  864. * The rodata section (but not the kernel text!) should also be
  865. * not-executable.
  866. */
  867. set_memory_nx(rodata_start, (end - rodata_start) >> PAGE_SHIFT);
  868. rodata_test();
  869. #ifdef CONFIG_CPA_DEBUG
  870. printk(KERN_INFO "Testing CPA: undo %lx-%lx\n", start, end);
  871. set_memory_rw(start, (end-start) >> PAGE_SHIFT);
  872. printk(KERN_INFO "Testing CPA: again\n");
  873. set_memory_ro(start, (end-start) >> PAGE_SHIFT);
  874. #endif
  875. }
  876. #endif
  877. int __init reserve_bootmem_generic(unsigned long phys, unsigned long len,
  878. int flags)
  879. {
  880. #ifdef CONFIG_NUMA
  881. int nid, next_nid;
  882. int ret;
  883. #endif
  884. unsigned long pfn = phys >> PAGE_SHIFT;
  885. if (pfn >= max_pfn) {
  886. /*
  887. * This can happen with kdump kernels when accessing
  888. * firmware tables:
  889. */
  890. if (pfn < max_pfn_mapped)
  891. return -EFAULT;
  892. printk(KERN_ERR "reserve_bootmem: illegal reserve %lx %lu\n",
  893. phys, len);
  894. return -EFAULT;
  895. }
  896. /* Should check here against the e820 map to avoid double free */
  897. #ifdef CONFIG_NUMA
  898. nid = phys_to_nid(phys);
  899. next_nid = phys_to_nid(phys + len - 1);
  900. if (nid == next_nid)
  901. ret = reserve_bootmem_node(NODE_DATA(nid), phys, len, flags);
  902. else
  903. ret = reserve_bootmem(phys, len, flags);
  904. if (ret != 0)
  905. return ret;
  906. #else
  907. reserve_bootmem(phys, len, BOOTMEM_DEFAULT);
  908. #endif
  909. if (phys+len <= MAX_DMA_PFN*PAGE_SIZE) {
  910. dma_reserve += len / PAGE_SIZE;
  911. set_dma_reserve(dma_reserve);
  912. }
  913. return 0;
  914. }
  915. int kern_addr_valid(unsigned long addr)
  916. {
  917. unsigned long above = ((long)addr) >> __VIRTUAL_MASK_SHIFT;
  918. pgd_t *pgd;
  919. pud_t *pud;
  920. pmd_t *pmd;
  921. pte_t *pte;
  922. if (above != 0 && above != -1UL)
  923. return 0;
  924. pgd = pgd_offset_k(addr);
  925. if (pgd_none(*pgd))
  926. return 0;
  927. pud = pud_offset(pgd, addr);
  928. if (pud_none(*pud))
  929. return 0;
  930. pmd = pmd_offset(pud, addr);
  931. if (pmd_none(*pmd))
  932. return 0;
  933. if (pmd_large(*pmd))
  934. return pfn_valid(pmd_pfn(*pmd));
  935. pte = pte_offset_kernel(pmd, addr);
  936. if (pte_none(*pte))
  937. return 0;
  938. return pfn_valid(pte_pfn(*pte));
  939. }
  940. /*
  941. * A pseudo VMA to allow ptrace access for the vsyscall page. This only
  942. * covers the 64bit vsyscall page now. 32bit has a real VMA now and does
  943. * not need special handling anymore:
  944. */
  945. static struct vm_area_struct gate_vma = {
  946. .vm_start = VSYSCALL_START,
  947. .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
  948. .vm_page_prot = PAGE_READONLY_EXEC,
  949. .vm_flags = VM_READ | VM_EXEC
  950. };
  951. struct vm_area_struct *get_gate_vma(struct task_struct *tsk)
  952. {
  953. #ifdef CONFIG_IA32_EMULATION
  954. if (test_tsk_thread_flag(tsk, TIF_IA32))
  955. return NULL;
  956. #endif
  957. return &gate_vma;
  958. }
  959. int in_gate_area(struct task_struct *task, unsigned long addr)
  960. {
  961. struct vm_area_struct *vma = get_gate_vma(task);
  962. if (!vma)
  963. return 0;
  964. return (addr >= vma->vm_start) && (addr < vma->vm_end);
  965. }
  966. /*
  967. * Use this when you have no reliable task/vma, typically from interrupt
  968. * context. It is less reliable than using the task's vma and may give
  969. * false positives:
  970. */
  971. int in_gate_area_no_task(unsigned long addr)
  972. {
  973. return (addr >= VSYSCALL_START) && (addr < VSYSCALL_END);
  974. }
  975. const char *arch_vma_name(struct vm_area_struct *vma)
  976. {
  977. if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
  978. return "[vdso]";
  979. if (vma == &gate_vma)
  980. return "[vsyscall]";
  981. return NULL;
  982. }
  983. #ifdef CONFIG_SPARSEMEM_VMEMMAP
  984. /*
  985. * Initialise the sparsemem vmemmap using huge-pages at the PMD level.
  986. */
  987. static long __meminitdata addr_start, addr_end;
  988. static void __meminitdata *p_start, *p_end;
  989. static int __meminitdata node_start;
  990. int __meminit
  991. vmemmap_populate(struct page *start_page, unsigned long size, int node)
  992. {
  993. unsigned long addr = (unsigned long)start_page;
  994. unsigned long end = (unsigned long)(start_page + size);
  995. unsigned long next;
  996. pgd_t *pgd;
  997. pud_t *pud;
  998. pmd_t *pmd;
  999. for (; addr < end; addr = next) {
  1000. void *p = NULL;
  1001. pgd = vmemmap_pgd_populate(addr, node);
  1002. if (!pgd)
  1003. return -ENOMEM;
  1004. pud = vmemmap_pud_populate(pgd, addr, node);
  1005. if (!pud)
  1006. return -ENOMEM;
  1007. if (!cpu_has_pse) {
  1008. next = (addr + PAGE_SIZE) & PAGE_MASK;
  1009. pmd = vmemmap_pmd_populate(pud, addr, node);
  1010. if (!pmd)
  1011. return -ENOMEM;
  1012. p = vmemmap_pte_populate(pmd, addr, node);
  1013. if (!p)
  1014. return -ENOMEM;
  1015. addr_end = addr + PAGE_SIZE;
  1016. p_end = p + PAGE_SIZE;
  1017. } else {
  1018. next = pmd_addr_end(addr, end);
  1019. pmd = pmd_offset(pud, addr);
  1020. if (pmd_none(*pmd)) {
  1021. pte_t entry;
  1022. p = vmemmap_alloc_block(PMD_SIZE, node);
  1023. if (!p)
  1024. return -ENOMEM;
  1025. entry = pfn_pte(__pa(p) >> PAGE_SHIFT,
  1026. PAGE_KERNEL_LARGE);
  1027. set_pmd(pmd, __pmd(pte_val(entry)));
  1028. /* check to see if we have contiguous blocks */
  1029. if (p_end != p || node_start != node) {
  1030. if (p_start)
  1031. printk(KERN_DEBUG " [%lx-%lx] PMD -> [%p-%p] on node %d\n",
  1032. addr_start, addr_end-1, p_start, p_end-1, node_start);
  1033. addr_start = addr;
  1034. node_start = node;
  1035. p_start = p;
  1036. }
  1037. addr_end = addr + PMD_SIZE;
  1038. p_end = p + PMD_SIZE;
  1039. } else
  1040. vmemmap_verify((pte_t *)pmd, node, addr, next);
  1041. }
  1042. }
  1043. return 0;
  1044. }
  1045. void __meminit vmemmap_populate_print_last(void)
  1046. {
  1047. if (p_start) {
  1048. printk(KERN_DEBUG " [%lx-%lx] PMD -> [%p-%p] on node %d\n",
  1049. addr_start, addr_end-1, p_start, p_end-1, node_start);
  1050. p_start = NULL;
  1051. p_end = NULL;
  1052. node_start = 0;
  1053. }
  1054. }
  1055. #endif