entry64.S 30 KB

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