entry-armv.S 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * linux/arch/arm/kernel/entry-armv.S
  4. *
  5. * Copyright (C) 1996,1997,1998 Russell King.
  6. * ARM700 fix by Matthew Godbolt ([email protected])
  7. * nommu support by Hyok S. Choi ([email protected])
  8. *
  9. * Low-level vector interface routines
  10. *
  11. * Note: there is a StrongARM bug in the STMIA rn, {regs}^ instruction
  12. * that causes it to save wrong values... Be aware!
  13. */
  14. #include <linux/init.h>
  15. #include <asm/assembler.h>
  16. #include <asm/memory.h>
  17. #include <asm/glue-df.h>
  18. #include <asm/glue-pf.h>
  19. #include <asm/vfpmacros.h>
  20. #include <asm/thread_notify.h>
  21. #include <asm/unwind.h>
  22. #include <asm/unistd.h>
  23. #include <asm/tls.h>
  24. #include <asm/system_info.h>
  25. #include <asm/uaccess-asm.h>
  26. #include "entry-header.S"
  27. #include <asm/probes.h>
  28. /*
  29. * Interrupt handling.
  30. */
  31. .macro irq_handler, from_user:req
  32. mov r1, sp
  33. ldr_this_cpu r2, irq_stack_ptr, r2, r3
  34. .if \from_user == 0
  35. @
  36. @ If we took the interrupt while running in the kernel, we may already
  37. @ be using the IRQ stack, so revert to the original value in that case.
  38. @
  39. subs r3, r2, r1 @ SP above bottom of IRQ stack?
  40. rsbscs r3, r3, #THREAD_SIZE @ ... and below the top?
  41. #ifdef CONFIG_VMAP_STACK
  42. ldr_va r3, high_memory, cc @ End of the linear region
  43. cmpcc r3, r1 @ Stack pointer was below it?
  44. #endif
  45. bcc 0f @ If not, switch to the IRQ stack
  46. mov r0, r1
  47. bl generic_handle_arch_irq
  48. b 1f
  49. 0:
  50. .endif
  51. mov_l r0, generic_handle_arch_irq
  52. bl call_with_stack
  53. 1:
  54. .endm
  55. .macro pabt_helper
  56. @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
  57. #ifdef MULTI_PABORT
  58. ldr_va ip, processor, offset=PROCESSOR_PABT_FUNC
  59. bl_r ip
  60. #else
  61. bl CPU_PABORT_HANDLER
  62. #endif
  63. .endm
  64. .macro dabt_helper
  65. @
  66. @ Call the processor-specific abort handler:
  67. @
  68. @ r2 - pt_regs
  69. @ r4 - aborted context pc
  70. @ r5 - aborted context psr
  71. @
  72. @ The abort handler must return the aborted address in r0, and
  73. @ the fault status register in r1. r9 must be preserved.
  74. @
  75. #ifdef MULTI_DABORT
  76. ldr_va ip, processor, offset=PROCESSOR_DABT_FUNC
  77. bl_r ip
  78. #else
  79. bl CPU_DABORT_HANDLER
  80. #endif
  81. .endm
  82. .section .entry.text,"ax",%progbits
  83. /*
  84. * Invalid mode handlers
  85. */
  86. .macro inv_entry, reason
  87. sub sp, sp, #PT_REGS_SIZE
  88. ARM( stmib sp, {r1 - lr} )
  89. THUMB( stmia sp, {r0 - r12} )
  90. THUMB( str sp, [sp, #S_SP] )
  91. THUMB( str lr, [sp, #S_LR] )
  92. mov r1, #\reason
  93. .endm
  94. __pabt_invalid:
  95. inv_entry BAD_PREFETCH
  96. b common_invalid
  97. ENDPROC(__pabt_invalid)
  98. __dabt_invalid:
  99. inv_entry BAD_DATA
  100. b common_invalid
  101. ENDPROC(__dabt_invalid)
  102. __irq_invalid:
  103. inv_entry BAD_IRQ
  104. b common_invalid
  105. ENDPROC(__irq_invalid)
  106. __und_invalid:
  107. inv_entry BAD_UNDEFINSTR
  108. @
  109. @ XXX fall through to common_invalid
  110. @
  111. @
  112. @ common_invalid - generic code for failed exception (re-entrant version of handlers)
  113. @
  114. common_invalid:
  115. zero_fp
  116. ldmia r0, {r4 - r6}
  117. add r0, sp, #S_PC @ here for interlock avoidance
  118. mov r7, #-1 @ "" "" "" ""
  119. str r4, [sp] @ save preserved r0
  120. stmia r0, {r5 - r7} @ lr_<exception>,
  121. @ cpsr_<exception>, "old_r0"
  122. mov r0, sp
  123. b bad_mode
  124. ENDPROC(__und_invalid)
  125. /*
  126. * SVC mode handlers
  127. */
  128. #if defined(CONFIG_AEABI) && (__LINUX_ARM_ARCH__ >= 5)
  129. #define SPFIX(code...) code
  130. #else
  131. #define SPFIX(code...)
  132. #endif
  133. .macro svc_entry, stack_hole=0, trace=1, uaccess=1, overflow_check=1
  134. UNWIND(.fnstart )
  135. sub sp, sp, #(SVC_REGS_SIZE + \stack_hole)
  136. THUMB( add sp, r1 ) @ get SP in a GPR without
  137. THUMB( sub r1, sp, r1 ) @ using a temp register
  138. .if \overflow_check
  139. UNWIND(.save {r0 - pc} )
  140. do_overflow_check (SVC_REGS_SIZE + \stack_hole)
  141. .endif
  142. #ifdef CONFIG_THUMB2_KERNEL
  143. tst r1, #4 @ test stack pointer alignment
  144. sub r1, sp, r1 @ restore original R1
  145. sub sp, r1 @ restore original SP
  146. #else
  147. SPFIX( tst sp, #4 )
  148. #endif
  149. SPFIX( subne sp, sp, #4 )
  150. ARM( stmib sp, {r1 - r12} )
  151. THUMB( stmia sp, {r0 - r12} ) @ No STMIB in Thumb-2
  152. ldmia r0, {r3 - r5}
  153. add r7, sp, #S_SP @ here for interlock avoidance
  154. mov r6, #-1 @ "" "" "" ""
  155. add r2, sp, #(SVC_REGS_SIZE + \stack_hole)
  156. SPFIX( addne r2, r2, #4 )
  157. str r3, [sp] @ save the "real" r0 copied
  158. @ from the exception stack
  159. mov r3, lr
  160. @
  161. @ We are now ready to fill in the remaining blanks on the stack:
  162. @
  163. @ r2 - sp_svc
  164. @ r3 - lr_svc
  165. @ r4 - lr_<exception>, already fixed up for correct return/restart
  166. @ r5 - spsr_<exception>
  167. @ r6 - orig_r0 (see pt_regs definition in ptrace.h)
  168. @
  169. stmia r7, {r2 - r6}
  170. get_thread_info tsk
  171. uaccess_entry tsk, r0, r1, r2, \uaccess
  172. .if \trace
  173. #ifdef CONFIG_TRACE_IRQFLAGS
  174. bl trace_hardirqs_off
  175. #endif
  176. .endif
  177. .endm
  178. .align 5
  179. __dabt_svc:
  180. svc_entry uaccess=0
  181. mov r2, sp
  182. dabt_helper
  183. THUMB( ldr r5, [sp, #S_PSR] ) @ potentially updated CPSR
  184. svc_exit r5 @ return from exception
  185. UNWIND(.fnend )
  186. ENDPROC(__dabt_svc)
  187. .align 5
  188. __irq_svc:
  189. svc_entry
  190. irq_handler from_user=0
  191. #ifdef CONFIG_PREEMPTION
  192. ldr r8, [tsk, #TI_PREEMPT] @ get preempt count
  193. ldr r0, [tsk, #TI_FLAGS] @ get flags
  194. teq r8, #0 @ if preempt count != 0
  195. movne r0, #0 @ force flags to 0
  196. tst r0, #_TIF_NEED_RESCHED
  197. blne svc_preempt
  198. #endif
  199. svc_exit r5, irq = 1 @ return from exception
  200. UNWIND(.fnend )
  201. ENDPROC(__irq_svc)
  202. .ltorg
  203. #ifdef CONFIG_PREEMPTION
  204. svc_preempt:
  205. mov r8, lr
  206. 1: bl preempt_schedule_irq @ irq en/disable is done inside
  207. ldr r0, [tsk, #TI_FLAGS] @ get new tasks TI_FLAGS
  208. tst r0, #_TIF_NEED_RESCHED
  209. reteq r8 @ go again
  210. b 1b
  211. #endif
  212. __und_fault:
  213. @ Correct the PC such that it is pointing at the instruction
  214. @ which caused the fault. If the faulting instruction was ARM
  215. @ the PC will be pointing at the next instruction, and have to
  216. @ subtract 4. Otherwise, it is Thumb, and the PC will be
  217. @ pointing at the second half of the Thumb instruction. We
  218. @ have to subtract 2.
  219. ldr r2, [r0, #S_PC]
  220. sub r2, r2, r1
  221. str r2, [r0, #S_PC]
  222. b do_undefinstr
  223. ENDPROC(__und_fault)
  224. .align 5
  225. __und_svc:
  226. #ifdef CONFIG_KPROBES
  227. @ If a kprobe is about to simulate a "stmdb sp..." instruction,
  228. @ it obviously needs free stack space which then will belong to
  229. @ the saved context.
  230. svc_entry MAX_STACK_SIZE
  231. #else
  232. svc_entry
  233. #endif
  234. mov r1, #4 @ PC correction to apply
  235. THUMB( tst r5, #PSR_T_BIT ) @ exception taken in Thumb mode?
  236. THUMB( movne r1, #2 ) @ if so, fix up PC correction
  237. mov r0, sp @ struct pt_regs *regs
  238. bl __und_fault
  239. __und_svc_finish:
  240. get_thread_info tsk
  241. ldr r5, [sp, #S_PSR] @ Get SVC cpsr
  242. svc_exit r5 @ return from exception
  243. UNWIND(.fnend )
  244. ENDPROC(__und_svc)
  245. .align 5
  246. __pabt_svc:
  247. svc_entry
  248. mov r2, sp @ regs
  249. pabt_helper
  250. svc_exit r5 @ return from exception
  251. UNWIND(.fnend )
  252. ENDPROC(__pabt_svc)
  253. .align 5
  254. __fiq_svc:
  255. svc_entry trace=0
  256. mov r0, sp @ struct pt_regs *regs
  257. bl handle_fiq_as_nmi
  258. svc_exit_via_fiq
  259. UNWIND(.fnend )
  260. ENDPROC(__fiq_svc)
  261. /*
  262. * Abort mode handlers
  263. */
  264. @
  265. @ Taking a FIQ in abort mode is similar to taking a FIQ in SVC mode
  266. @ and reuses the same macros. However in abort mode we must also
  267. @ save/restore lr_abt and spsr_abt to make nested aborts safe.
  268. @
  269. .align 5
  270. __fiq_abt:
  271. svc_entry trace=0
  272. ARM( msr cpsr_c, #ABT_MODE | PSR_I_BIT | PSR_F_BIT )
  273. THUMB( mov r0, #ABT_MODE | PSR_I_BIT | PSR_F_BIT )
  274. THUMB( msr cpsr_c, r0 )
  275. mov r1, lr @ Save lr_abt
  276. mrs r2, spsr @ Save spsr_abt, abort is now safe
  277. ARM( msr cpsr_c, #SVC_MODE | PSR_I_BIT | PSR_F_BIT )
  278. THUMB( mov r0, #SVC_MODE | PSR_I_BIT | PSR_F_BIT )
  279. THUMB( msr cpsr_c, r0 )
  280. stmfd sp!, {r1 - r2}
  281. add r0, sp, #8 @ struct pt_regs *regs
  282. bl handle_fiq_as_nmi
  283. ldmfd sp!, {r1 - r2}
  284. ARM( msr cpsr_c, #ABT_MODE | PSR_I_BIT | PSR_F_BIT )
  285. THUMB( mov r0, #ABT_MODE | PSR_I_BIT | PSR_F_BIT )
  286. THUMB( msr cpsr_c, r0 )
  287. mov lr, r1 @ Restore lr_abt, abort is unsafe
  288. msr spsr_cxsf, r2 @ Restore spsr_abt
  289. ARM( msr cpsr_c, #SVC_MODE | PSR_I_BIT | PSR_F_BIT )
  290. THUMB( mov r0, #SVC_MODE | PSR_I_BIT | PSR_F_BIT )
  291. THUMB( msr cpsr_c, r0 )
  292. svc_exit_via_fiq
  293. UNWIND(.fnend )
  294. ENDPROC(__fiq_abt)
  295. /*
  296. * User mode handlers
  297. *
  298. * EABI note: sp_svc is always 64-bit aligned here, so should PT_REGS_SIZE
  299. */
  300. #if defined(CONFIG_AEABI) && (__LINUX_ARM_ARCH__ >= 5) && (PT_REGS_SIZE & 7)
  301. #error "sizeof(struct pt_regs) must be a multiple of 8"
  302. #endif
  303. .macro usr_entry, trace=1, uaccess=1
  304. UNWIND(.fnstart )
  305. UNWIND(.cantunwind ) @ don't unwind the user space
  306. sub sp, sp, #PT_REGS_SIZE
  307. ARM( stmib sp, {r1 - r12} )
  308. THUMB( stmia sp, {r0 - r12} )
  309. ATRAP( mrc p15, 0, r7, c1, c0, 0)
  310. ATRAP( ldr_va r8, cr_alignment)
  311. ldmia r0, {r3 - r5}
  312. add r0, sp, #S_PC @ here for interlock avoidance
  313. mov r6, #-1 @ "" "" "" ""
  314. str r3, [sp] @ save the "real" r0 copied
  315. @ from the exception stack
  316. @
  317. @ We are now ready to fill in the remaining blanks on the stack:
  318. @
  319. @ r4 - lr_<exception>, already fixed up for correct return/restart
  320. @ r5 - spsr_<exception>
  321. @ r6 - orig_r0 (see pt_regs definition in ptrace.h)
  322. @
  323. @ Also, separately save sp_usr and lr_usr
  324. @
  325. stmia r0, {r4 - r6}
  326. ARM( stmdb r0, {sp, lr}^ )
  327. THUMB( store_user_sp_lr r0, r1, S_SP - S_PC )
  328. .if \uaccess
  329. uaccess_disable ip
  330. .endif
  331. @ Enable the alignment trap while in kernel mode
  332. ATRAP( teq r8, r7)
  333. ATRAP( mcrne p15, 0, r8, c1, c0, 0)
  334. reload_current r7, r8
  335. @
  336. @ Clear FP to mark the first stack frame
  337. @
  338. zero_fp
  339. .if \trace
  340. #ifdef CONFIG_TRACE_IRQFLAGS
  341. bl trace_hardirqs_off
  342. #endif
  343. ct_user_exit save = 0
  344. .endif
  345. .endm
  346. .macro kuser_cmpxchg_check
  347. #if !defined(CONFIG_CPU_32v6K) && defined(CONFIG_KUSER_HELPERS)
  348. #ifndef CONFIG_MMU
  349. #warning "NPTL on non MMU needs fixing"
  350. #else
  351. @ Make sure our user space atomic helper is restarted
  352. @ if it was interrupted in a critical region. Here we
  353. @ perform a quick test inline since it should be false
  354. @ 99.9999% of the time. The rest is done out of line.
  355. ldr r0, =TASK_SIZE
  356. cmp r4, r0
  357. blhs kuser_cmpxchg64_fixup
  358. #endif
  359. #endif
  360. .endm
  361. .align 5
  362. __dabt_usr:
  363. usr_entry uaccess=0
  364. kuser_cmpxchg_check
  365. mov r2, sp
  366. dabt_helper
  367. b ret_from_exception
  368. UNWIND(.fnend )
  369. ENDPROC(__dabt_usr)
  370. .align 5
  371. __irq_usr:
  372. usr_entry
  373. kuser_cmpxchg_check
  374. irq_handler from_user=1
  375. get_thread_info tsk
  376. mov why, #0
  377. b ret_to_user_from_irq
  378. UNWIND(.fnend )
  379. ENDPROC(__irq_usr)
  380. .ltorg
  381. .align 5
  382. __und_usr:
  383. usr_entry uaccess=0
  384. mov r2, r4
  385. mov r3, r5
  386. @ r2 = regs->ARM_pc, which is either 2 or 4 bytes ahead of the
  387. @ faulting instruction depending on Thumb mode.
  388. @ r3 = regs->ARM_cpsr
  389. @
  390. @ The emulation code returns using r9 if it has emulated the
  391. @ instruction, or the more conventional lr if we are to treat
  392. @ this as a real undefined instruction
  393. @
  394. badr r9, ret_from_exception
  395. @ IRQs must be enabled before attempting to read the instruction from
  396. @ user space since that could cause a page/translation fault if the
  397. @ page table was modified by another CPU.
  398. enable_irq
  399. tst r3, #PSR_T_BIT @ Thumb mode?
  400. bne __und_usr_thumb
  401. sub r4, r2, #4 @ ARM instr at LR - 4
  402. 1: ldrt r0, [r4]
  403. ARM_BE8(rev r0, r0) @ little endian instruction
  404. uaccess_disable ip
  405. @ r0 = 32-bit ARM instruction which caused the exception
  406. @ r2 = PC value for the following instruction (:= regs->ARM_pc)
  407. @ r4 = PC value for the faulting instruction
  408. @ lr = 32-bit undefined instruction function
  409. badr lr, __und_usr_fault_32
  410. b call_fpe
  411. __und_usr_thumb:
  412. @ Thumb instruction
  413. sub r4, r2, #2 @ First half of thumb instr at LR - 2
  414. #if CONFIG_ARM_THUMB && __LINUX_ARM_ARCH__ >= 6 && CONFIG_CPU_V7
  415. /*
  416. * Thumb-2 instruction handling. Note that because pre-v6 and >= v6 platforms
  417. * can never be supported in a single kernel, this code is not applicable at
  418. * all when __LINUX_ARM_ARCH__ < 6. This allows simplifying assumptions to be
  419. * made about .arch directives.
  420. */
  421. #if __LINUX_ARM_ARCH__ < 7
  422. /* If the target CPU may not be Thumb-2-capable, a run-time check is needed: */
  423. ldr_va r5, cpu_architecture
  424. cmp r5, #CPU_ARCH_ARMv7
  425. blo __und_usr_fault_16 @ 16bit undefined instruction
  426. /*
  427. * The following code won't get run unless the running CPU really is v7, so
  428. * coding round the lack of ldrht on older arches is pointless. Temporarily
  429. * override the assembler target arch with the minimum required instead:
  430. */
  431. .arch armv6t2
  432. #endif
  433. 2: ldrht r5, [r4]
  434. ARM_BE8(rev16 r5, r5) @ little endian instruction
  435. cmp r5, #0xe800 @ 32bit instruction if xx != 0
  436. blo __und_usr_fault_16_pan @ 16bit undefined instruction
  437. 3: ldrht r0, [r2]
  438. ARM_BE8(rev16 r0, r0) @ little endian instruction
  439. uaccess_disable ip
  440. add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
  441. str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
  442. orr r0, r0, r5, lsl #16
  443. badr lr, __und_usr_fault_32
  444. @ r0 = the two 16-bit Thumb instructions which caused the exception
  445. @ r2 = PC value for the following Thumb instruction (:= regs->ARM_pc)
  446. @ r4 = PC value for the first 16-bit Thumb instruction
  447. @ lr = 32bit undefined instruction function
  448. #if __LINUX_ARM_ARCH__ < 7
  449. /* If the target arch was overridden, change it back: */
  450. #ifdef CONFIG_CPU_32v6K
  451. .arch armv6k
  452. #else
  453. .arch armv6
  454. #endif
  455. #endif /* __LINUX_ARM_ARCH__ < 7 */
  456. #else /* !(CONFIG_ARM_THUMB && __LINUX_ARM_ARCH__ >= 6 && CONFIG_CPU_V7) */
  457. b __und_usr_fault_16
  458. #endif
  459. UNWIND(.fnend)
  460. ENDPROC(__und_usr)
  461. /*
  462. * The out of line fixup for the ldrt instructions above.
  463. */
  464. .pushsection .text.fixup, "ax"
  465. .align 2
  466. 4: str r4, [sp, #S_PC] @ retry current instruction
  467. ret r9
  468. .popsection
  469. .pushsection __ex_table,"a"
  470. .long 1b, 4b
  471. #if CONFIG_ARM_THUMB && __LINUX_ARM_ARCH__ >= 6 && CONFIG_CPU_V7
  472. .long 2b, 4b
  473. .long 3b, 4b
  474. #endif
  475. .popsection
  476. /*
  477. * Check whether the instruction is a co-processor instruction.
  478. * If yes, we need to call the relevant co-processor handler.
  479. *
  480. * Note that we don't do a full check here for the co-processor
  481. * instructions; all instructions with bit 27 set are well
  482. * defined. The only instructions that should fault are the
  483. * co-processor instructions. However, we have to watch out
  484. * for the ARM6/ARM7 SWI bug.
  485. *
  486. * NEON is a special case that has to be handled here. Not all
  487. * NEON instructions are co-processor instructions, so we have
  488. * to make a special case of checking for them. Plus, there's
  489. * five groups of them, so we have a table of mask/opcode pairs
  490. * to check against, and if any match then we branch off into the
  491. * NEON handler code.
  492. *
  493. * Emulators may wish to make use of the following registers:
  494. * r0 = instruction opcode (32-bit ARM or two 16-bit Thumb)
  495. * r2 = PC value to resume execution after successful emulation
  496. * r9 = normal "successful" return address
  497. * r10 = this threads thread_info structure
  498. * lr = unrecognised instruction return address
  499. * IRQs enabled, FIQs enabled.
  500. */
  501. @
  502. @ Fall-through from Thumb-2 __und_usr
  503. @
  504. #ifdef CONFIG_NEON
  505. get_thread_info r10 @ get current thread
  506. adr r6, .LCneon_thumb_opcodes
  507. b 2f
  508. #endif
  509. call_fpe:
  510. get_thread_info r10 @ get current thread
  511. #ifdef CONFIG_NEON
  512. adr r6, .LCneon_arm_opcodes
  513. 2: ldr r5, [r6], #4 @ mask value
  514. ldr r7, [r6], #4 @ opcode bits matching in mask
  515. cmp r5, #0 @ end mask?
  516. beq 1f
  517. and r8, r0, r5
  518. cmp r8, r7 @ NEON instruction?
  519. bne 2b
  520. mov r7, #1
  521. strb r7, [r10, #TI_USED_CP + 10] @ mark CP#10 as used
  522. strb r7, [r10, #TI_USED_CP + 11] @ mark CP#11 as used
  523. b do_vfp @ let VFP handler handle this
  524. 1:
  525. #endif
  526. tst r0, #0x08000000 @ only CDP/CPRT/LDC/STC have bit 27
  527. tstne r0, #0x04000000 @ bit 26 set on both ARM and Thumb-2
  528. reteq lr
  529. and r8, r0, #0x00000f00 @ mask out CP number
  530. mov r7, #1
  531. add r6, r10, r8, lsr #8 @ add used_cp[] array offset first
  532. strb r7, [r6, #TI_USED_CP] @ set appropriate used_cp[]
  533. #ifdef CONFIG_IWMMXT
  534. @ Test if we need to give access to iWMMXt coprocessors
  535. ldr r5, [r10, #TI_FLAGS]
  536. rsbs r7, r8, #(1 << 8) @ CP 0 or 1 only
  537. movscs r7, r5, lsr #(TIF_USING_IWMMXT + 1)
  538. bcs iwmmxt_task_enable
  539. #endif
  540. ARM( add pc, pc, r8, lsr #6 )
  541. THUMB( lsr r8, r8, #6 )
  542. THUMB( add pc, r8 )
  543. nop
  544. ret.w lr @ CP#0
  545. W(b) do_fpe @ CP#1 (FPE)
  546. W(b) do_fpe @ CP#2 (FPE)
  547. ret.w lr @ CP#3
  548. ret.w lr @ CP#4
  549. ret.w lr @ CP#5
  550. ret.w lr @ CP#6
  551. ret.w lr @ CP#7
  552. ret.w lr @ CP#8
  553. ret.w lr @ CP#9
  554. #ifdef CONFIG_VFP
  555. W(b) do_vfp @ CP#10 (VFP)
  556. W(b) do_vfp @ CP#11 (VFP)
  557. #else
  558. ret.w lr @ CP#10 (VFP)
  559. ret.w lr @ CP#11 (VFP)
  560. #endif
  561. ret.w lr @ CP#12
  562. ret.w lr @ CP#13
  563. ret.w lr @ CP#14 (Debug)
  564. ret.w lr @ CP#15 (Control)
  565. #ifdef CONFIG_NEON
  566. .align 6
  567. .LCneon_arm_opcodes:
  568. .word 0xfe000000 @ mask
  569. .word 0xf2000000 @ opcode
  570. .word 0xff100000 @ mask
  571. .word 0xf4000000 @ opcode
  572. .word 0x00000000 @ mask
  573. .word 0x00000000 @ opcode
  574. .LCneon_thumb_opcodes:
  575. .word 0xef000000 @ mask
  576. .word 0xef000000 @ opcode
  577. .word 0xff100000 @ mask
  578. .word 0xf9000000 @ opcode
  579. .word 0x00000000 @ mask
  580. .word 0x00000000 @ opcode
  581. #endif
  582. do_fpe:
  583. add r10, r10, #TI_FPSTATE @ r10 = workspace
  584. ldr_va pc, fp_enter, tmp=r4 @ Call FP module USR entry point
  585. /*
  586. * The FP module is called with these registers set:
  587. * r0 = instruction
  588. * r2 = PC+4
  589. * r9 = normal "successful" return address
  590. * r10 = FP workspace
  591. * lr = unrecognised FP instruction return address
  592. */
  593. .pushsection .data
  594. .align 2
  595. ENTRY(fp_enter)
  596. .word no_fp
  597. .popsection
  598. ENTRY(no_fp)
  599. ret lr
  600. ENDPROC(no_fp)
  601. __und_usr_fault_32:
  602. mov r1, #4
  603. b 1f
  604. __und_usr_fault_16_pan:
  605. uaccess_disable ip
  606. __und_usr_fault_16:
  607. mov r1, #2
  608. 1: mov r0, sp
  609. badr lr, ret_from_exception
  610. b __und_fault
  611. ENDPROC(__und_usr_fault_32)
  612. ENDPROC(__und_usr_fault_16)
  613. .align 5
  614. __pabt_usr:
  615. usr_entry
  616. mov r2, sp @ regs
  617. pabt_helper
  618. UNWIND(.fnend )
  619. /* fall through */
  620. /*
  621. * This is the return code to user mode for abort handlers
  622. */
  623. ENTRY(ret_from_exception)
  624. UNWIND(.fnstart )
  625. UNWIND(.cantunwind )
  626. get_thread_info tsk
  627. mov why, #0
  628. b ret_to_user
  629. UNWIND(.fnend )
  630. ENDPROC(__pabt_usr)
  631. ENDPROC(ret_from_exception)
  632. .align 5
  633. __fiq_usr:
  634. usr_entry trace=0
  635. kuser_cmpxchg_check
  636. mov r0, sp @ struct pt_regs *regs
  637. bl handle_fiq_as_nmi
  638. get_thread_info tsk
  639. restore_user_regs fast = 0, offset = 0
  640. UNWIND(.fnend )
  641. ENDPROC(__fiq_usr)
  642. /*
  643. * Register switch for ARMv3 and ARMv4 processors
  644. * r0 = previous task_struct, r1 = previous thread_info, r2 = next thread_info
  645. * previous and next are guaranteed not to be the same.
  646. */
  647. ENTRY(__switch_to)
  648. UNWIND(.fnstart )
  649. UNWIND(.cantunwind )
  650. add ip, r1, #TI_CPU_SAVE
  651. ARM( stmia ip!, {r4 - sl, fp, sp, lr} ) @ Store most regs on stack
  652. THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
  653. THUMB( str sp, [ip], #4 )
  654. THUMB( str lr, [ip], #4 )
  655. ldr r4, [r2, #TI_TP_VALUE]
  656. ldr r5, [r2, #TI_TP_VALUE + 4]
  657. #ifdef CONFIG_CPU_USE_DOMAINS
  658. mrc p15, 0, r6, c3, c0, 0 @ Get domain register
  659. str r6, [r1, #TI_CPU_DOMAIN] @ Save old domain register
  660. ldr r6, [r2, #TI_CPU_DOMAIN]
  661. #endif
  662. switch_tls r1, r4, r5, r3, r7
  663. #if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP) && \
  664. !defined(CONFIG_STACKPROTECTOR_PER_TASK)
  665. ldr r8, =__stack_chk_guard
  666. .if (TSK_STACK_CANARY > IMM12_MASK)
  667. add r9, r2, #TSK_STACK_CANARY & ~IMM12_MASK
  668. ldr r9, [r9, #TSK_STACK_CANARY & IMM12_MASK]
  669. .else
  670. ldr r9, [r2, #TSK_STACK_CANARY & IMM12_MASK]
  671. .endif
  672. #endif
  673. mov r7, r2 @ Preserve 'next'
  674. #ifdef CONFIG_CPU_USE_DOMAINS
  675. mcr p15, 0, r6, c3, c0, 0 @ Set domain register
  676. #endif
  677. mov r5, r0
  678. add r4, r2, #TI_CPU_SAVE
  679. ldr r0, =thread_notify_head
  680. mov r1, #THREAD_NOTIFY_SWITCH
  681. bl atomic_notifier_call_chain
  682. #if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP) && \
  683. !defined(CONFIG_STACKPROTECTOR_PER_TASK)
  684. str r9, [r8]
  685. #endif
  686. mov r0, r5
  687. #if !defined(CONFIG_THUMB2_KERNEL) && !defined(CONFIG_VMAP_STACK)
  688. set_current r7, r8
  689. ldmia r4, {r4 - sl, fp, sp, pc} @ Load all regs saved previously
  690. #else
  691. mov r1, r7
  692. ldmia r4, {r4 - sl, fp, ip, lr} @ Load all regs saved previously
  693. #ifdef CONFIG_VMAP_STACK
  694. @
  695. @ Do a dummy read from the new stack while running from the old one so
  696. @ that we can rely on do_translation_fault() to fix up any stale PMD
  697. @ entries covering the vmalloc region.
  698. @
  699. ldr r2, [ip]
  700. #endif
  701. @ When CONFIG_THREAD_INFO_IN_TASK=n, the update of SP itself is what
  702. @ effectuates the task switch, as that is what causes the observable
  703. @ values of current and current_thread_info to change. When
  704. @ CONFIG_THREAD_INFO_IN_TASK=y, setting current (and therefore
  705. @ current_thread_info) is done explicitly, and the update of SP just
  706. @ switches us to another stack, with few other side effects. In order
  707. @ to prevent this distinction from causing any inconsistencies, let's
  708. @ keep the 'set_current' call as close as we can to the update of SP.
  709. set_current r1, r2
  710. mov sp, ip
  711. ret lr
  712. #endif
  713. UNWIND(.fnend )
  714. ENDPROC(__switch_to)
  715. #ifdef CONFIG_VMAP_STACK
  716. .text
  717. .align 2
  718. __bad_stack:
  719. @
  720. @ We've just detected an overflow. We need to load the address of this
  721. @ CPU's overflow stack into the stack pointer register. We have only one
  722. @ scratch register so let's use a sequence of ADDs including one
  723. @ involving the PC, and decorate them with PC-relative group
  724. @ relocations. As these are ARM only, switch to ARM mode first.
  725. @
  726. @ We enter here with IP clobbered and its value stashed on the mode
  727. @ stack.
  728. @
  729. THUMB( bx pc )
  730. THUMB( nop )
  731. THUMB( .arm )
  732. ldr_this_cpu_armv6 ip, overflow_stack_ptr
  733. str sp, [ip, #-4]! @ Preserve original SP value
  734. mov sp, ip @ Switch to overflow stack
  735. pop {ip} @ Original SP in IP
  736. #if defined(CONFIG_UNWINDER_FRAME_POINTER) && defined(CONFIG_CC_IS_GCC)
  737. mov ip, ip @ mov expected by unwinder
  738. push {fp, ip, lr, pc} @ GCC flavor frame record
  739. #else
  740. str ip, [sp, #-8]! @ store original SP
  741. push {fpreg, lr} @ Clang flavor frame record
  742. #endif
  743. UNWIND( ldr ip, [r0, #4] ) @ load exception LR
  744. UNWIND( str ip, [sp, #12] ) @ store in the frame record
  745. ldr ip, [r0, #12] @ reload IP
  746. @ Store the original GPRs to the new stack.
  747. svc_entry uaccess=0, overflow_check=0
  748. UNWIND( .save {sp, pc} )
  749. UNWIND( .save {fpreg, lr} )
  750. UNWIND( .setfp fpreg, sp )
  751. ldr fpreg, [sp, #S_SP] @ Add our frame record
  752. @ to the linked list
  753. #if defined(CONFIG_UNWINDER_FRAME_POINTER) && defined(CONFIG_CC_IS_GCC)
  754. ldr r1, [fp, #4] @ reload SP at entry
  755. add fp, fp, #12
  756. #else
  757. ldr r1, [fpreg, #8]
  758. #endif
  759. str r1, [sp, #S_SP] @ store in pt_regs
  760. @ Stash the regs for handle_bad_stack
  761. mov r0, sp
  762. @ Time to die
  763. bl handle_bad_stack
  764. nop
  765. UNWIND( .fnend )
  766. ENDPROC(__bad_stack)
  767. #endif
  768. __INIT
  769. /*
  770. * User helpers.
  771. *
  772. * Each segment is 32-byte aligned and will be moved to the top of the high
  773. * vector page. New segments (if ever needed) must be added in front of
  774. * existing ones. This mechanism should be used only for things that are
  775. * really small and justified, and not be abused freely.
  776. *
  777. * See Documentation/arm/kernel_user_helpers.rst for formal definitions.
  778. */
  779. THUMB( .arm )
  780. .macro usr_ret, reg
  781. #ifdef CONFIG_ARM_THUMB
  782. bx \reg
  783. #else
  784. ret \reg
  785. #endif
  786. .endm
  787. .macro kuser_pad, sym, size
  788. .if (. - \sym) & 3
  789. .rept 4 - (. - \sym) & 3
  790. .byte 0
  791. .endr
  792. .endif
  793. .rept (\size - (. - \sym)) / 4
  794. .word 0xe7fddef1
  795. .endr
  796. .endm
  797. #ifdef CONFIG_KUSER_HELPERS
  798. .align 5
  799. .globl __kuser_helper_start
  800. __kuser_helper_start:
  801. /*
  802. * Due to the length of some sequences, __kuser_cmpxchg64 spans 2 regular
  803. * kuser "slots", therefore 0xffff0f80 is not used as a valid entry point.
  804. */
  805. __kuser_cmpxchg64: @ 0xffff0f60
  806. #if defined(CONFIG_CPU_32v6K)
  807. stmfd sp!, {r4, r5, r6, r7}
  808. ldrd r4, r5, [r0] @ load old val
  809. ldrd r6, r7, [r1] @ load new val
  810. smp_dmb arm
  811. 1: ldrexd r0, r1, [r2] @ load current val
  812. eors r3, r0, r4 @ compare with oldval (1)
  813. eorseq r3, r1, r5 @ compare with oldval (2)
  814. strexdeq r3, r6, r7, [r2] @ store newval if eq
  815. teqeq r3, #1 @ success?
  816. beq 1b @ if no then retry
  817. smp_dmb arm
  818. rsbs r0, r3, #0 @ set returned val and C flag
  819. ldmfd sp!, {r4, r5, r6, r7}
  820. usr_ret lr
  821. #elif !defined(CONFIG_SMP)
  822. #ifdef CONFIG_MMU
  823. /*
  824. * The only thing that can break atomicity in this cmpxchg64
  825. * implementation is either an IRQ or a data abort exception
  826. * causing another process/thread to be scheduled in the middle of
  827. * the critical sequence. The same strategy as for cmpxchg is used.
  828. */
  829. stmfd sp!, {r4, r5, r6, lr}
  830. ldmia r0, {r4, r5} @ load old val
  831. ldmia r1, {r6, lr} @ load new val
  832. 1: ldmia r2, {r0, r1} @ load current val
  833. eors r3, r0, r4 @ compare with oldval (1)
  834. eorseq r3, r1, r5 @ compare with oldval (2)
  835. 2: stmiaeq r2, {r6, lr} @ store newval if eq
  836. rsbs r0, r3, #0 @ set return val and C flag
  837. ldmfd sp!, {r4, r5, r6, pc}
  838. .text
  839. kuser_cmpxchg64_fixup:
  840. @ Called from kuser_cmpxchg_fixup.
  841. @ r4 = address of interrupted insn (must be preserved).
  842. @ sp = saved regs. r7 and r8 are clobbered.
  843. @ 1b = first critical insn, 2b = last critical insn.
  844. @ If r4 >= 1b and r4 <= 2b then saved pc_usr is set to 1b.
  845. mov r7, #0xffff0fff
  846. sub r7, r7, #(0xffff0fff - (0xffff0f60 + (1b - __kuser_cmpxchg64)))
  847. subs r8, r4, r7
  848. rsbscs r8, r8, #(2b - 1b)
  849. strcs r7, [sp, #S_PC]
  850. #if __LINUX_ARM_ARCH__ < 6
  851. bcc kuser_cmpxchg32_fixup
  852. #endif
  853. ret lr
  854. .previous
  855. #else
  856. #warning "NPTL on non MMU needs fixing"
  857. mov r0, #-1
  858. adds r0, r0, #0
  859. usr_ret lr
  860. #endif
  861. #else
  862. #error "incoherent kernel configuration"
  863. #endif
  864. kuser_pad __kuser_cmpxchg64, 64
  865. __kuser_memory_barrier: @ 0xffff0fa0
  866. smp_dmb arm
  867. usr_ret lr
  868. kuser_pad __kuser_memory_barrier, 32
  869. __kuser_cmpxchg: @ 0xffff0fc0
  870. #if __LINUX_ARM_ARCH__ < 6
  871. #ifdef CONFIG_MMU
  872. /*
  873. * The only thing that can break atomicity in this cmpxchg
  874. * implementation is either an IRQ or a data abort exception
  875. * causing another process/thread to be scheduled in the middle
  876. * of the critical sequence. To prevent this, code is added to
  877. * the IRQ and data abort exception handlers to set the pc back
  878. * to the beginning of the critical section if it is found to be
  879. * within that critical section (see kuser_cmpxchg_fixup).
  880. */
  881. 1: ldr r3, [r2] @ load current val
  882. subs r3, r3, r0 @ compare with oldval
  883. 2: streq r1, [r2] @ store newval if eq
  884. rsbs r0, r3, #0 @ set return val and C flag
  885. usr_ret lr
  886. .text
  887. kuser_cmpxchg32_fixup:
  888. @ Called from kuser_cmpxchg_check macro.
  889. @ r4 = address of interrupted insn (must be preserved).
  890. @ sp = saved regs. r7 and r8 are clobbered.
  891. @ 1b = first critical insn, 2b = last critical insn.
  892. @ If r4 >= 1b and r4 <= 2b then saved pc_usr is set to 1b.
  893. mov r7, #0xffff0fff
  894. sub r7, r7, #(0xffff0fff - (0xffff0fc0 + (1b - __kuser_cmpxchg)))
  895. subs r8, r4, r7
  896. rsbscs r8, r8, #(2b - 1b)
  897. strcs r7, [sp, #S_PC]
  898. ret lr
  899. .previous
  900. #else
  901. #warning "NPTL on non MMU needs fixing"
  902. mov r0, #-1
  903. adds r0, r0, #0
  904. usr_ret lr
  905. #endif
  906. #else
  907. smp_dmb arm
  908. 1: ldrex r3, [r2]
  909. subs r3, r3, r0
  910. strexeq r3, r1, [r2]
  911. teqeq r3, #1
  912. beq 1b
  913. rsbs r0, r3, #0
  914. /* beware -- each __kuser slot must be 8 instructions max */
  915. ALT_SMP(b __kuser_memory_barrier)
  916. ALT_UP(usr_ret lr)
  917. #endif
  918. kuser_pad __kuser_cmpxchg, 32
  919. __kuser_get_tls: @ 0xffff0fe0
  920. ldr r0, [pc, #(16 - 8)] @ read TLS, set in kuser_get_tls_init
  921. usr_ret lr
  922. mrc p15, 0, r0, c13, c0, 3 @ 0xffff0fe8 hardware TLS code
  923. kuser_pad __kuser_get_tls, 16
  924. .rep 3
  925. .word 0 @ 0xffff0ff0 software TLS value, then
  926. .endr @ pad up to __kuser_helper_version
  927. __kuser_helper_version: @ 0xffff0ffc
  928. .word ((__kuser_helper_end - __kuser_helper_start) >> 5)
  929. .globl __kuser_helper_end
  930. __kuser_helper_end:
  931. #endif
  932. THUMB( .thumb )
  933. /*
  934. * Vector stubs.
  935. *
  936. * This code is copied to 0xffff1000 so we can use branches in the
  937. * vectors, rather than ldr's. Note that this code must not exceed
  938. * a page size.
  939. *
  940. * Common stub entry macro:
  941. * Enter in IRQ mode, spsr = SVC/USR CPSR, lr = SVC/USR PC
  942. *
  943. * SP points to a minimal amount of processor-private memory, the address
  944. * of which is copied into r0 for the mode specific abort handler.
  945. */
  946. .macro vector_stub, name, mode, correction=0
  947. .align 5
  948. #ifdef CONFIG_HARDEN_BRANCH_HISTORY
  949. vector_bhb_bpiall_\name:
  950. mcr p15, 0, r0, c7, c5, 6 @ BPIALL
  951. @ isb not needed due to "movs pc, lr" in the vector stub
  952. @ which gives a "context synchronisation".
  953. #endif
  954. vector_\name:
  955. .if \correction
  956. sub lr, lr, #\correction
  957. .endif
  958. @ Save r0, lr_<exception> (parent PC)
  959. stmia sp, {r0, lr} @ save r0, lr
  960. @ Save spsr_<exception> (parent CPSR)
  961. .Lvec_\name:
  962. mrs lr, spsr
  963. str lr, [sp, #8] @ save spsr
  964. @
  965. @ Prepare for SVC32 mode. IRQs remain disabled.
  966. @
  967. mrs r0, cpsr
  968. eor r0, r0, #(\mode ^ SVC_MODE | PSR_ISETSTATE)
  969. msr spsr_cxsf, r0
  970. @
  971. @ the branch table must immediately follow this code
  972. @
  973. and lr, lr, #0x0f
  974. THUMB( adr r0, 1f )
  975. THUMB( ldr lr, [r0, lr, lsl #2] )
  976. mov r0, sp
  977. ARM( ldr lr, [pc, lr, lsl #2] )
  978. movs pc, lr @ branch to handler in SVC mode
  979. ENDPROC(vector_\name)
  980. #ifdef CONFIG_HARDEN_BRANCH_HISTORY
  981. .subsection 1
  982. .align 5
  983. vector_bhb_loop8_\name:
  984. .if \correction
  985. sub lr, lr, #\correction
  986. .endif
  987. @ Save r0, lr_<exception> (parent PC)
  988. stmia sp, {r0, lr}
  989. @ bhb workaround
  990. mov r0, #8
  991. 3: W(b) . + 4
  992. subs r0, r0, #1
  993. bne 3b
  994. dsb nsh
  995. @ isb not needed due to "movs pc, lr" in the vector stub
  996. @ which gives a "context synchronisation".
  997. b .Lvec_\name
  998. ENDPROC(vector_bhb_loop8_\name)
  999. .previous
  1000. #endif
  1001. .align 2
  1002. @ handler addresses follow this label
  1003. 1:
  1004. .endm
  1005. .section .stubs, "ax", %progbits
  1006. @ These need to remain at the start of the section so that
  1007. @ they are in range of the 'SWI' entries in the vector tables
  1008. @ located 4k down.
  1009. .L__vector_swi:
  1010. .word vector_swi
  1011. #ifdef CONFIG_HARDEN_BRANCH_HISTORY
  1012. .L__vector_bhb_loop8_swi:
  1013. .word vector_bhb_loop8_swi
  1014. .L__vector_bhb_bpiall_swi:
  1015. .word vector_bhb_bpiall_swi
  1016. #endif
  1017. vector_rst:
  1018. ARM( swi SYS_ERROR0 )
  1019. THUMB( svc #0 )
  1020. THUMB( nop )
  1021. b vector_und
  1022. /*
  1023. * Interrupt dispatcher
  1024. */
  1025. vector_stub irq, IRQ_MODE, 4
  1026. .long __irq_usr @ 0 (USR_26 / USR_32)
  1027. .long __irq_invalid @ 1 (FIQ_26 / FIQ_32)
  1028. .long __irq_invalid @ 2 (IRQ_26 / IRQ_32)
  1029. .long __irq_svc @ 3 (SVC_26 / SVC_32)
  1030. .long __irq_invalid @ 4
  1031. .long __irq_invalid @ 5
  1032. .long __irq_invalid @ 6
  1033. .long __irq_invalid @ 7
  1034. .long __irq_invalid @ 8
  1035. .long __irq_invalid @ 9
  1036. .long __irq_invalid @ a
  1037. .long __irq_invalid @ b
  1038. .long __irq_invalid @ c
  1039. .long __irq_invalid @ d
  1040. .long __irq_invalid @ e
  1041. .long __irq_invalid @ f
  1042. /*
  1043. * Data abort dispatcher
  1044. * Enter in ABT mode, spsr = USR CPSR, lr = USR PC
  1045. */
  1046. vector_stub dabt, ABT_MODE, 8
  1047. .long __dabt_usr @ 0 (USR_26 / USR_32)
  1048. .long __dabt_invalid @ 1 (FIQ_26 / FIQ_32)
  1049. .long __dabt_invalid @ 2 (IRQ_26 / IRQ_32)
  1050. .long __dabt_svc @ 3 (SVC_26 / SVC_32)
  1051. .long __dabt_invalid @ 4
  1052. .long __dabt_invalid @ 5
  1053. .long __dabt_invalid @ 6
  1054. .long __dabt_invalid @ 7
  1055. .long __dabt_invalid @ 8
  1056. .long __dabt_invalid @ 9
  1057. .long __dabt_invalid @ a
  1058. .long __dabt_invalid @ b
  1059. .long __dabt_invalid @ c
  1060. .long __dabt_invalid @ d
  1061. .long __dabt_invalid @ e
  1062. .long __dabt_invalid @ f
  1063. /*
  1064. * Prefetch abort dispatcher
  1065. * Enter in ABT mode, spsr = USR CPSR, lr = USR PC
  1066. */
  1067. vector_stub pabt, ABT_MODE, 4
  1068. .long __pabt_usr @ 0 (USR_26 / USR_32)
  1069. .long __pabt_invalid @ 1 (FIQ_26 / FIQ_32)
  1070. .long __pabt_invalid @ 2 (IRQ_26 / IRQ_32)
  1071. .long __pabt_svc @ 3 (SVC_26 / SVC_32)
  1072. .long __pabt_invalid @ 4
  1073. .long __pabt_invalid @ 5
  1074. .long __pabt_invalid @ 6
  1075. .long __pabt_invalid @ 7
  1076. .long __pabt_invalid @ 8
  1077. .long __pabt_invalid @ 9
  1078. .long __pabt_invalid @ a
  1079. .long __pabt_invalid @ b
  1080. .long __pabt_invalid @ c
  1081. .long __pabt_invalid @ d
  1082. .long __pabt_invalid @ e
  1083. .long __pabt_invalid @ f
  1084. /*
  1085. * Undef instr entry dispatcher
  1086. * Enter in UND mode, spsr = SVC/USR CPSR, lr = SVC/USR PC
  1087. */
  1088. vector_stub und, UND_MODE
  1089. .long __und_usr @ 0 (USR_26 / USR_32)
  1090. .long __und_invalid @ 1 (FIQ_26 / FIQ_32)
  1091. .long __und_invalid @ 2 (IRQ_26 / IRQ_32)
  1092. .long __und_svc @ 3 (SVC_26 / SVC_32)
  1093. .long __und_invalid @ 4
  1094. .long __und_invalid @ 5
  1095. .long __und_invalid @ 6
  1096. .long __und_invalid @ 7
  1097. .long __und_invalid @ 8
  1098. .long __und_invalid @ 9
  1099. .long __und_invalid @ a
  1100. .long __und_invalid @ b
  1101. .long __und_invalid @ c
  1102. .long __und_invalid @ d
  1103. .long __und_invalid @ e
  1104. .long __und_invalid @ f
  1105. .align 5
  1106. /*=============================================================================
  1107. * Address exception handler
  1108. *-----------------------------------------------------------------------------
  1109. * These aren't too critical.
  1110. * (they're not supposed to happen, and won't happen in 32-bit data mode).
  1111. */
  1112. vector_addrexcptn:
  1113. b vector_addrexcptn
  1114. /*=============================================================================
  1115. * FIQ "NMI" handler
  1116. *-----------------------------------------------------------------------------
  1117. * Handle a FIQ using the SVC stack allowing FIQ act like NMI on x86
  1118. * systems. This must be the last vector stub, so lets place it in its own
  1119. * subsection.
  1120. */
  1121. .subsection 2
  1122. vector_stub fiq, FIQ_MODE, 4
  1123. .long __fiq_usr @ 0 (USR_26 / USR_32)
  1124. .long __fiq_svc @ 1 (FIQ_26 / FIQ_32)
  1125. .long __fiq_svc @ 2 (IRQ_26 / IRQ_32)
  1126. .long __fiq_svc @ 3 (SVC_26 / SVC_32)
  1127. .long __fiq_svc @ 4
  1128. .long __fiq_svc @ 5
  1129. .long __fiq_svc @ 6
  1130. .long __fiq_abt @ 7
  1131. .long __fiq_svc @ 8
  1132. .long __fiq_svc @ 9
  1133. .long __fiq_svc @ a
  1134. .long __fiq_svc @ b
  1135. .long __fiq_svc @ c
  1136. .long __fiq_svc @ d
  1137. .long __fiq_svc @ e
  1138. .long __fiq_svc @ f
  1139. .globl vector_fiq
  1140. .section .vectors, "ax", %progbits
  1141. W(b) vector_rst
  1142. W(b) vector_und
  1143. ARM( .reloc ., R_ARM_LDR_PC_G0, .L__vector_swi )
  1144. THUMB( .reloc ., R_ARM_THM_PC12, .L__vector_swi )
  1145. W(ldr) pc, .
  1146. W(b) vector_pabt
  1147. W(b) vector_dabt
  1148. W(b) vector_addrexcptn
  1149. W(b) vector_irq
  1150. W(b) vector_fiq
  1151. #ifdef CONFIG_HARDEN_BRANCH_HISTORY
  1152. .section .vectors.bhb.loop8, "ax", %progbits
  1153. W(b) vector_rst
  1154. W(b) vector_bhb_loop8_und
  1155. ARM( .reloc ., R_ARM_LDR_PC_G0, .L__vector_bhb_loop8_swi )
  1156. THUMB( .reloc ., R_ARM_THM_PC12, .L__vector_bhb_loop8_swi )
  1157. W(ldr) pc, .
  1158. W(b) vector_bhb_loop8_pabt
  1159. W(b) vector_bhb_loop8_dabt
  1160. W(b) vector_addrexcptn
  1161. W(b) vector_bhb_loop8_irq
  1162. W(b) vector_bhb_loop8_fiq
  1163. .section .vectors.bhb.bpiall, "ax", %progbits
  1164. W(b) vector_rst
  1165. W(b) vector_bhb_bpiall_und
  1166. ARM( .reloc ., R_ARM_LDR_PC_G0, .L__vector_bhb_bpiall_swi )
  1167. THUMB( .reloc ., R_ARM_THM_PC12, .L__vector_bhb_bpiall_swi )
  1168. W(ldr) pc, .
  1169. W(b) vector_bhb_bpiall_pabt
  1170. W(b) vector_bhb_bpiall_dabt
  1171. W(b) vector_addrexcptn
  1172. W(b) vector_bhb_bpiall_irq
  1173. W(b) vector_bhb_bpiall_fiq
  1174. #endif
  1175. .data
  1176. .align 2
  1177. .globl cr_alignment
  1178. cr_alignment:
  1179. .space 4