entry.S 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. /*
  2. * Low Level Interrupts/Traps/Exceptions(non-TLB) Handling for ARC
  3. *
  4. * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  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. * vineetg: Feb 2011 (ptrace low level code fixes)
  11. * -traced syscall return code (r0) was not saved into pt_regs for restoring
  12. * into user reg-file when traded task rets to user space.
  13. * -syscalls needing arch-wrappers (mainly for passing sp as pt_regs)
  14. * were not invoking post-syscall trace hook (jumping directly into
  15. * ret_from_system_call)
  16. *
  17. * vineetg: Nov 2010:
  18. * -Vector table jumps (@8 bytes) converted into branches (@4 bytes)
  19. * -To maintain the slot size of 8 bytes/vector, added nop, which is
  20. * not executed at runtime.
  21. *
  22. * vineetg: Nov 2009 (Everything needed for TIF_RESTORE_SIGMASK)
  23. * -do_signal()invoked upon TIF_RESTORE_SIGMASK as well
  24. * -Wrappers for sys_{,rt_}sigsuspend() nolonger needed as they don't
  25. * need ptregs anymore
  26. *
  27. * Vineetg: Oct 2009
  28. * -In a rare scenario, Process gets a Priv-V exception and gets scheduled
  29. * out. Since we don't do FAKE RTIE for Priv-V, CPU excpetion state remains
  30. * active (AE bit enabled). This causes a double fault for a subseq valid
  31. * exception. Thus FAKE RTIE needed in low level Priv-Violation handler.
  32. * Instr Error could also cause similar scenario, so same there as well.
  33. *
  34. * Vineetg: Aug 28th 2008: Bug #94984
  35. * -Zero Overhead Loop Context shd be cleared when entering IRQ/EXcp/Trap
  36. * Normally CPU does this automatically, however when doing FAKE rtie,
  37. * we need to explicitly do this. The problem in macros
  38. * FAKE_RET_FROM_EXCPN and FAKE_RET_FROM_EXCPN_LOCK_IRQ was that this bit
  39. * was being "CLEARED" rather then "SET". Since it is Loop INHIBIT Bit,
  40. * setting it and not clearing it clears ZOL context
  41. *
  42. * Vineetg: May 16th, 2008
  43. * - r25 now contains the Current Task when in kernel
  44. *
  45. * Vineetg: Dec 22, 2007
  46. * Minor Surgery of Low Level ISR to make it SMP safe
  47. * - MMU_SCRATCH0 Reg used for freeing up r9 in Level 1 ISR
  48. * - _current_task is made an array of NR_CPUS
  49. * - Access of _current_task wrapped inside a macro so that if hardware
  50. * team agrees for a dedicated reg, no other code is touched
  51. *
  52. * Amit Bhor, Rahul Trivedi, Kanika Nema, Sameer Dhavale : Codito Tech 2004
  53. */
  54. /*------------------------------------------------------------------
  55. * Function ABI
  56. *------------------------------------------------------------------
  57. *
  58. * Arguments r0 - r7
  59. * Caller Saved Registers r0 - r12
  60. * Callee Saved Registers r13- r25
  61. * Global Pointer (gp) r26
  62. * Frame Pointer (fp) r27
  63. * Stack Pointer (sp) r28
  64. * Interrupt link register (ilink1) r29
  65. * Interrupt link register (ilink2) r30
  66. * Branch link register (blink) r31
  67. *------------------------------------------------------------------
  68. */
  69. .cpu A7
  70. ;############################ Vector Table #################################
  71. .macro VECTOR lbl
  72. #if 1 /* Just in case, build breaks */
  73. j \lbl
  74. #else
  75. b \lbl
  76. nop
  77. #endif
  78. .endm
  79. .section .vector, "ax",@progbits
  80. .align 4
  81. /* Each entry in the vector table must occupy 2 words. Since it is a jump
  82. * across sections (.vector to .text) we are gauranteed that 'j somewhere'
  83. * will use the 'j limm' form of the intrsuction as long as somewhere is in
  84. * a section other than .vector.
  85. */
  86. ; ********* Critical System Events **********************
  87. VECTOR res_service ; 0x0, Restart Vector (0x0)
  88. VECTOR mem_service ; 0x8, Mem exception (0x1)
  89. VECTOR instr_service ; 0x10, Instrn Error (0x2)
  90. ; ******************** Device ISRs **********************
  91. VECTOR handle_interrupt_level1
  92. VECTOR handle_interrupt_level1
  93. VECTOR handle_interrupt_level1
  94. VECTOR handle_interrupt_level1
  95. .rept 25
  96. VECTOR handle_interrupt_level1 ; Other devices
  97. .endr
  98. /* FOR ARC600: timer = 0x3, uart = 0x8, emac = 0x10 */
  99. ; ******************** Exceptions **********************
  100. VECTOR EV_MachineCheck ; 0x100, Fatal Machine check (0x20)
  101. VECTOR EV_TLBMissI ; 0x108, Intruction TLB miss (0x21)
  102. VECTOR EV_TLBMissD ; 0x110, Data TLB miss (0x22)
  103. VECTOR EV_TLBProtV ; 0x118, Protection Violation (0x23)
  104. ; or Misaligned Access
  105. VECTOR EV_PrivilegeV ; 0x120, Privilege Violation (0x24)
  106. VECTOR EV_Trap ; 0x128, Trap exception (0x25)
  107. VECTOR EV_Extension ; 0x130, Extn Intruction Excp (0x26)
  108. .rept 24
  109. VECTOR reserved ; Reserved Exceptions
  110. .endr
  111. #include <linux/linkage.h> /* ARC_{EXTRY,EXIT} */
  112. #include <asm/entry.h> /* SAVE_ALL_{INT1,INT2,TRAP...} */
  113. #include <asm/errno.h>
  114. #include <asm/arcregs.h>
  115. #include <asm/irqflags.h>
  116. ;##################### Scratch Mem for IRQ stack switching #############
  117. .section .data ; NOT .global
  118. .align 32
  119. .type int1_saved_reg, @object
  120. .size int1_saved_reg, 4
  121. int1_saved_reg:
  122. .zero 4
  123. ; ---------------------------------------------
  124. .section .text, "ax",@progbits
  125. res_service: ; processor restart
  126. flag 0x1 ; not implemented
  127. nop
  128. nop
  129. reserved: ; processor restart
  130. rtie ; jump to processor initializations
  131. ;##################### Interrupt Handling ##############################
  132. ; ---------------------------------------------
  133. ; Level 1 ISR
  134. ; ---------------------------------------------
  135. ARC_ENTRY handle_interrupt_level1
  136. /* free up r9 as scratchpad */
  137. st r9, [@int1_saved_reg]
  138. ;Which mode (user/kernel) was the system in when intr occured
  139. lr r9, [status32_l1]
  140. SWITCH_TO_KERNEL_STK
  141. SAVE_ALL_INT1
  142. lr r0, [icause1]
  143. and r0, r0, 0x1f
  144. bl.d @arch_do_IRQ
  145. mov r1, sp
  146. mov r8,0x1
  147. sr r8, [AUX_IRQ_LV12] ; clear bit in Sticky Status Reg
  148. b ret_from_exception
  149. ARC_EXIT handle_interrupt_level1
  150. ;################### Non TLB Exception Handling #############################
  151. ; ---------------------------------------------
  152. ; Instruction Error Exception Handler
  153. ; ---------------------------------------------
  154. ARC_ENTRY instr_service
  155. EXCPN_PROLOG_FREEUP_REG r9
  156. lr r9, [erstatus]
  157. SWITCH_TO_KERNEL_STK
  158. SAVE_ALL_SYS
  159. lr r0, [ecr]
  160. lr r1, [efa]
  161. mov r2, sp
  162. FAKE_RET_FROM_EXCPN r9
  163. bl do_insterror_or_kprobe
  164. b ret_from_exception
  165. ARC_EXIT instr_service
  166. ; ---------------------------------------------
  167. ; Memory Error Exception Handler
  168. ; ---------------------------------------------
  169. ARC_ENTRY mem_service
  170. EXCPN_PROLOG_FREEUP_REG r9
  171. lr r9, [erstatus]
  172. SWITCH_TO_KERNEL_STK
  173. SAVE_ALL_SYS
  174. lr r0, [ecr]
  175. lr r1, [efa]
  176. mov r2, sp
  177. bl do_memory_error
  178. b ret_from_exception
  179. ARC_EXIT mem_service
  180. ; ---------------------------------------------
  181. ; Machine Check Exception Handler
  182. ; ---------------------------------------------
  183. ARC_ENTRY EV_MachineCheck
  184. EXCPN_PROLOG_FREEUP_REG r9
  185. lr r9, [erstatus]
  186. SWITCH_TO_KERNEL_STK
  187. SAVE_ALL_SYS
  188. lr r0, [ecr]
  189. lr r1, [efa]
  190. mov r2, sp
  191. brne r0, 0x200100, 1f
  192. bl do_tlb_overlap_fault
  193. b ret_from_exception
  194. 1:
  195. ; DEAD END: can't do much, display Regs and HALT
  196. SAVE_CALLEE_SAVED_USER
  197. GET_CURR_TASK_FIELD_PTR TASK_THREAD, r10
  198. st sp, [r10, THREAD_CALLEE_REG]
  199. j do_machine_check_fault
  200. ARC_EXIT EV_MachineCheck
  201. ; ---------------------------------------------
  202. ; Protection Violation Exception Handler
  203. ; ---------------------------------------------
  204. ARC_ENTRY EV_TLBProtV
  205. EXCPN_PROLOG_FREEUP_REG r9
  206. ;Which mode (user/kernel) was the system in when Exception occured
  207. lr r9, [erstatus]
  208. SWITCH_TO_KERNEL_STK
  209. SAVE_ALL_SYS
  210. ;---------(3) Save some more regs-----------------
  211. ; vineetg: Mar 6th: Random Seg Fault issue #1
  212. ; ecr and efa were not saved in case an Intr sneaks in
  213. ; after fake rtie
  214. ;
  215. lr r3, [ecr]
  216. lr r4, [efa]
  217. ; --------(4) Return from CPU Exception Mode ---------
  218. ; Fake a rtie, but rtie to next label
  219. ; That way, subsequently, do_page_fault ( ) executes in pure kernel
  220. ; mode with further Exceptions enabled
  221. FAKE_RET_FROM_EXCPN r9
  222. ;------ (5) Type of Protection Violation? ----------
  223. ;
  224. ; ProtV Hardware Exception is triggered for Access Faults of 2 types
  225. ; -Access Violaton (WRITE to READ ONLY Page) - for linux COW
  226. ; -Unaligned Access (READ/WRITE on odd boundary)
  227. ;
  228. cmp r3, 0x230400 ; Misaligned data access ?
  229. beq 4f
  230. ;========= (6a) Access Violation Processing ========
  231. cmp r3, 0x230100
  232. mov r1, 0x0 ; if LD exception ? write = 0
  233. mov.ne r1, 0x1 ; else write = 1
  234. mov r2, r4 ; faulting address
  235. mov r0, sp ; pt_regs
  236. bl do_page_fault
  237. b ret_from_exception
  238. ;========== (6b) Non aligned access ============
  239. 4:
  240. mov r0, r3 ; cause code
  241. mov r1, r4 ; faulting address
  242. mov r2, sp ; pt_regs
  243. bl do_misaligned_access
  244. b ret_from_exception
  245. ARC_EXIT EV_TLBProtV
  246. ; ---------------------------------------------
  247. ; Privilege Violation Exception Handler
  248. ; ---------------------------------------------
  249. ARC_ENTRY EV_PrivilegeV
  250. EXCPN_PROLOG_FREEUP_REG r9
  251. lr r9, [erstatus]
  252. SWITCH_TO_KERNEL_STK
  253. SAVE_ALL_SYS
  254. lr r0, [ecr]
  255. lr r1, [efa]
  256. mov r2, sp
  257. FAKE_RET_FROM_EXCPN r9
  258. bl do_privilege_fault
  259. b ret_from_exception
  260. ARC_EXIT EV_PrivilegeV
  261. ; ---------------------------------------------
  262. ; Extension Instruction Exception Handler
  263. ; ---------------------------------------------
  264. ARC_ENTRY EV_Extension
  265. EXCPN_PROLOG_FREEUP_REG r9
  266. lr r9, [erstatus]
  267. SWITCH_TO_KERNEL_STK
  268. SAVE_ALL_SYS
  269. lr r0, [ecr]
  270. lr r1, [efa]
  271. mov r2, sp
  272. bl do_extension_fault
  273. b ret_from_exception
  274. ARC_EXIT EV_Extension
  275. ;######################### System Call Tracing #########################
  276. tracesys:
  277. ; save EFA in case tracer wants the PC of traced task
  278. ; using ERET won't work since next-PC has already committed
  279. lr r12, [efa]
  280. GET_CURR_TASK_FIELD_PTR TASK_THREAD, r11
  281. st r12, [r11, THREAD_FAULT_ADDR]
  282. ; PRE Sys Call Ptrace hook
  283. mov r0, sp ; pt_regs needed
  284. bl @syscall_trace_entry
  285. ; Tracing code now returns the syscall num (orig or modif)
  286. mov r8, r0
  287. ; Do the Sys Call as we normally would.
  288. ; Validate the Sys Call number
  289. cmp r8, NR_syscalls
  290. mov.hi r0, -ENOSYS
  291. bhi tracesys_exit
  292. ; Restore the sys-call args. Mere invocation of the hook abv could have
  293. ; clobbered them (since they are in scratch regs). The tracer could also
  294. ; have deliberately changed the syscall args: r0-r7
  295. ld r0, [sp, PT_r0]
  296. ld r1, [sp, PT_r1]
  297. ld r2, [sp, PT_r2]
  298. ld r3, [sp, PT_r3]
  299. ld r4, [sp, PT_r4]
  300. ld r5, [sp, PT_r5]
  301. ld r6, [sp, PT_r6]
  302. ld r7, [sp, PT_r7]
  303. ld.as r9, [sys_call_table, r8]
  304. jl [r9] ; Entry into Sys Call Handler
  305. tracesys_exit:
  306. st r0, [sp, PT_r0] ; sys call return value in pt_regs
  307. ;POST Sys Call Ptrace Hook
  308. bl @syscall_trace_exit
  309. b ret_from_exception ; NOT ret_from_system_call at is saves r0 which
  310. ; we'd done before calling post hook above
  311. ;################### Break Point TRAP ##########################
  312. ; ======= (5b) Trap is due to Break-Point =========
  313. trap_with_param:
  314. ; stop_pc info by gdb needs this info
  315. st orig_r8_IS_BRKPT, [sp, PT_orig_r8]
  316. mov r0, r12
  317. lr r1, [efa]
  318. mov r2, sp
  319. ; Now that we have read EFA, its safe to do "fake" rtie
  320. ; and get out of CPU exception mode
  321. FAKE_RET_FROM_EXCPN r11
  322. ; Save callee regs in case gdb wants to have a look
  323. ; SP will grow up by size of CALLEE Reg-File
  324. ; NOTE: clobbers r12
  325. SAVE_CALLEE_SAVED_USER
  326. ; save location of saved Callee Regs @ thread_struct->pc
  327. GET_CURR_TASK_FIELD_PTR TASK_THREAD, r10
  328. st sp, [r10, THREAD_CALLEE_REG]
  329. ; Call the trap handler
  330. bl do_non_swi_trap
  331. ; unwind stack to discard Callee saved Regs
  332. DISCARD_CALLEE_SAVED_USER
  333. b ret_from_exception
  334. ;##################### Trap Handling ##############################
  335. ;
  336. ; EV_Trap caused by TRAP_S and TRAP0 instructions.
  337. ;------------------------------------------------------------------
  338. ; (1) System Calls
  339. ; :parameters in r0-r7.
  340. ; :r8 has the system call number
  341. ; (2) Break Points
  342. ;------------------------------------------------------------------
  343. ARC_ENTRY EV_Trap
  344. ; Need at least 1 reg to code the early exception prolog
  345. EXCPN_PROLOG_FREEUP_REG r9
  346. ;Which mode (user/kernel) was the system in when intr occured
  347. lr r9, [erstatus]
  348. SWITCH_TO_KERNEL_STK
  349. SAVE_ALL_TRAP
  350. ;------- (4) What caused the Trap --------------
  351. lr r12, [ecr]
  352. and.f 0, r12, ECR_PARAM_MASK
  353. bnz trap_with_param
  354. ; ======= (5a) Trap is due to System Call ========
  355. ; Before doing anything, return from CPU Exception Mode
  356. FAKE_RET_FROM_EXCPN r11
  357. ; If syscall tracing ongoing, invoke pre-pos-hooks
  358. GET_CURR_THR_INFO_FLAGS r10
  359. btst r10, TIF_SYSCALL_TRACE
  360. bnz tracesys ; this never comes back
  361. ;============ This is normal System Call case ==========
  362. ; Sys-call num shd not exceed the total system calls avail
  363. cmp r8, NR_syscalls
  364. mov.hi r0, -ENOSYS
  365. bhi ret_from_system_call
  366. ; Offset into the syscall_table and call handler
  367. ld.as r9,[sys_call_table, r8]
  368. jl [r9] ; Entry into Sys Call Handler
  369. ; fall through to ret_from_system_call
  370. ARC_EXIT EV_Trap
  371. ARC_ENTRY ret_from_system_call
  372. st r0, [sp, PT_r0] ; sys call return value in pt_regs
  373. ; fall through yet again to ret_from_exception
  374. ;############# Return from Intr/Excp/Trap (Linux Specifics) ##############
  375. ;
  376. ; If ret to user mode do we need to handle signals, schedule() et al.
  377. ARC_ENTRY ret_from_exception
  378. ; Pre-{IRQ,Trap,Exception} K/U mode from pt_regs->status32
  379. ld r8, [sp, PT_status32] ; returning to User/Kernel Mode
  380. #ifdef CONFIG_PREEMPT
  381. bbit0 r8, STATUS_U_BIT, resume_kernel_mode
  382. #else
  383. bbit0 r8, STATUS_U_BIT, restore_regs
  384. #endif
  385. ; Before returning to User mode check-for-and-complete any pending work
  386. ; such as rescheduling/signal-delivery etc.
  387. resume_user_mode_begin:
  388. ; Disable IRQs to ensures that chk for pending work itself is atomic
  389. ; (and we don't end up missing a NEED_RESCHED/SIGPENDING due to an
  390. ; interim IRQ).
  391. IRQ_DISABLE r10
  392. ; Fast Path return to user mode if no pending work
  393. GET_CURR_THR_INFO_FLAGS r9
  394. and.f 0, r9, _TIF_WORK_MASK
  395. bz restore_regs
  396. ; --- (Slow Path #1) task preemption ---
  397. bbit0 r9, TIF_NEED_RESCHED, .Lchk_pend_signals
  398. mov blink, resume_user_mode_begin ; tail-call to U mode ret chks
  399. b @schedule ; BTST+Bnz causes relo error in link
  400. .Lchk_pend_signals:
  401. IRQ_ENABLE r10
  402. ; --- (Slow Path #2) pending signal ---
  403. mov r0, sp ; pt_regs for arg to do_signal()/do_notify_resume()
  404. bbit0 r9, TIF_SIGPENDING, .Lchk_notify_resume
  405. ; Normal Trap/IRQ entry only saves Scratch (caller-saved) regs
  406. ; in pt_reg since the "C" ABI (kernel code) will automatically
  407. ; save/restore callee-saved regs.
  408. ;
  409. ; However, here we need to explicitly save callee regs because
  410. ; (i) If this signal causes coredump - full regfile needed
  411. ; (ii) If signal is SIGTRAP/SIGSTOP, task is being traced thus
  412. ; tracer might call PEEKUSR(CALLEE reg)
  413. ;
  414. ; NOTE: SP will grow up by size of CALLEE Reg-File
  415. SAVE_CALLEE_SAVED_USER ; clobbers r12
  416. ; save location of saved Callee Regs @ thread_struct->callee
  417. GET_CURR_TASK_FIELD_PTR TASK_THREAD, r10
  418. st sp, [r10, THREAD_CALLEE_REG]
  419. bl @do_signal
  420. ; Ideally we want to discard the Callee reg above, however if this was
  421. ; a tracing signal, tracer could have done a POKEUSR(CALLEE reg)
  422. RESTORE_CALLEE_SAVED_USER
  423. b resume_user_mode_begin ; loop back to start of U mode ret
  424. ; --- (Slow Path #3) notify_resume ---
  425. .Lchk_notify_resume:
  426. btst r9, TIF_NOTIFY_RESUME
  427. blnz @do_notify_resume
  428. b resume_user_mode_begin ; unconditionally back to U mode ret chks
  429. ; for single exit point from this block
  430. #ifdef CONFIG_PREEMPT
  431. resume_kernel_mode:
  432. ; Can't preempt if preemption disabled
  433. GET_CURR_THR_INFO_FROM_SP r10
  434. ld r8, [r10, THREAD_INFO_PREEMPT_COUNT]
  435. brne r8, 0, restore_regs
  436. ; check if this task's NEED_RESCHED flag set
  437. ld r9, [r10, THREAD_INFO_FLAGS]
  438. bbit0 r9, TIF_NEED_RESCHED, restore_regs
  439. IRQ_DISABLE r9
  440. ; Invoke PREEMPTION
  441. bl preempt_schedule_irq
  442. ; preempt_schedule_irq() always returns with IRQ disabled
  443. #endif
  444. ; fall through
  445. ;############# Return from Intr/Excp/Trap (ARC Specifics) ##############
  446. ;
  447. ; Restore the saved sys context (common exit-path for EXCPN/IRQ/Trap)
  448. ; IRQ shd definitely not happen between now and rtie
  449. restore_regs :
  450. ; Disable Interrupts while restoring reg-file back
  451. ; XXX can this be optimised out
  452. IRQ_DISABLE_SAVE r9, r10 ;@r10 has prisitine (pre-disable) copy
  453. #ifdef CONFIG_ARC_CURR_IN_REG
  454. ; Restore User R25
  455. ; Earlier this used to be only for returning to user mode
  456. ; However with 2 levels of IRQ this can also happen even if
  457. ; in kernel mode
  458. ld r9, [sp, PT_sp]
  459. brhs r9, VMALLOC_START, 8f
  460. RESTORE_USER_R25
  461. 8:
  462. #endif
  463. ; Restore REG File. In case multiple Events outstanding,
  464. ; use the same priorty as rtie: EXCPN, L2 IRQ, L1 IRQ, None
  465. ; Note that we use realtime STATUS32 (not pt_regs->status32) to
  466. ; decide that.
  467. ; if Returning from Exception
  468. bbit0 r10, STATUS_AE_BIT, not_exception
  469. RESTORE_ALL_SYS
  470. rtie
  471. ; Not Exception so maybe Interrupts (Level 1 or 2)
  472. not_exception:
  473. bbit0 r10, STATUS_A1_BIT, not_level1_interrupt
  474. ;return from level 1
  475. RESTORE_ALL_INT1
  476. debug_marker_l1:
  477. rtie
  478. not_level1_interrupt:
  479. ;this case is for syscalls or Exceptions (with fake rtie)
  480. RESTORE_ALL_SYS
  481. debug_marker_syscall:
  482. rtie
  483. ARC_EXIT ret_from_exception
  484. ARC_ENTRY ret_from_fork
  485. ; when the forked child comes here from the __switch_to function
  486. ; r0 has the last task pointer.
  487. ; put last task in scheduler queue
  488. bl @schedule_tail
  489. ; If kernel thread, jump to it's entry-point
  490. ld r9, [sp, PT_status32]
  491. brne r9, 0, 1f
  492. jl.d [r14]
  493. mov r0, r13 ; arg to payload
  494. 1:
  495. ; special case of kernel_thread entry point returning back due to
  496. ; kernel_execve() - pretend return from syscall to ret to userland
  497. b ret_from_exception
  498. ARC_EXIT ret_from_fork
  499. ;################### Special Sys Call Wrappers ##########################
  500. ; TBD: call do_fork directly from here
  501. ARC_ENTRY sys_fork_wrapper
  502. SAVE_CALLEE_SAVED_USER
  503. bl @sys_fork
  504. DISCARD_CALLEE_SAVED_USER
  505. GET_CURR_THR_INFO_FLAGS r10
  506. btst r10, TIF_SYSCALL_TRACE
  507. bnz tracesys_exit
  508. b ret_from_system_call
  509. ARC_EXIT sys_fork_wrapper
  510. ARC_ENTRY sys_vfork_wrapper
  511. SAVE_CALLEE_SAVED_USER
  512. bl @sys_vfork
  513. DISCARD_CALLEE_SAVED_USER
  514. GET_CURR_THR_INFO_FLAGS r10
  515. btst r10, TIF_SYSCALL_TRACE
  516. bnz tracesys_exit
  517. b ret_from_system_call
  518. ARC_EXIT sys_vfork_wrapper
  519. ARC_ENTRY sys_clone_wrapper
  520. SAVE_CALLEE_SAVED_USER
  521. bl @sys_clone
  522. DISCARD_CALLEE_SAVED_USER
  523. GET_CURR_THR_INFO_FLAGS r10
  524. btst r10, TIF_SYSCALL_TRACE
  525. bnz tracesys_exit
  526. b ret_from_system_call
  527. ARC_EXIT sys_clone_wrapper