mmu.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133
  1. /*
  2. * linux/arch/arm/mm/mmu.c
  3. *
  4. * Copyright (C) 1995-2005 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/module.h>
  11. #include <linux/kernel.h>
  12. #include <linux/errno.h>
  13. #include <linux/init.h>
  14. #include <linux/mman.h>
  15. #include <linux/nodemask.h>
  16. #include <linux/memblock.h>
  17. #include <linux/fs.h>
  18. #include <linux/vmalloc.h>
  19. #include <asm/cp15.h>
  20. #include <asm/cputype.h>
  21. #include <asm/sections.h>
  22. #include <asm/cachetype.h>
  23. #include <asm/setup.h>
  24. #include <asm/sizes.h>
  25. #include <asm/smp_plat.h>
  26. #include <asm/tlb.h>
  27. #include <asm/highmem.h>
  28. #include <asm/traps.h>
  29. #include <asm/mach/arch.h>
  30. #include <asm/mach/map.h>
  31. #include "mm.h"
  32. /*
  33. * empty_zero_page is a special page that is used for
  34. * zero-initialized data and COW.
  35. */
  36. struct page *empty_zero_page;
  37. EXPORT_SYMBOL(empty_zero_page);
  38. /*
  39. * The pmd table for the upper-most set of pages.
  40. */
  41. pmd_t *top_pmd;
  42. #define CPOLICY_UNCACHED 0
  43. #define CPOLICY_BUFFERED 1
  44. #define CPOLICY_WRITETHROUGH 2
  45. #define CPOLICY_WRITEBACK 3
  46. #define CPOLICY_WRITEALLOC 4
  47. static unsigned int cachepolicy __initdata = CPOLICY_WRITEBACK;
  48. static unsigned int ecc_mask __initdata = 0;
  49. pgprot_t pgprot_user;
  50. pgprot_t pgprot_kernel;
  51. EXPORT_SYMBOL(pgprot_user);
  52. EXPORT_SYMBOL(pgprot_kernel);
  53. struct cachepolicy {
  54. const char policy[16];
  55. unsigned int cr_mask;
  56. pmdval_t pmd;
  57. pteval_t pte;
  58. };
  59. static struct cachepolicy cache_policies[] __initdata = {
  60. {
  61. .policy = "uncached",
  62. .cr_mask = CR_W|CR_C,
  63. .pmd = PMD_SECT_UNCACHED,
  64. .pte = L_PTE_MT_UNCACHED,
  65. }, {
  66. .policy = "buffered",
  67. .cr_mask = CR_C,
  68. .pmd = PMD_SECT_BUFFERED,
  69. .pte = L_PTE_MT_BUFFERABLE,
  70. }, {
  71. .policy = "writethrough",
  72. .cr_mask = 0,
  73. .pmd = PMD_SECT_WT,
  74. .pte = L_PTE_MT_WRITETHROUGH,
  75. }, {
  76. .policy = "writeback",
  77. .cr_mask = 0,
  78. .pmd = PMD_SECT_WB,
  79. .pte = L_PTE_MT_WRITEBACK,
  80. }, {
  81. .policy = "writealloc",
  82. .cr_mask = 0,
  83. .pmd = PMD_SECT_WBWA,
  84. .pte = L_PTE_MT_WRITEALLOC,
  85. }
  86. };
  87. /*
  88. * These are useful for identifying cache coherency
  89. * problems by allowing the cache or the cache and
  90. * writebuffer to be turned off. (Note: the write
  91. * buffer should not be on and the cache off).
  92. */
  93. static int __init early_cachepolicy(char *p)
  94. {
  95. int i;
  96. for (i = 0; i < ARRAY_SIZE(cache_policies); i++) {
  97. int len = strlen(cache_policies[i].policy);
  98. if (memcmp(p, cache_policies[i].policy, len) == 0) {
  99. cachepolicy = i;
  100. cr_alignment &= ~cache_policies[i].cr_mask;
  101. cr_no_alignment &= ~cache_policies[i].cr_mask;
  102. break;
  103. }
  104. }
  105. if (i == ARRAY_SIZE(cache_policies))
  106. printk(KERN_ERR "ERROR: unknown or unsupported cache policy\n");
  107. /*
  108. * This restriction is partly to do with the way we boot; it is
  109. * unpredictable to have memory mapped using two different sets of
  110. * memory attributes (shared, type, and cache attribs). We can not
  111. * change these attributes once the initial assembly has setup the
  112. * page tables.
  113. */
  114. if (cpu_architecture() >= CPU_ARCH_ARMv6) {
  115. printk(KERN_WARNING "Only cachepolicy=writeback supported on ARMv6 and later\n");
  116. cachepolicy = CPOLICY_WRITEBACK;
  117. }
  118. flush_cache_all();
  119. set_cr(cr_alignment);
  120. return 0;
  121. }
  122. early_param("cachepolicy", early_cachepolicy);
  123. static int __init early_nocache(char *__unused)
  124. {
  125. char *p = "buffered";
  126. printk(KERN_WARNING "nocache is deprecated; use cachepolicy=%s\n", p);
  127. early_cachepolicy(p);
  128. return 0;
  129. }
  130. early_param("nocache", early_nocache);
  131. static int __init early_nowrite(char *__unused)
  132. {
  133. char *p = "uncached";
  134. printk(KERN_WARNING "nowb is deprecated; use cachepolicy=%s\n", p);
  135. early_cachepolicy(p);
  136. return 0;
  137. }
  138. early_param("nowb", early_nowrite);
  139. #ifndef CONFIG_ARM_LPAE
  140. static int __init early_ecc(char *p)
  141. {
  142. if (memcmp(p, "on", 2) == 0)
  143. ecc_mask = PMD_PROTECTION;
  144. else if (memcmp(p, "off", 3) == 0)
  145. ecc_mask = 0;
  146. return 0;
  147. }
  148. early_param("ecc", early_ecc);
  149. #endif
  150. static int __init noalign_setup(char *__unused)
  151. {
  152. cr_alignment &= ~CR_A;
  153. cr_no_alignment &= ~CR_A;
  154. set_cr(cr_alignment);
  155. return 1;
  156. }
  157. __setup("noalign", noalign_setup);
  158. #ifndef CONFIG_SMP
  159. void adjust_cr(unsigned long mask, unsigned long set)
  160. {
  161. unsigned long flags;
  162. mask &= ~CR_A;
  163. set &= mask;
  164. local_irq_save(flags);
  165. cr_no_alignment = (cr_no_alignment & ~mask) | set;
  166. cr_alignment = (cr_alignment & ~mask) | set;
  167. set_cr((get_cr() & ~mask) | set);
  168. local_irq_restore(flags);
  169. }
  170. #endif
  171. #define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
  172. #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
  173. static struct mem_type mem_types[] = {
  174. [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
  175. .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
  176. L_PTE_SHARED,
  177. .prot_l1 = PMD_TYPE_TABLE,
  178. .prot_sect = PROT_SECT_DEVICE | PMD_SECT_S,
  179. .domain = DOMAIN_IO,
  180. },
  181. [MT_DEVICE_NONSHARED] = { /* ARMv6 non-shared device */
  182. .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_NONSHARED,
  183. .prot_l1 = PMD_TYPE_TABLE,
  184. .prot_sect = PROT_SECT_DEVICE,
  185. .domain = DOMAIN_IO,
  186. },
  187. [MT_DEVICE_CACHED] = { /* ioremap_cached */
  188. .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_CACHED,
  189. .prot_l1 = PMD_TYPE_TABLE,
  190. .prot_sect = PROT_SECT_DEVICE | PMD_SECT_WB,
  191. .domain = DOMAIN_IO,
  192. },
  193. [MT_DEVICE_WC] = { /* ioremap_wc */
  194. .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_WC,
  195. .prot_l1 = PMD_TYPE_TABLE,
  196. .prot_sect = PROT_SECT_DEVICE,
  197. .domain = DOMAIN_IO,
  198. },
  199. [MT_UNCACHED] = {
  200. .prot_pte = PROT_PTE_DEVICE,
  201. .prot_l1 = PMD_TYPE_TABLE,
  202. .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
  203. .domain = DOMAIN_IO,
  204. },
  205. [MT_CACHECLEAN] = {
  206. .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
  207. .domain = DOMAIN_KERNEL,
  208. },
  209. #ifndef CONFIG_ARM_LPAE
  210. [MT_MINICLEAN] = {
  211. .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
  212. .domain = DOMAIN_KERNEL,
  213. },
  214. #endif
  215. [MT_LOW_VECTORS] = {
  216. .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
  217. L_PTE_RDONLY,
  218. .prot_l1 = PMD_TYPE_TABLE,
  219. .domain = DOMAIN_USER,
  220. },
  221. [MT_HIGH_VECTORS] = {
  222. .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
  223. L_PTE_USER | L_PTE_RDONLY,
  224. .prot_l1 = PMD_TYPE_TABLE,
  225. .domain = DOMAIN_USER,
  226. },
  227. [MT_MEMORY] = {
  228. .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
  229. .prot_l1 = PMD_TYPE_TABLE,
  230. .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
  231. .domain = DOMAIN_KERNEL,
  232. },
  233. [MT_ROM] = {
  234. .prot_sect = PMD_TYPE_SECT,
  235. .domain = DOMAIN_KERNEL,
  236. },
  237. [MT_MEMORY_NONCACHED] = {
  238. .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
  239. L_PTE_MT_BUFFERABLE,
  240. .prot_l1 = PMD_TYPE_TABLE,
  241. .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
  242. .domain = DOMAIN_KERNEL,
  243. },
  244. [MT_MEMORY_DTCM] = {
  245. .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
  246. L_PTE_XN,
  247. .prot_l1 = PMD_TYPE_TABLE,
  248. .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
  249. .domain = DOMAIN_KERNEL,
  250. },
  251. [MT_MEMORY_ITCM] = {
  252. .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
  253. .prot_l1 = PMD_TYPE_TABLE,
  254. .domain = DOMAIN_KERNEL,
  255. },
  256. [MT_MEMORY_SO] = {
  257. .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
  258. L_PTE_MT_UNCACHED,
  259. .prot_l1 = PMD_TYPE_TABLE,
  260. .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
  261. PMD_SECT_UNCACHED | PMD_SECT_XN,
  262. .domain = DOMAIN_KERNEL,
  263. },
  264. };
  265. const struct mem_type *get_mem_type(unsigned int type)
  266. {
  267. return type < ARRAY_SIZE(mem_types) ? &mem_types[type] : NULL;
  268. }
  269. EXPORT_SYMBOL(get_mem_type);
  270. /*
  271. * Adjust the PMD section entries according to the CPU in use.
  272. */
  273. static void __init build_mem_type_table(void)
  274. {
  275. struct cachepolicy *cp;
  276. unsigned int cr = get_cr();
  277. pteval_t user_pgprot, kern_pgprot, vecs_pgprot;
  278. int cpu_arch = cpu_architecture();
  279. int i;
  280. if (cpu_arch < CPU_ARCH_ARMv6) {
  281. #if defined(CONFIG_CPU_DCACHE_DISABLE)
  282. if (cachepolicy > CPOLICY_BUFFERED)
  283. cachepolicy = CPOLICY_BUFFERED;
  284. #elif defined(CONFIG_CPU_DCACHE_WRITETHROUGH)
  285. if (cachepolicy > CPOLICY_WRITETHROUGH)
  286. cachepolicy = CPOLICY_WRITETHROUGH;
  287. #endif
  288. }
  289. if (cpu_arch < CPU_ARCH_ARMv5) {
  290. if (cachepolicy >= CPOLICY_WRITEALLOC)
  291. cachepolicy = CPOLICY_WRITEBACK;
  292. ecc_mask = 0;
  293. }
  294. if (is_smp())
  295. cachepolicy = CPOLICY_WRITEALLOC;
  296. /*
  297. * Strip out features not present on earlier architectures.
  298. * Pre-ARMv5 CPUs don't have TEX bits. Pre-ARMv6 CPUs or those
  299. * without extended page tables don't have the 'Shared' bit.
  300. */
  301. if (cpu_arch < CPU_ARCH_ARMv5)
  302. for (i = 0; i < ARRAY_SIZE(mem_types); i++)
  303. mem_types[i].prot_sect &= ~PMD_SECT_TEX(7);
  304. if ((cpu_arch < CPU_ARCH_ARMv6 || !(cr & CR_XP)) && !cpu_is_xsc3())
  305. for (i = 0; i < ARRAY_SIZE(mem_types); i++)
  306. mem_types[i].prot_sect &= ~PMD_SECT_S;
  307. /*
  308. * ARMv5 and lower, bit 4 must be set for page tables (was: cache
  309. * "update-able on write" bit on ARM610). However, Xscale and
  310. * Xscale3 require this bit to be cleared.
  311. */
  312. if (cpu_is_xscale() || cpu_is_xsc3()) {
  313. for (i = 0; i < ARRAY_SIZE(mem_types); i++) {
  314. mem_types[i].prot_sect &= ~PMD_BIT4;
  315. mem_types[i].prot_l1 &= ~PMD_BIT4;
  316. }
  317. } else if (cpu_arch < CPU_ARCH_ARMv6) {
  318. for (i = 0; i < ARRAY_SIZE(mem_types); i++) {
  319. if (mem_types[i].prot_l1)
  320. mem_types[i].prot_l1 |= PMD_BIT4;
  321. if (mem_types[i].prot_sect)
  322. mem_types[i].prot_sect |= PMD_BIT4;
  323. }
  324. }
  325. /*
  326. * Mark the device areas according to the CPU/architecture.
  327. */
  328. if (cpu_is_xsc3() || (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP))) {
  329. if (!cpu_is_xsc3()) {
  330. /*
  331. * Mark device regions on ARMv6+ as execute-never
  332. * to prevent speculative instruction fetches.
  333. */
  334. mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
  335. mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
  336. mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
  337. mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
  338. }
  339. if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
  340. /*
  341. * For ARMv7 with TEX remapping,
  342. * - shared device is SXCB=1100
  343. * - nonshared device is SXCB=0100
  344. * - write combine device mem is SXCB=0001
  345. * (Uncached Normal memory)
  346. */
  347. mem_types[MT_DEVICE].prot_sect |= PMD_SECT_TEX(1);
  348. mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_TEX(1);
  349. mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_BUFFERABLE;
  350. } else if (cpu_is_xsc3()) {
  351. /*
  352. * For Xscale3,
  353. * - shared device is TEXCB=00101
  354. * - nonshared device is TEXCB=01000
  355. * - write combine device mem is TEXCB=00100
  356. * (Inner/Outer Uncacheable in xsc3 parlance)
  357. */
  358. mem_types[MT_DEVICE].prot_sect |= PMD_SECT_TEX(1) | PMD_SECT_BUFFERED;
  359. mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_TEX(2);
  360. mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_TEX(1);
  361. } else {
  362. /*
  363. * For ARMv6 and ARMv7 without TEX remapping,
  364. * - shared device is TEXCB=00001
  365. * - nonshared device is TEXCB=01000
  366. * - write combine device mem is TEXCB=00100
  367. * (Uncached Normal in ARMv6 parlance).
  368. */
  369. mem_types[MT_DEVICE].prot_sect |= PMD_SECT_BUFFERED;
  370. mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_TEX(2);
  371. mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_TEX(1);
  372. }
  373. } else {
  374. /*
  375. * On others, write combining is "Uncached/Buffered"
  376. */
  377. mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_BUFFERABLE;
  378. }
  379. /*
  380. * Now deal with the memory-type mappings
  381. */
  382. cp = &cache_policies[cachepolicy];
  383. vecs_pgprot = kern_pgprot = user_pgprot = cp->pte;
  384. /*
  385. * Only use write-through for non-SMP systems
  386. */
  387. if (!is_smp() && cpu_arch >= CPU_ARCH_ARMv5 && cachepolicy > CPOLICY_WRITETHROUGH)
  388. vecs_pgprot = cache_policies[CPOLICY_WRITETHROUGH].pte;
  389. /*
  390. * Enable CPU-specific coherency if supported.
  391. * (Only available on XSC3 at the moment.)
  392. */
  393. if (arch_is_coherent() && cpu_is_xsc3()) {
  394. mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
  395. mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
  396. mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
  397. mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
  398. }
  399. /*
  400. * ARMv6 and above have extended page tables.
  401. */
  402. if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
  403. #ifndef CONFIG_ARM_LPAE
  404. /*
  405. * Mark cache clean areas and XIP ROM read only
  406. * from SVC mode and no access from userspace.
  407. */
  408. mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
  409. mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
  410. mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
  411. #endif
  412. if (is_smp()) {
  413. /*
  414. * Mark memory with the "shared" attribute
  415. * for SMP systems
  416. */
  417. user_pgprot |= L_PTE_SHARED;
  418. kern_pgprot |= L_PTE_SHARED;
  419. vecs_pgprot |= L_PTE_SHARED;
  420. mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_S;
  421. mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
  422. mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
  423. mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
  424. mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
  425. mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
  426. mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
  427. mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
  428. }
  429. }
  430. /*
  431. * Non-cacheable Normal - intended for memory areas that must
  432. * not cause dirty cache line writebacks when used
  433. */
  434. if (cpu_arch >= CPU_ARCH_ARMv6) {
  435. if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
  436. /* Non-cacheable Normal is XCB = 001 */
  437. mem_types[MT_MEMORY_NONCACHED].prot_sect |=
  438. PMD_SECT_BUFFERED;
  439. } else {
  440. /* For both ARMv6 and non-TEX-remapping ARMv7 */
  441. mem_types[MT_MEMORY_NONCACHED].prot_sect |=
  442. PMD_SECT_TEX(1);
  443. }
  444. } else {
  445. mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
  446. }
  447. #ifdef CONFIG_ARM_LPAE
  448. /*
  449. * Do not generate access flag faults for the kernel mappings.
  450. */
  451. for (i = 0; i < ARRAY_SIZE(mem_types); i++) {
  452. mem_types[i].prot_pte |= PTE_EXT_AF;
  453. mem_types[i].prot_sect |= PMD_SECT_AF;
  454. }
  455. kern_pgprot |= PTE_EXT_AF;
  456. vecs_pgprot |= PTE_EXT_AF;
  457. #endif
  458. for (i = 0; i < 16; i++) {
  459. unsigned long v = pgprot_val(protection_map[i]);
  460. protection_map[i] = __pgprot(v | user_pgprot);
  461. }
  462. mem_types[MT_LOW_VECTORS].prot_pte |= vecs_pgprot;
  463. mem_types[MT_HIGH_VECTORS].prot_pte |= vecs_pgprot;
  464. pgprot_user = __pgprot(L_PTE_PRESENT | L_PTE_YOUNG | user_pgprot);
  465. pgprot_kernel = __pgprot(L_PTE_PRESENT | L_PTE_YOUNG |
  466. L_PTE_DIRTY | kern_pgprot);
  467. mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
  468. mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
  469. mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
  470. mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
  471. mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
  472. mem_types[MT_ROM].prot_sect |= cp->pmd;
  473. switch (cp->pmd) {
  474. case PMD_SECT_WT:
  475. mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_WT;
  476. break;
  477. case PMD_SECT_WB:
  478. case PMD_SECT_WBWA:
  479. mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_WB;
  480. break;
  481. }
  482. printk("Memory policy: ECC %sabled, Data cache %s\n",
  483. ecc_mask ? "en" : "dis", cp->policy);
  484. for (i = 0; i < ARRAY_SIZE(mem_types); i++) {
  485. struct mem_type *t = &mem_types[i];
  486. if (t->prot_l1)
  487. t->prot_l1 |= PMD_DOMAIN(t->domain);
  488. if (t->prot_sect)
  489. t->prot_sect |= PMD_DOMAIN(t->domain);
  490. }
  491. }
  492. #ifdef CONFIG_ARM_DMA_MEM_BUFFERABLE
  493. pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
  494. unsigned long size, pgprot_t vma_prot)
  495. {
  496. if (!pfn_valid(pfn))
  497. return pgprot_noncached(vma_prot);
  498. else if (file->f_flags & O_SYNC)
  499. return pgprot_writecombine(vma_prot);
  500. return vma_prot;
  501. }
  502. EXPORT_SYMBOL(phys_mem_access_prot);
  503. #endif
  504. #define vectors_base() (vectors_high() ? 0xffff0000 : 0)
  505. static void __init *early_alloc_aligned(unsigned long sz, unsigned long align)
  506. {
  507. void *ptr = __va(memblock_alloc(sz, align));
  508. memset(ptr, 0, sz);
  509. return ptr;
  510. }
  511. static void __init *early_alloc(unsigned long sz)
  512. {
  513. return early_alloc_aligned(sz, sz);
  514. }
  515. static pte_t * __init early_pte_alloc(pmd_t *pmd, unsigned long addr, unsigned long prot)
  516. {
  517. if (pmd_none(*pmd)) {
  518. pte_t *pte = early_alloc(PTE_HWTABLE_OFF + PTE_HWTABLE_SIZE);
  519. __pmd_populate(pmd, __pa(pte), prot);
  520. }
  521. BUG_ON(pmd_bad(*pmd));
  522. return pte_offset_kernel(pmd, addr);
  523. }
  524. static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr,
  525. unsigned long end, unsigned long pfn,
  526. const struct mem_type *type)
  527. {
  528. pte_t *pte = early_pte_alloc(pmd, addr, type->prot_l1);
  529. do {
  530. set_pte_ext(pte, pfn_pte(pfn, __pgprot(type->prot_pte)), 0);
  531. pfn++;
  532. } while (pte++, addr += PAGE_SIZE, addr != end);
  533. }
  534. static void __init alloc_init_section(pud_t *pud, unsigned long addr,
  535. unsigned long end, phys_addr_t phys,
  536. const struct mem_type *type)
  537. {
  538. pmd_t *pmd = pmd_offset(pud, addr);
  539. /*
  540. * Try a section mapping - end, addr and phys must all be aligned
  541. * to a section boundary. Note that PMDs refer to the individual
  542. * L1 entries, whereas PGDs refer to a group of L1 entries making
  543. * up one logical pointer to an L2 table.
  544. */
  545. if (((addr | end | phys) & ~SECTION_MASK) == 0) {
  546. pmd_t *p = pmd;
  547. #ifndef CONFIG_ARM_LPAE
  548. if (addr & SECTION_SIZE)
  549. pmd++;
  550. #endif
  551. do {
  552. *pmd = __pmd(phys | type->prot_sect);
  553. phys += SECTION_SIZE;
  554. } while (pmd++, addr += SECTION_SIZE, addr != end);
  555. flush_pmd_entry(p);
  556. } else {
  557. /*
  558. * No need to loop; pte's aren't interested in the
  559. * individual L1 entries.
  560. */
  561. alloc_init_pte(pmd, addr, end, __phys_to_pfn(phys), type);
  562. }
  563. }
  564. static void alloc_init_pud(pgd_t *pgd, unsigned long addr, unsigned long end,
  565. unsigned long phys, const struct mem_type *type)
  566. {
  567. pud_t *pud = pud_offset(pgd, addr);
  568. unsigned long next;
  569. do {
  570. next = pud_addr_end(addr, end);
  571. alloc_init_section(pud, addr, next, phys, type);
  572. phys += next - addr;
  573. } while (pud++, addr = next, addr != end);
  574. }
  575. #ifndef CONFIG_ARM_LPAE
  576. static void __init create_36bit_mapping(struct map_desc *md,
  577. const struct mem_type *type)
  578. {
  579. unsigned long addr, length, end;
  580. phys_addr_t phys;
  581. pgd_t *pgd;
  582. addr = md->virtual;
  583. phys = __pfn_to_phys(md->pfn);
  584. length = PAGE_ALIGN(md->length);
  585. if (!(cpu_architecture() >= CPU_ARCH_ARMv6 || cpu_is_xsc3())) {
  586. printk(KERN_ERR "MM: CPU does not support supersection "
  587. "mapping for 0x%08llx at 0x%08lx\n",
  588. (long long)__pfn_to_phys((u64)md->pfn), addr);
  589. return;
  590. }
  591. /* N.B. ARMv6 supersections are only defined to work with domain 0.
  592. * Since domain assignments can in fact be arbitrary, the
  593. * 'domain == 0' check below is required to insure that ARMv6
  594. * supersections are only allocated for domain 0 regardless
  595. * of the actual domain assignments in use.
  596. */
  597. if (type->domain) {
  598. printk(KERN_ERR "MM: invalid domain in supersection "
  599. "mapping for 0x%08llx at 0x%08lx\n",
  600. (long long)__pfn_to_phys((u64)md->pfn), addr);
  601. return;
  602. }
  603. if ((addr | length | __pfn_to_phys(md->pfn)) & ~SUPERSECTION_MASK) {
  604. printk(KERN_ERR "MM: cannot create mapping for 0x%08llx"
  605. " at 0x%08lx invalid alignment\n",
  606. (long long)__pfn_to_phys((u64)md->pfn), addr);
  607. return;
  608. }
  609. /*
  610. * Shift bits [35:32] of address into bits [23:20] of PMD
  611. * (See ARMv6 spec).
  612. */
  613. phys |= (((md->pfn >> (32 - PAGE_SHIFT)) & 0xF) << 20);
  614. pgd = pgd_offset_k(addr);
  615. end = addr + length;
  616. do {
  617. pud_t *pud = pud_offset(pgd, addr);
  618. pmd_t *pmd = pmd_offset(pud, addr);
  619. int i;
  620. for (i = 0; i < 16; i++)
  621. *pmd++ = __pmd(phys | type->prot_sect | PMD_SECT_SUPER);
  622. addr += SUPERSECTION_SIZE;
  623. phys += SUPERSECTION_SIZE;
  624. pgd += SUPERSECTION_SIZE >> PGDIR_SHIFT;
  625. } while (addr != end);
  626. }
  627. #endif /* !CONFIG_ARM_LPAE */
  628. /*
  629. * Create the page directory entries and any necessary
  630. * page tables for the mapping specified by `md'. We
  631. * are able to cope here with varying sizes and address
  632. * offsets, and we take full advantage of sections and
  633. * supersections.
  634. */
  635. static void __init create_mapping(struct map_desc *md)
  636. {
  637. unsigned long addr, length, end;
  638. phys_addr_t phys;
  639. const struct mem_type *type;
  640. pgd_t *pgd;
  641. if (md->virtual != vectors_base() && md->virtual < TASK_SIZE) {
  642. printk(KERN_WARNING "BUG: not creating mapping for 0x%08llx"
  643. " at 0x%08lx in user region\n",
  644. (long long)__pfn_to_phys((u64)md->pfn), md->virtual);
  645. return;
  646. }
  647. if ((md->type == MT_DEVICE || md->type == MT_ROM) &&
  648. md->virtual >= PAGE_OFFSET &&
  649. (md->virtual < VMALLOC_START || md->virtual >= VMALLOC_END)) {
  650. printk(KERN_WARNING "BUG: mapping for 0x%08llx"
  651. " at 0x%08lx out of vmalloc space\n",
  652. (long long)__pfn_to_phys((u64)md->pfn), md->virtual);
  653. }
  654. type = &mem_types[md->type];
  655. #ifndef CONFIG_ARM_LPAE
  656. /*
  657. * Catch 36-bit addresses
  658. */
  659. if (md->pfn >= 0x100000) {
  660. create_36bit_mapping(md, type);
  661. return;
  662. }
  663. #endif
  664. addr = md->virtual & PAGE_MASK;
  665. phys = __pfn_to_phys(md->pfn);
  666. length = PAGE_ALIGN(md->length + (md->virtual & ~PAGE_MASK));
  667. if (type->prot_l1 == 0 && ((addr | phys | length) & ~SECTION_MASK)) {
  668. printk(KERN_WARNING "BUG: map for 0x%08llx at 0x%08lx can not "
  669. "be mapped using pages, ignoring.\n",
  670. (long long)__pfn_to_phys(md->pfn), addr);
  671. return;
  672. }
  673. pgd = pgd_offset_k(addr);
  674. end = addr + length;
  675. do {
  676. unsigned long next = pgd_addr_end(addr, end);
  677. alloc_init_pud(pgd, addr, next, phys, type);
  678. phys += next - addr;
  679. addr = next;
  680. } while (pgd++, addr != end);
  681. }
  682. /*
  683. * Create the architecture specific mappings
  684. */
  685. void __init iotable_init(struct map_desc *io_desc, int nr)
  686. {
  687. struct map_desc *md;
  688. struct vm_struct *vm;
  689. if (!nr)
  690. return;
  691. vm = early_alloc_aligned(sizeof(*vm) * nr, __alignof__(*vm));
  692. for (md = io_desc; nr; md++, nr--) {
  693. create_mapping(md);
  694. vm->addr = (void *)(md->virtual & PAGE_MASK);
  695. vm->size = PAGE_ALIGN(md->length + (md->virtual & ~PAGE_MASK));
  696. vm->phys_addr = __pfn_to_phys(md->pfn);
  697. vm->flags = VM_IOREMAP | VM_ARM_STATIC_MAPPING;
  698. vm->flags |= VM_ARM_MTYPE(md->type);
  699. vm->caller = iotable_init;
  700. vm_area_add_early(vm++);
  701. }
  702. }
  703. static void * __initdata vmalloc_min =
  704. (void *)(VMALLOC_END - (240 << 20) - VMALLOC_OFFSET);
  705. /*
  706. * vmalloc=size forces the vmalloc area to be exactly 'size'
  707. * bytes. This can be used to increase (or decrease) the vmalloc
  708. * area - the default is 240m.
  709. */
  710. static int __init early_vmalloc(char *arg)
  711. {
  712. unsigned long vmalloc_reserve = memparse(arg, NULL);
  713. if (vmalloc_reserve < SZ_16M) {
  714. vmalloc_reserve = SZ_16M;
  715. printk(KERN_WARNING
  716. "vmalloc area too small, limiting to %luMB\n",
  717. vmalloc_reserve >> 20);
  718. }
  719. if (vmalloc_reserve > VMALLOC_END - (PAGE_OFFSET + SZ_32M)) {
  720. vmalloc_reserve = VMALLOC_END - (PAGE_OFFSET + SZ_32M);
  721. printk(KERN_WARNING
  722. "vmalloc area is too big, limiting to %luMB\n",
  723. vmalloc_reserve >> 20);
  724. }
  725. vmalloc_min = (void *)(VMALLOC_END - vmalloc_reserve);
  726. return 0;
  727. }
  728. early_param("vmalloc", early_vmalloc);
  729. static phys_addr_t lowmem_limit __initdata = 0;
  730. void __init sanity_check_meminfo(void)
  731. {
  732. int i, j, highmem = 0;
  733. for (i = 0, j = 0; i < meminfo.nr_banks; i++) {
  734. struct membank *bank = &meminfo.bank[j];
  735. *bank = meminfo.bank[i];
  736. if (bank->start > ULONG_MAX)
  737. highmem = 1;
  738. #ifdef CONFIG_HIGHMEM
  739. if (__va(bank->start) >= vmalloc_min ||
  740. __va(bank->start) < (void *)PAGE_OFFSET)
  741. highmem = 1;
  742. bank->highmem = highmem;
  743. /*
  744. * Split those memory banks which are partially overlapping
  745. * the vmalloc area greatly simplifying things later.
  746. */
  747. if (!highmem && __va(bank->start) < vmalloc_min &&
  748. bank->size > vmalloc_min - __va(bank->start)) {
  749. if (meminfo.nr_banks >= NR_BANKS) {
  750. printk(KERN_CRIT "NR_BANKS too low, "
  751. "ignoring high memory\n");
  752. } else {
  753. memmove(bank + 1, bank,
  754. (meminfo.nr_banks - i) * sizeof(*bank));
  755. meminfo.nr_banks++;
  756. i++;
  757. bank[1].size -= vmalloc_min - __va(bank->start);
  758. bank[1].start = __pa(vmalloc_min - 1) + 1;
  759. bank[1].highmem = highmem = 1;
  760. j++;
  761. }
  762. bank->size = vmalloc_min - __va(bank->start);
  763. }
  764. #else
  765. bank->highmem = highmem;
  766. /*
  767. * Highmem banks not allowed with !CONFIG_HIGHMEM.
  768. */
  769. if (highmem) {
  770. printk(KERN_NOTICE "Ignoring RAM at %.8llx-%.8llx "
  771. "(!CONFIG_HIGHMEM).\n",
  772. (unsigned long long)bank->start,
  773. (unsigned long long)bank->start + bank->size - 1);
  774. continue;
  775. }
  776. /*
  777. * Check whether this memory bank would entirely overlap
  778. * the vmalloc area.
  779. */
  780. if (__va(bank->start) >= vmalloc_min ||
  781. __va(bank->start) < (void *)PAGE_OFFSET) {
  782. printk(KERN_NOTICE "Ignoring RAM at %.8llx-%.8llx "
  783. "(vmalloc region overlap).\n",
  784. (unsigned long long)bank->start,
  785. (unsigned long long)bank->start + bank->size - 1);
  786. continue;
  787. }
  788. /*
  789. * Check whether this memory bank would partially overlap
  790. * the vmalloc area.
  791. */
  792. if (__va(bank->start + bank->size) > vmalloc_min ||
  793. __va(bank->start + bank->size) < __va(bank->start)) {
  794. unsigned long newsize = vmalloc_min - __va(bank->start);
  795. printk(KERN_NOTICE "Truncating RAM at %.8llx-%.8llx "
  796. "to -%.8llx (vmalloc region overlap).\n",
  797. (unsigned long long)bank->start,
  798. (unsigned long long)bank->start + bank->size - 1,
  799. (unsigned long long)bank->start + newsize - 1);
  800. bank->size = newsize;
  801. }
  802. #endif
  803. if (!bank->highmem && bank->start + bank->size > lowmem_limit)
  804. lowmem_limit = bank->start + bank->size;
  805. j++;
  806. }
  807. #ifdef CONFIG_HIGHMEM
  808. if (highmem) {
  809. const char *reason = NULL;
  810. if (cache_is_vipt_aliasing()) {
  811. /*
  812. * Interactions between kmap and other mappings
  813. * make highmem support with aliasing VIPT caches
  814. * rather difficult.
  815. */
  816. reason = "with VIPT aliasing cache";
  817. }
  818. if (reason) {
  819. printk(KERN_CRIT "HIGHMEM is not supported %s, ignoring high memory\n",
  820. reason);
  821. while (j > 0 && meminfo.bank[j - 1].highmem)
  822. j--;
  823. }
  824. }
  825. #endif
  826. meminfo.nr_banks = j;
  827. high_memory = __va(lowmem_limit - 1) + 1;
  828. memblock_set_current_limit(lowmem_limit);
  829. }
  830. static inline void prepare_page_table(void)
  831. {
  832. unsigned long addr;
  833. phys_addr_t end;
  834. /*
  835. * Clear out all the mappings below the kernel image.
  836. */
  837. for (addr = 0; addr < MODULES_VADDR; addr += PMD_SIZE)
  838. pmd_clear(pmd_off_k(addr));
  839. #ifdef CONFIG_XIP_KERNEL
  840. /* The XIP kernel is mapped in the module area -- skip over it */
  841. addr = ((unsigned long)_etext + PMD_SIZE - 1) & PMD_MASK;
  842. #endif
  843. for ( ; addr < PAGE_OFFSET; addr += PMD_SIZE)
  844. pmd_clear(pmd_off_k(addr));
  845. /*
  846. * Find the end of the first block of lowmem.
  847. */
  848. end = memblock.memory.regions[0].base + memblock.memory.regions[0].size;
  849. if (end >= lowmem_limit)
  850. end = lowmem_limit;
  851. /*
  852. * Clear out all the kernel space mappings, except for the first
  853. * memory bank, up to the vmalloc region.
  854. */
  855. for (addr = __phys_to_virt(end);
  856. addr < VMALLOC_START; addr += PMD_SIZE)
  857. pmd_clear(pmd_off_k(addr));
  858. }
  859. #ifdef CONFIG_ARM_LPAE
  860. /* the first page is reserved for pgd */
  861. #define SWAPPER_PG_DIR_SIZE (PAGE_SIZE + \
  862. PTRS_PER_PGD * PTRS_PER_PMD * sizeof(pmd_t))
  863. #else
  864. #define SWAPPER_PG_DIR_SIZE (PTRS_PER_PGD * sizeof(pgd_t))
  865. #endif
  866. /*
  867. * Reserve the special regions of memory
  868. */
  869. void __init arm_mm_memblock_reserve(void)
  870. {
  871. /*
  872. * Reserve the page tables. These are already in use,
  873. * and can only be in node 0.
  874. */
  875. memblock_reserve(__pa(swapper_pg_dir), SWAPPER_PG_DIR_SIZE);
  876. #ifdef CONFIG_SA1111
  877. /*
  878. * Because of the SA1111 DMA bug, we want to preserve our
  879. * precious DMA-able memory...
  880. */
  881. memblock_reserve(PHYS_OFFSET, __pa(swapper_pg_dir) - PHYS_OFFSET);
  882. #endif
  883. }
  884. /*
  885. * Set up the device mappings. Since we clear out the page tables for all
  886. * mappings above VMALLOC_START, we will remove any debug device mappings.
  887. * This means you have to be careful how you debug this function, or any
  888. * called function. This means you can't use any function or debugging
  889. * method which may touch any device, otherwise the kernel _will_ crash.
  890. */
  891. static void __init devicemaps_init(struct machine_desc *mdesc)
  892. {
  893. struct map_desc map;
  894. unsigned long addr;
  895. void *vectors;
  896. /*
  897. * Allocate the vector page early.
  898. */
  899. vectors = early_alloc(PAGE_SIZE);
  900. early_trap_init(vectors);
  901. for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
  902. pmd_clear(pmd_off_k(addr));
  903. /*
  904. * Map the kernel if it is XIP.
  905. * It is always first in the modulearea.
  906. */
  907. #ifdef CONFIG_XIP_KERNEL
  908. map.pfn = __phys_to_pfn(CONFIG_XIP_PHYS_ADDR & SECTION_MASK);
  909. map.virtual = MODULES_VADDR;
  910. map.length = ((unsigned long)_etext - map.virtual + ~SECTION_MASK) & SECTION_MASK;
  911. map.type = MT_ROM;
  912. create_mapping(&map);
  913. #endif
  914. /*
  915. * Map the cache flushing regions.
  916. */
  917. #ifdef FLUSH_BASE
  918. map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS);
  919. map.virtual = FLUSH_BASE;
  920. map.length = SZ_1M;
  921. map.type = MT_CACHECLEAN;
  922. create_mapping(&map);
  923. #endif
  924. #ifdef FLUSH_BASE_MINICACHE
  925. map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS + SZ_1M);
  926. map.virtual = FLUSH_BASE_MINICACHE;
  927. map.length = SZ_1M;
  928. map.type = MT_MINICLEAN;
  929. create_mapping(&map);
  930. #endif
  931. /*
  932. * Create a mapping for the machine vectors at the high-vectors
  933. * location (0xffff0000). If we aren't using high-vectors, also
  934. * create a mapping at the low-vectors virtual address.
  935. */
  936. map.pfn = __phys_to_pfn(virt_to_phys(vectors));
  937. map.virtual = 0xffff0000;
  938. map.length = PAGE_SIZE;
  939. map.type = MT_HIGH_VECTORS;
  940. create_mapping(&map);
  941. if (!vectors_high()) {
  942. map.virtual = 0;
  943. map.type = MT_LOW_VECTORS;
  944. create_mapping(&map);
  945. }
  946. /*
  947. * Ask the machine support to map in the statically mapped devices.
  948. */
  949. if (mdesc->map_io)
  950. mdesc->map_io();
  951. /*
  952. * Finally flush the caches and tlb to ensure that we're in a
  953. * consistent state wrt the writebuffer. This also ensures that
  954. * any write-allocated cache lines in the vector page are written
  955. * back. After this point, we can start to touch devices again.
  956. */
  957. local_flush_tlb_all();
  958. flush_cache_all();
  959. }
  960. static void __init kmap_init(void)
  961. {
  962. #ifdef CONFIG_HIGHMEM
  963. pkmap_page_table = early_pte_alloc(pmd_off_k(PKMAP_BASE),
  964. PKMAP_BASE, _PAGE_KERNEL_TABLE);
  965. #endif
  966. }
  967. static void __init map_lowmem(void)
  968. {
  969. struct memblock_region *reg;
  970. /* Map all the lowmem memory banks. */
  971. for_each_memblock(memory, reg) {
  972. phys_addr_t start = reg->base;
  973. phys_addr_t end = start + reg->size;
  974. struct map_desc map;
  975. if (end > lowmem_limit)
  976. end = lowmem_limit;
  977. if (start >= end)
  978. break;
  979. map.pfn = __phys_to_pfn(start);
  980. map.virtual = __phys_to_virt(start);
  981. map.length = end - start;
  982. map.type = MT_MEMORY;
  983. create_mapping(&map);
  984. }
  985. }
  986. /*
  987. * paging_init() sets up the page tables, initialises the zone memory
  988. * maps, and sets up the zero page, bad page and bad page tables.
  989. */
  990. void __init paging_init(struct machine_desc *mdesc)
  991. {
  992. void *zero_page;
  993. memblock_set_current_limit(lowmem_limit);
  994. build_mem_type_table();
  995. prepare_page_table();
  996. map_lowmem();
  997. devicemaps_init(mdesc);
  998. kmap_init();
  999. top_pmd = pmd_off_k(0xffff0000);
  1000. /* allocate the zero page. */
  1001. zero_page = early_alloc(PAGE_SIZE);
  1002. bootmem_init();
  1003. empty_zero_page = virt_to_page(zero_page);
  1004. __flush_dcache_page(NULL, empty_zero_page);
  1005. }