entry.S 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * S390 low-level entry points.
  4. *
  5. * Copyright IBM Corp. 1999, 2012
  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/init.h>
  12. #include <linux/linkage.h>
  13. #include <asm/alternative-asm.h>
  14. #include <asm/processor.h>
  15. #include <asm/cache.h>
  16. #include <asm/ctl_reg.h>
  17. #include <asm/dwarf.h>
  18. #include <asm/errno.h>
  19. #include <asm/ptrace.h>
  20. #include <asm/thread_info.h>
  21. #include <asm/asm-offsets.h>
  22. #include <asm/unistd.h>
  23. #include <asm/page.h>
  24. #include <asm/sigp.h>
  25. #include <asm/irq.h>
  26. #include <asm/vx-insn.h>
  27. #include <asm/setup.h>
  28. #include <asm/nmi.h>
  29. #include <asm/export.h>
  30. #include <asm/nospec-insn.h>
  31. __PT_R0 = __PT_GPRS
  32. __PT_R1 = __PT_GPRS + 8
  33. __PT_R2 = __PT_GPRS + 16
  34. __PT_R3 = __PT_GPRS + 24
  35. __PT_R4 = __PT_GPRS + 32
  36. __PT_R5 = __PT_GPRS + 40
  37. __PT_R6 = __PT_GPRS + 48
  38. __PT_R7 = __PT_GPRS + 56
  39. __PT_R8 = __PT_GPRS + 64
  40. __PT_R9 = __PT_GPRS + 72
  41. __PT_R10 = __PT_GPRS + 80
  42. __PT_R11 = __PT_GPRS + 88
  43. __PT_R12 = __PT_GPRS + 96
  44. __PT_R13 = __PT_GPRS + 104
  45. __PT_R14 = __PT_GPRS + 112
  46. __PT_R15 = __PT_GPRS + 120
  47. STACK_SHIFT = PAGE_SHIFT + THREAD_SIZE_ORDER
  48. STACK_SIZE = 1 << STACK_SHIFT
  49. STACK_INIT = STACK_SIZE - STACK_FRAME_OVERHEAD - __PT_SIZE
  50. _TIF_WORK = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
  51. _TIF_UPROBE | _TIF_GUARDED_STORAGE | _TIF_PATCH_PENDING)
  52. _TIF_TRACE = (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | \
  53. _TIF_SYSCALL_TRACEPOINT)
  54. _CIF_WORK = (_CIF_MCCK_PENDING | _CIF_ASCE_PRIMARY | \
  55. _CIF_ASCE_SECONDARY | _CIF_FPU)
  56. _PIF_WORK = (_PIF_PER_TRAP | _PIF_SYSCALL_RESTART)
  57. _LPP_OFFSET = __LC_LPP
  58. #define BASED(name) name-cleanup_critical(%r13)
  59. .macro TRACE_IRQS_ON
  60. #ifdef CONFIG_TRACE_IRQFLAGS
  61. basr %r2,%r0
  62. brasl %r14,trace_hardirqs_on_caller
  63. #endif
  64. .endm
  65. .macro TRACE_IRQS_OFF
  66. #ifdef CONFIG_TRACE_IRQFLAGS
  67. basr %r2,%r0
  68. brasl %r14,trace_hardirqs_off_caller
  69. #endif
  70. .endm
  71. .macro LOCKDEP_SYS_EXIT
  72. #ifdef CONFIG_LOCKDEP
  73. tm __PT_PSW+1(%r11),0x01 # returning to user ?
  74. jz .+10
  75. brasl %r14,lockdep_sys_exit
  76. #endif
  77. .endm
  78. .macro CHECK_STACK stacksize,savearea
  79. #ifdef CONFIG_CHECK_STACK
  80. tml %r15,\stacksize - CONFIG_STACK_GUARD
  81. lghi %r14,\savearea
  82. jz stack_overflow
  83. #endif
  84. .endm
  85. .macro SWITCH_ASYNC savearea,timer
  86. tmhh %r8,0x0001 # interrupting from user ?
  87. jnz 1f
  88. lgr %r14,%r9
  89. slg %r14,BASED(.Lcritical_start)
  90. clg %r14,BASED(.Lcritical_length)
  91. jhe 0f
  92. lghi %r11,\savearea # inside critical section, do cleanup
  93. brasl %r14,cleanup_critical
  94. tmhh %r8,0x0001 # retest problem state after cleanup
  95. jnz 1f
  96. 0: lg %r14,__LC_ASYNC_STACK # are we already on the async stack?
  97. slgr %r14,%r15
  98. srag %r14,%r14,STACK_SHIFT
  99. jnz 2f
  100. CHECK_STACK 1<<STACK_SHIFT,\savearea
  101. aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
  102. j 3f
  103. 1: UPDATE_VTIME %r14,%r15,\timer
  104. BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
  105. 2: lg %r15,__LC_ASYNC_STACK # load async stack
  106. 3: la %r11,STACK_FRAME_OVERHEAD(%r15)
  107. .endm
  108. .macro UPDATE_VTIME w1,w2,enter_timer
  109. lg \w1,__LC_EXIT_TIMER
  110. lg \w2,__LC_LAST_UPDATE_TIMER
  111. slg \w1,\enter_timer
  112. slg \w2,__LC_EXIT_TIMER
  113. alg \w1,__LC_USER_TIMER
  114. alg \w2,__LC_SYSTEM_TIMER
  115. stg \w1,__LC_USER_TIMER
  116. stg \w2,__LC_SYSTEM_TIMER
  117. mvc __LC_LAST_UPDATE_TIMER(8),\enter_timer
  118. .endm
  119. .macro REENABLE_IRQS
  120. stg %r8,__LC_RETURN_PSW
  121. ni __LC_RETURN_PSW,0xbf
  122. ssm __LC_RETURN_PSW
  123. .endm
  124. .macro STCK savearea
  125. #ifdef CONFIG_HAVE_MARCH_Z9_109_FEATURES
  126. .insn s,0xb27c0000,\savearea # store clock fast
  127. #else
  128. .insn s,0xb2050000,\savearea # store clock
  129. #endif
  130. .endm
  131. /*
  132. * The TSTMSK macro generates a test-under-mask instruction by
  133. * calculating the memory offset for the specified mask value.
  134. * Mask value can be any constant. The macro shifts the mask
  135. * value to calculate the memory offset for the test-under-mask
  136. * instruction.
  137. */
  138. .macro TSTMSK addr, mask, size=8, bytepos=0
  139. .if (\bytepos < \size) && (\mask >> 8)
  140. .if (\mask & 0xff)
  141. .error "Mask exceeds byte boundary"
  142. .endif
  143. TSTMSK \addr, "(\mask >> 8)", \size, "(\bytepos + 1)"
  144. .exitm
  145. .endif
  146. .ifeq \mask
  147. .error "Mask must not be zero"
  148. .endif
  149. off = \size - \bytepos - 1
  150. tm off+\addr, \mask
  151. .endm
  152. .macro BPOFF
  153. ALTERNATIVE "", ".long 0xb2e8c000", 82
  154. .endm
  155. .macro BPON
  156. ALTERNATIVE "", ".long 0xb2e8d000", 82
  157. .endm
  158. .macro BPENTER tif_ptr,tif_mask
  159. ALTERNATIVE "TSTMSK \tif_ptr,\tif_mask; jz .+8; .long 0xb2e8d000", \
  160. "", 82
  161. .endm
  162. .macro BPEXIT tif_ptr,tif_mask
  163. TSTMSK \tif_ptr,\tif_mask
  164. ALTERNATIVE "jz .+8; .long 0xb2e8c000", \
  165. "jnz .+8; .long 0xb2e8d000", 82
  166. .endm
  167. GEN_BR_THUNK %r9
  168. GEN_BR_THUNK %r14
  169. GEN_BR_THUNK %r14,%r11
  170. .section .kprobes.text, "ax"
  171. .Ldummy:
  172. /*
  173. * This nop exists only in order to avoid that __switch_to starts at
  174. * the beginning of the kprobes text section. In that case we would
  175. * have several symbols at the same address. E.g. objdump would take
  176. * an arbitrary symbol name when disassembling this code.
  177. * With the added nop in between the __switch_to symbol is unique
  178. * again.
  179. */
  180. nop 0
  181. ENTRY(__bpon)
  182. .globl __bpon
  183. BPON
  184. BR_EX %r14
  185. /*
  186. * Scheduler resume function, called by switch_to
  187. * gpr2 = (task_struct *) prev
  188. * gpr3 = (task_struct *) next
  189. * Returns:
  190. * gpr2 = prev
  191. */
  192. ENTRY(__switch_to)
  193. stmg %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task
  194. lghi %r4,__TASK_stack
  195. lghi %r1,__TASK_thread
  196. lg %r5,0(%r4,%r3) # start of kernel stack of next
  197. stg %r15,__THREAD_ksp(%r1,%r2) # store kernel stack of prev
  198. lgr %r15,%r5
  199. aghi %r15,STACK_INIT # end of kernel stack of next
  200. stg %r3,__LC_CURRENT # store task struct of next
  201. stg %r15,__LC_KERNEL_STACK # store end of kernel stack
  202. lg %r15,__THREAD_ksp(%r1,%r3) # load kernel stack of next
  203. aghi %r3,__TASK_pid
  204. mvc __LC_CURRENT_PID(4,%r0),0(%r3) # store pid of next
  205. lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task
  206. ALTERNATIVE "", ".insn s,0xb2800000,_LPP_OFFSET", 40
  207. BR_EX %r14
  208. .L__critical_start:
  209. #if IS_ENABLED(CONFIG_KVM)
  210. /*
  211. * sie64a calling convention:
  212. * %r2 pointer to sie control block
  213. * %r3 guest register save area
  214. */
  215. ENTRY(sie64a)
  216. stmg %r6,%r14,__SF_GPRS(%r15) # save kernel registers
  217. lg %r12,__LC_CURRENT
  218. stg %r2,__SF_SIE_CONTROL(%r15) # save control block pointer
  219. stg %r3,__SF_SIE_SAVEAREA(%r15) # save guest register save area
  220. xc __SF_SIE_REASON(8,%r15),__SF_SIE_REASON(%r15) # reason code = 0
  221. mvc __SF_SIE_FLAGS(8,%r15),__TI_flags(%r12) # copy thread flags
  222. TSTMSK __LC_CPU_FLAGS,_CIF_FPU # load guest fp/vx registers ?
  223. jno .Lsie_load_guest_gprs
  224. brasl %r14,load_fpu_regs # load guest fp/vx regs
  225. .Lsie_load_guest_gprs:
  226. lmg %r0,%r13,0(%r3) # load guest gprs 0-13
  227. lg %r14,__LC_GMAP # get gmap pointer
  228. ltgr %r14,%r14
  229. jz .Lsie_gmap
  230. lctlg %c1,%c1,__GMAP_ASCE(%r14) # load primary asce
  231. .Lsie_gmap:
  232. lg %r14,__SF_SIE_CONTROL(%r15) # get control block pointer
  233. oi __SIE_PROG0C+3(%r14),1 # we are going into SIE now
  234. tm __SIE_PROG20+3(%r14),3 # last exit...
  235. jnz .Lsie_skip
  236. TSTMSK __LC_CPU_FLAGS,_CIF_FPU
  237. jo .Lsie_skip # exit if fp/vx regs changed
  238. BPEXIT __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
  239. .Lsie_entry:
  240. sie 0(%r14)
  241. .Lsie_exit:
  242. BPOFF
  243. BPENTER __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
  244. .Lsie_skip:
  245. ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE
  246. lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
  247. .Lsie_done:
  248. # some program checks are suppressing. C code (e.g. do_protection_exception)
  249. # will rewind the PSW by the ILC, which is often 4 bytes in case of SIE. There
  250. # are some corner cases (e.g. runtime instrumentation) where ILC is unpredictable.
  251. # Other instructions between sie64a and .Lsie_done should not cause program
  252. # interrupts. So lets use 3 nops as a landing pad for all possible rewinds.
  253. # See also .Lcleanup_sie
  254. .Lrewind_pad6:
  255. nopr 7
  256. .Lrewind_pad4:
  257. nopr 7
  258. .Lrewind_pad2:
  259. nopr 7
  260. .globl sie_exit
  261. sie_exit:
  262. lg %r14,__SF_SIE_SAVEAREA(%r15) # load guest register save area
  263. stmg %r0,%r13,0(%r14) # save guest gprs 0-13
  264. xgr %r0,%r0 # clear guest registers to
  265. xgr %r1,%r1 # prevent speculative use
  266. xgr %r2,%r2
  267. xgr %r3,%r3
  268. xgr %r4,%r4
  269. xgr %r5,%r5
  270. lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers
  271. lg %r2,__SF_SIE_REASON(%r15) # return exit reason code
  272. BR_EX %r14
  273. .Lsie_fault:
  274. lghi %r14,-EFAULT
  275. stg %r14,__SF_SIE_REASON(%r15) # set exit reason code
  276. j sie_exit
  277. EX_TABLE(.Lrewind_pad6,.Lsie_fault)
  278. EX_TABLE(.Lrewind_pad4,.Lsie_fault)
  279. EX_TABLE(.Lrewind_pad2,.Lsie_fault)
  280. EX_TABLE(sie_exit,.Lsie_fault)
  281. EXPORT_SYMBOL(sie64a)
  282. EXPORT_SYMBOL(sie_exit)
  283. #endif
  284. /*
  285. * SVC interrupt handler routine. System calls are synchronous events and
  286. * are executed with interrupts enabled.
  287. */
  288. ENTRY(system_call)
  289. stpt __LC_SYNC_ENTER_TIMER
  290. .Lsysc_stmg:
  291. stmg %r8,%r15,__LC_SAVE_AREA_SYNC
  292. BPOFF
  293. lg %r12,__LC_CURRENT
  294. lghi %r13,__TASK_thread
  295. lghi %r14,_PIF_SYSCALL
  296. .Lsysc_per:
  297. lg %r15,__LC_KERNEL_STACK
  298. la %r11,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs
  299. .Lsysc_vtime:
  300. UPDATE_VTIME %r8,%r9,__LC_SYNC_ENTER_TIMER
  301. BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
  302. stmg %r0,%r7,__PT_R0(%r11)
  303. mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
  304. mvc __PT_PSW(16,%r11),__LC_SVC_OLD_PSW
  305. mvc __PT_INT_CODE(4,%r11),__LC_SVC_ILC
  306. stg %r14,__PT_FLAGS(%r11)
  307. .Lsysc_do_svc:
  308. # clear user controlled register to prevent speculative use
  309. xgr %r0,%r0
  310. # load address of system call table
  311. lg %r10,__THREAD_sysc_table(%r13,%r12)
  312. llgh %r8,__PT_INT_CODE+2(%r11)
  313. slag %r8,%r8,2 # shift and test for svc 0
  314. jnz .Lsysc_nr_ok
  315. # svc 0: system call number in %r1
  316. llgfr %r1,%r1 # clear high word in r1
  317. cghi %r1,NR_syscalls
  318. jnl .Lsysc_nr_ok
  319. sth %r1,__PT_INT_CODE+2(%r11)
  320. slag %r8,%r1,2
  321. .Lsysc_nr_ok:
  322. xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
  323. stg %r2,__PT_ORIG_GPR2(%r11)
  324. stg %r7,STACK_FRAME_OVERHEAD(%r15)
  325. lgf %r9,0(%r8,%r10) # get system call add.
  326. TSTMSK __TI_flags(%r12),_TIF_TRACE
  327. jnz .Lsysc_tracesys
  328. BASR_EX %r14,%r9 # call sys_xxxx
  329. stg %r2,__PT_R2(%r11) # store return value
  330. .Lsysc_return:
  331. #ifdef CONFIG_DEBUG_RSEQ
  332. lgr %r2,%r11
  333. brasl %r14,rseq_syscall
  334. #endif
  335. LOCKDEP_SYS_EXIT
  336. .Lsysc_tif:
  337. TSTMSK __PT_FLAGS(%r11),_PIF_WORK
  338. jnz .Lsysc_work
  339. TSTMSK __TI_flags(%r12),_TIF_WORK
  340. jnz .Lsysc_work # check for work
  341. TSTMSK __LC_CPU_FLAGS,_CIF_WORK
  342. jnz .Lsysc_work
  343. BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
  344. .Lsysc_restore:
  345. lg %r14,__LC_VDSO_PER_CPU
  346. lmg %r0,%r10,__PT_R0(%r11)
  347. mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
  348. .Lsysc_exit_timer:
  349. stpt __LC_EXIT_TIMER
  350. mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
  351. lmg %r11,%r15,__PT_R11(%r11)
  352. lpswe __LC_RETURN_PSW
  353. .Lsysc_done:
  354. #
  355. # One of the work bits is on. Find out which one.
  356. #
  357. .Lsysc_work:
  358. TSTMSK __LC_CPU_FLAGS,_CIF_MCCK_PENDING
  359. jo .Lsysc_mcck_pending
  360. TSTMSK __TI_flags(%r12),_TIF_NEED_RESCHED
  361. jo .Lsysc_reschedule
  362. TSTMSK __PT_FLAGS(%r11),_PIF_SYSCALL_RESTART
  363. jo .Lsysc_syscall_restart
  364. #ifdef CONFIG_UPROBES
  365. TSTMSK __TI_flags(%r12),_TIF_UPROBE
  366. jo .Lsysc_uprobe_notify
  367. #endif
  368. TSTMSK __TI_flags(%r12),_TIF_GUARDED_STORAGE
  369. jo .Lsysc_guarded_storage
  370. TSTMSK __PT_FLAGS(%r11),_PIF_PER_TRAP
  371. jo .Lsysc_singlestep
  372. #ifdef CONFIG_LIVEPATCH
  373. TSTMSK __TI_flags(%r12),_TIF_PATCH_PENDING
  374. jo .Lsysc_patch_pending # handle live patching just before
  375. # signals and possible syscall restart
  376. #endif
  377. TSTMSK __PT_FLAGS(%r11),_PIF_SYSCALL_RESTART
  378. jo .Lsysc_syscall_restart
  379. TSTMSK __TI_flags(%r12),_TIF_SIGPENDING
  380. jo .Lsysc_sigpending
  381. TSTMSK __TI_flags(%r12),_TIF_NOTIFY_RESUME
  382. jo .Lsysc_notify_resume
  383. TSTMSK __LC_CPU_FLAGS,_CIF_FPU
  384. jo .Lsysc_vxrs
  385. TSTMSK __LC_CPU_FLAGS,(_CIF_ASCE_PRIMARY|_CIF_ASCE_SECONDARY)
  386. jnz .Lsysc_asce
  387. j .Lsysc_return # beware of critical section cleanup
  388. #
  389. # _TIF_NEED_RESCHED is set, call schedule
  390. #
  391. .Lsysc_reschedule:
  392. larl %r14,.Lsysc_return
  393. jg schedule
  394. #
  395. # _CIF_MCCK_PENDING is set, call handler
  396. #
  397. .Lsysc_mcck_pending:
  398. larl %r14,.Lsysc_return
  399. jg s390_handle_mcck # TIF bit will be cleared by handler
  400. #
  401. # _CIF_ASCE_PRIMARY and/or _CIF_ASCE_SECONDARY set, load user space asce
  402. #
  403. .Lsysc_asce:
  404. ni __LC_CPU_FLAGS+7,255-_CIF_ASCE_SECONDARY
  405. lctlg %c7,%c7,__LC_VDSO_ASCE # load secondary asce
  406. TSTMSK __LC_CPU_FLAGS,_CIF_ASCE_PRIMARY
  407. jz .Lsysc_return
  408. #ifndef CONFIG_HAVE_MARCH_Z10_FEATURES
  409. tm __LC_STFLE_FAC_LIST+3,0x10 # has MVCOS ?
  410. jnz .Lsysc_set_fs_fixup
  411. ni __LC_CPU_FLAGS+7,255-_CIF_ASCE_PRIMARY
  412. lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
  413. j .Lsysc_return
  414. .Lsysc_set_fs_fixup:
  415. #endif
  416. larl %r14,.Lsysc_return
  417. jg set_fs_fixup
  418. #
  419. # CIF_FPU is set, restore floating-point controls and floating-point registers.
  420. #
  421. .Lsysc_vxrs:
  422. larl %r14,.Lsysc_return
  423. jg load_fpu_regs
  424. #
  425. # _TIF_SIGPENDING is set, call do_signal
  426. #
  427. .Lsysc_sigpending:
  428. lgr %r2,%r11 # pass pointer to pt_regs
  429. brasl %r14,do_signal
  430. TSTMSK __PT_FLAGS(%r11),_PIF_SYSCALL
  431. jno .Lsysc_return
  432. .Lsysc_do_syscall:
  433. lghi %r13,__TASK_thread
  434. lmg %r2,%r7,__PT_R2(%r11) # load svc arguments
  435. lghi %r1,0 # svc 0 returns -ENOSYS
  436. j .Lsysc_do_svc
  437. #
  438. # _TIF_NOTIFY_RESUME is set, call do_notify_resume
  439. #
  440. .Lsysc_notify_resume:
  441. lgr %r2,%r11 # pass pointer to pt_regs
  442. larl %r14,.Lsysc_return
  443. jg do_notify_resume
  444. #
  445. # _TIF_UPROBE is set, call uprobe_notify_resume
  446. #
  447. #ifdef CONFIG_UPROBES
  448. .Lsysc_uprobe_notify:
  449. lgr %r2,%r11 # pass pointer to pt_regs
  450. larl %r14,.Lsysc_return
  451. jg uprobe_notify_resume
  452. #endif
  453. #
  454. # _TIF_GUARDED_STORAGE is set, call guarded_storage_load
  455. #
  456. .Lsysc_guarded_storage:
  457. lgr %r2,%r11 # pass pointer to pt_regs
  458. larl %r14,.Lsysc_return
  459. jg gs_load_bc_cb
  460. #
  461. # _TIF_PATCH_PENDING is set, call klp_update_patch_state
  462. #
  463. #ifdef CONFIG_LIVEPATCH
  464. .Lsysc_patch_pending:
  465. lg %r2,__LC_CURRENT # pass pointer to task struct
  466. larl %r14,.Lsysc_return
  467. jg klp_update_patch_state
  468. #endif
  469. #
  470. # _PIF_PER_TRAP is set, call do_per_trap
  471. #
  472. .Lsysc_singlestep:
  473. ni __PT_FLAGS+7(%r11),255-_PIF_PER_TRAP
  474. lgr %r2,%r11 # pass pointer to pt_regs
  475. larl %r14,.Lsysc_return
  476. jg do_per_trap
  477. #
  478. # _PIF_SYSCALL_RESTART is set, repeat the current system call
  479. #
  480. .Lsysc_syscall_restart:
  481. ni __PT_FLAGS+7(%r11),255-_PIF_SYSCALL_RESTART
  482. lmg %r1,%r7,__PT_R1(%r11) # load svc arguments
  483. lg %r2,__PT_ORIG_GPR2(%r11)
  484. j .Lsysc_do_svc
  485. #
  486. # call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
  487. # and after the system call
  488. #
  489. .Lsysc_tracesys:
  490. lgr %r2,%r11 # pass pointer to pt_regs
  491. la %r3,0
  492. llgh %r0,__PT_INT_CODE+2(%r11)
  493. stg %r0,__PT_R2(%r11)
  494. brasl %r14,do_syscall_trace_enter
  495. lghi %r0,NR_syscalls
  496. clgr %r0,%r2
  497. jnh .Lsysc_tracenogo
  498. sllg %r8,%r2,2
  499. lgf %r9,0(%r8,%r10)
  500. .Lsysc_tracego:
  501. lmg %r3,%r7,__PT_R3(%r11)
  502. stg %r7,STACK_FRAME_OVERHEAD(%r15)
  503. lg %r2,__PT_ORIG_GPR2(%r11)
  504. BASR_EX %r14,%r9 # call sys_xxx
  505. stg %r2,__PT_R2(%r11) # store return value
  506. .Lsysc_tracenogo:
  507. TSTMSK __TI_flags(%r12),_TIF_TRACE
  508. jz .Lsysc_return
  509. lgr %r2,%r11 # pass pointer to pt_regs
  510. larl %r14,.Lsysc_return
  511. jg do_syscall_trace_exit
  512. #
  513. # a new process exits the kernel with ret_from_fork
  514. #
  515. ENTRY(ret_from_fork)
  516. la %r11,STACK_FRAME_OVERHEAD(%r15)
  517. lg %r12,__LC_CURRENT
  518. brasl %r14,schedule_tail
  519. TRACE_IRQS_ON
  520. ssm __LC_SVC_NEW_PSW # reenable interrupts
  521. tm __PT_PSW+1(%r11),0x01 # forking a kernel thread ?
  522. jne .Lsysc_tracenogo
  523. # it's a kernel thread
  524. lmg %r9,%r10,__PT_R9(%r11) # load gprs
  525. ENTRY(kernel_thread_starter)
  526. la %r2,0(%r10)
  527. BASR_EX %r14,%r9
  528. j .Lsysc_tracenogo
  529. /*
  530. * Program check handler routine
  531. */
  532. ENTRY(pgm_check_handler)
  533. stpt __LC_SYNC_ENTER_TIMER
  534. BPOFF
  535. stmg %r8,%r15,__LC_SAVE_AREA_SYNC
  536. lg %r10,__LC_LAST_BREAK
  537. lg %r12,__LC_CURRENT
  538. lghi %r11,0
  539. larl %r13,cleanup_critical
  540. lmg %r8,%r9,__LC_PGM_OLD_PSW
  541. tmhh %r8,0x0001 # test problem state bit
  542. jnz 2f # -> fault in user space
  543. #if IS_ENABLED(CONFIG_KVM)
  544. # cleanup critical section for program checks in sie64a
  545. lgr %r14,%r9
  546. slg %r14,BASED(.Lsie_critical_start)
  547. clg %r14,BASED(.Lsie_critical_length)
  548. jhe 0f
  549. lg %r14,__SF_SIE_CONTROL(%r15) # get control block pointer
  550. ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE
  551. lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
  552. larl %r9,sie_exit # skip forward to sie_exit
  553. lghi %r11,_PIF_GUEST_FAULT
  554. #endif
  555. 0: tmhh %r8,0x4000 # PER bit set in old PSW ?
  556. jnz 1f # -> enabled, can't be a double fault
  557. tm __LC_PGM_ILC+3,0x80 # check for per exception
  558. jnz .Lpgm_svcper # -> single stepped svc
  559. 1: CHECK_STACK STACK_SIZE,__LC_SAVE_AREA_SYNC
  560. aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
  561. j 4f
  562. 2: UPDATE_VTIME %r14,%r15,__LC_SYNC_ENTER_TIMER
  563. BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
  564. lg %r15,__LC_KERNEL_STACK
  565. lgr %r14,%r12
  566. aghi %r14,__TASK_thread # pointer to thread_struct
  567. lghi %r13,__LC_PGM_TDB
  568. tm __LC_PGM_ILC+2,0x02 # check for transaction abort
  569. jz 3f
  570. mvc __THREAD_trap_tdb(256,%r14),0(%r13)
  571. 3: stg %r10,__THREAD_last_break(%r14)
  572. 4: lgr %r13,%r11
  573. la %r11,STACK_FRAME_OVERHEAD(%r15)
  574. stmg %r0,%r7,__PT_R0(%r11)
  575. # clear user controlled registers to prevent speculative use
  576. xgr %r0,%r0
  577. xgr %r1,%r1
  578. xgr %r2,%r2
  579. xgr %r3,%r3
  580. xgr %r4,%r4
  581. xgr %r5,%r5
  582. xgr %r6,%r6
  583. xgr %r7,%r7
  584. mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
  585. stmg %r8,%r9,__PT_PSW(%r11)
  586. mvc __PT_INT_CODE(4,%r11),__LC_PGM_ILC
  587. mvc __PT_INT_PARM_LONG(8,%r11),__LC_TRANS_EXC_CODE
  588. stg %r13,__PT_FLAGS(%r11)
  589. stg %r10,__PT_ARGS(%r11)
  590. tm __LC_PGM_ILC+3,0x80 # check for per exception
  591. jz 5f
  592. tmhh %r8,0x0001 # kernel per event ?
  593. jz .Lpgm_kprobe
  594. oi __PT_FLAGS+7(%r11),_PIF_PER_TRAP
  595. mvc __THREAD_per_address(8,%r14),__LC_PER_ADDRESS
  596. mvc __THREAD_per_cause(2,%r14),__LC_PER_CODE
  597. mvc __THREAD_per_paid(1,%r14),__LC_PER_ACCESS_ID
  598. 5: REENABLE_IRQS
  599. xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
  600. larl %r1,pgm_check_table
  601. llgh %r10,__PT_INT_CODE+2(%r11)
  602. nill %r10,0x007f
  603. sll %r10,2
  604. je .Lpgm_return
  605. lgf %r9,0(%r10,%r1) # load address of handler routine
  606. lgr %r2,%r11 # pass pointer to pt_regs
  607. BASR_EX %r14,%r9 # branch to interrupt-handler
  608. .Lpgm_return:
  609. LOCKDEP_SYS_EXIT
  610. tm __PT_PSW+1(%r11),0x01 # returning to user ?
  611. jno .Lsysc_restore
  612. TSTMSK __PT_FLAGS(%r11),_PIF_SYSCALL
  613. jo .Lsysc_do_syscall
  614. j .Lsysc_tif
  615. #
  616. # PER event in supervisor state, must be kprobes
  617. #
  618. .Lpgm_kprobe:
  619. REENABLE_IRQS
  620. xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
  621. lgr %r2,%r11 # pass pointer to pt_regs
  622. brasl %r14,do_per_trap
  623. j .Lpgm_return
  624. #
  625. # single stepped system call
  626. #
  627. .Lpgm_svcper:
  628. mvc __LC_RETURN_PSW(8),__LC_SVC_NEW_PSW
  629. lghi %r13,__TASK_thread
  630. larl %r14,.Lsysc_per
  631. stg %r14,__LC_RETURN_PSW+8
  632. lghi %r14,_PIF_SYSCALL | _PIF_PER_TRAP
  633. lpswe __LC_RETURN_PSW # branch to .Lsysc_per and enable irqs
  634. /*
  635. * IO interrupt handler routine
  636. */
  637. ENTRY(io_int_handler)
  638. STCK __LC_INT_CLOCK
  639. stpt __LC_ASYNC_ENTER_TIMER
  640. BPOFF
  641. stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
  642. lg %r12,__LC_CURRENT
  643. larl %r13,cleanup_critical
  644. lmg %r8,%r9,__LC_IO_OLD_PSW
  645. SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER
  646. stmg %r0,%r7,__PT_R0(%r11)
  647. # clear user controlled registers to prevent speculative use
  648. xgr %r0,%r0
  649. xgr %r1,%r1
  650. xgr %r2,%r2
  651. xgr %r3,%r3
  652. xgr %r4,%r4
  653. xgr %r5,%r5
  654. xgr %r6,%r6
  655. xgr %r7,%r7
  656. xgr %r10,%r10
  657. mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
  658. stmg %r8,%r9,__PT_PSW(%r11)
  659. mvc __PT_INT_CODE(12,%r11),__LC_SUBCHANNEL_ID
  660. xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
  661. TSTMSK __LC_CPU_FLAGS,_CIF_IGNORE_IRQ
  662. jo .Lio_restore
  663. TRACE_IRQS_OFF
  664. xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
  665. .Lio_loop:
  666. lgr %r2,%r11 # pass pointer to pt_regs
  667. lghi %r3,IO_INTERRUPT
  668. tm __PT_INT_CODE+8(%r11),0x80 # adapter interrupt ?
  669. jz .Lio_call
  670. lghi %r3,THIN_INTERRUPT
  671. .Lio_call:
  672. brasl %r14,do_IRQ
  673. TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_LPAR
  674. jz .Lio_return
  675. tpi 0
  676. jz .Lio_return
  677. mvc __PT_INT_CODE(12,%r11),__LC_SUBCHANNEL_ID
  678. j .Lio_loop
  679. .Lio_return:
  680. LOCKDEP_SYS_EXIT
  681. TRACE_IRQS_ON
  682. .Lio_tif:
  683. TSTMSK __TI_flags(%r12),_TIF_WORK
  684. jnz .Lio_work # there is work to do (signals etc.)
  685. TSTMSK __LC_CPU_FLAGS,_CIF_WORK
  686. jnz .Lio_work
  687. .Lio_restore:
  688. lg %r14,__LC_VDSO_PER_CPU
  689. lmg %r0,%r10,__PT_R0(%r11)
  690. mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
  691. tm __PT_PSW+1(%r11),0x01 # returning to user ?
  692. jno .Lio_exit_kernel
  693. BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
  694. .Lio_exit_timer:
  695. stpt __LC_EXIT_TIMER
  696. mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
  697. .Lio_exit_kernel:
  698. lmg %r11,%r15,__PT_R11(%r11)
  699. lpswe __LC_RETURN_PSW
  700. .Lio_done:
  701. #
  702. # There is work todo, find out in which context we have been interrupted:
  703. # 1) if we return to user space we can do all _TIF_WORK work
  704. # 2) if we return to kernel code and kvm is enabled check if we need to
  705. # modify the psw to leave SIE
  706. # 3) if we return to kernel code and preemptive scheduling is enabled check
  707. # the preemption counter and if it is zero call preempt_schedule_irq
  708. # Before any work can be done, a switch to the kernel stack is required.
  709. #
  710. .Lio_work:
  711. tm __PT_PSW+1(%r11),0x01 # returning to user ?
  712. jo .Lio_work_user # yes -> do resched & signal
  713. #ifdef CONFIG_PREEMPT
  714. # check for preemptive scheduling
  715. icm %r0,15,__LC_PREEMPT_COUNT
  716. jnz .Lio_restore # preemption is disabled
  717. TSTMSK __TI_flags(%r12),_TIF_NEED_RESCHED
  718. jno .Lio_restore
  719. # switch to kernel stack
  720. lg %r1,__PT_R15(%r11)
  721. aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
  722. mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
  723. xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
  724. la %r11,STACK_FRAME_OVERHEAD(%r1)
  725. lgr %r15,%r1
  726. # TRACE_IRQS_ON already done at .Lio_return, call
  727. # TRACE_IRQS_OFF to keep things symmetrical
  728. TRACE_IRQS_OFF
  729. brasl %r14,preempt_schedule_irq
  730. j .Lio_return
  731. #else
  732. j .Lio_restore
  733. #endif
  734. #
  735. # Need to do work before returning to userspace, switch to kernel stack
  736. #
  737. .Lio_work_user:
  738. lg %r1,__LC_KERNEL_STACK
  739. mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
  740. xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
  741. la %r11,STACK_FRAME_OVERHEAD(%r1)
  742. lgr %r15,%r1
  743. #
  744. # One of the work bits is on. Find out which one.
  745. #
  746. .Lio_work_tif:
  747. TSTMSK __LC_CPU_FLAGS,_CIF_MCCK_PENDING
  748. jo .Lio_mcck_pending
  749. TSTMSK __TI_flags(%r12),_TIF_NEED_RESCHED
  750. jo .Lio_reschedule
  751. #ifdef CONFIG_LIVEPATCH
  752. TSTMSK __TI_flags(%r12),_TIF_PATCH_PENDING
  753. jo .Lio_patch_pending
  754. #endif
  755. TSTMSK __TI_flags(%r12),_TIF_SIGPENDING
  756. jo .Lio_sigpending
  757. TSTMSK __TI_flags(%r12),_TIF_NOTIFY_RESUME
  758. jo .Lio_notify_resume
  759. TSTMSK __TI_flags(%r12),_TIF_GUARDED_STORAGE
  760. jo .Lio_guarded_storage
  761. TSTMSK __LC_CPU_FLAGS,_CIF_FPU
  762. jo .Lio_vxrs
  763. TSTMSK __LC_CPU_FLAGS,(_CIF_ASCE_PRIMARY|_CIF_ASCE_SECONDARY)
  764. jnz .Lio_asce
  765. j .Lio_return # beware of critical section cleanup
  766. #
  767. # _CIF_MCCK_PENDING is set, call handler
  768. #
  769. .Lio_mcck_pending:
  770. # TRACE_IRQS_ON already done at .Lio_return
  771. brasl %r14,s390_handle_mcck # TIF bit will be cleared by handler
  772. TRACE_IRQS_OFF
  773. j .Lio_return
  774. #
  775. # _CIF_ASCE_PRIMARY and/or CIF_ASCE_SECONDARY set, load user space asce
  776. #
  777. .Lio_asce:
  778. ni __LC_CPU_FLAGS+7,255-_CIF_ASCE_SECONDARY
  779. lctlg %c7,%c7,__LC_VDSO_ASCE # load secondary asce
  780. TSTMSK __LC_CPU_FLAGS,_CIF_ASCE_PRIMARY
  781. jz .Lio_return
  782. #ifndef CONFIG_HAVE_MARCH_Z10_FEATURES
  783. tm __LC_STFLE_FAC_LIST+3,0x10 # has MVCOS ?
  784. jnz .Lio_set_fs_fixup
  785. ni __LC_CPU_FLAGS+7,255-_CIF_ASCE_PRIMARY
  786. lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
  787. j .Lio_return
  788. .Lio_set_fs_fixup:
  789. #endif
  790. larl %r14,.Lio_return
  791. jg set_fs_fixup
  792. #
  793. # CIF_FPU is set, restore floating-point controls and floating-point registers.
  794. #
  795. .Lio_vxrs:
  796. larl %r14,.Lio_return
  797. jg load_fpu_regs
  798. #
  799. # _TIF_GUARDED_STORAGE is set, call guarded_storage_load
  800. #
  801. .Lio_guarded_storage:
  802. # TRACE_IRQS_ON already done at .Lio_return
  803. ssm __LC_SVC_NEW_PSW # reenable interrupts
  804. lgr %r2,%r11 # pass pointer to pt_regs
  805. brasl %r14,gs_load_bc_cb
  806. ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
  807. TRACE_IRQS_OFF
  808. j .Lio_return
  809. #
  810. # _TIF_NEED_RESCHED is set, call schedule
  811. #
  812. .Lio_reschedule:
  813. # TRACE_IRQS_ON already done at .Lio_return
  814. ssm __LC_SVC_NEW_PSW # reenable interrupts
  815. brasl %r14,schedule # call scheduler
  816. ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
  817. TRACE_IRQS_OFF
  818. j .Lio_return
  819. #
  820. # _TIF_PATCH_PENDING is set, call klp_update_patch_state
  821. #
  822. #ifdef CONFIG_LIVEPATCH
  823. .Lio_patch_pending:
  824. lg %r2,__LC_CURRENT # pass pointer to task struct
  825. larl %r14,.Lio_return
  826. jg klp_update_patch_state
  827. #endif
  828. #
  829. # _TIF_SIGPENDING or is set, call do_signal
  830. #
  831. .Lio_sigpending:
  832. # TRACE_IRQS_ON already done at .Lio_return
  833. ssm __LC_SVC_NEW_PSW # reenable interrupts
  834. lgr %r2,%r11 # pass pointer to pt_regs
  835. brasl %r14,do_signal
  836. ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
  837. TRACE_IRQS_OFF
  838. j .Lio_return
  839. #
  840. # _TIF_NOTIFY_RESUME or is set, call do_notify_resume
  841. #
  842. .Lio_notify_resume:
  843. # TRACE_IRQS_ON already done at .Lio_return
  844. ssm __LC_SVC_NEW_PSW # reenable interrupts
  845. lgr %r2,%r11 # pass pointer to pt_regs
  846. brasl %r14,do_notify_resume
  847. ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
  848. TRACE_IRQS_OFF
  849. j .Lio_return
  850. /*
  851. * External interrupt handler routine
  852. */
  853. ENTRY(ext_int_handler)
  854. STCK __LC_INT_CLOCK
  855. stpt __LC_ASYNC_ENTER_TIMER
  856. BPOFF
  857. stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
  858. lg %r12,__LC_CURRENT
  859. larl %r13,cleanup_critical
  860. lmg %r8,%r9,__LC_EXT_OLD_PSW
  861. SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER
  862. stmg %r0,%r7,__PT_R0(%r11)
  863. # clear user controlled registers to prevent speculative use
  864. xgr %r0,%r0
  865. xgr %r1,%r1
  866. xgr %r2,%r2
  867. xgr %r3,%r3
  868. xgr %r4,%r4
  869. xgr %r5,%r5
  870. xgr %r6,%r6
  871. xgr %r7,%r7
  872. xgr %r10,%r10
  873. mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
  874. stmg %r8,%r9,__PT_PSW(%r11)
  875. lghi %r1,__LC_EXT_PARAMS2
  876. mvc __PT_INT_CODE(4,%r11),__LC_EXT_CPU_ADDR
  877. mvc __PT_INT_PARM(4,%r11),__LC_EXT_PARAMS
  878. mvc __PT_INT_PARM_LONG(8,%r11),0(%r1)
  879. xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
  880. TSTMSK __LC_CPU_FLAGS,_CIF_IGNORE_IRQ
  881. jo .Lio_restore
  882. TRACE_IRQS_OFF
  883. xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
  884. lgr %r2,%r11 # pass pointer to pt_regs
  885. lghi %r3,EXT_INTERRUPT
  886. brasl %r14,do_IRQ
  887. j .Lio_return
  888. /*
  889. * Load idle PSW. The second "half" of this function is in .Lcleanup_idle.
  890. */
  891. ENTRY(psw_idle)
  892. stg %r3,__SF_EMPTY(%r15)
  893. larl %r1,.Lpsw_idle_lpsw+4
  894. stg %r1,__SF_EMPTY+8(%r15)
  895. #ifdef CONFIG_SMP
  896. larl %r1,smp_cpu_mtid
  897. llgf %r1,0(%r1)
  898. ltgr %r1,%r1
  899. jz .Lpsw_idle_stcctm
  900. .insn rsy,0xeb0000000017,%r1,5,__SF_EMPTY+16(%r15)
  901. .Lpsw_idle_stcctm:
  902. #endif
  903. oi __LC_CPU_FLAGS+7,_CIF_ENABLED_WAIT
  904. BPON
  905. STCK __CLOCK_IDLE_ENTER(%r2)
  906. stpt __TIMER_IDLE_ENTER(%r2)
  907. .Lpsw_idle_lpsw:
  908. lpswe __SF_EMPTY(%r15)
  909. BR_EX %r14
  910. .Lpsw_idle_end:
  911. /*
  912. * Store floating-point controls and floating-point or vector register
  913. * depending whether the vector facility is available. A critical section
  914. * cleanup assures that the registers are stored even if interrupted for
  915. * some other work. The CIF_FPU flag is set to trigger a lazy restore
  916. * of the register contents at return from io or a system call.
  917. */
  918. ENTRY(save_fpu_regs)
  919. lg %r2,__LC_CURRENT
  920. aghi %r2,__TASK_thread
  921. TSTMSK __LC_CPU_FLAGS,_CIF_FPU
  922. jo .Lsave_fpu_regs_exit
  923. stfpc __THREAD_FPU_fpc(%r2)
  924. lg %r3,__THREAD_FPU_regs(%r2)
  925. TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
  926. jz .Lsave_fpu_regs_fp # no -> store FP regs
  927. VSTM %v0,%v15,0,%r3 # vstm 0,15,0(3)
  928. VSTM %v16,%v31,256,%r3 # vstm 16,31,256(3)
  929. j .Lsave_fpu_regs_done # -> set CIF_FPU flag
  930. .Lsave_fpu_regs_fp:
  931. std 0,0(%r3)
  932. std 1,8(%r3)
  933. std 2,16(%r3)
  934. std 3,24(%r3)
  935. std 4,32(%r3)
  936. std 5,40(%r3)
  937. std 6,48(%r3)
  938. std 7,56(%r3)
  939. std 8,64(%r3)
  940. std 9,72(%r3)
  941. std 10,80(%r3)
  942. std 11,88(%r3)
  943. std 12,96(%r3)
  944. std 13,104(%r3)
  945. std 14,112(%r3)
  946. std 15,120(%r3)
  947. .Lsave_fpu_regs_done:
  948. oi __LC_CPU_FLAGS+7,_CIF_FPU
  949. .Lsave_fpu_regs_exit:
  950. BR_EX %r14
  951. .Lsave_fpu_regs_end:
  952. EXPORT_SYMBOL(save_fpu_regs)
  953. /*
  954. * Load floating-point controls and floating-point or vector registers.
  955. * A critical section cleanup assures that the register contents are
  956. * loaded even if interrupted for some other work.
  957. *
  958. * There are special calling conventions to fit into sysc and io return work:
  959. * %r15: <kernel stack>
  960. * The function requires:
  961. * %r4
  962. */
  963. load_fpu_regs:
  964. lg %r4,__LC_CURRENT
  965. aghi %r4,__TASK_thread
  966. TSTMSK __LC_CPU_FLAGS,_CIF_FPU
  967. jno .Lload_fpu_regs_exit
  968. lfpc __THREAD_FPU_fpc(%r4)
  969. TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
  970. lg %r4,__THREAD_FPU_regs(%r4) # %r4 <- reg save area
  971. jz .Lload_fpu_regs_fp # -> no VX, load FP regs
  972. VLM %v0,%v15,0,%r4
  973. VLM %v16,%v31,256,%r4
  974. j .Lload_fpu_regs_done
  975. .Lload_fpu_regs_fp:
  976. ld 0,0(%r4)
  977. ld 1,8(%r4)
  978. ld 2,16(%r4)
  979. ld 3,24(%r4)
  980. ld 4,32(%r4)
  981. ld 5,40(%r4)
  982. ld 6,48(%r4)
  983. ld 7,56(%r4)
  984. ld 8,64(%r4)
  985. ld 9,72(%r4)
  986. ld 10,80(%r4)
  987. ld 11,88(%r4)
  988. ld 12,96(%r4)
  989. ld 13,104(%r4)
  990. ld 14,112(%r4)
  991. ld 15,120(%r4)
  992. .Lload_fpu_regs_done:
  993. ni __LC_CPU_FLAGS+7,255-_CIF_FPU
  994. .Lload_fpu_regs_exit:
  995. BR_EX %r14
  996. .Lload_fpu_regs_end:
  997. .L__critical_end:
  998. /*
  999. * Machine check handler routines
  1000. */
  1001. ENTRY(mcck_int_handler)
  1002. STCK __LC_MCCK_CLOCK
  1003. BPOFF
  1004. la %r1,4095 # validate r1
  1005. spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # validate cpu timer
  1006. sckc __LC_CLOCK_COMPARATOR # validate comparator
  1007. lam %a0,%a15,__LC_AREGS_SAVE_AREA-4095(%r1) # validate acrs
  1008. lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# validate gprs
  1009. lg %r12,__LC_CURRENT
  1010. larl %r13,cleanup_critical
  1011. lmg %r8,%r9,__LC_MCK_OLD_PSW
  1012. TSTMSK __LC_MCCK_CODE,MCCK_CODE_SYSTEM_DAMAGE
  1013. jo .Lmcck_panic # yes -> rest of mcck code invalid
  1014. TSTMSK __LC_MCCK_CODE,MCCK_CODE_CR_VALID
  1015. jno .Lmcck_panic # control registers invalid -> panic
  1016. la %r14,4095
  1017. lctlg %c0,%c15,__LC_CREGS_SAVE_AREA-4095(%r14) # validate ctl regs
  1018. ptlb
  1019. lg %r11,__LC_MCESAD-4095(%r14) # extended machine check save area
  1020. nill %r11,0xfc00 # MCESA_ORIGIN_MASK
  1021. TSTMSK __LC_CREGS_SAVE_AREA+16-4095(%r14),CR2_GUARDED_STORAGE
  1022. jno 0f
  1023. TSTMSK __LC_MCCK_CODE,MCCK_CODE_GS_VALID
  1024. jno 0f
  1025. .insn rxy,0xe3000000004d,0,__MCESA_GS_SAVE_AREA(%r11) # LGSC
  1026. 0: l %r14,__LC_FP_CREG_SAVE_AREA-4095(%r14)
  1027. TSTMSK __LC_MCCK_CODE,MCCK_CODE_FC_VALID
  1028. jo 0f
  1029. sr %r14,%r14
  1030. 0: sfpc %r14
  1031. TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
  1032. jo 0f
  1033. lghi %r14,__LC_FPREGS_SAVE_AREA
  1034. ld %f0,0(%r14)
  1035. ld %f1,8(%r14)
  1036. ld %f2,16(%r14)
  1037. ld %f3,24(%r14)
  1038. ld %f4,32(%r14)
  1039. ld %f5,40(%r14)
  1040. ld %f6,48(%r14)
  1041. ld %f7,56(%r14)
  1042. ld %f8,64(%r14)
  1043. ld %f9,72(%r14)
  1044. ld %f10,80(%r14)
  1045. ld %f11,88(%r14)
  1046. ld %f12,96(%r14)
  1047. ld %f13,104(%r14)
  1048. ld %f14,112(%r14)
  1049. ld %f15,120(%r14)
  1050. j 1f
  1051. 0: VLM %v0,%v15,0,%r11
  1052. VLM %v16,%v31,256,%r11
  1053. 1: lghi %r14,__LC_CPU_TIMER_SAVE_AREA
  1054. mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
  1055. TSTMSK __LC_MCCK_CODE,MCCK_CODE_CPU_TIMER_VALID
  1056. jo 3f
  1057. la %r14,__LC_SYNC_ENTER_TIMER
  1058. clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
  1059. jl 0f
  1060. la %r14,__LC_ASYNC_ENTER_TIMER
  1061. 0: clc 0(8,%r14),__LC_EXIT_TIMER
  1062. jl 1f
  1063. la %r14,__LC_EXIT_TIMER
  1064. 1: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
  1065. jl 2f
  1066. la %r14,__LC_LAST_UPDATE_TIMER
  1067. 2: spt 0(%r14)
  1068. mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
  1069. 3: TSTMSK __LC_MCCK_CODE,MCCK_CODE_PSW_MWP_VALID
  1070. jno .Lmcck_panic
  1071. tmhh %r8,0x0001 # interrupting from user ?
  1072. jnz 4f
  1073. TSTMSK __LC_MCCK_CODE,MCCK_CODE_PSW_IA_VALID
  1074. jno .Lmcck_panic
  1075. 4: SWITCH_ASYNC __LC_GPREGS_SAVE_AREA+64,__LC_MCCK_ENTER_TIMER
  1076. .Lmcck_skip:
  1077. lghi %r14,__LC_GPREGS_SAVE_AREA+64
  1078. stmg %r0,%r7,__PT_R0(%r11)
  1079. # clear user controlled registers to prevent speculative use
  1080. xgr %r0,%r0
  1081. xgr %r1,%r1
  1082. xgr %r2,%r2
  1083. xgr %r3,%r3
  1084. xgr %r4,%r4
  1085. xgr %r5,%r5
  1086. xgr %r6,%r6
  1087. xgr %r7,%r7
  1088. xgr %r10,%r10
  1089. mvc __PT_R8(64,%r11),0(%r14)
  1090. stmg %r8,%r9,__PT_PSW(%r11)
  1091. xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
  1092. xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
  1093. lgr %r2,%r11 # pass pointer to pt_regs
  1094. brasl %r14,s390_do_machine_check
  1095. tm __PT_PSW+1(%r11),0x01 # returning to user ?
  1096. jno .Lmcck_return
  1097. lg %r1,__LC_KERNEL_STACK # switch to kernel stack
  1098. mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
  1099. xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
  1100. la %r11,STACK_FRAME_OVERHEAD(%r1)
  1101. lgr %r15,%r1
  1102. ssm __LC_PGM_NEW_PSW # turn dat on, keep irqs off
  1103. TSTMSK __LC_CPU_FLAGS,_CIF_MCCK_PENDING
  1104. jno .Lmcck_return
  1105. TRACE_IRQS_OFF
  1106. brasl %r14,s390_handle_mcck
  1107. TRACE_IRQS_ON
  1108. .Lmcck_return:
  1109. lg %r14,__LC_VDSO_PER_CPU
  1110. lmg %r0,%r10,__PT_R0(%r11)
  1111. mvc __LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW
  1112. tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
  1113. jno 0f
  1114. BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
  1115. stpt __LC_EXIT_TIMER
  1116. mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
  1117. 0: lmg %r11,%r15,__PT_R11(%r11)
  1118. lpswe __LC_RETURN_MCCK_PSW
  1119. .Lmcck_panic:
  1120. lg %r15,__LC_PANIC_STACK
  1121. la %r11,STACK_FRAME_OVERHEAD(%r15)
  1122. j .Lmcck_skip
  1123. #
  1124. # PSW restart interrupt handler
  1125. #
  1126. ENTRY(restart_int_handler)
  1127. ALTERNATIVE "", ".insn s,0xb2800000,_LPP_OFFSET", 40
  1128. stg %r15,__LC_SAVE_AREA_RESTART
  1129. lg %r15,__LC_RESTART_STACK
  1130. aghi %r15,-__PT_SIZE # create pt_regs on stack
  1131. xc 0(__PT_SIZE,%r15),0(%r15)
  1132. stmg %r0,%r14,__PT_R0(%r15)
  1133. mvc __PT_R15(8,%r15),__LC_SAVE_AREA_RESTART
  1134. mvc __PT_PSW(16,%r15),__LC_RST_OLD_PSW # store restart old psw
  1135. aghi %r15,-STACK_FRAME_OVERHEAD # create stack frame on stack
  1136. xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15)
  1137. lg %r1,__LC_RESTART_FN # load fn, parm & source cpu
  1138. lg %r2,__LC_RESTART_DATA
  1139. lg %r3,__LC_RESTART_SOURCE
  1140. ltgr %r3,%r3 # test source cpu address
  1141. jm 1f # negative -> skip source stop
  1142. 0: sigp %r4,%r3,SIGP_SENSE # sigp sense to source cpu
  1143. brc 10,0b # wait for status stored
  1144. 1: basr %r14,%r1 # call function
  1145. stap __SF_EMPTY(%r15) # store cpu address
  1146. llgh %r3,__SF_EMPTY(%r15)
  1147. 2: sigp %r4,%r3,SIGP_STOP # sigp stop to current cpu
  1148. brc 2,2b
  1149. 3: j 3b
  1150. .section .kprobes.text, "ax"
  1151. #ifdef CONFIG_CHECK_STACK
  1152. /*
  1153. * The synchronous or the asynchronous stack overflowed. We are dead.
  1154. * No need to properly save the registers, we are going to panic anyway.
  1155. * Setup a pt_regs so that show_trace can provide a good call trace.
  1156. */
  1157. stack_overflow:
  1158. lg %r15,__LC_PANIC_STACK # change to panic stack
  1159. la %r11,STACK_FRAME_OVERHEAD(%r15)
  1160. stmg %r0,%r7,__PT_R0(%r11)
  1161. stmg %r8,%r9,__PT_PSW(%r11)
  1162. mvc __PT_R8(64,%r11),0(%r14)
  1163. stg %r10,__PT_ORIG_GPR2(%r11) # store last break to orig_gpr2
  1164. xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
  1165. lgr %r2,%r11 # pass pointer to pt_regs
  1166. jg kernel_stack_overflow
  1167. #endif
  1168. cleanup_critical:
  1169. #if IS_ENABLED(CONFIG_KVM)
  1170. clg %r9,BASED(.Lcleanup_table_sie) # .Lsie_gmap
  1171. jl 0f
  1172. clg %r9,BASED(.Lcleanup_table_sie+8)# .Lsie_done
  1173. jl .Lcleanup_sie
  1174. #endif
  1175. clg %r9,BASED(.Lcleanup_table) # system_call
  1176. jl 0f
  1177. clg %r9,BASED(.Lcleanup_table+8) # .Lsysc_do_svc
  1178. jl .Lcleanup_system_call
  1179. clg %r9,BASED(.Lcleanup_table+16) # .Lsysc_tif
  1180. jl 0f
  1181. clg %r9,BASED(.Lcleanup_table+24) # .Lsysc_restore
  1182. jl .Lcleanup_sysc_tif
  1183. clg %r9,BASED(.Lcleanup_table+32) # .Lsysc_done
  1184. jl .Lcleanup_sysc_restore
  1185. clg %r9,BASED(.Lcleanup_table+40) # .Lio_tif
  1186. jl 0f
  1187. clg %r9,BASED(.Lcleanup_table+48) # .Lio_restore
  1188. jl .Lcleanup_io_tif
  1189. clg %r9,BASED(.Lcleanup_table+56) # .Lio_done
  1190. jl .Lcleanup_io_restore
  1191. clg %r9,BASED(.Lcleanup_table+64) # psw_idle
  1192. jl 0f
  1193. clg %r9,BASED(.Lcleanup_table+72) # .Lpsw_idle_end
  1194. jl .Lcleanup_idle
  1195. clg %r9,BASED(.Lcleanup_table+80) # save_fpu_regs
  1196. jl 0f
  1197. clg %r9,BASED(.Lcleanup_table+88) # .Lsave_fpu_regs_end
  1198. jl .Lcleanup_save_fpu_regs
  1199. clg %r9,BASED(.Lcleanup_table+96) # load_fpu_regs
  1200. jl 0f
  1201. clg %r9,BASED(.Lcleanup_table+104) # .Lload_fpu_regs_end
  1202. jl .Lcleanup_load_fpu_regs
  1203. 0: BR_EX %r14,%r11
  1204. .align 8
  1205. .Lcleanup_table:
  1206. .quad system_call
  1207. .quad .Lsysc_do_svc
  1208. .quad .Lsysc_tif
  1209. .quad .Lsysc_restore
  1210. .quad .Lsysc_done
  1211. .quad .Lio_tif
  1212. .quad .Lio_restore
  1213. .quad .Lio_done
  1214. .quad psw_idle
  1215. .quad .Lpsw_idle_end
  1216. .quad save_fpu_regs
  1217. .quad .Lsave_fpu_regs_end
  1218. .quad load_fpu_regs
  1219. .quad .Lload_fpu_regs_end
  1220. #if IS_ENABLED(CONFIG_KVM)
  1221. .Lcleanup_table_sie:
  1222. .quad .Lsie_gmap
  1223. .quad .Lsie_done
  1224. .Lcleanup_sie:
  1225. cghi %r11,__LC_SAVE_AREA_ASYNC #Is this in normal interrupt?
  1226. je 1f
  1227. slg %r9,BASED(.Lsie_crit_mcck_start)
  1228. clg %r9,BASED(.Lsie_crit_mcck_length)
  1229. jh 1f
  1230. oi __LC_CPU_FLAGS+7, _CIF_MCCK_GUEST
  1231. 1: BPENTER __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
  1232. lg %r9,__SF_SIE_CONTROL(%r15) # get control block pointer
  1233. ni __SIE_PROG0C+3(%r9),0xfe # no longer in SIE
  1234. lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
  1235. larl %r9,sie_exit # skip forward to sie_exit
  1236. BR_EX %r14,%r11
  1237. #endif
  1238. .Lcleanup_system_call:
  1239. # check if stpt has been executed
  1240. clg %r9,BASED(.Lcleanup_system_call_insn)
  1241. jh 0f
  1242. mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
  1243. cghi %r11,__LC_SAVE_AREA_ASYNC
  1244. je 0f
  1245. mvc __LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER
  1246. 0: # check if stmg has been executed
  1247. clg %r9,BASED(.Lcleanup_system_call_insn+8)
  1248. jh 0f
  1249. mvc __LC_SAVE_AREA_SYNC(64),0(%r11)
  1250. 0: # check if base register setup + TIF bit load has been done
  1251. clg %r9,BASED(.Lcleanup_system_call_insn+16)
  1252. jhe 0f
  1253. # set up saved register r12 task struct pointer
  1254. stg %r12,32(%r11)
  1255. # set up saved register r13 __TASK_thread offset
  1256. mvc 40(8,%r11),BASED(.Lcleanup_system_call_const)
  1257. 0: # check if the user time update has been done
  1258. clg %r9,BASED(.Lcleanup_system_call_insn+24)
  1259. jh 0f
  1260. lg %r15,__LC_EXIT_TIMER
  1261. slg %r15,__LC_SYNC_ENTER_TIMER
  1262. alg %r15,__LC_USER_TIMER
  1263. stg %r15,__LC_USER_TIMER
  1264. 0: # check if the system time update has been done
  1265. clg %r9,BASED(.Lcleanup_system_call_insn+32)
  1266. jh 0f
  1267. lg %r15,__LC_LAST_UPDATE_TIMER
  1268. slg %r15,__LC_EXIT_TIMER
  1269. alg %r15,__LC_SYSTEM_TIMER
  1270. stg %r15,__LC_SYSTEM_TIMER
  1271. 0: # update accounting time stamp
  1272. mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
  1273. BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
  1274. # set up saved register r11
  1275. lg %r15,__LC_KERNEL_STACK
  1276. la %r9,STACK_FRAME_OVERHEAD(%r15)
  1277. stg %r9,24(%r11) # r11 pt_regs pointer
  1278. # fill pt_regs
  1279. mvc __PT_R8(64,%r9),__LC_SAVE_AREA_SYNC
  1280. stmg %r0,%r7,__PT_R0(%r9)
  1281. mvc __PT_PSW(16,%r9),__LC_SVC_OLD_PSW
  1282. mvc __PT_INT_CODE(4,%r9),__LC_SVC_ILC
  1283. xc __PT_FLAGS(8,%r9),__PT_FLAGS(%r9)
  1284. mvi __PT_FLAGS+7(%r9),_PIF_SYSCALL
  1285. # setup saved register r15
  1286. stg %r15,56(%r11) # r15 stack pointer
  1287. # set new psw address and exit
  1288. larl %r9,.Lsysc_do_svc
  1289. BR_EX %r14,%r11
  1290. .Lcleanup_system_call_insn:
  1291. .quad system_call
  1292. .quad .Lsysc_stmg
  1293. .quad .Lsysc_per
  1294. .quad .Lsysc_vtime+36
  1295. .quad .Lsysc_vtime+42
  1296. .Lcleanup_system_call_const:
  1297. .quad __TASK_thread
  1298. .Lcleanup_sysc_tif:
  1299. larl %r9,.Lsysc_tif
  1300. BR_EX %r14,%r11
  1301. .Lcleanup_sysc_restore:
  1302. # check if stpt has been executed
  1303. clg %r9,BASED(.Lcleanup_sysc_restore_insn)
  1304. jh 0f
  1305. mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
  1306. cghi %r11,__LC_SAVE_AREA_ASYNC
  1307. je 0f
  1308. mvc __LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
  1309. 0: clg %r9,BASED(.Lcleanup_sysc_restore_insn+8)
  1310. je 1f
  1311. lg %r9,24(%r11) # get saved pointer to pt_regs
  1312. mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
  1313. mvc 0(64,%r11),__PT_R8(%r9)
  1314. lmg %r0,%r7,__PT_R0(%r9)
  1315. 1: lmg %r8,%r9,__LC_RETURN_PSW
  1316. BR_EX %r14,%r11
  1317. .Lcleanup_sysc_restore_insn:
  1318. .quad .Lsysc_exit_timer
  1319. .quad .Lsysc_done - 4
  1320. .Lcleanup_io_tif:
  1321. larl %r9,.Lio_tif
  1322. BR_EX %r14,%r11
  1323. .Lcleanup_io_restore:
  1324. # check if stpt has been executed
  1325. clg %r9,BASED(.Lcleanup_io_restore_insn)
  1326. jh 0f
  1327. mvc __LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
  1328. 0: clg %r9,BASED(.Lcleanup_io_restore_insn+8)
  1329. je 1f
  1330. lg %r9,24(%r11) # get saved r11 pointer to pt_regs
  1331. mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
  1332. mvc 0(64,%r11),__PT_R8(%r9)
  1333. lmg %r0,%r7,__PT_R0(%r9)
  1334. 1: lmg %r8,%r9,__LC_RETURN_PSW
  1335. BR_EX %r14,%r11
  1336. .Lcleanup_io_restore_insn:
  1337. .quad .Lio_exit_timer
  1338. .quad .Lio_done - 4
  1339. .Lcleanup_idle:
  1340. ni __LC_CPU_FLAGS+7,255-_CIF_ENABLED_WAIT
  1341. # copy interrupt clock & cpu timer
  1342. mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_INT_CLOCK
  1343. mvc __TIMER_IDLE_EXIT(8,%r2),__LC_ASYNC_ENTER_TIMER
  1344. cghi %r11,__LC_SAVE_AREA_ASYNC
  1345. je 0f
  1346. mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_MCCK_CLOCK
  1347. mvc __TIMER_IDLE_EXIT(8,%r2),__LC_MCCK_ENTER_TIMER
  1348. 0: # check if stck & stpt have been executed
  1349. clg %r9,BASED(.Lcleanup_idle_insn)
  1350. jhe 1f
  1351. mvc __CLOCK_IDLE_ENTER(8,%r2),__CLOCK_IDLE_EXIT(%r2)
  1352. mvc __TIMER_IDLE_ENTER(8,%r2),__TIMER_IDLE_EXIT(%r2)
  1353. 1: # calculate idle cycles
  1354. #ifdef CONFIG_SMP
  1355. clg %r9,BASED(.Lcleanup_idle_insn)
  1356. jl 3f
  1357. larl %r1,smp_cpu_mtid
  1358. llgf %r1,0(%r1)
  1359. ltgr %r1,%r1
  1360. jz 3f
  1361. .insn rsy,0xeb0000000017,%r1,5,__SF_EMPTY+80(%r15)
  1362. larl %r3,mt_cycles
  1363. ag %r3,__LC_PERCPU_OFFSET
  1364. la %r4,__SF_EMPTY+16(%r15)
  1365. 2: lg %r0,0(%r3)
  1366. slg %r0,0(%r4)
  1367. alg %r0,64(%r4)
  1368. stg %r0,0(%r3)
  1369. la %r3,8(%r3)
  1370. la %r4,8(%r4)
  1371. brct %r1,2b
  1372. #endif
  1373. 3: # account system time going idle
  1374. lg %r9,__LC_STEAL_TIMER
  1375. alg %r9,__CLOCK_IDLE_ENTER(%r2)
  1376. slg %r9,__LC_LAST_UPDATE_CLOCK
  1377. stg %r9,__LC_STEAL_TIMER
  1378. mvc __LC_LAST_UPDATE_CLOCK(8),__CLOCK_IDLE_EXIT(%r2)
  1379. lg %r9,__LC_SYSTEM_TIMER
  1380. alg %r9,__LC_LAST_UPDATE_TIMER
  1381. slg %r9,__TIMER_IDLE_ENTER(%r2)
  1382. stg %r9,__LC_SYSTEM_TIMER
  1383. mvc __LC_LAST_UPDATE_TIMER(8),__TIMER_IDLE_EXIT(%r2)
  1384. # prepare return psw
  1385. nihh %r8,0xfcfd # clear irq & wait state bits
  1386. lg %r9,48(%r11) # return from psw_idle
  1387. BR_EX %r14,%r11
  1388. .Lcleanup_idle_insn:
  1389. .quad .Lpsw_idle_lpsw
  1390. .Lcleanup_save_fpu_regs:
  1391. larl %r9,save_fpu_regs
  1392. BR_EX %r14,%r11
  1393. .Lcleanup_load_fpu_regs:
  1394. larl %r9,load_fpu_regs
  1395. BR_EX %r14,%r11
  1396. /*
  1397. * Integer constants
  1398. */
  1399. .align 8
  1400. .Lcritical_start:
  1401. .quad .L__critical_start
  1402. .Lcritical_length:
  1403. .quad .L__critical_end - .L__critical_start
  1404. #if IS_ENABLED(CONFIG_KVM)
  1405. .Lsie_critical_start:
  1406. .quad .Lsie_gmap
  1407. .Lsie_critical_length:
  1408. .quad .Lsie_done - .Lsie_gmap
  1409. .Lsie_crit_mcck_start:
  1410. .quad .Lsie_entry
  1411. .Lsie_crit_mcck_length:
  1412. .quad .Lsie_skip - .Lsie_entry
  1413. #endif
  1414. .section .rodata, "a"
  1415. #define SYSCALL(esame,emu) .long esame
  1416. .globl sys_call_table
  1417. sys_call_table:
  1418. #include "asm/syscall_table.h"
  1419. #undef SYSCALL
  1420. #ifdef CONFIG_COMPAT
  1421. #define SYSCALL(esame,emu) .long emu
  1422. .globl sys_call_table_emu
  1423. sys_call_table_emu:
  1424. #include "asm/syscall_table.h"
  1425. #undef SYSCALL
  1426. #endif