mmu.txt 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. MMUv3 initialization sequence.
  2. The code in the initialize_mmu macro sets up MMUv3 memory mapping
  3. identically to MMUv2 fixed memory mapping. Depending on
  4. CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX symbol this code is
  5. located in addresses it was linked for (symbol undefined), or not
  6. (symbol defined), so it needs to be position-independent.
  7. The code has the following assumptions:
  8. This code fragment is run only on an MMU v3.
  9. TLBs are in their reset state.
  10. ITLBCFG and DTLBCFG are zero (reset state).
  11. RASID is 0x04030201 (reset state).
  12. PS.RING is zero (reset state).
  13. LITBASE is zero (reset state, PC-relative literals); required to be PIC.
  14. TLB setup proceeds along the following steps.
  15. Legend:
  16. VA = virtual address (two upper nibbles of it);
  17. PA = physical address (two upper nibbles of it);
  18. pc = physical range that contains this code;
  19. After step 2, we jump to virtual address in the range 0x40000000..0x5fffffff
  20. or 0x00000000..0x1fffffff, depending on whether the kernel was loaded below
  21. 0x40000000 or above. That address corresponds to next instruction to execute
  22. in this code. After step 4, we jump to intended (linked) address of this code.
  23. The scheme below assumes that the kernel is loaded below 0x40000000.
  24. Step0 Step1 Step2 Step3 Step4 Step5
  25. ===== ===== ===== ===== ===== =====
  26. VA PA PA PA PA VA PA PA
  27. ------ -- -- -- -- ------ -- --
  28. E0..FF -> E0 -> E0 -> E0 F0..FF -> F0 -> F0
  29. C0..DF -> C0 -> C0 -> C0 E0..EF -> F0 -> F0
  30. A0..BF -> A0 -> A0 -> A0 D8..DF -> 00 -> 00
  31. 80..9F -> 80 -> 80 -> 80 D0..D7 -> 00 -> 00
  32. 60..7F -> 60 -> 60 -> 60
  33. 40..5F -> 40 -> pc -> pc 40..5F -> pc
  34. 20..3F -> 20 -> 20 -> 20
  35. 00..1F -> 00 -> 00 -> 00
  36. The default location of IO peripherals is above 0xf0000000. This may be changed
  37. using a "ranges" property in a device tree simple-bus node. See the Devicetree
  38. Specification, section 4.5 for details on the syntax and semantics of
  39. simple-bus nodes. The following limitations apply:
  40. 1. Only top level simple-bus nodes are considered
  41. 2. Only one (first) simple-bus node is considered
  42. 3. Empty "ranges" properties are not supported
  43. 4. Only the first triplet in the "ranges" property is considered
  44. 5. The parent-bus-address value is rounded down to the nearest 256MB boundary
  45. 6. The IO area covers the entire 256MB segment of parent-bus-address; the
  46. "ranges" triplet length field is ignored
  47. MMUv3 address space layouts.
  48. ============================
  49. Default MMUv2-compatible layout.
  50. Symbol VADDR Size
  51. +------------------+
  52. | Userspace | 0x00000000 TASK_SIZE
  53. +------------------+ 0x40000000
  54. +------------------+
  55. | Page table | XCHAL_PAGE_TABLE_VADDR 0x80000000 XCHAL_PAGE_TABLE_SIZE
  56. +------------------+
  57. | KASAN shadow map | KASAN_SHADOW_START 0x80400000 KASAN_SHADOW_SIZE
  58. +------------------+ 0x8e400000
  59. +------------------+
  60. | VMALLOC area | VMALLOC_START 0xc0000000 128MB - 64KB
  61. +------------------+ VMALLOC_END
  62. | Cache aliasing | TLBTEMP_BASE_1 0xc7ff0000 DCACHE_WAY_SIZE
  63. | remap area 1 |
  64. +------------------+
  65. | Cache aliasing | TLBTEMP_BASE_2 DCACHE_WAY_SIZE
  66. | remap area 2 |
  67. +------------------+
  68. +------------------+
  69. | KMAP area | PKMAP_BASE PTRS_PER_PTE *
  70. | | DCACHE_N_COLORS *
  71. | | PAGE_SIZE
  72. | | (4MB * DCACHE_N_COLORS)
  73. +------------------+
  74. | Atomic KMAP area | FIXADDR_START KM_TYPE_NR *
  75. | | NR_CPUS *
  76. | | DCACHE_N_COLORS *
  77. | | PAGE_SIZE
  78. +------------------+ FIXADDR_TOP 0xcffff000
  79. +------------------+
  80. | Cached KSEG | XCHAL_KSEG_CACHED_VADDR 0xd0000000 128MB
  81. +------------------+
  82. | Uncached KSEG | XCHAL_KSEG_BYPASS_VADDR 0xd8000000 128MB
  83. +------------------+
  84. | Cached KIO | XCHAL_KIO_CACHED_VADDR 0xe0000000 256MB
  85. +------------------+
  86. | Uncached KIO | XCHAL_KIO_BYPASS_VADDR 0xf0000000 256MB
  87. +------------------+
  88. 256MB cached + 256MB uncached layout.
  89. Symbol VADDR Size
  90. +------------------+
  91. | Userspace | 0x00000000 TASK_SIZE
  92. +------------------+ 0x40000000
  93. +------------------+
  94. | Page table | XCHAL_PAGE_TABLE_VADDR 0x80000000 XCHAL_PAGE_TABLE_SIZE
  95. +------------------+
  96. | KASAN shadow map | KASAN_SHADOW_START 0x80400000 KASAN_SHADOW_SIZE
  97. +------------------+ 0x8e400000
  98. +------------------+
  99. | VMALLOC area | VMALLOC_START 0xa0000000 128MB - 64KB
  100. +------------------+ VMALLOC_END
  101. | Cache aliasing | TLBTEMP_BASE_1 0xa7ff0000 DCACHE_WAY_SIZE
  102. | remap area 1 |
  103. +------------------+
  104. | Cache aliasing | TLBTEMP_BASE_2 DCACHE_WAY_SIZE
  105. | remap area 2 |
  106. +------------------+
  107. +------------------+
  108. | KMAP area | PKMAP_BASE PTRS_PER_PTE *
  109. | | DCACHE_N_COLORS *
  110. | | PAGE_SIZE
  111. | | (4MB * DCACHE_N_COLORS)
  112. +------------------+
  113. | Atomic KMAP area | FIXADDR_START KM_TYPE_NR *
  114. | | NR_CPUS *
  115. | | DCACHE_N_COLORS *
  116. | | PAGE_SIZE
  117. +------------------+ FIXADDR_TOP 0xaffff000
  118. +------------------+
  119. | Cached KSEG | XCHAL_KSEG_CACHED_VADDR 0xb0000000 256MB
  120. +------------------+
  121. | Uncached KSEG | XCHAL_KSEG_BYPASS_VADDR 0xc0000000 256MB
  122. +------------------+
  123. +------------------+
  124. | Cached KIO | XCHAL_KIO_CACHED_VADDR 0xe0000000 256MB
  125. +------------------+
  126. | Uncached KIO | XCHAL_KIO_BYPASS_VADDR 0xf0000000 256MB
  127. +------------------+
  128. 512MB cached + 512MB uncached layout.
  129. Symbol VADDR Size
  130. +------------------+
  131. | Userspace | 0x00000000 TASK_SIZE
  132. +------------------+ 0x40000000
  133. +------------------+
  134. | Page table | XCHAL_PAGE_TABLE_VADDR 0x80000000 XCHAL_PAGE_TABLE_SIZE
  135. +------------------+
  136. | KASAN shadow map | KASAN_SHADOW_START 0x80400000 KASAN_SHADOW_SIZE
  137. +------------------+ 0x8e400000
  138. +------------------+
  139. | VMALLOC area | VMALLOC_START 0x90000000 128MB - 64KB
  140. +------------------+ VMALLOC_END
  141. | Cache aliasing | TLBTEMP_BASE_1 0x97ff0000 DCACHE_WAY_SIZE
  142. | remap area 1 |
  143. +------------------+
  144. | Cache aliasing | TLBTEMP_BASE_2 DCACHE_WAY_SIZE
  145. | remap area 2 |
  146. +------------------+
  147. +------------------+
  148. | KMAP area | PKMAP_BASE PTRS_PER_PTE *
  149. | | DCACHE_N_COLORS *
  150. | | PAGE_SIZE
  151. | | (4MB * DCACHE_N_COLORS)
  152. +------------------+
  153. | Atomic KMAP area | FIXADDR_START KM_TYPE_NR *
  154. | | NR_CPUS *
  155. | | DCACHE_N_COLORS *
  156. | | PAGE_SIZE
  157. +------------------+ FIXADDR_TOP 0x9ffff000
  158. +------------------+
  159. | Cached KSEG | XCHAL_KSEG_CACHED_VADDR 0xa0000000 512MB
  160. +------------------+
  161. | Uncached KSEG | XCHAL_KSEG_BYPASS_VADDR 0xc0000000 512MB
  162. +------------------+
  163. | Cached KIO | XCHAL_KIO_CACHED_VADDR 0xe0000000 256MB
  164. +------------------+
  165. | Uncached KIO | XCHAL_KIO_BYPASS_VADDR 0xf0000000 256MB
  166. +------------------+