entry.S 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086
  1. /*
  2. * arch/s390/kernel/entry.S
  3. * S390 low-level entry points.
  4. *
  5. * Copyright (C) IBM Corp. 1999,2006
  6. * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
  7. * Hartmut Penner (hp@de.ibm.com),
  8. * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
  9. * Heiko Carstens <heiko.carstens@de.ibm.com>
  10. */
  11. #include <linux/linkage.h>
  12. #include <linux/init.h>
  13. #include <asm/cache.h>
  14. #include <asm/errno.h>
  15. #include <asm/ptrace.h>
  16. #include <asm/thread_info.h>
  17. #include <asm/asm-offsets.h>
  18. #include <asm/unistd.h>
  19. #include <asm/page.h>
  20. /*
  21. * Stack layout for the system_call stack entry.
  22. * The first few entries are identical to the user_regs_struct.
  23. */
  24. SP_PTREGS = STACK_FRAME_OVERHEAD
  25. SP_ARGS = STACK_FRAME_OVERHEAD + __PT_ARGS
  26. SP_PSW = STACK_FRAME_OVERHEAD + __PT_PSW
  27. SP_R0 = STACK_FRAME_OVERHEAD + __PT_GPRS
  28. SP_R1 = STACK_FRAME_OVERHEAD + __PT_GPRS + 4
  29. SP_R2 = STACK_FRAME_OVERHEAD + __PT_GPRS + 8
  30. SP_R3 = STACK_FRAME_OVERHEAD + __PT_GPRS + 12
  31. SP_R4 = STACK_FRAME_OVERHEAD + __PT_GPRS + 16
  32. SP_R5 = STACK_FRAME_OVERHEAD + __PT_GPRS + 20
  33. SP_R6 = STACK_FRAME_OVERHEAD + __PT_GPRS + 24
  34. SP_R7 = STACK_FRAME_OVERHEAD + __PT_GPRS + 28
  35. SP_R8 = STACK_FRAME_OVERHEAD + __PT_GPRS + 32
  36. SP_R9 = STACK_FRAME_OVERHEAD + __PT_GPRS + 36
  37. SP_R10 = STACK_FRAME_OVERHEAD + __PT_GPRS + 40
  38. SP_R11 = STACK_FRAME_OVERHEAD + __PT_GPRS + 44
  39. SP_R12 = STACK_FRAME_OVERHEAD + __PT_GPRS + 48
  40. SP_R13 = STACK_FRAME_OVERHEAD + __PT_GPRS + 52
  41. SP_R14 = STACK_FRAME_OVERHEAD + __PT_GPRS + 56
  42. SP_R15 = STACK_FRAME_OVERHEAD + __PT_GPRS + 60
  43. SP_ORIG_R2 = STACK_FRAME_OVERHEAD + __PT_ORIG_GPR2
  44. SP_ILC = STACK_FRAME_OVERHEAD + __PT_ILC
  45. SP_SVCNR = STACK_FRAME_OVERHEAD + __PT_SVCNR
  46. SP_SIZE = STACK_FRAME_OVERHEAD + __PT_SIZE
  47. _TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
  48. _TIF_MCCK_PENDING | _TIF_RESTART_SVC | _TIF_PER_TRAP )
  49. _TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
  50. _TIF_MCCK_PENDING)
  51. _TIF_SYSCALL = (_TIF_SYSCALL_TRACE>>8 | _TIF_SYSCALL_AUDIT>>8 | \
  52. _TIF_SECCOMP>>8 | _TIF_SYSCALL_TRACEPOINT>>8)
  53. STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
  54. STACK_SIZE = 1 << STACK_SHIFT
  55. #define BASED(name) name-system_call(%r13)
  56. #ifdef CONFIG_TRACE_IRQFLAGS
  57. .macro TRACE_IRQS_ON
  58. basr %r2,%r0
  59. l %r1,BASED(.Ltrace_irq_on_caller)
  60. basr %r14,%r1
  61. .endm
  62. .macro TRACE_IRQS_OFF
  63. basr %r2,%r0
  64. l %r1,BASED(.Ltrace_irq_off_caller)
  65. basr %r14,%r1
  66. .endm
  67. #else
  68. #define TRACE_IRQS_ON
  69. #define TRACE_IRQS_OFF
  70. #endif
  71. #ifdef CONFIG_LOCKDEP
  72. .macro LOCKDEP_SYS_EXIT
  73. tm SP_PSW+1(%r15),0x01 # returning to user ?
  74. jz 0f
  75. l %r1,BASED(.Llockdep_sys_exit)
  76. basr %r14,%r1
  77. 0:
  78. .endm
  79. #else
  80. #define LOCKDEP_SYS_EXIT
  81. #endif
  82. /*
  83. * Register usage in interrupt handlers:
  84. * R9 - pointer to current task structure
  85. * R13 - pointer to literal pool
  86. * R14 - return register for function calls
  87. * R15 - kernel stack pointer
  88. */
  89. .macro UPDATE_VTIME lc_from,lc_to,lc_sum
  90. lm %r10,%r11,\lc_from
  91. sl %r10,\lc_to
  92. sl %r11,\lc_to+4
  93. bc 3,BASED(0f)
  94. sl %r10,BASED(.Lc_1)
  95. 0: al %r10,\lc_sum
  96. al %r11,\lc_sum+4
  97. bc 12,BASED(1f)
  98. al %r10,BASED(.Lc_1)
  99. 1: stm %r10,%r11,\lc_sum
  100. .endm
  101. .macro SAVE_ALL_SVC psworg,savearea
  102. stm %r12,%r15,\savearea
  103. l %r13,__LC_SVC_NEW_PSW+4 # load &system_call to %r13
  104. l %r15,__LC_KERNEL_STACK # problem state -> load ksp
  105. s %r15,BASED(.Lc_spsize) # make room for registers & psw
  106. .endm
  107. .macro SAVE_ALL_BASE savearea
  108. stm %r12,%r15,\savearea
  109. l %r13,__LC_SVC_NEW_PSW+4 # load &system_call to %r13
  110. .endm
  111. .macro SAVE_ALL_PGM psworg,savearea
  112. tm \psworg+1,0x01 # test problem state bit
  113. #ifdef CONFIG_CHECK_STACK
  114. bnz BASED(1f)
  115. tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
  116. bnz BASED(2f)
  117. la %r12,\psworg
  118. b BASED(stack_overflow)
  119. #else
  120. bz BASED(2f)
  121. #endif
  122. 1: l %r15,__LC_KERNEL_STACK # problem state -> load ksp
  123. 2: s %r15,BASED(.Lc_spsize) # make room for registers & psw
  124. .endm
  125. .macro SAVE_ALL_ASYNC psworg,savearea
  126. stm %r12,%r15,\savearea
  127. l %r13,__LC_SVC_NEW_PSW+4 # load &system_call to %r13
  128. la %r12,\psworg
  129. tm \psworg+1,0x01 # test problem state bit
  130. bnz BASED(1f) # from user -> load async stack
  131. clc \psworg+4(4),BASED(.Lcritical_end)
  132. bhe BASED(0f)
  133. clc \psworg+4(4),BASED(.Lcritical_start)
  134. bl BASED(0f)
  135. l %r14,BASED(.Lcleanup_critical)
  136. basr %r14,%r14
  137. tm 1(%r12),0x01 # retest problem state after cleanup
  138. bnz BASED(1f)
  139. 0: l %r14,__LC_ASYNC_STACK # are we already on the async stack ?
  140. slr %r14,%r15
  141. sra %r14,STACK_SHIFT
  142. #ifdef CONFIG_CHECK_STACK
  143. bnz BASED(1f)
  144. tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
  145. bnz BASED(2f)
  146. b BASED(stack_overflow)
  147. #else
  148. bz BASED(2f)
  149. #endif
  150. 1: l %r15,__LC_ASYNC_STACK
  151. 2: s %r15,BASED(.Lc_spsize) # make room for registers & psw
  152. .endm
  153. .macro CREATE_STACK_FRAME savearea
  154. xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15)
  155. st %r2,SP_ORIG_R2(%r15) # store original content of gpr 2
  156. mvc SP_R12(16,%r15),\savearea # move %r12-%r15 to stack
  157. stm %r0,%r11,SP_R0(%r15) # store gprs %r0-%r11 to kernel stack
  158. .endm
  159. .macro RESTORE_ALL psworg,sync
  160. mvc \psworg(8),SP_PSW(%r15) # move user PSW to lowcore
  161. .if !\sync
  162. ni \psworg+1,0xfd # clear wait state bit
  163. .endif
  164. lm %r0,%r15,SP_R0(%r15) # load gprs 0-15 of user
  165. stpt __LC_EXIT_TIMER
  166. lpsw \psworg # back to caller
  167. .endm
  168. .macro REENABLE_IRQS
  169. mvc __SF_EMPTY(1,%r15),SP_PSW(%r15)
  170. ni __SF_EMPTY(%r15),0xbf
  171. ssm __SF_EMPTY(%r15)
  172. .endm
  173. .section .kprobes.text, "ax"
  174. /*
  175. * Scheduler resume function, called by switch_to
  176. * gpr2 = (task_struct *) prev
  177. * gpr3 = (task_struct *) next
  178. * Returns:
  179. * gpr2 = prev
  180. */
  181. .globl __switch_to
  182. __switch_to:
  183. basr %r1,0
  184. 0: l %r4,__THREAD_info(%r2) # get thread_info of prev
  185. l %r5,__THREAD_info(%r3) # get thread_info of next
  186. tm __TI_flags+3(%r4),_TIF_MCCK_PENDING # machine check pending?
  187. bz 1f-0b(%r1)
  188. ni __TI_flags+3(%r4),255-_TIF_MCCK_PENDING # clear flag in prev
  189. oi __TI_flags+3(%r5),_TIF_MCCK_PENDING # set it in next
  190. 1: stm %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task
  191. st %r15,__THREAD_ksp(%r2) # store kernel stack of prev
  192. l %r15,__THREAD_ksp(%r3) # load kernel stack of next
  193. lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4
  194. lm %r6,%r15,__SF_GPRS(%r15) # load gprs of next task
  195. st %r3,__LC_CURRENT # store task struct of next
  196. mvc __LC_CURRENT_PID(4,%r0),__TASK_pid(%r3) # store pid of next
  197. st %r5,__LC_THREAD_INFO # store thread info of next
  198. ahi %r5,STACK_SIZE # end of kernel stack of next
  199. st %r5,__LC_KERNEL_STACK # store end of kernel stack
  200. br %r14
  201. __critical_start:
  202. /*
  203. * SVC interrupt handler routine. System calls are synchronous events and
  204. * are executed with interrupts enabled.
  205. */
  206. .globl system_call
  207. system_call:
  208. stpt __LC_SYNC_ENTER_TIMER
  209. sysc_saveall:
  210. SAVE_ALL_SVC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
  211. CREATE_STACK_FRAME __LC_SAVE_AREA
  212. mvc SP_PSW(8,%r15),__LC_SVC_OLD_PSW
  213. mvc SP_ILC(4,%r15),__LC_SVC_ILC
  214. l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
  215. sysc_vtime:
  216. UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
  217. sysc_stime:
  218. UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
  219. sysc_update:
  220. mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
  221. sysc_do_svc:
  222. xr %r7,%r7
  223. icm %r7,3,SP_SVCNR(%r15) # load svc number and test for svc 0
  224. bnz BASED(sysc_nr_ok) # svc number > 0
  225. # svc 0: system call number in %r1
  226. cl %r1,BASED(.Lnr_syscalls)
  227. bnl BASED(sysc_nr_ok)
  228. sth %r1,SP_SVCNR(%r15)
  229. lr %r7,%r1 # copy svc number to %r7
  230. sysc_nr_ok:
  231. sll %r7,2 # svc number *4
  232. l %r10,BASED(.Lsysc_table)
  233. tm __TI_flags+2(%r12),_TIF_SYSCALL
  234. mvc SP_ARGS(4,%r15),SP_R7(%r15)
  235. l %r8,0(%r7,%r10) # get system call addr.
  236. bnz BASED(sysc_tracesys)
  237. basr %r14,%r8 # call sys_xxxx
  238. st %r2,SP_R2(%r15) # store return value (change R2 on stack)
  239. sysc_return:
  240. LOCKDEP_SYS_EXIT
  241. sysc_tif:
  242. tm __TI_flags+3(%r12),_TIF_WORK_SVC
  243. bnz BASED(sysc_work) # there is work to do (signals etc.)
  244. sysc_restore:
  245. RESTORE_ALL __LC_RETURN_PSW,1
  246. sysc_done:
  247. #
  248. # There is work to do, but first we need to check if we return to userspace.
  249. #
  250. sysc_work:
  251. tm SP_PSW+1(%r15),0x01 # returning to user ?
  252. bno BASED(sysc_restore)
  253. #
  254. # One of the work bits is on. Find out which one.
  255. #
  256. sysc_work_tif:
  257. tm __TI_flags+3(%r12),_TIF_MCCK_PENDING
  258. bo BASED(sysc_mcck_pending)
  259. tm __TI_flags+3(%r12),_TIF_NEED_RESCHED
  260. bo BASED(sysc_reschedule)
  261. tm __TI_flags+3(%r12),_TIF_SIGPENDING
  262. bo BASED(sysc_sigpending)
  263. tm __TI_flags+3(%r12),_TIF_NOTIFY_RESUME
  264. bo BASED(sysc_notify_resume)
  265. tm __TI_flags+3(%r12),_TIF_RESTART_SVC
  266. bo BASED(sysc_restart)
  267. tm __TI_flags+3(%r12),_TIF_PER_TRAP
  268. bo BASED(sysc_singlestep)
  269. b BASED(sysc_return) # beware of critical section cleanup
  270. #
  271. # _TIF_NEED_RESCHED is set, call schedule
  272. #
  273. sysc_reschedule:
  274. l %r1,BASED(.Lschedule)
  275. la %r14,BASED(sysc_return)
  276. br %r1 # call scheduler
  277. #
  278. # _TIF_MCCK_PENDING is set, call handler
  279. #
  280. sysc_mcck_pending:
  281. l %r1,BASED(.Ls390_handle_mcck)
  282. la %r14,BASED(sysc_return)
  283. br %r1 # TIF bit will be cleared by handler
  284. #
  285. # _TIF_SIGPENDING is set, call do_signal
  286. #
  287. sysc_sigpending:
  288. ni __TI_flags+3(%r12),255-_TIF_PER_TRAP # clear TIF_PER_TRAP
  289. la %r2,SP_PTREGS(%r15) # load pt_regs
  290. l %r1,BASED(.Ldo_signal)
  291. basr %r14,%r1 # call do_signal
  292. tm __TI_flags+3(%r12),_TIF_RESTART_SVC
  293. bo BASED(sysc_restart)
  294. tm __TI_flags+3(%r12),_TIF_PER_TRAP
  295. bo BASED(sysc_singlestep)
  296. b BASED(sysc_return)
  297. #
  298. # _TIF_NOTIFY_RESUME is set, call do_notify_resume
  299. #
  300. sysc_notify_resume:
  301. la %r2,SP_PTREGS(%r15) # load pt_regs
  302. l %r1,BASED(.Ldo_notify_resume)
  303. la %r14,BASED(sysc_return)
  304. br %r1 # call do_notify_resume
  305. #
  306. # _TIF_RESTART_SVC is set, set up registers and restart svc
  307. #
  308. sysc_restart:
  309. ni __TI_flags+3(%r12),255-_TIF_RESTART_SVC # clear TIF_RESTART_SVC
  310. l %r7,SP_R2(%r15) # load new svc number
  311. mvc SP_R2(4,%r15),SP_ORIG_R2(%r15) # restore first argument
  312. lm %r2,%r6,SP_R2(%r15) # load svc arguments
  313. sth %r7,SP_SVCNR(%r15)
  314. b BASED(sysc_nr_ok) # restart svc
  315. #
  316. # _TIF_PER_TRAP is set, call do_per_trap
  317. #
  318. sysc_singlestep:
  319. ni __TI_flags+3(%r12),255-_TIF_PER_TRAP # clear TIF_PER_TRAP
  320. xc SP_SVCNR(2,%r15),SP_SVCNR(%r15) # clear svc number
  321. la %r2,SP_PTREGS(%r15) # address of register-save area
  322. l %r1,BASED(.Lhandle_per) # load adr. of per handler
  323. la %r14,BASED(sysc_return) # load adr. of system return
  324. br %r1 # branch to do_per_trap
  325. #
  326. # call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
  327. # and after the system call
  328. #
  329. sysc_tracesys:
  330. l %r1,BASED(.Ltrace_entry)
  331. la %r2,SP_PTREGS(%r15) # load pt_regs
  332. la %r3,0
  333. xr %r0,%r0
  334. icm %r0,3,SP_SVCNR(%r15)
  335. st %r0,SP_R2(%r15)
  336. basr %r14,%r1
  337. cl %r2,BASED(.Lnr_syscalls)
  338. bnl BASED(sysc_tracenogo)
  339. lr %r7,%r2
  340. sll %r7,2 # svc number *4
  341. l %r8,0(%r7,%r10)
  342. sysc_tracego:
  343. lm %r3,%r6,SP_R3(%r15)
  344. mvc SP_ARGS(4,%r15),SP_R7(%r15)
  345. l %r2,SP_ORIG_R2(%r15)
  346. basr %r14,%r8 # call sys_xxx
  347. st %r2,SP_R2(%r15) # store return value
  348. sysc_tracenogo:
  349. tm __TI_flags+2(%r12),_TIF_SYSCALL
  350. bz BASED(sysc_return)
  351. l %r1,BASED(.Ltrace_exit)
  352. la %r2,SP_PTREGS(%r15) # load pt_regs
  353. la %r14,BASED(sysc_return)
  354. br %r1
  355. #
  356. # a new process exits the kernel with ret_from_fork
  357. #
  358. .globl ret_from_fork
  359. ret_from_fork:
  360. l %r13,__LC_SVC_NEW_PSW+4
  361. l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
  362. tm SP_PSW+1(%r15),0x01 # forking a kernel thread ?
  363. bo BASED(0f)
  364. st %r15,SP_R15(%r15) # store stack pointer for new kthread
  365. 0: l %r1,BASED(.Lschedtail)
  366. basr %r14,%r1
  367. TRACE_IRQS_ON
  368. stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
  369. b BASED(sysc_tracenogo)
  370. #
  371. # kernel_execve function needs to deal with pt_regs that is not
  372. # at the usual place
  373. #
  374. .globl kernel_execve
  375. kernel_execve:
  376. stm %r12,%r15,48(%r15)
  377. lr %r14,%r15
  378. l %r13,__LC_SVC_NEW_PSW+4
  379. s %r15,BASED(.Lc_spsize)
  380. st %r14,__SF_BACKCHAIN(%r15)
  381. la %r12,SP_PTREGS(%r15)
  382. xc 0(__PT_SIZE,%r12),0(%r12)
  383. l %r1,BASED(.Ldo_execve)
  384. lr %r5,%r12
  385. basr %r14,%r1
  386. ltr %r2,%r2
  387. be BASED(0f)
  388. a %r15,BASED(.Lc_spsize)
  389. lm %r12,%r15,48(%r15)
  390. br %r14
  391. # execve succeeded.
  392. 0: stnsm __SF_EMPTY(%r15),0xfc # disable interrupts
  393. l %r15,__LC_KERNEL_STACK # load ksp
  394. s %r15,BASED(.Lc_spsize) # make room for registers & psw
  395. mvc SP_PTREGS(__PT_SIZE,%r15),0(%r12) # copy pt_regs
  396. l %r12,__LC_THREAD_INFO
  397. xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15)
  398. stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
  399. l %r1,BASED(.Lexecve_tail)
  400. basr %r14,%r1
  401. b BASED(sysc_return)
  402. /*
  403. * Program check handler routine
  404. */
  405. .globl pgm_check_handler
  406. pgm_check_handler:
  407. /*
  408. * First we need to check for a special case:
  409. * Single stepping an instruction that disables the PER event mask will
  410. * cause a PER event AFTER the mask has been set. Example: SVC or LPSW.
  411. * For a single stepped SVC the program check handler gets control after
  412. * the SVC new PSW has been loaded. But we want to execute the SVC first and
  413. * then handle the PER event. Therefore we update the SVC old PSW to point
  414. * to the pgm_check_handler and branch to the SVC handler after we checked
  415. * if we have to load the kernel stack register.
  416. * For every other possible cause for PER event without the PER mask set
  417. * we just ignore the PER event (FIXME: is there anything we have to do
  418. * for LPSW?).
  419. */
  420. stpt __LC_SYNC_ENTER_TIMER
  421. SAVE_ALL_BASE __LC_SAVE_AREA
  422. tm __LC_PGM_INT_CODE+1,0x80 # check whether we got a per exception
  423. bnz BASED(pgm_per) # got per exception -> special case
  424. SAVE_ALL_PGM __LC_PGM_OLD_PSW,__LC_SAVE_AREA
  425. CREATE_STACK_FRAME __LC_SAVE_AREA
  426. xc SP_ILC(4,%r15),SP_ILC(%r15)
  427. mvc SP_PSW(8,%r15),__LC_PGM_OLD_PSW
  428. l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
  429. tm SP_PSW+1(%r15),0x01 # interrupting from user ?
  430. bz BASED(pgm_no_vtime)
  431. UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
  432. UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
  433. mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
  434. pgm_no_vtime:
  435. l %r3,__LC_PGM_ILC # load program interruption code
  436. l %r4,__LC_TRANS_EXC_CODE
  437. REENABLE_IRQS
  438. la %r8,0x7f
  439. nr %r8,%r3
  440. sll %r8,2
  441. l %r1,BASED(.Ljump_table)
  442. l %r1,0(%r8,%r1) # load address of handler routine
  443. la %r2,SP_PTREGS(%r15) # address of register-save area
  444. basr %r14,%r1 # branch to interrupt-handler
  445. pgm_exit:
  446. b BASED(sysc_return)
  447. #
  448. # handle per exception
  449. #
  450. pgm_per:
  451. tm __LC_PGM_OLD_PSW,0x40 # test if per event recording is on
  452. bnz BASED(pgm_per_std) # ok, normal per event from user space
  453. # ok its one of the special cases, now we need to find out which one
  454. clc __LC_PGM_OLD_PSW(8),__LC_SVC_NEW_PSW
  455. be BASED(pgm_svcper)
  456. # no interesting special case, ignore PER event
  457. lm %r12,%r15,__LC_SAVE_AREA
  458. lpsw 0x28
  459. #
  460. # Normal per exception
  461. #
  462. pgm_per_std:
  463. SAVE_ALL_PGM __LC_PGM_OLD_PSW,__LC_SAVE_AREA
  464. CREATE_STACK_FRAME __LC_SAVE_AREA
  465. mvc SP_PSW(8,%r15),__LC_PGM_OLD_PSW
  466. l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
  467. tm SP_PSW+1(%r15),0x01 # interrupting from user ?
  468. bz BASED(pgm_no_vtime2)
  469. UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
  470. UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
  471. mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
  472. pgm_no_vtime2:
  473. l %r1,__TI_task(%r12)
  474. tm SP_PSW+1(%r15),0x01 # kernel per event ?
  475. bz BASED(kernel_per)
  476. mvc __THREAD_per_cause(2,%r1),__LC_PER_CAUSE
  477. mvc __THREAD_per_address(4,%r1),__LC_PER_ADDRESS
  478. mvc __THREAD_per_paid(1,%r1),__LC_PER_PAID
  479. oi __TI_flags+3(%r12),_TIF_PER_TRAP # set TIF_PER_TRAP
  480. l %r3,__LC_PGM_ILC # load program interruption code
  481. l %r4,__LC_TRANS_EXC_CODE
  482. REENABLE_IRQS
  483. la %r8,0x7f
  484. nr %r8,%r3 # clear per-event-bit and ilc
  485. be BASED(pgm_exit2) # only per or per+check ?
  486. sll %r8,2
  487. l %r1,BASED(.Ljump_table)
  488. l %r1,0(%r8,%r1) # load address of handler routine
  489. la %r2,SP_PTREGS(%r15) # address of register-save area
  490. basr %r14,%r1 # branch to interrupt-handler
  491. pgm_exit2:
  492. b BASED(sysc_return)
  493. #
  494. # it was a single stepped SVC that is causing all the trouble
  495. #
  496. pgm_svcper:
  497. SAVE_ALL_PGM __LC_SVC_OLD_PSW,__LC_SAVE_AREA
  498. CREATE_STACK_FRAME __LC_SAVE_AREA
  499. mvc SP_PSW(8,%r15),__LC_SVC_OLD_PSW
  500. mvc SP_ILC(4,%r15),__LC_SVC_ILC
  501. l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
  502. UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
  503. UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
  504. mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
  505. l %r8,__TI_task(%r12)
  506. mvc __THREAD_per_cause(2,%r8),__LC_PER_CAUSE
  507. mvc __THREAD_per_address(4,%r8),__LC_PER_ADDRESS
  508. mvc __THREAD_per_paid(1,%r8),__LC_PER_PAID
  509. oi __TI_flags+3(%r12),_TIF_PER_TRAP # set TIF_PER_TRAP
  510. stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
  511. lm %r2,%r6,SP_R2(%r15) # load svc arguments
  512. b BASED(sysc_do_svc)
  513. #
  514. # per was called from kernel, must be kprobes
  515. #
  516. kernel_per:
  517. REENABLE_IRQS
  518. xc SP_SVCNR(2,%r15),SP_SVCNR(%r15)
  519. la %r2,SP_PTREGS(%r15) # address of register-save area
  520. l %r1,BASED(.Lhandle_per) # load adr. of per handler
  521. basr %r14,%r1 # branch to do_single_step
  522. b BASED(pgm_exit)
  523. /*
  524. * IO interrupt handler routine
  525. */
  526. .globl io_int_handler
  527. io_int_handler:
  528. stck __LC_INT_CLOCK
  529. stpt __LC_ASYNC_ENTER_TIMER
  530. SAVE_ALL_ASYNC __LC_IO_OLD_PSW,__LC_SAVE_AREA+16
  531. CREATE_STACK_FRAME __LC_SAVE_AREA+16
  532. mvc SP_PSW(8,%r15),0(%r12) # move user PSW to stack
  533. l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
  534. tm SP_PSW+1(%r15),0x01 # interrupting from user ?
  535. bz BASED(io_no_vtime)
  536. UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
  537. UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
  538. mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
  539. io_no_vtime:
  540. TRACE_IRQS_OFF
  541. l %r1,BASED(.Ldo_IRQ) # load address of do_IRQ
  542. la %r2,SP_PTREGS(%r15) # address of register-save area
  543. basr %r14,%r1 # branch to standard irq handler
  544. io_return:
  545. LOCKDEP_SYS_EXIT
  546. TRACE_IRQS_ON
  547. io_tif:
  548. tm __TI_flags+3(%r12),_TIF_WORK_INT
  549. bnz BASED(io_work) # there is work to do (signals etc.)
  550. io_restore:
  551. RESTORE_ALL __LC_RETURN_PSW,0
  552. io_done:
  553. #
  554. # There is work todo, find out in which context we have been interrupted:
  555. # 1) if we return to user space we can do all _TIF_WORK_INT work
  556. # 2) if we return to kernel code and preemptive scheduling is enabled check
  557. # the preemption counter and if it is zero call preempt_schedule_irq
  558. # Before any work can be done, a switch to the kernel stack is required.
  559. #
  560. io_work:
  561. tm SP_PSW+1(%r15),0x01 # returning to user ?
  562. bo BASED(io_work_user) # yes -> do resched & signal
  563. #ifdef CONFIG_PREEMPT
  564. # check for preemptive scheduling
  565. icm %r0,15,__TI_precount(%r12)
  566. bnz BASED(io_restore) # preemption disabled
  567. tm __TI_flags+3(%r12),_TIF_NEED_RESCHED
  568. bno BASED(io_restore)
  569. # switch to kernel stack
  570. l %r1,SP_R15(%r15)
  571. s %r1,BASED(.Lc_spsize)
  572. mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
  573. xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1) # clear back chain
  574. lr %r15,%r1
  575. # TRACE_IRQS_ON already done at io_return, call
  576. # TRACE_IRQS_OFF to keep things symmetrical
  577. TRACE_IRQS_OFF
  578. l %r1,BASED(.Lpreempt_schedule_irq)
  579. basr %r14,%r1 # call preempt_schedule_irq
  580. b BASED(io_return)
  581. #else
  582. b BASED(io_restore)
  583. #endif
  584. #
  585. # Need to do work before returning to userspace, switch to kernel stack
  586. #
  587. io_work_user:
  588. l %r1,__LC_KERNEL_STACK
  589. s %r1,BASED(.Lc_spsize)
  590. mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
  591. xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1) # clear back chain
  592. lr %r15,%r1
  593. #
  594. # One of the work bits is on. Find out which one.
  595. # Checked are: _TIF_SIGPENDING, _TIF_NOTIFY_RESUME, _TIF_NEED_RESCHED
  596. # and _TIF_MCCK_PENDING
  597. #
  598. io_work_tif:
  599. tm __TI_flags+3(%r12),_TIF_MCCK_PENDING
  600. bo BASED(io_mcck_pending)
  601. tm __TI_flags+3(%r12),_TIF_NEED_RESCHED
  602. bo BASED(io_reschedule)
  603. tm __TI_flags+3(%r12),_TIF_SIGPENDING
  604. bo BASED(io_sigpending)
  605. tm __TI_flags+3(%r12),_TIF_NOTIFY_RESUME
  606. bo BASED(io_notify_resume)
  607. b BASED(io_return) # beware of critical section cleanup
  608. #
  609. # _TIF_MCCK_PENDING is set, call handler
  610. #
  611. io_mcck_pending:
  612. # TRACE_IRQS_ON already done at io_return
  613. l %r1,BASED(.Ls390_handle_mcck)
  614. basr %r14,%r1 # TIF bit will be cleared by handler
  615. TRACE_IRQS_OFF
  616. b BASED(io_return)
  617. #
  618. # _TIF_NEED_RESCHED is set, call schedule
  619. #
  620. io_reschedule:
  621. # TRACE_IRQS_ON already done at io_return
  622. l %r1,BASED(.Lschedule)
  623. stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
  624. basr %r14,%r1 # call scheduler
  625. stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
  626. TRACE_IRQS_OFF
  627. b BASED(io_return)
  628. #
  629. # _TIF_SIGPENDING is set, call do_signal
  630. #
  631. io_sigpending:
  632. # TRACE_IRQS_ON already done at io_return
  633. stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
  634. la %r2,SP_PTREGS(%r15) # load pt_regs
  635. l %r1,BASED(.Ldo_signal)
  636. basr %r14,%r1 # call do_signal
  637. stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
  638. TRACE_IRQS_OFF
  639. b BASED(io_return)
  640. #
  641. # _TIF_SIGPENDING is set, call do_signal
  642. #
  643. io_notify_resume:
  644. # TRACE_IRQS_ON already done at io_return
  645. stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
  646. la %r2,SP_PTREGS(%r15) # load pt_regs
  647. l %r1,BASED(.Ldo_notify_resume)
  648. basr %r14,%r1 # call do_signal
  649. stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
  650. TRACE_IRQS_OFF
  651. b BASED(io_return)
  652. /*
  653. * External interrupt handler routine
  654. */
  655. .globl ext_int_handler
  656. ext_int_handler:
  657. stck __LC_INT_CLOCK
  658. stpt __LC_ASYNC_ENTER_TIMER
  659. SAVE_ALL_ASYNC __LC_EXT_OLD_PSW,__LC_SAVE_AREA+16
  660. CREATE_STACK_FRAME __LC_SAVE_AREA+16
  661. mvc SP_PSW(8,%r15),0(%r12) # move user PSW to stack
  662. l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
  663. tm SP_PSW+1(%r15),0x01 # interrupting from user ?
  664. bz BASED(ext_no_vtime)
  665. UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
  666. UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
  667. mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
  668. ext_no_vtime:
  669. TRACE_IRQS_OFF
  670. la %r2,SP_PTREGS(%r15) # address of register-save area
  671. l %r3,__LC_CPU_ADDRESS # get cpu address + interruption code
  672. l %r4,__LC_EXT_PARAMS # get external parameters
  673. l %r1,BASED(.Ldo_extint)
  674. basr %r14,%r1
  675. b BASED(io_return)
  676. __critical_end:
  677. /*
  678. * Machine check handler routines
  679. */
  680. .globl mcck_int_handler
  681. mcck_int_handler:
  682. stck __LC_MCCK_CLOCK
  683. spt __LC_CPU_TIMER_SAVE_AREA # revalidate cpu timer
  684. lm %r0,%r15,__LC_GPREGS_SAVE_AREA # revalidate gprs
  685. SAVE_ALL_BASE __LC_SAVE_AREA+32
  686. la %r12,__LC_MCK_OLD_PSW
  687. tm __LC_MCCK_CODE,0x80 # system damage?
  688. bo BASED(mcck_int_main) # yes -> rest of mcck code invalid
  689. mvc __LC_MCCK_ENTER_TIMER(8),__LC_CPU_TIMER_SAVE_AREA
  690. tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
  691. bo BASED(1f)
  692. la %r14,__LC_SYNC_ENTER_TIMER
  693. clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
  694. bl BASED(0f)
  695. la %r14,__LC_ASYNC_ENTER_TIMER
  696. 0: clc 0(8,%r14),__LC_EXIT_TIMER
  697. bl BASED(0f)
  698. la %r14,__LC_EXIT_TIMER
  699. 0: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
  700. bl BASED(0f)
  701. la %r14,__LC_LAST_UPDATE_TIMER
  702. 0: spt 0(%r14)
  703. mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
  704. 1: tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid?
  705. bno BASED(mcck_int_main) # no -> skip cleanup critical
  706. tm __LC_MCK_OLD_PSW+1,0x01 # test problem state bit
  707. bnz BASED(mcck_int_main) # from user -> load async stack
  708. clc __LC_MCK_OLD_PSW+4(4),BASED(.Lcritical_end)
  709. bhe BASED(mcck_int_main)
  710. clc __LC_MCK_OLD_PSW+4(4),BASED(.Lcritical_start)
  711. bl BASED(mcck_int_main)
  712. l %r14,BASED(.Lcleanup_critical)
  713. basr %r14,%r14
  714. mcck_int_main:
  715. l %r14,__LC_PANIC_STACK # are we already on the panic stack?
  716. slr %r14,%r15
  717. sra %r14,PAGE_SHIFT
  718. be BASED(0f)
  719. l %r15,__LC_PANIC_STACK # load panic stack
  720. 0: s %r15,BASED(.Lc_spsize) # make room for registers & psw
  721. CREATE_STACK_FRAME __LC_SAVE_AREA+32
  722. mvc SP_PSW(8,%r15),0(%r12)
  723. l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
  724. tm __LC_MCCK_CODE+2,0x08 # mwp of old psw valid?
  725. bno BASED(mcck_no_vtime) # no -> skip cleanup critical
  726. tm SP_PSW+1(%r15),0x01 # interrupting from user ?
  727. bz BASED(mcck_no_vtime)
  728. UPDATE_VTIME __LC_EXIT_TIMER,__LC_MCCK_ENTER_TIMER,__LC_USER_TIMER
  729. UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
  730. mvc __LC_LAST_UPDATE_TIMER(8),__LC_MCCK_ENTER_TIMER
  731. mcck_no_vtime:
  732. la %r2,SP_PTREGS(%r15) # load pt_regs
  733. l %r1,BASED(.Ls390_mcck)
  734. basr %r14,%r1 # call machine check handler
  735. tm SP_PSW+1(%r15),0x01 # returning to user ?
  736. bno BASED(mcck_return)
  737. l %r1,__LC_KERNEL_STACK # switch to kernel stack
  738. s %r1,BASED(.Lc_spsize)
  739. mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
  740. xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1) # clear back chain
  741. lr %r15,%r1
  742. stosm __SF_EMPTY(%r15),0x04 # turn dat on
  743. tm __TI_flags+3(%r12),_TIF_MCCK_PENDING
  744. bno BASED(mcck_return)
  745. TRACE_IRQS_OFF
  746. l %r1,BASED(.Ls390_handle_mcck)
  747. basr %r14,%r1 # call machine check handler
  748. TRACE_IRQS_ON
  749. mcck_return:
  750. mvc __LC_RETURN_MCCK_PSW(8),SP_PSW(%r15) # move return PSW
  751. ni __LC_RETURN_MCCK_PSW+1,0xfd # clear wait state bit
  752. tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
  753. bno BASED(0f)
  754. lm %r0,%r15,SP_R0(%r15) # load gprs 0-15
  755. stpt __LC_EXIT_TIMER
  756. lpsw __LC_RETURN_MCCK_PSW # back to caller
  757. 0: lm %r0,%r15,SP_R0(%r15) # load gprs 0-15
  758. lpsw __LC_RETURN_MCCK_PSW # back to caller
  759. RESTORE_ALL __LC_RETURN_MCCK_PSW,0
  760. /*
  761. * Restart interruption handler, kick starter for additional CPUs
  762. */
  763. #ifdef CONFIG_SMP
  764. __CPUINIT
  765. .globl restart_int_handler
  766. restart_int_handler:
  767. basr %r1,0
  768. restart_base:
  769. spt restart_vtime-restart_base(%r1)
  770. stck __LC_LAST_UPDATE_CLOCK
  771. mvc __LC_LAST_UPDATE_TIMER(8),restart_vtime-restart_base(%r1)
  772. mvc __LC_EXIT_TIMER(8),restart_vtime-restart_base(%r1)
  773. l %r15,__LC_SAVE_AREA+60 # load ksp
  774. lctl %c0,%c15,__LC_CREGS_SAVE_AREA # get new ctl regs
  775. lam %a0,%a15,__LC_AREGS_SAVE_AREA
  776. lm %r6,%r15,__SF_GPRS(%r15) # load registers from clone
  777. l %r1,__LC_THREAD_INFO
  778. mvc __LC_USER_TIMER(8),__TI_user_timer(%r1)
  779. mvc __LC_SYSTEM_TIMER(8),__TI_system_timer(%r1)
  780. xc __LC_STEAL_TIMER(8),__LC_STEAL_TIMER
  781. stosm __SF_EMPTY(%r15),0x04 # now we can turn dat on
  782. basr %r14,0
  783. l %r14,restart_addr-.(%r14)
  784. basr %r14,%r14 # branch to start_secondary
  785. restart_addr:
  786. .long start_secondary
  787. .align 8
  788. restart_vtime:
  789. .long 0x7fffffff,0xffffffff
  790. .previous
  791. #else
  792. /*
  793. * If we do not run with SMP enabled, let the new CPU crash ...
  794. */
  795. .globl restart_int_handler
  796. restart_int_handler:
  797. basr %r1,0
  798. restart_base:
  799. lpsw restart_crash-restart_base(%r1)
  800. .align 8
  801. restart_crash:
  802. .long 0x000a0000,0x00000000
  803. restart_go:
  804. #endif
  805. .section .kprobes.text, "ax"
  806. #ifdef CONFIG_CHECK_STACK
  807. /*
  808. * The synchronous or the asynchronous stack overflowed. We are dead.
  809. * No need to properly save the registers, we are going to panic anyway.
  810. * Setup a pt_regs so that show_trace can provide a good call trace.
  811. */
  812. stack_overflow:
  813. l %r15,__LC_PANIC_STACK # change to panic stack
  814. sl %r15,BASED(.Lc_spsize)
  815. mvc SP_PSW(8,%r15),0(%r12) # move user PSW to stack
  816. stm %r0,%r11,SP_R0(%r15) # store gprs %r0-%r11 to kernel stack
  817. la %r1,__LC_SAVE_AREA
  818. ch %r12,BASED(.L0x020) # old psw addr == __LC_SVC_OLD_PSW ?
  819. be BASED(0f)
  820. ch %r12,BASED(.L0x028) # old psw addr == __LC_PGM_OLD_PSW ?
  821. be BASED(0f)
  822. la %r1,__LC_SAVE_AREA+16
  823. 0: mvc SP_R12(16,%r15),0(%r1) # move %r12-%r15 to stack
  824. xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15) # clear back chain
  825. l %r1,BASED(1f) # branch to kernel_stack_overflow
  826. la %r2,SP_PTREGS(%r15) # load pt_regs
  827. br %r1
  828. 1: .long kernel_stack_overflow
  829. #endif
  830. cleanup_table_system_call:
  831. .long system_call + 0x80000000, sysc_do_svc + 0x80000000
  832. cleanup_table_sysc_tif:
  833. .long sysc_tif + 0x80000000, sysc_restore + 0x80000000
  834. cleanup_table_sysc_restore:
  835. .long sysc_restore + 0x80000000, sysc_done + 0x80000000
  836. cleanup_table_io_tif:
  837. .long io_tif + 0x80000000, io_restore + 0x80000000
  838. cleanup_table_io_restore:
  839. .long io_restore + 0x80000000, io_done + 0x80000000
  840. cleanup_critical:
  841. clc 4(4,%r12),BASED(cleanup_table_system_call)
  842. bl BASED(0f)
  843. clc 4(4,%r12),BASED(cleanup_table_system_call+4)
  844. bl BASED(cleanup_system_call)
  845. 0:
  846. clc 4(4,%r12),BASED(cleanup_table_sysc_tif)
  847. bl BASED(0f)
  848. clc 4(4,%r12),BASED(cleanup_table_sysc_tif+4)
  849. bl BASED(cleanup_sysc_tif)
  850. 0:
  851. clc 4(4,%r12),BASED(cleanup_table_sysc_restore)
  852. bl BASED(0f)
  853. clc 4(4,%r12),BASED(cleanup_table_sysc_restore+4)
  854. bl BASED(cleanup_sysc_restore)
  855. 0:
  856. clc 4(4,%r12),BASED(cleanup_table_io_tif)
  857. bl BASED(0f)
  858. clc 4(4,%r12),BASED(cleanup_table_io_tif+4)
  859. bl BASED(cleanup_io_tif)
  860. 0:
  861. clc 4(4,%r12),BASED(cleanup_table_io_restore)
  862. bl BASED(0f)
  863. clc 4(4,%r12),BASED(cleanup_table_io_restore+4)
  864. bl BASED(cleanup_io_restore)
  865. 0:
  866. br %r14
  867. cleanup_system_call:
  868. mvc __LC_RETURN_PSW(8),0(%r12)
  869. clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+4)
  870. bh BASED(0f)
  871. mvc __LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER
  872. c %r12,BASED(.Lmck_old_psw)
  873. be BASED(0f)
  874. mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
  875. 0: c %r12,BASED(.Lmck_old_psw)
  876. la %r12,__LC_SAVE_AREA+32
  877. be BASED(0f)
  878. la %r12,__LC_SAVE_AREA+16
  879. 0: clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+8)
  880. bhe BASED(cleanup_vtime)
  881. clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn)
  882. bh BASED(0f)
  883. mvc __LC_SAVE_AREA(16),0(%r12)
  884. 0: st %r13,4(%r12)
  885. l %r15,__LC_KERNEL_STACK # problem state -> load ksp
  886. s %r15,BASED(.Lc_spsize) # make room for registers & psw
  887. st %r15,12(%r12)
  888. CREATE_STACK_FRAME __LC_SAVE_AREA
  889. mvc SP_PSW(8,%r15),__LC_SVC_OLD_PSW
  890. mvc SP_ILC(4,%r15),__LC_SVC_ILC
  891. mvc 0(4,%r12),__LC_THREAD_INFO
  892. cleanup_vtime:
  893. clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+12)
  894. bhe BASED(cleanup_stime)
  895. UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
  896. cleanup_stime:
  897. clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+16)
  898. bh BASED(cleanup_update)
  899. UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
  900. cleanup_update:
  901. mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
  902. mvc __LC_RETURN_PSW+4(4),BASED(cleanup_table_system_call+4)
  903. la %r12,__LC_RETURN_PSW
  904. br %r14
  905. cleanup_system_call_insn:
  906. .long sysc_saveall + 0x80000000
  907. .long system_call + 0x80000000
  908. .long sysc_vtime + 0x80000000
  909. .long sysc_stime + 0x80000000
  910. .long sysc_update + 0x80000000
  911. cleanup_sysc_tif:
  912. mvc __LC_RETURN_PSW(4),0(%r12)
  913. mvc __LC_RETURN_PSW+4(4),BASED(cleanup_table_sysc_tif)
  914. la %r12,__LC_RETURN_PSW
  915. br %r14
  916. cleanup_sysc_restore:
  917. clc 4(4,%r12),BASED(cleanup_sysc_restore_insn)
  918. be BASED(2f)
  919. mvc __LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
  920. c %r12,BASED(.Lmck_old_psw)
  921. be BASED(0f)
  922. mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
  923. 0: clc 4(4,%r12),BASED(cleanup_sysc_restore_insn+4)
  924. be BASED(2f)
  925. mvc __LC_RETURN_PSW(8),SP_PSW(%r15)
  926. c %r12,BASED(.Lmck_old_psw)
  927. la %r12,__LC_SAVE_AREA+32
  928. be BASED(1f)
  929. la %r12,__LC_SAVE_AREA+16
  930. 1: mvc 0(16,%r12),SP_R12(%r15)
  931. lm %r0,%r11,SP_R0(%r15)
  932. l %r15,SP_R15(%r15)
  933. 2: la %r12,__LC_RETURN_PSW
  934. br %r14
  935. cleanup_sysc_restore_insn:
  936. .long sysc_done - 4 + 0x80000000
  937. .long sysc_done - 8 + 0x80000000
  938. cleanup_io_tif:
  939. mvc __LC_RETURN_PSW(4),0(%r12)
  940. mvc __LC_RETURN_PSW+4(4),BASED(cleanup_table_io_tif)
  941. la %r12,__LC_RETURN_PSW
  942. br %r14
  943. cleanup_io_restore:
  944. clc 4(4,%r12),BASED(cleanup_io_restore_insn)
  945. be BASED(1f)
  946. mvc __LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
  947. clc 4(4,%r12),BASED(cleanup_io_restore_insn+4)
  948. be BASED(1f)
  949. mvc __LC_RETURN_PSW(8),SP_PSW(%r15)
  950. mvc __LC_SAVE_AREA+32(16),SP_R12(%r15)
  951. lm %r0,%r11,SP_R0(%r15)
  952. l %r15,SP_R15(%r15)
  953. 1: la %r12,__LC_RETURN_PSW
  954. br %r14
  955. cleanup_io_restore_insn:
  956. .long io_done - 4 + 0x80000000
  957. .long io_done - 8 + 0x80000000
  958. /*
  959. * Integer constants
  960. */
  961. .align 4
  962. .Lc_spsize: .long SP_SIZE
  963. .Lc_overhead: .long STACK_FRAME_OVERHEAD
  964. .Lnr_syscalls: .long NR_syscalls
  965. .L0x018: .short 0x018
  966. .L0x020: .short 0x020
  967. .L0x028: .short 0x028
  968. .L0x030: .short 0x030
  969. .L0x038: .short 0x038
  970. .Lc_1: .long 1
  971. /*
  972. * Symbol constants
  973. */
  974. .Ls390_mcck: .long s390_do_machine_check
  975. .Ls390_handle_mcck:
  976. .long s390_handle_mcck
  977. .Lmck_old_psw: .long __LC_MCK_OLD_PSW
  978. .Ldo_IRQ: .long do_IRQ
  979. .Ldo_extint: .long do_extint
  980. .Ldo_signal: .long do_signal
  981. .Ldo_notify_resume:
  982. .long do_notify_resume
  983. .Lhandle_per: .long do_per_trap
  984. .Ldo_execve: .long do_execve
  985. .Lexecve_tail: .long execve_tail
  986. .Ljump_table: .long pgm_check_table
  987. .Lschedule: .long schedule
  988. #ifdef CONFIG_PREEMPT
  989. .Lpreempt_schedule_irq:
  990. .long preempt_schedule_irq
  991. #endif
  992. .Ltrace_entry: .long do_syscall_trace_enter
  993. .Ltrace_exit: .long do_syscall_trace_exit
  994. .Lschedtail: .long schedule_tail
  995. .Lsysc_table: .long sys_call_table
  996. #ifdef CONFIG_TRACE_IRQFLAGS
  997. .Ltrace_irq_on_caller:
  998. .long trace_hardirqs_on_caller
  999. .Ltrace_irq_off_caller:
  1000. .long trace_hardirqs_off_caller
  1001. #endif
  1002. #ifdef CONFIG_LOCKDEP
  1003. .Llockdep_sys_exit:
  1004. .long lockdep_sys_exit
  1005. #endif
  1006. .Lcritical_start:
  1007. .long __critical_start + 0x80000000
  1008. .Lcritical_end:
  1009. .long __critical_end + 0x80000000
  1010. .Lcleanup_critical:
  1011. .long cleanup_critical
  1012. .section .rodata, "a"
  1013. #define SYSCALL(esa,esame,emu) .long esa
  1014. .globl sys_call_table
  1015. sys_call_table:
  1016. #include "syscalls.S"
  1017. #undef SYSCALL