bl31.scat 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. #! armclang -E -x c
  2. /*
  3. * Copyright (c) 2019, ARM Limited and Contributors. All rights reserved.
  4. *
  5. * SPDX-License-Identifier: BSD-3-Clause
  6. */
  7. #include <platform_def.h>
  8. #define PAGE_SIZE (1024 * 4)
  9. LR_START BL31_BASE
  10. {
  11. __BL31_START__ +0 FIXED EMPTY 0
  12. {
  13. /* placeholder */
  14. }
  15. /* BL31_BASE address must be aligned on a page boundary. */
  16. ScatterAssert((ImageBase(__BL31_START__) AND 0xFFF) == 0)
  17. }
  18. LR_TEXT BL31_BASE
  19. {
  20. __TEXT__ +0 FIXED
  21. {
  22. *(:gdef:bl31_entrypoint, +FIRST)
  23. *(.text*)
  24. *(.vectors)
  25. .ANY1(+RO-CODE)
  26. }
  27. __TEXT_EPILOGUE__ AlignExpr(+0, PAGE_SIZE) FIXED EMPTY 0
  28. {
  29. /* section delimiter */
  30. }
  31. }
  32. LR_RO_DATA +0
  33. {
  34. __RODATA__ AlignExpr(ImageLimit(LR_TEXT), 0) FIXED
  35. {
  36. *(.rodata*)
  37. .ANY2(+RO-DATA)
  38. }
  39. /* Ensure 8-byte alignment for descriptors and ensure inclusion */
  40. __RT_SVC_DESCS__ AlignExpr(ImageLimit(__RODATA__), 8) FIXED
  41. {
  42. *(.rt_svc_descs)
  43. }
  44. #if ENABLE_PMF
  45. /* Ensure 8-byte alignment for descriptors and ensure inclusion */
  46. __PMF_SVC_DESCS__ AlignExpr(ImageLimit(__RT_SVC_DESCS__), 8) FIXED
  47. {
  48. *(.pmf_svc_descs)
  49. }
  50. #endif /* ENABLE_PMF */
  51. /*
  52. * Ensure 8-byte alignment for cpu_ops so that its fields are also
  53. * aligned.
  54. */
  55. __CPU_OPS__ AlignExpr(+0, 8) FIXED
  56. {
  57. *(.cpu_ops)
  58. }
  59. /*
  60. * Keep the .got section in the RO section as it is patched
  61. * prior to enabling the MMU and having the .got in RO is better for
  62. * security. GOT is a table of addresses so ensure 8-byte alignment.
  63. */
  64. __GOT__ AlignExpr(ImageLimit(__CPU_OPS__), 8) FIXED
  65. {
  66. *(.got)
  67. }
  68. /* Place pubsub sections for events */
  69. __PUBSUB_EVENTS__ AlignExpr(+0, 8) EMPTY 0
  70. {
  71. /* placeholder */
  72. }
  73. #include <lib/el3_runtime/pubsub_events.h>
  74. __RODATA_EPILOGUE__ AlignExpr(+0, PAGE_SIZE) FIXED EMPTY 0
  75. {
  76. /* section delimiter */
  77. }
  78. }
  79. /* cpu_ops must always be defined */
  80. ScatterAssert(ImageLength(__CPU_OPS__) > 0)
  81. #if SPM_MM
  82. LR_SPM +0
  83. {
  84. /*
  85. * Exception vectors of the SPM shim layer. They must be aligned to a 2K
  86. * address, but we need to place them in a separate page so that we can set
  87. * individual permissions to them, so the actual alignment needed is 4K.
  88. *
  89. * There's no need to include this into the RO section of BL31 because it
  90. * doesn't need to be accessed by BL31.
  91. */
  92. __SPM_SHIM_EXCEPTIONS__ AlignExpr(ImageLimit(LR_RO_DATA), PAGE_SIZE) FIXED
  93. {
  94. *(.spm_shim_exceptions)
  95. }
  96. __SPM_SHIM_EXCEPTIONS_EPILOGUE__ AlignExpr(ImageLimit(__SPM_SHIM_EXCEPTIONS__), PAGE_SIZE) FIXED
  97. {
  98. /* placeholder */
  99. }
  100. }
  101. #endif
  102. LR_RW_DATA +0
  103. {
  104. __DATA__ AlignExpr(+0, 16) FIXED
  105. {
  106. *(.data*)
  107. *(.constdata)
  108. *(locale$$data)
  109. }
  110. }
  111. LR_RELA +0
  112. {
  113. /*
  114. * .rela.dyn needs to come after .data for the read-elf utility to parse
  115. * this section correctly. Ensure 8-byte alignment so that the fields of
  116. * RELA data structure are aligned.
  117. */
  118. __RELA__ AlignExpr(ImageLimit(LR_RW_DATA), 8) FIXED
  119. {
  120. *(.rela.dyn)
  121. }
  122. }
  123. #ifdef BL31_PROGBITS_LIMIT
  124. /* BL31 progbits has exceeded its limit. */
  125. ScatterAssert(ImageLimit(LR_RELA) <= BL31_PROGBITS_LIMIT)
  126. #endif
  127. LR_STACKS +0
  128. {
  129. __STACKS__ AlignExpr(+0, 64) FIXED
  130. {
  131. *(.tzfw_normal_stacks)
  132. }
  133. }
  134. #define __BAKERY_LOCK_SIZE__ (ImageLimit(__BAKERY_LOCKS_EPILOGUE__) - \
  135. ImageBase(__BAKERY_LOCKS__))
  136. #define BAKERY_LOCK_SIZE (__BAKERY_LOCK_SIZE__ * (PLATFORM_CORE_COUNT - 1))
  137. #define __PMF_TIMESTAMP_SIZE__ (ImageLimit(__PMF_TIMESTAMP__) - \
  138. ImageBase(__PMF_TIMESTAMP__))
  139. #define PER_CPU_TIMESTAMP_SIZE (__PMF_TIMESTAMP_SIZE__ * (PLATFORM_CORE_COUNT - 1))
  140. LR_BSS +0
  141. {
  142. __BSS__ AlignExpr(ImageLimit(LR_STACKS), 256) FIXED
  143. {
  144. *(.bss*)
  145. *(COMDAT)
  146. }
  147. #if !USE_COHERENT_MEM
  148. /*
  149. * Bakery locks are stored in normal .bss memory
  150. *
  151. * Each lock's data is spread across multiple cache lines, one per CPU,
  152. * but multiple locks can share the same cache line.
  153. * The compiler will allocate enough memory for one CPU's bakery locks,
  154. * the remaining cache lines are allocated by the linker script
  155. */
  156. __BAKERY_LOCKS__ AlignExpr(ImageLimit(__BSS__), CACHE_WRITEBACK_GRANULE) FIXED
  157. {
  158. *(.bakery_lock)
  159. }
  160. __BAKERY_LOCKS_EPILOGUE__ AlignExpr(ImageLimit(__BAKERY_LOCKS__), CACHE_WRITEBACK_GRANULE) FIXED EMPTY 0
  161. {
  162. /* section delimiter */
  163. }
  164. __PER_CPU_BAKERY_LOCKS__ ImageLimit(__BAKERY_LOCKS_EPILOGUE__) FIXED FILL 0 BAKERY_LOCK_SIZE
  165. {
  166. /* padded memory section to store per cpu bakery locks */
  167. }
  168. #ifdef PLAT_PERCPU_BAKERY_LOCK_SIZE
  169. /* PLAT_PERCPU_BAKERY_LOCK_SIZE does not match bakery lock requirements */
  170. ScatterAssert(__PER_CPU_BAKERY_LOCK_SIZE__ == PLAT_PERCPU_BAKERY_LOCK_SIZE)
  171. #endif
  172. #endif
  173. #if ENABLE_PMF
  174. /*
  175. * Time-stamps are stored in normal .bss memory
  176. *
  177. * The compiler will allocate enough memory for one CPU's time-stamps,
  178. * the remaining memory for other CPU's is allocated by the
  179. * linker script
  180. */
  181. __PMF_TIMESTAMP__ AlignExpr(+0, CACHE_WRITEBACK_GRANULE) FIXED EMPTY CACHE_WRITEBACK_GRANULE
  182. {
  183. /* store timestamps in this carved out memory */
  184. }
  185. __PMF_TIMESTAMP_EPILOGUE__ AlignExpr(ImageLimit(__PMF_TIMESTAMP__), CACHE_WRITEBACK_GRANULE) FIXED EMPTY 0
  186. {
  187. /*
  188. * placeholder to make __PMF_TIMESTAMP_START__ end on a
  189. * CACHE_WRITEBACK_GRANULE boundary
  190. */
  191. }
  192. __PER_CPU_TIMESTAMPS__ +0 FIXED FILL 0 PER_CPU_TIMESTAMP_SIZE
  193. {
  194. /* padded memory section to store per cpu timestamps */
  195. }
  196. #endif /* ENABLE_PMF */
  197. }
  198. LR_XLAT_TABLE +0
  199. {
  200. .xlat_table +0 FIXED
  201. {
  202. *(.xlat_table)
  203. }
  204. }
  205. #if USE_COHERENT_MEM
  206. LR_COHERENT_RAM +0
  207. {
  208. /*
  209. * The base address of the coherent memory section must be page-aligned (4K)
  210. * to guarantee that the coherent data are stored on their own pages and
  211. * are not mixed with normal data. This is required to set up the correct
  212. * memory attributes for the coherent data page tables.
  213. */
  214. __COHERENT_RAM__ AlignExpr(+0, PAGE_SIZE) FIXED
  215. {
  216. /*
  217. * Bakery locks are stored in coherent memory
  218. *
  219. * Each lock's data is contiguous and fully allocated by the compiler
  220. */
  221. *(.bakery_lock)
  222. *(.tzfw_coherent_mem)
  223. }
  224. __COHERENT_RAM_EPILOGUE_UNALIGNED__ +0 FIXED EMPTY 0
  225. {
  226. /* section delimiter */
  227. }
  228. /*
  229. * Memory page(s) mapped to this section will be marked
  230. * as device memory. No other unexpected data must creep in.
  231. * Ensure the rest of the current memory page is unused.
  232. */
  233. __COHERENT_RAM_EPILOGUE__ AlignExpr(ImageLimit(__COHERENT_RAM_START__), PAGE_SIZE) FIXED EMPTY 0
  234. {
  235. /* section delimiter */
  236. }
  237. }
  238. #endif
  239. LR_END +0
  240. {
  241. __BL31_END__ +0 FIXED EMPTY 0
  242. {
  243. /* placeholder */
  244. }
  245. /* BL31 image has exceeded its limit. */
  246. ScatterAssert(ImageLimit(__BL31_END__) <= BL31_LIMIT)
  247. }