proc.S 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Based on arch/arm/mm/proc.S
  4. *
  5. * Copyright (C) 2001 Deep Blue Solutions Ltd.
  6. * Copyright (C) 2012 ARM Ltd.
  7. * Author: Catalin Marinas <catalin.marinas@arm.com>
  8. */
  9. #include <linux/init.h>
  10. #include <linux/linkage.h>
  11. #include <linux/pgtable.h>
  12. #include <linux/cfi_types.h>
  13. #include <asm/assembler.h>
  14. #include <asm/asm-offsets.h>
  15. #include <asm/asm_pointer_auth.h>
  16. #include <asm/hwcap.h>
  17. #include <asm/kernel-pgtable.h>
  18. #include <asm/pgtable-hwdef.h>
  19. #include <asm/cpufeature.h>
  20. #include <asm/alternative.h>
  21. #include <asm/smp.h>
  22. #include <asm/sysreg.h>
  23. #ifdef CONFIG_ARM64_64K_PAGES
  24. #define TCR_TG_FLAGS ((TCR_EL1_TG0_64K << TCR_EL1_TG0_SHIFT) |\
  25. (TCR_EL1_TG1_64K << TCR_EL1_TG1_SHIFT))
  26. #elif defined(CONFIG_ARM64_16K_PAGES)
  27. #define TCR_TG_FLAGS ((TCR_EL1_TG0_16K << TCR_EL1_TG0_SHIFT) |\
  28. (TCR_EL1_TG1_16K << TCR_EL1_TG1_SHIFT))
  29. #else /* CONFIG_ARM64_4K_PAGES */
  30. #define TCR_TG_FLAGS ((TCR_EL1_TG0_4K << TCR_EL1_TG0_SHIFT) |\
  31. (TCR_EL1_TG1_4K << TCR_EL1_TG1_SHIFT))
  32. #endif
  33. #ifdef CONFIG_RANDOMIZE_BASE
  34. #define TCR_KASLR_FLAGS TCR_EL1_NFD1
  35. #else
  36. #define TCR_KASLR_FLAGS 0
  37. #endif
  38. /* PTWs cacheable, inner/outer WBWA */
  39. #define TCR_CACHE_FLAGS TCR_IRGN_WBWA | TCR_ORGN_WBWA
  40. #ifdef CONFIG_KASAN_SW_TAGS
  41. #define TCR_KASAN_SW_FLAGS TCR_EL1_TBI1 | TCR_EL1_TBID1
  42. #else
  43. #define TCR_KASAN_SW_FLAGS 0
  44. #endif
  45. #ifdef CONFIG_ARM64_MTE
  46. /*
  47. * The mte_zero_clear_page_tags() implementation uses DC GZVA, which relies on
  48. * TBI being enabled at EL1. TCMA1 is needed to treat accesses with the
  49. * match-all tag (0xF) as Tag Unchecked, irrespective of the SCTLR_EL1.TCF
  50. * setting.
  51. */
  52. #define TCR_MTE_FLAGS TCR_EL1_TCMA1 | TCR_EL1_TBI1 | TCR_EL1_TBID1
  53. #else
  54. #define TCR_MTE_FLAGS 0
  55. #endif
  56. #define TCR_IRGN_WBWA ((TCR_EL1_IRGN0_WBWA << TCR_EL1_IRGN0_SHIFT) |\
  57. (TCR_EL1_IRGN1_WBWA << TCR_EL1_IRGN1_SHIFT))
  58. #define TCR_ORGN_WBWA ((TCR_EL1_ORGN0_WBWA << TCR_EL1_ORGN0_SHIFT) |\
  59. (TCR_EL1_ORGN1_WBWA << TCR_EL1_ORGN1_SHIFT))
  60. #define TCR_SHARED ((TCR_EL1_SH0_INNER << TCR_EL1_SH0_SHIFT) |\
  61. (TCR_EL1_SH1_INNER << TCR_EL1_SH1_SHIFT))
  62. /*
  63. * Default MAIR_EL1. MT_NORMAL_TAGGED is initially mapped as Normal memory and
  64. * changed during mte_cpu_setup to Normal Tagged if the system supports MTE.
  65. */
  66. #define MAIR_EL1_SET \
  67. (MAIR_ATTRIDX(MAIR_ATTR_DEVICE_nGnRnE, MT_DEVICE_nGnRnE) | \
  68. MAIR_ATTRIDX(MAIR_ATTR_DEVICE_nGnRE, MT_DEVICE_nGnRE) | \
  69. MAIR_ATTRIDX(MAIR_ATTR_NORMAL_NC, MT_NORMAL_NC) | \
  70. MAIR_ATTRIDX(MAIR_ATTR_NORMAL, MT_NORMAL) | \
  71. MAIR_ATTRIDX(MAIR_ATTR_NORMAL, MT_NORMAL_TAGGED))
  72. #ifdef CONFIG_CPU_PM
  73. /**
  74. * cpu_do_suspend - save CPU registers context
  75. *
  76. * x0: virtual address of context pointer
  77. *
  78. * This must be kept in sync with struct cpu_suspend_ctx in <asm/suspend.h>.
  79. */
  80. SYM_FUNC_START(cpu_do_suspend)
  81. mrs x2, tpidr_el0
  82. mrs x3, tpidrro_el0
  83. mrs x4, contextidr_el1
  84. mrs x5, osdlr_el1
  85. mrs x6, cpacr_el1
  86. mrs x7, tcr_el1
  87. mrs x8, vbar_el1
  88. mrs x9, mdscr_el1
  89. mrs x10, oslsr_el1
  90. mrs x11, sctlr_el1
  91. get_this_cpu_offset x12
  92. mrs x13, sp_el0
  93. stp x2, x3, [x0]
  94. stp x4, x5, [x0, #16]
  95. stp x6, x7, [x0, #32]
  96. stp x8, x9, [x0, #48]
  97. stp x10, x11, [x0, #64]
  98. stp x12, x13, [x0, #80]
  99. /*
  100. * Save x18 as it may be used as a platform register, e.g. by shadow
  101. * call stack.
  102. */
  103. str x18, [x0, #96]
  104. alternative_if ARM64_HAS_TCR2
  105. mrs x2, REG_TCR2_EL1
  106. str x2, [x0, #104]
  107. alternative_else_nop_endif
  108. ret
  109. SYM_FUNC_END(cpu_do_suspend)
  110. /**
  111. * cpu_do_resume - restore CPU register context
  112. *
  113. * x0: Address of context pointer
  114. */
  115. SYM_FUNC_START(cpu_do_resume)
  116. ldp x2, x3, [x0]
  117. ldp x4, x5, [x0, #16]
  118. ldp x6, x8, [x0, #32]
  119. ldp x9, x10, [x0, #48]
  120. ldp x11, x12, [x0, #64]
  121. ldp x13, x14, [x0, #80]
  122. /*
  123. * Restore x18, as it may be used as a platform register, and clear
  124. * the buffer to minimize the risk of exposure when used for shadow
  125. * call stack.
  126. */
  127. ldr x18, [x0, #96]
  128. str xzr, [x0, #96]
  129. msr tpidr_el0, x2
  130. msr tpidrro_el0, x3
  131. msr contextidr_el1, x4
  132. msr cpacr_el1, x6
  133. /* Don't change t0sz here, mask those bits when restoring */
  134. mrs x7, tcr_el1
  135. bfi x8, x7, TCR_EL1_T0SZ_SHIFT, TCR_EL1_T0SZ_WIDTH
  136. msr tcr_el1, x8
  137. msr vbar_el1, x9
  138. msr mdscr_el1, x10
  139. alternative_if ARM64_HAS_TCR2
  140. ldr x2, [x0, #104]
  141. msr REG_TCR2_EL1, x2
  142. alternative_else_nop_endif
  143. msr sctlr_el1, x12
  144. set_this_cpu_offset x13
  145. msr sp_el0, x14
  146. /*
  147. * Restore oslsr_el1 by writing oslar_el1
  148. */
  149. msr osdlr_el1, x5
  150. ubfx x11, x11, #1, #1
  151. msr oslar_el1, x11
  152. reset_pmuserenr_el0 x0 // Disable PMU access from EL0
  153. reset_amuserenr_el0 x0 // Disable AMU access from EL0
  154. alternative_if ARM64_HAS_RAS_EXTN
  155. msr_s SYS_DISR_EL1, xzr
  156. alternative_else_nop_endif
  157. ptrauth_keys_install_kernel_nosync x14, x1, x2, x3
  158. isb
  159. ret
  160. SYM_FUNC_END(cpu_do_resume)
  161. #endif
  162. .pushsection ".idmap.text", "a"
  163. .macro __idmap_cpu_set_reserved_ttbr1, tmp1, tmp2
  164. adrp \tmp1, reserved_pg_dir
  165. phys_to_ttbr \tmp2, \tmp1
  166. offset_ttbr1 \tmp2, \tmp1
  167. msr ttbr1_el1, \tmp2
  168. isb
  169. tlbi vmalle1
  170. dsb nsh
  171. isb
  172. .endm
  173. /*
  174. * void idmap_cpu_replace_ttbr1(phys_addr_t ttbr1)
  175. *
  176. * This is the low-level counterpart to cpu_replace_ttbr1, and should not be
  177. * called by anything else. It can only be executed from a TTBR0 mapping.
  178. */
  179. SYM_TYPED_FUNC_START(idmap_cpu_replace_ttbr1)
  180. __idmap_cpu_set_reserved_ttbr1 x1, x3
  181. offset_ttbr1 x0, x3
  182. msr ttbr1_el1, x0
  183. isb
  184. ret
  185. SYM_FUNC_END(idmap_cpu_replace_ttbr1)
  186. SYM_FUNC_ALIAS(__pi_idmap_cpu_replace_ttbr1, idmap_cpu_replace_ttbr1)
  187. .popsection
  188. #ifdef CONFIG_UNMAP_KERNEL_AT_EL0
  189. #define KPTI_NG_PTE_FLAGS (PTE_ATTRINDX(MT_NORMAL) | PTE_TYPE_PAGE | \
  190. PTE_AF | PTE_SHARED | PTE_UXN | PTE_WRITE)
  191. .pushsection ".idmap.text", "a"
  192. .macro pte_to_phys, phys, pte
  193. and \phys, \pte, #PTE_ADDR_LOW
  194. #ifdef CONFIG_ARM64_PA_BITS_52
  195. and \pte, \pte, #PTE_ADDR_HIGH
  196. orr \phys, \phys, \pte, lsl #PTE_ADDR_HIGH_SHIFT
  197. #endif
  198. .endm
  199. .macro kpti_mk_tbl_ng, type, num_entries
  200. add end_\type\()p, cur_\type\()p, #\num_entries * 8
  201. .Ldo_\type:
  202. ldr \type, [cur_\type\()p], #8 // Load the entry and advance
  203. tbz \type, #0, .Lnext_\type // Skip invalid and
  204. tbnz \type, #11, .Lnext_\type // non-global entries
  205. orr \type, \type, #PTE_NG // Same bit for blocks and pages
  206. str \type, [cur_\type\()p, #-8] // Update the entry
  207. .ifnc \type, pte
  208. tbnz \type, #1, .Lderef_\type
  209. .endif
  210. .Lnext_\type:
  211. cmp cur_\type\()p, end_\type\()p
  212. b.ne .Ldo_\type
  213. .endm
  214. /*
  215. * Dereference the current table entry and map it into the temporary
  216. * fixmap slot associated with the current level.
  217. */
  218. .macro kpti_map_pgtbl, type, level
  219. str xzr, [temp_pte, #8 * (\level + 2)] // break before make
  220. dsb nshst
  221. add pte, temp_pte, #PAGE_SIZE * (\level + 2)
  222. lsr pte, pte, #12
  223. tlbi vaae1, pte
  224. dsb nsh
  225. isb
  226. phys_to_pte pte, cur_\type\()p
  227. add cur_\type\()p, temp_pte, #PAGE_SIZE * (\level + 2)
  228. orr pte, pte, pte_flags
  229. str pte, [temp_pte, #8 * (\level + 2)]
  230. dsb nshst
  231. .endm
  232. /*
  233. * void __kpti_install_ng_mappings(int cpu, int num_secondaries, phys_addr_t temp_pgd,
  234. * unsigned long temp_pte_va)
  235. *
  236. * Called exactly once from stop_machine context by each CPU found during boot.
  237. */
  238. SYM_TYPED_FUNC_START(idmap_kpti_install_ng_mappings)
  239. cpu .req w0
  240. temp_pte .req x0
  241. num_cpus .req w1
  242. pte_flags .req x1
  243. temp_pgd_phys .req x2
  244. swapper_ttb .req x3
  245. flag_ptr .req x4
  246. cur_pgdp .req x5
  247. end_pgdp .req x6
  248. pgd .req x7
  249. cur_pudp .req x8
  250. end_pudp .req x9
  251. cur_pmdp .req x11
  252. end_pmdp .req x12
  253. cur_ptep .req x14
  254. end_ptep .req x15
  255. pte .req x16
  256. valid .req x17
  257. cur_p4dp .req x19
  258. end_p4dp .req x20
  259. mov x5, x3 // preserve temp_pte arg
  260. mrs swapper_ttb, ttbr1_el1
  261. adr_l flag_ptr, idmap_kpti_bbml2_flag
  262. cbnz cpu, __idmap_kpti_secondary
  263. #if CONFIG_PGTABLE_LEVELS > 4
  264. stp x29, x30, [sp, #-32]!
  265. mov x29, sp
  266. stp x19, x20, [sp, #16]
  267. #endif
  268. /* We're the boot CPU. Wait for the others to catch up */
  269. sevl
  270. 1: wfe
  271. ldaxr w17, [flag_ptr]
  272. eor w17, w17, num_cpus
  273. cbnz w17, 1b
  274. /* Switch to the temporary page tables on this CPU only */
  275. __idmap_cpu_set_reserved_ttbr1 x8, x9
  276. offset_ttbr1 temp_pgd_phys, x8
  277. msr ttbr1_el1, temp_pgd_phys
  278. isb
  279. mov temp_pte, x5
  280. mov_q pte_flags, KPTI_NG_PTE_FLAGS
  281. /* Everybody is enjoying the idmap, so we can rewrite swapper. */
  282. #ifdef CONFIG_ARM64_LPA2
  283. /*
  284. * If LPA2 support is configured, but 52-bit virtual addressing is not
  285. * enabled at runtime, we will fall back to one level of paging less,
  286. * and so we have to walk swapper_pg_dir as if we dereferenced its
  287. * address from a PGD level entry, and terminate the PGD level loop
  288. * right after.
  289. */
  290. adrp pgd, swapper_pg_dir // walk &swapper_pg_dir at the next level
  291. mov cur_pgdp, end_pgdp // must be equal to terminate the PGD loop
  292. alternative_if_not ARM64_HAS_VA52
  293. b .Lderef_pgd // skip to the next level
  294. alternative_else_nop_endif
  295. /*
  296. * LPA2 based 52-bit virtual addressing requires 52-bit physical
  297. * addressing to be enabled as well. In this case, the shareability
  298. * bits are repurposed as physical address bits, and should not be
  299. * set in pte_flags.
  300. */
  301. bic pte_flags, pte_flags, #PTE_SHARED
  302. #endif
  303. /* PGD */
  304. adrp cur_pgdp, swapper_pg_dir
  305. kpti_map_pgtbl pgd, -1
  306. kpti_mk_tbl_ng pgd, PTRS_PER_PGD
  307. /* Ensure all the updated entries are visible to secondary CPUs */
  308. dsb ishst
  309. /* We're done: fire up swapper_pg_dir again */
  310. __idmap_cpu_set_reserved_ttbr1 x8, x9
  311. msr ttbr1_el1, swapper_ttb
  312. isb
  313. /* Set the flag to zero to indicate that we're all done */
  314. str wzr, [flag_ptr]
  315. #if CONFIG_PGTABLE_LEVELS > 4
  316. ldp x19, x20, [sp, #16]
  317. ldp x29, x30, [sp], #32
  318. #endif
  319. ret
  320. .Lderef_pgd:
  321. /* P4D */
  322. .if CONFIG_PGTABLE_LEVELS > 4
  323. p4d .req x30
  324. pte_to_phys cur_p4dp, pgd
  325. kpti_map_pgtbl p4d, 0
  326. kpti_mk_tbl_ng p4d, PTRS_PER_P4D
  327. b .Lnext_pgd
  328. .else /* CONFIG_PGTABLE_LEVELS <= 4 */
  329. p4d .req pgd
  330. .set .Lnext_p4d, .Lnext_pgd
  331. .endif
  332. .Lderef_p4d:
  333. /* PUD */
  334. .if CONFIG_PGTABLE_LEVELS > 3
  335. pud .req x10
  336. pte_to_phys cur_pudp, p4d
  337. kpti_map_pgtbl pud, 1
  338. kpti_mk_tbl_ng pud, PTRS_PER_PUD
  339. b .Lnext_p4d
  340. .else /* CONFIG_PGTABLE_LEVELS <= 3 */
  341. pud .req pgd
  342. .set .Lnext_pud, .Lnext_pgd
  343. .endif
  344. .Lderef_pud:
  345. /* PMD */
  346. .if CONFIG_PGTABLE_LEVELS > 2
  347. pmd .req x13
  348. pte_to_phys cur_pmdp, pud
  349. kpti_map_pgtbl pmd, 2
  350. kpti_mk_tbl_ng pmd, PTRS_PER_PMD
  351. b .Lnext_pud
  352. .else /* CONFIG_PGTABLE_LEVELS <= 2 */
  353. pmd .req pgd
  354. .set .Lnext_pmd, .Lnext_pgd
  355. .endif
  356. .Lderef_pmd:
  357. /* PTE */
  358. pte_to_phys cur_ptep, pmd
  359. kpti_map_pgtbl pte, 3
  360. kpti_mk_tbl_ng pte, PTRS_PER_PTE
  361. b .Lnext_pmd
  362. .unreq cpu
  363. .unreq temp_pte
  364. .unreq num_cpus
  365. .unreq pte_flags
  366. .unreq temp_pgd_phys
  367. .unreq cur_pgdp
  368. .unreq end_pgdp
  369. .unreq pgd
  370. .unreq cur_pudp
  371. .unreq end_pudp
  372. .unreq pud
  373. .unreq cur_pmdp
  374. .unreq end_pmdp
  375. .unreq pmd
  376. .unreq cur_ptep
  377. .unreq end_ptep
  378. .unreq pte
  379. .unreq valid
  380. .unreq cur_p4dp
  381. .unreq end_p4dp
  382. .unreq p4d
  383. /* Secondary CPUs end up here */
  384. __idmap_kpti_secondary:
  385. /* Uninstall swapper before surgery begins */
  386. __idmap_cpu_set_reserved_ttbr1 x16, x17
  387. b scondary_cpu_wait
  388. .unreq swapper_ttb
  389. .unreq flag_ptr
  390. SYM_FUNC_END(idmap_kpti_install_ng_mappings)
  391. .popsection
  392. #endif
  393. .pushsection ".idmap.text", "a"
  394. SYM_TYPED_FUNC_START(wait_linear_map_split_to_ptes)
  395. /* Must be same registers as in idmap_kpti_install_ng_mappings */
  396. swapper_ttb .req x3
  397. flag_ptr .req x4
  398. mrs swapper_ttb, ttbr1_el1
  399. adr_l flag_ptr, idmap_kpti_bbml2_flag
  400. __idmap_cpu_set_reserved_ttbr1 x16, x17
  401. scondary_cpu_wait:
  402. /* Increment the flag to let the boot CPU we're ready */
  403. 1: ldxr w16, [flag_ptr]
  404. add w16, w16, #1
  405. stxr w17, w16, [flag_ptr]
  406. cbnz w17, 1b
  407. /* Wait for the boot CPU to finish messing around with swapper */
  408. sevl
  409. 1: wfe
  410. ldxr w16, [flag_ptr]
  411. cbnz w16, 1b
  412. /* All done, act like nothing happened */
  413. msr ttbr1_el1, swapper_ttb
  414. isb
  415. ret
  416. .unreq swapper_ttb
  417. .unreq flag_ptr
  418. SYM_FUNC_END(wait_linear_map_split_to_ptes)
  419. .popsection
  420. /*
  421. * __cpu_setup
  422. *
  423. * Initialise the processor for turning the MMU on.
  424. *
  425. * Output:
  426. * Return in x0 the value of the SCTLR_EL1 register.
  427. */
  428. .pushsection ".idmap.text", "a"
  429. SYM_FUNC_START(__cpu_setup)
  430. tlbi vmalle1 // Invalidate local TLB
  431. dsb nsh
  432. msr cpacr_el1, xzr // Reset cpacr_el1
  433. mov x1, MDSCR_EL1_TDCC // Reset mdscr_el1 and disable
  434. msr mdscr_el1, x1 // access to the DCC from EL0
  435. reset_pmuserenr_el0 x1 // Disable PMU access from EL0
  436. reset_amuserenr_el0 x1 // Disable AMU access from EL0
  437. /*
  438. * Default values for VMSA control registers. These will be adjusted
  439. * below depending on detected CPU features.
  440. */
  441. mair .req x17
  442. tcr .req x16
  443. tcr2 .req x15
  444. mov_q mair, MAIR_EL1_SET
  445. mov_q tcr, TCR_T0SZ(IDMAP_VA_BITS) | TCR_T1SZ(VA_BITS_MIN) | TCR_CACHE_FLAGS | \
  446. TCR_SHARED | TCR_TG_FLAGS | TCR_KASLR_FLAGS | TCR_EL1_AS | \
  447. TCR_EL1_TBI0 | TCR_EL1_A1 | TCR_KASAN_SW_FLAGS | TCR_MTE_FLAGS
  448. mov tcr2, xzr
  449. tcr_clear_errata_bits tcr, x9, x5
  450. #ifdef CONFIG_ARM64_VA_BITS_52
  451. mov x9, #64 - VA_BITS
  452. alternative_if ARM64_HAS_VA52
  453. tcr_set_t1sz tcr, x9
  454. #ifdef CONFIG_ARM64_LPA2
  455. orr tcr, tcr, #TCR_EL1_DS
  456. #endif
  457. alternative_else_nop_endif
  458. #endif
  459. /*
  460. * Set the IPS bits in TCR_EL1.
  461. */
  462. tcr_compute_pa_size tcr, #TCR_EL1_IPS_SHIFT, x5, x6
  463. #ifdef CONFIG_ARM64_HW_AFDBM
  464. /*
  465. * Enable hardware update of the Access Flags bit.
  466. * Hardware dirty bit management is enabled later,
  467. * via capabilities.
  468. */
  469. mrs x9, ID_AA64MMFR1_EL1
  470. ubfx x9, x9, ID_AA64MMFR1_EL1_HAFDBS_SHIFT, #4
  471. cbz x9, 1f
  472. orr tcr, tcr, #TCR_EL1_HA // hardware Access flag update
  473. #ifdef CONFIG_ARM64_HAFT
  474. cmp x9, ID_AA64MMFR1_EL1_HAFDBS_HAFT
  475. b.lt 1f
  476. orr tcr2, tcr2, TCR2_EL1_HAFT
  477. #endif /* CONFIG_ARM64_HAFT */
  478. 1:
  479. #endif /* CONFIG_ARM64_HW_AFDBM */
  480. msr mair_el1, mair
  481. msr tcr_el1, tcr
  482. mrs_s x1, SYS_ID_AA64MMFR3_EL1
  483. ubfx x1, x1, #ID_AA64MMFR3_EL1_S1PIE_SHIFT, #4
  484. cbz x1, .Lskip_indirection
  485. mov_q x0, PIE_E0_ASM
  486. msr REG_PIRE0_EL1, x0
  487. mov_q x0, PIE_E1_ASM
  488. msr REG_PIR_EL1, x0
  489. orr tcr2, tcr2, TCR2_EL1_PIE
  490. .Lskip_indirection:
  491. mrs_s x1, SYS_ID_AA64MMFR3_EL1
  492. ubfx x1, x1, #ID_AA64MMFR3_EL1_TCRX_SHIFT, #4
  493. cbz x1, 1f
  494. msr REG_TCR2_EL1, tcr2
  495. 1:
  496. /*
  497. * Prepare SCTLR
  498. */
  499. mov_q x0, INIT_SCTLR_EL1_MMU_ON
  500. ret // return to head.S
  501. .unreq mair
  502. .unreq tcr
  503. .unreq tcr2
  504. SYM_FUNC_END(__cpu_setup)