init_32.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214
  1. /*
  2. *
  3. * Copyright (C) 1995 Linus Torvalds
  4. *
  5. * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
  6. */
  7. #include <linux/module.h>
  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/hugetlb.h>
  18. #include <linux/swap.h>
  19. #include <linux/smp.h>
  20. #include <linux/init.h>
  21. #include <linux/highmem.h>
  22. #include <linux/pagemap.h>
  23. #include <linux/pci.h>
  24. #include <linux/pfn.h>
  25. #include <linux/poison.h>
  26. #include <linux/bootmem.h>
  27. #include <linux/slab.h>
  28. #include <linux/proc_fs.h>
  29. #include <linux/memory_hotplug.h>
  30. #include <linux/initrd.h>
  31. #include <linux/cpumask.h>
  32. #include <asm/asm.h>
  33. #include <asm/bios_ebda.h>
  34. #include <asm/processor.h>
  35. #include <asm/system.h>
  36. #include <asm/uaccess.h>
  37. #include <asm/pgtable.h>
  38. #include <asm/dma.h>
  39. #include <asm/fixmap.h>
  40. #include <asm/e820.h>
  41. #include <asm/apic.h>
  42. #include <asm/bugs.h>
  43. #include <asm/tlb.h>
  44. #include <asm/tlbflush.h>
  45. #include <asm/pgalloc.h>
  46. #include <asm/sections.h>
  47. #include <asm/paravirt.h>
  48. #include <asm/setup.h>
  49. #include <asm/cacheflush.h>
  50. unsigned long max_low_pfn_mapped;
  51. unsigned long max_pfn_mapped;
  52. DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
  53. unsigned long highstart_pfn, highend_pfn;
  54. static noinline int do_test_wp_bit(void);
  55. static unsigned long __initdata table_start;
  56. static unsigned long __meminitdata table_end;
  57. static unsigned long __meminitdata table_top;
  58. static int __initdata after_init_bootmem;
  59. static __init void *alloc_low_page(void)
  60. {
  61. unsigned long pfn = table_end++;
  62. void *adr;
  63. if (pfn >= table_top)
  64. panic("alloc_low_page: ran out of memory");
  65. adr = __va(pfn * PAGE_SIZE);
  66. memset(adr, 0, PAGE_SIZE);
  67. return adr;
  68. }
  69. /*
  70. * Creates a middle page table and puts a pointer to it in the
  71. * given global directory entry. This only returns the gd entry
  72. * in non-PAE compilation mode, since the middle layer is folded.
  73. */
  74. static pmd_t * __init one_md_table_init(pgd_t *pgd)
  75. {
  76. pud_t *pud;
  77. pmd_t *pmd_table;
  78. #ifdef CONFIG_X86_PAE
  79. if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
  80. if (after_init_bootmem)
  81. pmd_table = (pmd_t *)alloc_bootmem_low_pages(PAGE_SIZE);
  82. else
  83. pmd_table = (pmd_t *)alloc_low_page();
  84. paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
  85. set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
  86. pud = pud_offset(pgd, 0);
  87. BUG_ON(pmd_table != pmd_offset(pud, 0));
  88. return pmd_table;
  89. }
  90. #endif
  91. pud = pud_offset(pgd, 0);
  92. pmd_table = pmd_offset(pud, 0);
  93. return pmd_table;
  94. }
  95. /*
  96. * Create a page table and place a pointer to it in a middle page
  97. * directory entry:
  98. */
  99. static pte_t * __init one_page_table_init(pmd_t *pmd)
  100. {
  101. if (!(pmd_val(*pmd) & _PAGE_PRESENT)) {
  102. pte_t *page_table = NULL;
  103. if (after_init_bootmem) {
  104. #ifdef CONFIG_DEBUG_PAGEALLOC
  105. page_table = (pte_t *) alloc_bootmem_pages(PAGE_SIZE);
  106. #endif
  107. if (!page_table)
  108. page_table =
  109. (pte_t *)alloc_bootmem_low_pages(PAGE_SIZE);
  110. } else
  111. page_table = (pte_t *)alloc_low_page();
  112. paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
  113. set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
  114. BUG_ON(page_table != pte_offset_kernel(pmd, 0));
  115. }
  116. return pte_offset_kernel(pmd, 0);
  117. }
  118. static pte_t *__init page_table_kmap_check(pte_t *pte, pmd_t *pmd,
  119. unsigned long vaddr, pte_t *lastpte)
  120. {
  121. #ifdef CONFIG_HIGHMEM
  122. /*
  123. * Something (early fixmap) may already have put a pte
  124. * page here, which causes the page table allocation
  125. * to become nonlinear. Attempt to fix it, and if it
  126. * is still nonlinear then we have to bug.
  127. */
  128. int pmd_idx_kmap_begin = fix_to_virt(FIX_KMAP_END) >> PMD_SHIFT;
  129. int pmd_idx_kmap_end = fix_to_virt(FIX_KMAP_BEGIN) >> PMD_SHIFT;
  130. if (pmd_idx_kmap_begin != pmd_idx_kmap_end
  131. && (vaddr >> PMD_SHIFT) >= pmd_idx_kmap_begin
  132. && (vaddr >> PMD_SHIFT) <= pmd_idx_kmap_end
  133. && ((__pa(pte) >> PAGE_SHIFT) < table_start
  134. || (__pa(pte) >> PAGE_SHIFT) >= table_end)) {
  135. pte_t *newpte;
  136. int i;
  137. BUG_ON(after_init_bootmem);
  138. newpte = alloc_low_page();
  139. for (i = 0; i < PTRS_PER_PTE; i++)
  140. set_pte(newpte + i, pte[i]);
  141. paravirt_alloc_pte(&init_mm, __pa(newpte) >> PAGE_SHIFT);
  142. set_pmd(pmd, __pmd(__pa(newpte)|_PAGE_TABLE));
  143. BUG_ON(newpte != pte_offset_kernel(pmd, 0));
  144. __flush_tlb_all();
  145. paravirt_release_pte(__pa(pte) >> PAGE_SHIFT);
  146. pte = newpte;
  147. }
  148. BUG_ON(vaddr < fix_to_virt(FIX_KMAP_BEGIN - 1)
  149. && vaddr > fix_to_virt(FIX_KMAP_END)
  150. && lastpte && lastpte + PTRS_PER_PTE != pte);
  151. #endif
  152. return pte;
  153. }
  154. /*
  155. * This function initializes a certain range of kernel virtual memory
  156. * with new bootmem page tables, everywhere page tables are missing in
  157. * the given range.
  158. *
  159. * NOTE: The pagetables are allocated contiguous on the physical space
  160. * so we can cache the place of the first one and move around without
  161. * checking the pgd every time.
  162. */
  163. static void __init
  164. page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
  165. {
  166. int pgd_idx, pmd_idx;
  167. unsigned long vaddr;
  168. pgd_t *pgd;
  169. pmd_t *pmd;
  170. pte_t *pte = NULL;
  171. vaddr = start;
  172. pgd_idx = pgd_index(vaddr);
  173. pmd_idx = pmd_index(vaddr);
  174. pgd = pgd_base + pgd_idx;
  175. for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
  176. pmd = one_md_table_init(pgd);
  177. pmd = pmd + pmd_index(vaddr);
  178. for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
  179. pmd++, pmd_idx++) {
  180. pte = page_table_kmap_check(one_page_table_init(pmd),
  181. pmd, vaddr, pte);
  182. vaddr += PMD_SIZE;
  183. }
  184. pmd_idx = 0;
  185. }
  186. }
  187. static inline int is_kernel_text(unsigned long addr)
  188. {
  189. if (addr >= PAGE_OFFSET && addr <= (unsigned long)__init_end)
  190. return 1;
  191. return 0;
  192. }
  193. /*
  194. * This maps the physical memory to kernel virtual address space, a total
  195. * of max_low_pfn pages, by creating page tables starting from address
  196. * PAGE_OFFSET:
  197. */
  198. static void __init kernel_physical_mapping_init(pgd_t *pgd_base,
  199. unsigned long start_pfn,
  200. unsigned long end_pfn,
  201. int use_pse)
  202. {
  203. int pgd_idx, pmd_idx, pte_ofs;
  204. unsigned long pfn;
  205. pgd_t *pgd;
  206. pmd_t *pmd;
  207. pte_t *pte;
  208. unsigned pages_2m, pages_4k;
  209. int mapping_iter;
  210. /*
  211. * First iteration will setup identity mapping using large/small pages
  212. * based on use_pse, with other attributes same as set by
  213. * the early code in head_32.S
  214. *
  215. * Second iteration will setup the appropriate attributes (NX, GLOBAL..)
  216. * as desired for the kernel identity mapping.
  217. *
  218. * This two pass mechanism conforms to the TLB app note which says:
  219. *
  220. * "Software should not write to a paging-structure entry in a way
  221. * that would change, for any linear address, both the page size
  222. * and either the page frame or attributes."
  223. */
  224. mapping_iter = 1;
  225. if (!cpu_has_pse)
  226. use_pse = 0;
  227. repeat:
  228. pages_2m = pages_4k = 0;
  229. pfn = start_pfn;
  230. pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
  231. pgd = pgd_base + pgd_idx;
  232. for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
  233. pmd = one_md_table_init(pgd);
  234. if (pfn >= end_pfn)
  235. continue;
  236. #ifdef CONFIG_X86_PAE
  237. pmd_idx = pmd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
  238. pmd += pmd_idx;
  239. #else
  240. pmd_idx = 0;
  241. #endif
  242. for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
  243. pmd++, pmd_idx++) {
  244. unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
  245. /*
  246. * Map with big pages if possible, otherwise
  247. * create normal page tables:
  248. */
  249. if (use_pse) {
  250. unsigned int addr2;
  251. pgprot_t prot = PAGE_KERNEL_LARGE;
  252. /*
  253. * first pass will use the same initial
  254. * identity mapping attribute + _PAGE_PSE.
  255. */
  256. pgprot_t init_prot =
  257. __pgprot(PTE_IDENT_ATTR |
  258. _PAGE_PSE);
  259. addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
  260. PAGE_OFFSET + PAGE_SIZE-1;
  261. if (is_kernel_text(addr) ||
  262. is_kernel_text(addr2))
  263. prot = PAGE_KERNEL_LARGE_EXEC;
  264. pages_2m++;
  265. if (mapping_iter == 1)
  266. set_pmd(pmd, pfn_pmd(pfn, init_prot));
  267. else
  268. set_pmd(pmd, pfn_pmd(pfn, prot));
  269. pfn += PTRS_PER_PTE;
  270. continue;
  271. }
  272. pte = one_page_table_init(pmd);
  273. pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
  274. pte += pte_ofs;
  275. for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
  276. pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
  277. pgprot_t prot = PAGE_KERNEL;
  278. /*
  279. * first pass will use the same initial
  280. * identity mapping attribute.
  281. */
  282. pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
  283. if (is_kernel_text(addr))
  284. prot = PAGE_KERNEL_EXEC;
  285. pages_4k++;
  286. if (mapping_iter == 1)
  287. set_pte(pte, pfn_pte(pfn, init_prot));
  288. else
  289. set_pte(pte, pfn_pte(pfn, prot));
  290. }
  291. }
  292. }
  293. if (mapping_iter == 1) {
  294. /*
  295. * update direct mapping page count only in the first
  296. * iteration.
  297. */
  298. update_page_count(PG_LEVEL_2M, pages_2m);
  299. update_page_count(PG_LEVEL_4K, pages_4k);
  300. /*
  301. * local global flush tlb, which will flush the previous
  302. * mappings present in both small and large page TLB's.
  303. */
  304. __flush_tlb_all();
  305. /*
  306. * Second iteration will set the actual desired PTE attributes.
  307. */
  308. mapping_iter = 2;
  309. goto repeat;
  310. }
  311. }
  312. /*
  313. * devmem_is_allowed() checks to see if /dev/mem access to a certain address
  314. * is valid. The argument is a physical page number.
  315. *
  316. *
  317. * On x86, access has to be given to the first megabyte of ram because that area
  318. * contains bios code and data regions used by X and dosemu and similar apps.
  319. * Access has to be given to non-kernel-ram areas as well, these contain the PCI
  320. * mmio resources as well as potential bios/acpi data regions.
  321. */
  322. int devmem_is_allowed(unsigned long pagenr)
  323. {
  324. if (pagenr <= 256)
  325. return 1;
  326. if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
  327. return 0;
  328. if (!page_is_ram(pagenr))
  329. return 1;
  330. return 0;
  331. }
  332. pte_t *kmap_pte;
  333. pgprot_t kmap_prot;
  334. static inline pte_t *kmap_get_fixmap_pte(unsigned long vaddr)
  335. {
  336. return pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k(vaddr),
  337. vaddr), vaddr), vaddr);
  338. }
  339. static void __init kmap_init(void)
  340. {
  341. unsigned long kmap_vstart;
  342. /*
  343. * Cache the first kmap pte:
  344. */
  345. kmap_vstart = __fix_to_virt(FIX_KMAP_BEGIN);
  346. kmap_pte = kmap_get_fixmap_pte(kmap_vstart);
  347. kmap_prot = PAGE_KERNEL;
  348. }
  349. #ifdef CONFIG_HIGHMEM
  350. static void __init permanent_kmaps_init(pgd_t *pgd_base)
  351. {
  352. unsigned long vaddr;
  353. pgd_t *pgd;
  354. pud_t *pud;
  355. pmd_t *pmd;
  356. pte_t *pte;
  357. vaddr = PKMAP_BASE;
  358. page_table_range_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, pgd_base);
  359. pgd = swapper_pg_dir + pgd_index(vaddr);
  360. pud = pud_offset(pgd, vaddr);
  361. pmd = pmd_offset(pud, vaddr);
  362. pte = pte_offset_kernel(pmd, vaddr);
  363. pkmap_page_table = pte;
  364. }
  365. static void __init add_one_highpage_init(struct page *page, int pfn)
  366. {
  367. ClearPageReserved(page);
  368. init_page_count(page);
  369. __free_page(page);
  370. totalhigh_pages++;
  371. }
  372. struct add_highpages_data {
  373. unsigned long start_pfn;
  374. unsigned long end_pfn;
  375. };
  376. static int __init add_highpages_work_fn(unsigned long start_pfn,
  377. unsigned long end_pfn, void *datax)
  378. {
  379. int node_pfn;
  380. struct page *page;
  381. unsigned long final_start_pfn, final_end_pfn;
  382. struct add_highpages_data *data;
  383. data = (struct add_highpages_data *)datax;
  384. final_start_pfn = max(start_pfn, data->start_pfn);
  385. final_end_pfn = min(end_pfn, data->end_pfn);
  386. if (final_start_pfn >= final_end_pfn)
  387. return 0;
  388. for (node_pfn = final_start_pfn; node_pfn < final_end_pfn;
  389. node_pfn++) {
  390. if (!pfn_valid(node_pfn))
  391. continue;
  392. page = pfn_to_page(node_pfn);
  393. add_one_highpage_init(page, node_pfn);
  394. }
  395. return 0;
  396. }
  397. void __init add_highpages_with_active_regions(int nid, unsigned long start_pfn,
  398. unsigned long end_pfn)
  399. {
  400. struct add_highpages_data data;
  401. data.start_pfn = start_pfn;
  402. data.end_pfn = end_pfn;
  403. work_with_active_regions(nid, add_highpages_work_fn, &data);
  404. }
  405. #else
  406. static inline void permanent_kmaps_init(pgd_t *pgd_base)
  407. {
  408. }
  409. #endif /* CONFIG_HIGHMEM */
  410. void __init native_pagetable_setup_start(pgd_t *base)
  411. {
  412. unsigned long pfn, va;
  413. pgd_t *pgd;
  414. pud_t *pud;
  415. pmd_t *pmd;
  416. pte_t *pte;
  417. /*
  418. * Remove any mappings which extend past the end of physical
  419. * memory from the boot time page table:
  420. */
  421. for (pfn = max_low_pfn + 1; pfn < 1<<(32-PAGE_SHIFT); pfn++) {
  422. va = PAGE_OFFSET + (pfn<<PAGE_SHIFT);
  423. pgd = base + pgd_index(va);
  424. if (!pgd_present(*pgd))
  425. break;
  426. pud = pud_offset(pgd, va);
  427. pmd = pmd_offset(pud, va);
  428. if (!pmd_present(*pmd))
  429. break;
  430. pte = pte_offset_kernel(pmd, va);
  431. if (!pte_present(*pte))
  432. break;
  433. pte_clear(NULL, va, pte);
  434. }
  435. paravirt_alloc_pmd(&init_mm, __pa(base) >> PAGE_SHIFT);
  436. }
  437. void __init native_pagetable_setup_done(pgd_t *base)
  438. {
  439. }
  440. /*
  441. * Build a proper pagetable for the kernel mappings. Up until this
  442. * point, we've been running on some set of pagetables constructed by
  443. * the boot process.
  444. *
  445. * If we're booting on native hardware, this will be a pagetable
  446. * constructed in arch/x86/kernel/head_32.S. The root of the
  447. * pagetable will be swapper_pg_dir.
  448. *
  449. * If we're booting paravirtualized under a hypervisor, then there are
  450. * more options: we may already be running PAE, and the pagetable may
  451. * or may not be based in swapper_pg_dir. In any case,
  452. * paravirt_pagetable_setup_start() will set up swapper_pg_dir
  453. * appropriately for the rest of the initialization to work.
  454. *
  455. * In general, pagetable_init() assumes that the pagetable may already
  456. * be partially populated, and so it avoids stomping on any existing
  457. * mappings.
  458. */
  459. static void __init early_ioremap_page_table_range_init(pgd_t *pgd_base)
  460. {
  461. unsigned long vaddr, end;
  462. /*
  463. * Fixed mappings, only the page table structure has to be
  464. * created - mappings will be set by set_fixmap():
  465. */
  466. vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK;
  467. end = (FIXADDR_TOP + PMD_SIZE - 1) & PMD_MASK;
  468. page_table_range_init(vaddr, end, pgd_base);
  469. early_ioremap_reset();
  470. }
  471. static void __init pagetable_init(void)
  472. {
  473. pgd_t *pgd_base = swapper_pg_dir;
  474. permanent_kmaps_init(pgd_base);
  475. }
  476. #ifdef CONFIG_ACPI_SLEEP
  477. /*
  478. * ACPI suspend needs this for resume, because things like the intel-agp
  479. * driver might have split up a kernel 4MB mapping.
  480. */
  481. char swsusp_pg_dir[PAGE_SIZE]
  482. __attribute__ ((aligned(PAGE_SIZE)));
  483. static inline void save_pg_dir(void)
  484. {
  485. memcpy(swsusp_pg_dir, swapper_pg_dir, PAGE_SIZE);
  486. }
  487. #else /* !CONFIG_ACPI_SLEEP */
  488. static inline void save_pg_dir(void)
  489. {
  490. }
  491. #endif /* !CONFIG_ACPI_SLEEP */
  492. void zap_low_mappings(void)
  493. {
  494. int i;
  495. /*
  496. * Zap initial low-memory mappings.
  497. *
  498. * Note that "pgd_clear()" doesn't do it for
  499. * us, because pgd_clear() is a no-op on i386.
  500. */
  501. for (i = 0; i < KERNEL_PGD_BOUNDARY; i++) {
  502. #ifdef CONFIG_X86_PAE
  503. set_pgd(swapper_pg_dir+i, __pgd(1 + __pa(empty_zero_page)));
  504. #else
  505. set_pgd(swapper_pg_dir+i, __pgd(0));
  506. #endif
  507. }
  508. flush_tlb_all();
  509. }
  510. int nx_enabled;
  511. pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
  512. EXPORT_SYMBOL_GPL(__supported_pte_mask);
  513. #ifdef CONFIG_X86_PAE
  514. static int disable_nx __initdata;
  515. /*
  516. * noexec = on|off
  517. *
  518. * Control non executable mappings.
  519. *
  520. * on Enable
  521. * off Disable
  522. */
  523. static int __init noexec_setup(char *str)
  524. {
  525. if (!str || !strcmp(str, "on")) {
  526. if (cpu_has_nx) {
  527. __supported_pte_mask |= _PAGE_NX;
  528. disable_nx = 0;
  529. }
  530. } else {
  531. if (!strcmp(str, "off")) {
  532. disable_nx = 1;
  533. __supported_pte_mask &= ~_PAGE_NX;
  534. } else {
  535. return -EINVAL;
  536. }
  537. }
  538. return 0;
  539. }
  540. early_param("noexec", noexec_setup);
  541. static void __init set_nx(void)
  542. {
  543. unsigned int v[4], l, h;
  544. if (cpu_has_pae && (cpuid_eax(0x80000000) > 0x80000001)) {
  545. cpuid(0x80000001, &v[0], &v[1], &v[2], &v[3]);
  546. if ((v[3] & (1 << 20)) && !disable_nx) {
  547. rdmsr(MSR_EFER, l, h);
  548. l |= EFER_NX;
  549. wrmsr(MSR_EFER, l, h);
  550. nx_enabled = 1;
  551. __supported_pte_mask |= _PAGE_NX;
  552. }
  553. }
  554. }
  555. #endif
  556. /* user-defined highmem size */
  557. static unsigned int highmem_pages = -1;
  558. /*
  559. * highmem=size forces highmem to be exactly 'size' bytes.
  560. * This works even on boxes that have no highmem otherwise.
  561. * This also works to reduce highmem size on bigger boxes.
  562. */
  563. static int __init parse_highmem(char *arg)
  564. {
  565. if (!arg)
  566. return -EINVAL;
  567. highmem_pages = memparse(arg, &arg) >> PAGE_SHIFT;
  568. return 0;
  569. }
  570. early_param("highmem", parse_highmem);
  571. #define MSG_HIGHMEM_TOO_BIG \
  572. "highmem size (%luMB) is bigger than pages available (%luMB)!\n"
  573. #define MSG_LOWMEM_TOO_SMALL \
  574. "highmem size (%luMB) results in <64MB lowmem, ignoring it!\n"
  575. /*
  576. * All of RAM fits into lowmem - but if user wants highmem
  577. * artificially via the highmem=x boot parameter then create
  578. * it:
  579. */
  580. void __init lowmem_pfn_init(void)
  581. {
  582. /* max_low_pfn is 0, we already have early_res support */
  583. max_low_pfn = max_pfn;
  584. if (highmem_pages == -1)
  585. highmem_pages = 0;
  586. #ifdef CONFIG_HIGHMEM
  587. if (highmem_pages >= max_pfn) {
  588. printk(KERN_ERR MSG_HIGHMEM_TOO_BIG,
  589. pages_to_mb(highmem_pages), pages_to_mb(max_pfn));
  590. highmem_pages = 0;
  591. }
  592. if (highmem_pages) {
  593. if (max_low_pfn - highmem_pages < 64*1024*1024/PAGE_SIZE) {
  594. printk(KERN_ERR MSG_LOWMEM_TOO_SMALL,
  595. pages_to_mb(highmem_pages));
  596. highmem_pages = 0;
  597. }
  598. max_low_pfn -= highmem_pages;
  599. }
  600. #else
  601. if (highmem_pages)
  602. printk(KERN_ERR "ignoring highmem size on non-highmem kernel!\n");
  603. #endif
  604. }
  605. #define MSG_HIGHMEM_TOO_SMALL \
  606. "only %luMB highmem pages available, ignoring highmem size of %luMB!\n"
  607. #define MSG_HIGHMEM_TRIMMED \
  608. "Warning: only 4GB will be used. Use a HIGHMEM64G enabled kernel!\n"
  609. /*
  610. * We have more RAM than fits into lowmem - we try to put it into
  611. * highmem, also taking the highmem=x boot parameter into account:
  612. */
  613. void __init highmem_pfn_init(void)
  614. {
  615. max_low_pfn = MAXMEM_PFN;
  616. if (highmem_pages == -1)
  617. highmem_pages = max_pfn - MAXMEM_PFN;
  618. if (highmem_pages + MAXMEM_PFN < max_pfn)
  619. max_pfn = MAXMEM_PFN + highmem_pages;
  620. if (highmem_pages + MAXMEM_PFN > max_pfn) {
  621. printk(KERN_WARNING MSG_HIGHMEM_TOO_SMALL,
  622. pages_to_mb(max_pfn - MAXMEM_PFN),
  623. pages_to_mb(highmem_pages));
  624. highmem_pages = 0;
  625. }
  626. #ifndef CONFIG_HIGHMEM
  627. /* Maximum memory usable is what is directly addressable */
  628. printk(KERN_WARNING "Warning only %ldMB will be used.\n", MAXMEM>>20);
  629. if (max_pfn > MAX_NONPAE_PFN)
  630. printk(KERN_WARNING "Use a HIGHMEM64G enabled kernel.\n");
  631. else
  632. printk(KERN_WARNING "Use a HIGHMEM enabled kernel.\n");
  633. max_pfn = MAXMEM_PFN;
  634. #else /* !CONFIG_HIGHMEM */
  635. #ifndef CONFIG_HIGHMEM64G
  636. if (max_pfn > MAX_NONPAE_PFN) {
  637. max_pfn = MAX_NONPAE_PFN;
  638. printk(KERN_WARNING MSG_HIGHMEM_TRIMMED);
  639. }
  640. #endif /* !CONFIG_HIGHMEM64G */
  641. #endif /* !CONFIG_HIGHMEM */
  642. }
  643. /*
  644. * Determine low and high memory ranges:
  645. */
  646. void __init find_low_pfn_range(void)
  647. {
  648. /* it could update max_pfn */
  649. if (max_pfn <= MAXMEM_PFN)
  650. lowmem_pfn_init();
  651. else
  652. highmem_pfn_init();
  653. }
  654. #ifndef CONFIG_NEED_MULTIPLE_NODES
  655. void __init initmem_init(unsigned long start_pfn,
  656. unsigned long end_pfn)
  657. {
  658. #ifdef CONFIG_HIGHMEM
  659. highstart_pfn = highend_pfn = max_pfn;
  660. if (max_pfn > max_low_pfn)
  661. highstart_pfn = max_low_pfn;
  662. memory_present(0, 0, highend_pfn);
  663. e820_register_active_regions(0, 0, highend_pfn);
  664. printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
  665. pages_to_mb(highend_pfn - highstart_pfn));
  666. num_physpages = highend_pfn;
  667. high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
  668. #else
  669. memory_present(0, 0, max_low_pfn);
  670. e820_register_active_regions(0, 0, max_low_pfn);
  671. num_physpages = max_low_pfn;
  672. high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
  673. #endif
  674. #ifdef CONFIG_FLATMEM
  675. max_mapnr = num_physpages;
  676. #endif
  677. printk(KERN_NOTICE "%ldMB LOWMEM available.\n",
  678. pages_to_mb(max_low_pfn));
  679. setup_bootmem_allocator();
  680. }
  681. #endif /* !CONFIG_NEED_MULTIPLE_NODES */
  682. static void __init zone_sizes_init(void)
  683. {
  684. unsigned long max_zone_pfns[MAX_NR_ZONES];
  685. memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
  686. max_zone_pfns[ZONE_DMA] =
  687. virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
  688. max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
  689. #ifdef CONFIG_HIGHMEM
  690. max_zone_pfns[ZONE_HIGHMEM] = highend_pfn;
  691. #endif
  692. free_area_init_nodes(max_zone_pfns);
  693. }
  694. void __init setup_bootmem_allocator(void)
  695. {
  696. int i;
  697. unsigned long bootmap_size, bootmap;
  698. /*
  699. * Initialize the boot-time allocator (with low memory only):
  700. */
  701. bootmap_size = bootmem_bootmap_pages(max_low_pfn)<<PAGE_SHIFT;
  702. bootmap = find_e820_area(min_low_pfn<<PAGE_SHIFT,
  703. max_pfn_mapped<<PAGE_SHIFT, bootmap_size,
  704. PAGE_SIZE);
  705. if (bootmap == -1L)
  706. panic("Cannot find bootmem map of size %ld\n", bootmap_size);
  707. reserve_early(bootmap, bootmap + bootmap_size, "BOOTMAP");
  708. /* don't touch min_low_pfn */
  709. bootmap_size = init_bootmem_node(NODE_DATA(0), bootmap >> PAGE_SHIFT,
  710. min_low_pfn, max_low_pfn);
  711. printk(KERN_INFO " mapped low ram: 0 - %08lx\n",
  712. max_pfn_mapped<<PAGE_SHIFT);
  713. printk(KERN_INFO " low ram: %08lx - %08lx\n",
  714. min_low_pfn<<PAGE_SHIFT, max_low_pfn<<PAGE_SHIFT);
  715. printk(KERN_INFO " bootmap %08lx - %08lx\n",
  716. bootmap, bootmap + bootmap_size);
  717. for_each_online_node(i)
  718. free_bootmem_with_active_regions(i, max_low_pfn);
  719. early_res_to_bootmem(0, max_low_pfn<<PAGE_SHIFT);
  720. after_init_bootmem = 1;
  721. }
  722. static void __init find_early_table_space(unsigned long end, int use_pse)
  723. {
  724. unsigned long puds, pmds, ptes, tables, start;
  725. puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
  726. tables = roundup(puds * sizeof(pud_t), PAGE_SIZE);
  727. pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
  728. tables += roundup(pmds * sizeof(pmd_t), PAGE_SIZE);
  729. if (use_pse) {
  730. unsigned long extra;
  731. extra = end - ((end>>PMD_SHIFT) << PMD_SHIFT);
  732. extra += PMD_SIZE;
  733. ptes = (extra + PAGE_SIZE - 1) >> PAGE_SHIFT;
  734. } else
  735. ptes = (end + PAGE_SIZE - 1) >> PAGE_SHIFT;
  736. tables += roundup(ptes * sizeof(pte_t), PAGE_SIZE);
  737. /* for fixmap */
  738. tables += roundup(__end_of_fixed_addresses * sizeof(pte_t), PAGE_SIZE);
  739. /*
  740. * RED-PEN putting page tables only on node 0 could
  741. * cause a hotspot and fill up ZONE_DMA. The page tables
  742. * need roughly 0.5KB per GB.
  743. */
  744. start = 0x7000;
  745. table_start = find_e820_area(start, max_pfn_mapped<<PAGE_SHIFT,
  746. tables, PAGE_SIZE);
  747. if (table_start == -1UL)
  748. panic("Cannot find space for the kernel page tables");
  749. table_start >>= PAGE_SHIFT;
  750. table_end = table_start;
  751. table_top = table_start + (tables>>PAGE_SHIFT);
  752. printk(KERN_DEBUG "kernel direct mapping tables up to %lx @ %lx-%lx\n",
  753. end, table_start << PAGE_SHIFT,
  754. (table_start << PAGE_SHIFT) + tables);
  755. }
  756. unsigned long __init_refok init_memory_mapping(unsigned long start,
  757. unsigned long end)
  758. {
  759. pgd_t *pgd_base = swapper_pg_dir;
  760. unsigned long start_pfn, end_pfn;
  761. unsigned long big_page_start;
  762. #ifdef CONFIG_DEBUG_PAGEALLOC
  763. /*
  764. * For CONFIG_DEBUG_PAGEALLOC, identity mapping will use small pages.
  765. * This will simplify cpa(), which otherwise needs to support splitting
  766. * large pages into small in interrupt context, etc.
  767. */
  768. int use_pse = 0;
  769. #else
  770. int use_pse = cpu_has_pse;
  771. #endif
  772. /*
  773. * Find space for the kernel direct mapping tables.
  774. */
  775. if (!after_init_bootmem)
  776. find_early_table_space(end, use_pse);
  777. #ifdef CONFIG_X86_PAE
  778. set_nx();
  779. if (nx_enabled)
  780. printk(KERN_INFO "NX (Execute Disable) protection: active\n");
  781. #endif
  782. /* Enable PSE if available */
  783. if (cpu_has_pse)
  784. set_in_cr4(X86_CR4_PSE);
  785. /* Enable PGE if available */
  786. if (cpu_has_pge) {
  787. set_in_cr4(X86_CR4_PGE);
  788. __supported_pte_mask |= _PAGE_GLOBAL;
  789. }
  790. /*
  791. * Don't use a large page for the first 2/4MB of memory
  792. * because there are often fixed size MTRRs in there
  793. * and overlapping MTRRs into large pages can cause
  794. * slowdowns.
  795. */
  796. big_page_start = PMD_SIZE;
  797. if (start < big_page_start) {
  798. start_pfn = start >> PAGE_SHIFT;
  799. end_pfn = min(big_page_start>>PAGE_SHIFT, end>>PAGE_SHIFT);
  800. } else {
  801. /* head is not big page alignment ? */
  802. start_pfn = start >> PAGE_SHIFT;
  803. end_pfn = ((start + (PMD_SIZE - 1))>>PMD_SHIFT)
  804. << (PMD_SHIFT - PAGE_SHIFT);
  805. }
  806. if (start_pfn < end_pfn)
  807. kernel_physical_mapping_init(pgd_base, start_pfn, end_pfn, 0);
  808. /* big page range */
  809. start_pfn = ((start + (PMD_SIZE - 1))>>PMD_SHIFT)
  810. << (PMD_SHIFT - PAGE_SHIFT);
  811. if (start_pfn < (big_page_start >> PAGE_SHIFT))
  812. start_pfn = big_page_start >> PAGE_SHIFT;
  813. end_pfn = (end>>PMD_SHIFT) << (PMD_SHIFT - PAGE_SHIFT);
  814. if (start_pfn < end_pfn)
  815. kernel_physical_mapping_init(pgd_base, start_pfn, end_pfn,
  816. use_pse);
  817. /* tail is not big page alignment ? */
  818. start_pfn = end_pfn;
  819. if (start_pfn > (big_page_start>>PAGE_SHIFT)) {
  820. end_pfn = end >> PAGE_SHIFT;
  821. if (start_pfn < end_pfn)
  822. kernel_physical_mapping_init(pgd_base, start_pfn,
  823. end_pfn, 0);
  824. }
  825. early_ioremap_page_table_range_init(pgd_base);
  826. load_cr3(swapper_pg_dir);
  827. __flush_tlb_all();
  828. if (!after_init_bootmem)
  829. reserve_early(table_start << PAGE_SHIFT,
  830. table_end << PAGE_SHIFT, "PGTABLE");
  831. if (!after_init_bootmem)
  832. early_memtest(start, end);
  833. return end >> PAGE_SHIFT;
  834. }
  835. /*
  836. * paging_init() sets up the page tables - note that the first 8MB are
  837. * already mapped by head.S.
  838. *
  839. * This routines also unmaps the page at virtual kernel address 0, so
  840. * that we can trap those pesky NULL-reference errors in the kernel.
  841. */
  842. void __init paging_init(void)
  843. {
  844. pagetable_init();
  845. __flush_tlb_all();
  846. kmap_init();
  847. /*
  848. * NOTE: at this point the bootmem allocator is fully available.
  849. */
  850. sparse_init();
  851. zone_sizes_init();
  852. }
  853. /*
  854. * Test if the WP bit works in supervisor mode. It isn't supported on 386's
  855. * and also on some strange 486's. All 586+'s are OK. This used to involve
  856. * black magic jumps to work around some nasty CPU bugs, but fortunately the
  857. * switch to using exceptions got rid of all that.
  858. */
  859. static void __init test_wp_bit(void)
  860. {
  861. printk(KERN_INFO
  862. "Checking if this processor honours the WP bit even in supervisor mode...");
  863. /* Any page-aligned address will do, the test is non-destructive */
  864. __set_fixmap(FIX_WP_TEST, __pa(&swapper_pg_dir), PAGE_READONLY);
  865. boot_cpu_data.wp_works_ok = do_test_wp_bit();
  866. clear_fixmap(FIX_WP_TEST);
  867. if (!boot_cpu_data.wp_works_ok) {
  868. printk(KERN_CONT "No.\n");
  869. #ifdef CONFIG_X86_WP_WORKS_OK
  870. panic(
  871. "This kernel doesn't support CPU's with broken WP. Recompile it for a 386!");
  872. #endif
  873. } else {
  874. printk(KERN_CONT "Ok.\n");
  875. }
  876. }
  877. static struct kcore_list kcore_mem, kcore_vmalloc;
  878. void __init mem_init(void)
  879. {
  880. int codesize, reservedpages, datasize, initsize;
  881. int tmp;
  882. pci_iommu_alloc();
  883. #ifdef CONFIG_FLATMEM
  884. BUG_ON(!mem_map);
  885. #endif
  886. /* this will put all low memory onto the freelists */
  887. totalram_pages += free_all_bootmem();
  888. reservedpages = 0;
  889. for (tmp = 0; tmp < max_low_pfn; tmp++)
  890. /*
  891. * Only count reserved RAM pages:
  892. */
  893. if (page_is_ram(tmp) && PageReserved(pfn_to_page(tmp)))
  894. reservedpages++;
  895. set_highmem_pages_init();
  896. codesize = (unsigned long) &_etext - (unsigned long) &_text;
  897. datasize = (unsigned long) &_edata - (unsigned long) &_etext;
  898. initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
  899. kclist_add(&kcore_mem, __va(0), max_low_pfn << PAGE_SHIFT);
  900. kclist_add(&kcore_vmalloc, (void *)VMALLOC_START,
  901. VMALLOC_END-VMALLOC_START);
  902. printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
  903. "%dk reserved, %dk data, %dk init, %ldk highmem)\n",
  904. (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
  905. num_physpages << (PAGE_SHIFT-10),
  906. codesize >> 10,
  907. reservedpages << (PAGE_SHIFT-10),
  908. datasize >> 10,
  909. initsize >> 10,
  910. (unsigned long) (totalhigh_pages << (PAGE_SHIFT-10))
  911. );
  912. printk(KERN_INFO "virtual kernel memory layout:\n"
  913. " fixmap : 0x%08lx - 0x%08lx (%4ld kB)\n"
  914. #ifdef CONFIG_HIGHMEM
  915. " pkmap : 0x%08lx - 0x%08lx (%4ld kB)\n"
  916. #endif
  917. " vmalloc : 0x%08lx - 0x%08lx (%4ld MB)\n"
  918. " lowmem : 0x%08lx - 0x%08lx (%4ld MB)\n"
  919. " .init : 0x%08lx - 0x%08lx (%4ld kB)\n"
  920. " .data : 0x%08lx - 0x%08lx (%4ld kB)\n"
  921. " .text : 0x%08lx - 0x%08lx (%4ld kB)\n",
  922. FIXADDR_START, FIXADDR_TOP,
  923. (FIXADDR_TOP - FIXADDR_START) >> 10,
  924. #ifdef CONFIG_HIGHMEM
  925. PKMAP_BASE, PKMAP_BASE+LAST_PKMAP*PAGE_SIZE,
  926. (LAST_PKMAP*PAGE_SIZE) >> 10,
  927. #endif
  928. VMALLOC_START, VMALLOC_END,
  929. (VMALLOC_END - VMALLOC_START) >> 20,
  930. (unsigned long)__va(0), (unsigned long)high_memory,
  931. ((unsigned long)high_memory - (unsigned long)__va(0)) >> 20,
  932. (unsigned long)&__init_begin, (unsigned long)&__init_end,
  933. ((unsigned long)&__init_end -
  934. (unsigned long)&__init_begin) >> 10,
  935. (unsigned long)&_etext, (unsigned long)&_edata,
  936. ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
  937. (unsigned long)&_text, (unsigned long)&_etext,
  938. ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
  939. /*
  940. * Check boundaries twice: Some fundamental inconsistencies can
  941. * be detected at build time already.
  942. */
  943. #define __FIXADDR_TOP (-PAGE_SIZE)
  944. #ifdef CONFIG_HIGHMEM
  945. BUILD_BUG_ON(PKMAP_BASE + LAST_PKMAP*PAGE_SIZE > FIXADDR_START);
  946. BUILD_BUG_ON(VMALLOC_END > PKMAP_BASE);
  947. #endif
  948. #define high_memory (-128UL << 20)
  949. BUILD_BUG_ON(VMALLOC_START >= VMALLOC_END);
  950. #undef high_memory
  951. #undef __FIXADDR_TOP
  952. #ifdef CONFIG_HIGHMEM
  953. BUG_ON(PKMAP_BASE + LAST_PKMAP*PAGE_SIZE > FIXADDR_START);
  954. BUG_ON(VMALLOC_END > PKMAP_BASE);
  955. #endif
  956. BUG_ON(VMALLOC_START >= VMALLOC_END);
  957. BUG_ON((unsigned long)high_memory > VMALLOC_START);
  958. if (boot_cpu_data.wp_works_ok < 0)
  959. test_wp_bit();
  960. save_pg_dir();
  961. zap_low_mappings();
  962. }
  963. #ifdef CONFIG_MEMORY_HOTPLUG
  964. int arch_add_memory(int nid, u64 start, u64 size)
  965. {
  966. struct pglist_data *pgdata = NODE_DATA(nid);
  967. struct zone *zone = pgdata->node_zones + ZONE_HIGHMEM;
  968. unsigned long start_pfn = start >> PAGE_SHIFT;
  969. unsigned long nr_pages = size >> PAGE_SHIFT;
  970. return __add_pages(nid, zone, start_pfn, nr_pages);
  971. }
  972. #endif
  973. /*
  974. * This function cannot be __init, since exceptions don't work in that
  975. * section. Put this after the callers, so that it cannot be inlined.
  976. */
  977. static noinline int do_test_wp_bit(void)
  978. {
  979. char tmp_reg;
  980. int flag;
  981. __asm__ __volatile__(
  982. " movb %0, %1 \n"
  983. "1: movb %1, %0 \n"
  984. " xorl %2, %2 \n"
  985. "2: \n"
  986. _ASM_EXTABLE(1b,2b)
  987. :"=m" (*(char *)fix_to_virt(FIX_WP_TEST)),
  988. "=q" (tmp_reg),
  989. "=r" (flag)
  990. :"2" (1)
  991. :"memory");
  992. return flag;
  993. }
  994. #ifdef CONFIG_DEBUG_RODATA
  995. const int rodata_test_data = 0xC3;
  996. EXPORT_SYMBOL_GPL(rodata_test_data);
  997. void mark_rodata_ro(void)
  998. {
  999. unsigned long start = PFN_ALIGN(_text);
  1000. unsigned long size = PFN_ALIGN(_etext) - start;
  1001. #ifndef CONFIG_DYNAMIC_FTRACE
  1002. /* Dynamic tracing modifies the kernel text section */
  1003. set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
  1004. printk(KERN_INFO "Write protecting the kernel text: %luk\n",
  1005. size >> 10);
  1006. #ifdef CONFIG_CPA_DEBUG
  1007. printk(KERN_INFO "Testing CPA: Reverting %lx-%lx\n",
  1008. start, start+size);
  1009. set_pages_rw(virt_to_page(start), size>>PAGE_SHIFT);
  1010. printk(KERN_INFO "Testing CPA: write protecting again\n");
  1011. set_pages_ro(virt_to_page(start), size>>PAGE_SHIFT);
  1012. #endif
  1013. #endif /* CONFIG_DYNAMIC_FTRACE */
  1014. start += size;
  1015. size = (unsigned long)__end_rodata - start;
  1016. set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
  1017. printk(KERN_INFO "Write protecting the kernel read-only data: %luk\n",
  1018. size >> 10);
  1019. rodata_test();
  1020. #ifdef CONFIG_CPA_DEBUG
  1021. printk(KERN_INFO "Testing CPA: undo %lx-%lx\n", start, start + size);
  1022. set_pages_rw(virt_to_page(start), size >> PAGE_SHIFT);
  1023. printk(KERN_INFO "Testing CPA: write protecting again\n");
  1024. set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
  1025. #endif
  1026. }
  1027. #endif
  1028. #ifdef CONFIG_BLK_DEV_INITRD
  1029. void free_initrd_mem(unsigned long start, unsigned long end)
  1030. {
  1031. free_init_pages("initrd memory", start, end);
  1032. }
  1033. #endif
  1034. int __init reserve_bootmem_generic(unsigned long phys, unsigned long len,
  1035. int flags)
  1036. {
  1037. return reserve_bootmem(phys, len, flags);
  1038. }