blob: 3f4d272577d343cc41904e10d57800efb1d2a5cc [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * S390 low-level entry points.
4 *
Heiko Carstensa53c8fa2012-07-20 11:15:04 +02005 * Copyright IBM Corp. 1999, 2012
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
Heiko Carstens25d83cb2006-09-28 16:56:37 +02007 * Hartmut Penner (hp@de.ibm.com),
8 * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
Heiko Carstens77fa2242005-06-25 14:55:30 -07009 * Heiko Carstens <heiko.carstens@de.ibm.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 */
11
Heiko Carstens2bc89b52008-02-05 16:50:40 +010012#include <linux/init.h>
Jan Glauber144d6342011-07-24 10:48:19 +020013#include <linux/linkage.h>
Martin Schwidefskyb0586612018-03-26 15:27:36 +020014#include <asm/alternative-asm.h>
Heiko Carstenseb608fb2012-09-05 13:26:11 +020015#include <asm/processor.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <asm/cache.h>
Martin Schwidefsky3037a522017-10-12 13:24:48 +020017#include <asm/ctl_reg.h>
Hendrik Bruecknerdc24b7b2018-02-19 11:27:09 +010018#include <asm/dwarf.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <asm/errno.h>
20#include <asm/ptrace.h>
21#include <asm/thread_info.h>
Sam Ravnborg0013a852005-09-09 20:57:26 +020022#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <asm/unistd.h>
24#include <asm/page.h>
Heiko Carstenseb546192012-06-04 15:05:43 +020025#include <asm/sigp.h>
Martin Schwidefsky1f44a2252013-06-27 09:01:09 +020026#include <asm/irq.h>
Hendrik Brueckner9977e882015-06-10 12:53:42 +020027#include <asm/vx-insn.h>
Hendrik Brueckner83abeff2015-10-01 17:02:48 +020028#include <asm/setup.h>
29#include <asm/nmi.h>
Al Viro711f5df2016-01-12 13:30:03 -050030#include <asm/export.h>
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +020031#include <asm/nospec-insn.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
Martin Schwidefskyc5328902011-12-27 11:27:15 +010033__PT_R0 = __PT_GPRS
34__PT_R1 = __PT_GPRS + 8
35__PT_R2 = __PT_GPRS + 16
36__PT_R3 = __PT_GPRS + 24
37__PT_R4 = __PT_GPRS + 32
38__PT_R5 = __PT_GPRS + 40
39__PT_R6 = __PT_GPRS + 48
40__PT_R7 = __PT_GPRS + 56
41__PT_R8 = __PT_GPRS + 64
42__PT_R9 = __PT_GPRS + 72
43__PT_R10 = __PT_GPRS + 80
44__PT_R11 = __PT_GPRS + 88
45__PT_R12 = __PT_GPRS + 96
46__PT_R13 = __PT_GPRS + 104
47__PT_R14 = __PT_GPRS + 112
48__PT_R15 = __PT_GPRS + 120
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Heiko Carstens3a890382016-11-14 14:39:16 +010050STACK_SHIFT = PAGE_SHIFT + THREAD_SIZE_ORDER
Linus Torvalds1da177e2005-04-16 15:20:36 -070051STACK_SIZE = 1 << STACK_SHIFT
Martin Schwidefskydc7ee002013-04-24 10:20:43 +020052STACK_INIT = STACK_SIZE - STACK_FRAME_OVERHEAD - __PT_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
Jan Willeke2a0a5b22014-09-22 16:39:06 +020054_TIF_WORK = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
Linus Torvalds76f19482017-05-02 18:24:16 -070055 _TIF_UPROBE | _TIF_GUARDED_STORAGE | _TIF_PATCH_PENDING)
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +020056_TIF_TRACE = (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | \
57 _TIF_SYSCALL_TRACEPOINT)
Heiko Carstensb5a882f2017-02-17 08:13:28 +010058_CIF_WORK = (_CIF_MCCK_PENDING | _CIF_ASCE_PRIMARY | \
59 _CIF_ASCE_SECONDARY | _CIF_FPU)
Martin Schwidefsky23fefe12017-06-07 14:10:24 +020060_PIF_WORK = (_PIF_PER_TRAP | _PIF_SYSCALL_RESTART)
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
Martin Schwidefskye5b98192018-03-26 15:23:33 +020062_LPP_OFFSET = __LC_LPP
63
Hendrik Brueckner9977e882015-06-10 12:53:42 +020064#define BASED(name) name-cleanup_critical(%r13)
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
Martin Schwidefskyc5328902011-12-27 11:27:15 +010066 .macro TRACE_IRQS_ON
67#ifdef CONFIG_TRACE_IRQFLAGS
68 basr %r2,%r0
69 brasl %r14,trace_hardirqs_on_caller
70#endif
71 .endm
72
73 .macro TRACE_IRQS_OFF
74#ifdef CONFIG_TRACE_IRQFLAGS
75 basr %r2,%r0
76 brasl %r14,trace_hardirqs_off_caller
77#endif
78 .endm
79
80 .macro LOCKDEP_SYS_EXIT
81#ifdef CONFIG_LOCKDEP
82 tm __PT_PSW+1(%r11),0x01 # returning to user ?
83 jz .+10
84 brasl %r14,lockdep_sys_exit
85#endif
86 .endm
87
Martin Schwidefskyce3dc442017-09-12 16:37:33 +020088 .macro CHECK_STACK savearea
Martin Schwidefsky63b12242006-06-29 14:58:05 +020089#ifdef CONFIG_CHECK_STACK
Martin Schwidefskyce3dc442017-09-12 16:37:33 +020090 tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
Martin Schwidefskyc5328902011-12-27 11:27:15 +010091 lghi %r14,\savearea
92 jz stack_overflow
Martin Schwidefsky63b12242006-06-29 14:58:05 +020093#endif
Martin Schwidefsky63b12242006-06-29 14:58:05 +020094 .endm
95
Martin Schwidefskyce3dc442017-09-12 16:37:33 +020096 .macro CHECK_VMAP_STACK savearea,oklabel
97#ifdef CONFIG_VMAP_STACK
98 lgr %r14,%r15
99 nill %r14,0x10000 - STACK_SIZE
100 oill %r14,STACK_INIT
101 clg %r14,__LC_KERNEL_STACK
102 je \oklabel
103 clg %r14,__LC_ASYNC_STACK
104 je \oklabel
105 clg %r14,__LC_NODAT_STACK
106 je \oklabel
107 clg %r14,__LC_RESTART_STACK
108 je \oklabel
109 lghi %r14,\savearea
110 j stack_overflow
111#else
112 j \oklabel
113#endif
114 .endm
115
Martin Schwidefsky2acb94f2015-06-22 17:28:14 +0200116 .macro SWITCH_ASYNC savearea,timer
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100117 tmhh %r8,0x0001 # interrupting from user ?
118 jnz 1f
119 lgr %r14,%r9
120 slg %r14,BASED(.Lcritical_start)
121 clg %r14,BASED(.Lcritical_length)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 jhe 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100123 lghi %r11,\savearea # inside critical section, do cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 brasl %r14,cleanup_critical
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100125 tmhh %r8,0x0001 # retest problem state after cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 jnz 1f
Martin Schwidefskyce3dc442017-09-12 16:37:33 +02001270: lg %r14,__LC_ASYNC_STACK # are we already on the target stack?
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 slgr %r14,%r15
Martin Schwidefsky2acb94f2015-06-22 17:28:14 +0200129 srag %r14,%r14,STACK_SHIFT
Martin Schwidefskya359bb12015-06-22 17:27:48 +0200130 jnz 2f
Martin Schwidefskyce3dc442017-09-12 16:37:33 +0200131 CHECK_STACK \savearea
Martin Schwidefskydc7ee002013-04-24 10:20:43 +0200132 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
Martin Schwidefskya359bb12015-06-22 17:27:48 +0200133 j 3f
Martin Schwidefsky34525e12017-01-25 12:54:17 +01001341: UPDATE_VTIME %r14,%r15,\timer
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100135 BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
Martin Schwidefsky2acb94f2015-06-22 17:28:14 +02001362: lg %r15,__LC_ASYNC_STACK # load async stack
Martin Schwidefskya359bb12015-06-22 17:27:48 +02001373: la %r11,STACK_FRAME_OVERHEAD(%r15)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700138 .endm
139
Martin Schwidefskya359bb12015-06-22 17:27:48 +0200140 .macro UPDATE_VTIME w1,w2,enter_timer
141 lg \w1,__LC_EXIT_TIMER
142 lg \w2,__LC_LAST_UPDATE_TIMER
143 slg \w1,\enter_timer
144 slg \w2,__LC_EXIT_TIMER
145 alg \w1,__LC_USER_TIMER
146 alg \w2,__LC_SYSTEM_TIMER
147 stg \w1,__LC_USER_TIMER
148 stg \w2,__LC_SYSTEM_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100149 mvc __LC_LAST_UPDATE_TIMER(8),\enter_timer
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200150 .endm
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151
Martin Schwidefsky1e546222010-10-25 16:10:37 +0200152 .macro REENABLE_IRQS
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100153 stg %r8,__LC_RETURN_PSW
154 ni __LC_RETURN_PSW,0xbf
155 ssm __LC_RETURN_PSW
Martin Schwidefsky1e546222010-10-25 16:10:37 +0200156 .endm
157
Heiko Carstens473e66b2012-05-09 16:27:39 +0200158 .macro STCK savearea
Heiko Carstensd652d592012-05-14 10:35:22 +0200159#ifdef CONFIG_HAVE_MARCH_Z9_109_FEATURES
Heiko Carstens473e66b2012-05-09 16:27:39 +0200160 .insn s,0xb27c0000,\savearea # store clock fast
161#else
162 .insn s,0xb2050000,\savearea # store clock
163#endif
164 .endm
165
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200166 /*
167 * The TSTMSK macro generates a test-under-mask instruction by
168 * calculating the memory offset for the specified mask value.
169 * Mask value can be any constant. The macro shifts the mask
170 * value to calculate the memory offset for the test-under-mask
171 * instruction.
172 */
173 .macro TSTMSK addr, mask, size=8, bytepos=0
174 .if (\bytepos < \size) && (\mask >> 8)
175 .if (\mask & 0xff)
176 .error "Mask exceeds byte boundary"
177 .endif
178 TSTMSK \addr, "(\mask >> 8)", \size, "(\bytepos + 1)"
179 .exitm
180 .endif
181 .ifeq \mask
182 .error "Mask must not be zero"
183 .endif
184 off = \size - \bytepos - 1
185 tm off+\addr, \mask
186 .endm
187
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100188 .macro BPOFF
Martin Schwidefskyb0586612018-03-26 15:27:36 +0200189 ALTERNATIVE "", ".long 0xb2e8c000", 82
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100190 .endm
191
192 .macro BPON
Martin Schwidefskyb0586612018-03-26 15:27:36 +0200193 ALTERNATIVE "", ".long 0xb2e8d000", 82
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100194 .endm
195
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100196 .macro BPENTER tif_ptr,tif_mask
Martin Schwidefskyb0586612018-03-26 15:27:36 +0200197 ALTERNATIVE "TSTMSK \tif_ptr,\tif_mask; jz .+8; .long 0xb2e8d000", \
198 "", 82
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100199 .endm
200
201 .macro BPEXIT tif_ptr,tif_mask
202 TSTMSK \tif_ptr,\tif_mask
Martin Schwidefskyb0586612018-03-26 15:27:36 +0200203 ALTERNATIVE "jz .+8; .long 0xb2e8c000", \
204 "jnz .+8; .long 0xb2e8d000", 82
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100205 .endm
206
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200207 GEN_BR_THUNK %r9
208 GEN_BR_THUNK %r14
209 GEN_BR_THUNK %r14,%r11
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +0100210
Martin Schwidefsky860dba42011-01-05 12:47:25 +0100211 .section .kprobes.text, "ax"
Heiko Carstens46210c42016-06-30 12:40:25 +0200212.Ldummy:
213 /*
214 * This nop exists only in order to avoid that __switch_to starts at
215 * the beginning of the kprobes text section. In that case we would
216 * have several symbols at the same address. E.g. objdump would take
217 * an arbitrary symbol name when disassembling this code.
218 * With the added nop in between the __switch_to symbol is unique
219 * again.
220 */
221 nop 0
Martin Schwidefsky860dba42011-01-05 12:47:25 +0100222
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100223ENTRY(__bpon)
224 .globl __bpon
225 BPON
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200226 BR_EX %r14
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100227ENDPROC(__bpon)
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100228
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229/*
230 * Scheduler resume function, called by switch_to
231 * gpr2 = (task_struct *) prev
232 * gpr3 = (task_struct *) next
233 * Returns:
234 * gpr2 = prev
235 */
Jan Glauber144d6342011-07-24 10:48:19 +0200236ENTRY(__switch_to)
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +0200237 stmg %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task
Heiko Carstens3241d3e2017-11-16 14:54:04 +0100238 lghi %r4,__TASK_stack
239 lghi %r1,__TASK_thread
Vasily Gorbik9fed9202018-10-26 15:29:59 +0200240 llill %r5,STACK_INIT
Heiko Carstens3241d3e2017-11-16 14:54:04 +0100241 stg %r15,__THREAD_ksp(%r1,%r2) # store kernel stack of prev
Vasily Gorbik9fed9202018-10-26 15:29:59 +0200242 lg %r15,0(%r4,%r3) # start of kernel stack of next
243 agr %r15,%r5 # end of kernel stack of next
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +0200244 stg %r3,__LC_CURRENT # store task struct of next
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +0200245 stg %r15,__LC_KERNEL_STACK # store end of kernel stack
Heiko Carstens3241d3e2017-11-16 14:54:04 +0100246 lg %r15,__THREAD_ksp(%r1,%r3) # load kernel stack of next
247 aghi %r3,__TASK_pid
248 mvc __LC_CURRENT_PID(4,%r0),0(%r3) # store pid of next
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200249 lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task
Martin Schwidefskye5b98192018-03-26 15:23:33 +0200250 ALTERNATIVE "", ".insn s,0xb2800000,_LPP_OFFSET", 40
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200251 BR_EX %r14
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100252ENDPROC(__switch_to)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100254.L__critical_start:
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200255
256#if IS_ENABLED(CONFIG_KVM)
257/*
258 * sie64a calling convention:
259 * %r2 pointer to sie control block
260 * %r3 guest register save area
261 */
262ENTRY(sie64a)
263 stmg %r6,%r14,__SF_GPRS(%r15) # save kernel registers
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100264 lg %r12,__LC_CURRENT
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100265 stg %r2,__SF_SIE_CONTROL(%r15) # save control block pointer
266 stg %r3,__SF_SIE_SAVEAREA(%r15) # save guest register save area
267 xc __SF_SIE_REASON(8,%r15),__SF_SIE_REASON(%r15) # reason code = 0
268 mvc __SF_SIE_FLAGS(8,%r15),__TI_flags(%r12) # copy thread flags
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200269 TSTMSK __LC_CPU_FLAGS,_CIF_FPU # load guest fp/vx registers ?
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200270 jno .Lsie_load_guest_gprs
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200271 brasl %r14,load_fpu_regs # load guest fp/vx regs
272.Lsie_load_guest_gprs:
273 lmg %r0,%r13,0(%r3) # load guest gprs 0-13
274 lg %r14,__LC_GMAP # get gmap pointer
275 ltgr %r14,%r14
276 jz .Lsie_gmap
277 lctlg %c1,%c1,__GMAP_ASCE(%r14) # load primary asce
278.Lsie_gmap:
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100279 lg %r14,__SF_SIE_CONTROL(%r15) # get control block pointer
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200280 oi __SIE_PROG0C+3(%r14),1 # we are going into SIE now
281 tm __SIE_PROG20+3(%r14),3 # last exit...
282 jnz .Lsie_skip
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200283 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200284 jo .Lsie_skip # exit if fp/vx regs changed
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100285 BPEXIT __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
QingFeng Haoc9295002017-06-07 11:30:42 +0200286.Lsie_entry:
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200287 sie 0(%r14)
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100288.Lsie_exit:
289 BPOFF
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100290 BPENTER __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200291.Lsie_skip:
292 ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE
293 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
294.Lsie_done:
295# some program checks are suppressing. C code (e.g. do_protection_exception)
Christian Borntraegerc0e7bb32017-05-15 14:11:03 +0200296# will rewind the PSW by the ILC, which is often 4 bytes in case of SIE. There
297# are some corner cases (e.g. runtime instrumentation) where ILC is unpredictable.
298# Other instructions between sie64a and .Lsie_done should not cause program
299# interrupts. So lets use 3 nops as a landing pad for all possible rewinds.
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200300# See also .Lcleanup_sie
Christian Borntraegerc0e7bb32017-05-15 14:11:03 +0200301.Lrewind_pad6:
302 nopr 7
303.Lrewind_pad4:
304 nopr 7
305.Lrewind_pad2:
306 nopr 7
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200307 .globl sie_exit
308sie_exit:
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100309 lg %r14,__SF_SIE_SAVEAREA(%r15) # load guest register save area
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200310 stmg %r0,%r13,0(%r14) # save guest gprs 0-13
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100311 xgr %r0,%r0 # clear guest registers to
312 xgr %r1,%r1 # prevent speculative use
313 xgr %r2,%r2
314 xgr %r3,%r3
315 xgr %r4,%r4
316 xgr %r5,%r5
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200317 lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100318 lg %r2,__SF_SIE_REASON(%r15) # return exit reason code
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200319 BR_EX %r14
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200320.Lsie_fault:
321 lghi %r14,-EFAULT
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100322 stg %r14,__SF_SIE_REASON(%r15) # set exit reason code
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200323 j sie_exit
324
Christian Borntraegerc0e7bb32017-05-15 14:11:03 +0200325 EX_TABLE(.Lrewind_pad6,.Lsie_fault)
326 EX_TABLE(.Lrewind_pad4,.Lsie_fault)
327 EX_TABLE(.Lrewind_pad2,.Lsie_fault)
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200328 EX_TABLE(sie_exit,.Lsie_fault)
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100329ENDPROC(sie64a)
Al Viro711f5df2016-01-12 13:30:03 -0500330EXPORT_SYMBOL(sie64a)
331EXPORT_SYMBOL(sie_exit)
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200332#endif
333
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334/*
335 * SVC interrupt handler routine. System calls are synchronous events and
336 * are executed with interrupts enabled.
337 */
338
Jan Glauber144d6342011-07-24 10:48:19 +0200339ENTRY(system_call)
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100340 stpt __LC_SYNC_ENTER_TIMER
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100341.Lsysc_stmg:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100342 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100343 BPOFF
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100344 lg %r12,__LC_CURRENT
Martin Schwidefsky34525e12017-01-25 12:54:17 +0100345 lghi %r13,__TASK_thread
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200346 lghi %r14,_PIF_SYSCALL
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100347.Lsysc_per:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100348 lg %r15,__LC_KERNEL_STACK
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100349 la %r11,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs
Martin Schwidefskya359bb12015-06-22 17:27:48 +0200350.Lsysc_vtime:
Martin Schwidefsky34525e12017-01-25 12:54:17 +0100351 UPDATE_VTIME %r8,%r9,__LC_SYNC_ENTER_TIMER
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100352 BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100353 stmg %r0,%r7,__PT_R0(%r11)
354 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
355 mvc __PT_PSW(16,%r11),__LC_SVC_OLD_PSW
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100356 mvc __PT_INT_CODE(4,%r11),__LC_SVC_ILC
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200357 stg %r14,__PT_FLAGS(%r11)
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100358.Lsysc_do_svc:
Christian Borntraegerd3f46892018-03-05 19:18:47 +0000359 # clear user controlled register to prevent speculative use
360 xgr %r0,%r0
Martin Schwidefskyef280c82016-11-08 12:33:38 +0100361 # load address of system call table
Martin Schwidefskyef280c82016-11-08 12:33:38 +0100362 lg %r10,__THREAD_sysc_table(%r13,%r12)
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100363 llgh %r8,__PT_INT_CODE+2(%r11)
Gerald Schaeferff4a7422019-02-03 21:36:13 +0100364 slag %r8,%r8,3 # shift and test for svc 0
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100365 jnz .Lsysc_nr_ok
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366 # svc 0: system call number in %r1
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100367 llgfr %r1,%r1 # clear high word in r1
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200368 cghi %r1,NR_syscalls
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100369 jnl .Lsysc_nr_ok
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100370 sth %r1,__PT_INT_CODE+2(%r11)
Gerald Schaeferff4a7422019-02-03 21:36:13 +0100371 slag %r8,%r1,3
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100372.Lsysc_nr_ok:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100373 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
374 stg %r2,__PT_ORIG_GPR2(%r11)
375 stg %r7,STACK_FRAME_OVERHEAD(%r15)
Gerald Schaeferff4a7422019-02-03 21:36:13 +0100376 lg %r9,0(%r8,%r10) # get system call add.
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200377 TSTMSK __TI_flags(%r12),_TIF_TRACE
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100378 jnz .Lsysc_tracesys
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200379 BASR_EX %r14,%r9 # call sys_xxxx
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100380 stg %r2,__PT_R2(%r11) # store return value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100382.Lsysc_return:
Heiko Carstens9d6d99e2018-06-30 10:54:15 +0200383#ifdef CONFIG_DEBUG_RSEQ
384 lgr %r2,%r11
385 brasl %r14,rseq_syscall
386#endif
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200387 LOCKDEP_SYS_EXIT
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100388.Lsysc_tif:
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200389 TSTMSK __PT_FLAGS(%r11),_PIF_WORK
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100390 jnz .Lsysc_work
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200391 TSTMSK __TI_flags(%r12),_TIF_WORK
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100392 jnz .Lsysc_work # check for work
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200393 TSTMSK __LC_CPU_FLAGS,_CIF_WORK
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100394 jnz .Lsysc_work
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100395 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100396.Lsysc_restore:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100397 lg %r14,__LC_VDSO_PER_CPU
398 lmg %r0,%r10,__PT_R0(%r11)
399 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
Martin Schwidefsky07a63cb2017-05-02 13:36:00 +0200400.Lsysc_exit_timer:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100401 stpt __LC_EXIT_TIMER
402 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
403 lmg %r11,%r15,__PT_R11(%r11)
404 lpswe __LC_RETURN_PSW
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100405.Lsysc_done:
Heiko Carstens411788e2007-11-20 11:13:32 +0100406
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407#
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200408# One of the work bits is on. Find out which one.
409#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100410.Lsysc_work:
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200411 TSTMSK __LC_CPU_FLAGS,_CIF_MCCK_PENDING
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100412 jo .Lsysc_mcck_pending
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200413 TSTMSK __TI_flags(%r12),_TIF_NEED_RESCHED
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100414 jo .Lsysc_reschedule
Martin Schwidefsky23fefe12017-06-07 14:10:24 +0200415 TSTMSK __PT_FLAGS(%r11),_PIF_SYSCALL_RESTART
416 jo .Lsysc_syscall_restart
Jan Willeke2a0a5b22014-09-22 16:39:06 +0200417#ifdef CONFIG_UPROBES
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200418 TSTMSK __TI_flags(%r12),_TIF_UPROBE
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100419 jo .Lsysc_uprobe_notify
Jan Willeke2a0a5b22014-09-22 16:39:06 +0200420#endif
Martin Schwidefsky916cda12016-01-26 14:10:34 +0100421 TSTMSK __TI_flags(%r12),_TIF_GUARDED_STORAGE
422 jo .Lsysc_guarded_storage
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200423 TSTMSK __PT_FLAGS(%r11),_PIF_PER_TRAP
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100424 jo .Lsysc_singlestep
Miroslav Benes2f09ca62017-02-13 19:42:34 -0600425#ifdef CONFIG_LIVEPATCH
426 TSTMSK __TI_flags(%r12),_TIF_PATCH_PENDING
427 jo .Lsysc_patch_pending # handle live patching just before
428 # signals and possible syscall restart
429#endif
Martin Schwidefsky23fefe12017-06-07 14:10:24 +0200430 TSTMSK __PT_FLAGS(%r11),_PIF_SYSCALL_RESTART
431 jo .Lsysc_syscall_restart
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200432 TSTMSK __TI_flags(%r12),_TIF_SIGPENDING
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100433 jo .Lsysc_sigpending
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200434 TSTMSK __TI_flags(%r12),_TIF_NOTIFY_RESUME
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100435 jo .Lsysc_notify_resume
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200436 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200437 jo .Lsysc_vxrs
Heiko Carstensb5a882f2017-02-17 08:13:28 +0100438 TSTMSK __LC_CPU_FLAGS,(_CIF_ASCE_PRIMARY|_CIF_ASCE_SECONDARY)
439 jnz .Lsysc_asce
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100440 j .Lsysc_return # beware of critical section cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441
442#
443# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200444#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100445.Lsysc_reschedule:
446 larl %r14,.Lsysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100447 jg schedule
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448
449#
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200450# _CIF_MCCK_PENDING is set, call handler
Heiko Carstens77fa2242005-06-25 14:55:30 -0700451#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100452.Lsysc_mcck_pending:
453 larl %r14,.Lsysc_return
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200454 jg s390_handle_mcck # TIF bit will be cleared by handler
Heiko Carstens77fa2242005-06-25 14:55:30 -0700455
456#
Martin Schwidefsky0aaba412017-08-22 12:08:22 +0200457# _CIF_ASCE_PRIMARY and/or _CIF_ASCE_SECONDARY set, load user space asce
Heiko Carstens457f2182014-03-21 10:42:25 +0100458#
Heiko Carstensb5a882f2017-02-17 08:13:28 +0100459.Lsysc_asce:
Martin Schwidefsky0aaba412017-08-22 12:08:22 +0200460 ni __LC_CPU_FLAGS+7,255-_CIF_ASCE_SECONDARY
461 lctlg %c7,%c7,__LC_VDSO_ASCE # load secondary asce
462 TSTMSK __LC_CPU_FLAGS,_CIF_ASCE_PRIMARY
463 jz .Lsysc_return
464#ifndef CONFIG_HAVE_MARCH_Z10_FEATURES
465 tm __LC_STFLE_FAC_LIST+3,0x10 # has MVCOS ?
466 jnz .Lsysc_set_fs_fixup
Heiko Carstens606aa4a2017-02-17 08:12:30 +0100467 ni __LC_CPU_FLAGS+7,255-_CIF_ASCE_PRIMARY
Heiko Carstens457f2182014-03-21 10:42:25 +0100468 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
Martin Schwidefsky0aaba412017-08-22 12:08:22 +0200469 j .Lsysc_return
470.Lsysc_set_fs_fixup:
471#endif
Heiko Carstensb5a882f2017-02-17 08:13:28 +0100472 larl %r14,.Lsysc_return
473 jg set_fs_fixup
Heiko Carstens457f2182014-03-21 10:42:25 +0100474
475#
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200476# CIF_FPU is set, restore floating-point controls and floating-point registers.
477#
478.Lsysc_vxrs:
479 larl %r14,.Lsysc_return
480 jg load_fpu_regs
481
482#
Roland McGrath02a029b2008-04-30 00:53:08 -0700483# _TIF_SIGPENDING is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100485.Lsysc_sigpending:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100486 lgr %r2,%r11 # pass pointer to pt_regs
487 brasl %r14,do_signal
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200488 TSTMSK __PT_FLAGS(%r11),_PIF_SYSCALL
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100489 jno .Lsysc_return
Martin Schwidefsky57d7f932016-03-22 10:54:24 +0100490.Lsysc_do_syscall:
491 lghi %r13,__TASK_thread
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100492 lmg %r2,%r7,__PT_R2(%r11) # load svc arguments
Martin Schwidefsky57d7f932016-03-22 10:54:24 +0100493 lghi %r1,0 # svc 0 returns -ENOSYS
494 j .Lsysc_do_svc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495
496#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200497# _TIF_NOTIFY_RESUME is set, call do_notify_resume
498#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100499.Lsysc_notify_resume:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100500 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100501 larl %r14,.Lsysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100502 jg do_notify_resume
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200503
504#
Jan Willeke2a0a5b22014-09-22 16:39:06 +0200505# _TIF_UPROBE is set, call uprobe_notify_resume
506#
507#ifdef CONFIG_UPROBES
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100508.Lsysc_uprobe_notify:
Jan Willeke2a0a5b22014-09-22 16:39:06 +0200509 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100510 larl %r14,.Lsysc_return
Jan Willeke2a0a5b22014-09-22 16:39:06 +0200511 jg uprobe_notify_resume
512#endif
513
514#
Martin Schwidefsky916cda12016-01-26 14:10:34 +0100515# _TIF_GUARDED_STORAGE is set, call guarded_storage_load
516#
517.Lsysc_guarded_storage:
518 lgr %r2,%r11 # pass pointer to pt_regs
519 larl %r14,.Lsysc_return
520 jg gs_load_bc_cb
Linus Torvalds76f19482017-05-02 18:24:16 -0700521#
Miroslav Benes2f09ca62017-02-13 19:42:34 -0600522# _TIF_PATCH_PENDING is set, call klp_update_patch_state
523#
524#ifdef CONFIG_LIVEPATCH
525.Lsysc_patch_pending:
526 lg %r2,__LC_CURRENT # pass pointer to task struct
527 larl %r14,.Lsysc_return
528 jg klp_update_patch_state
529#endif
Martin Schwidefsky916cda12016-01-26 14:10:34 +0100530
531#
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200532# _PIF_PER_TRAP is set, call do_per_trap
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100534.Lsysc_singlestep:
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200535 ni __PT_FLAGS+7(%r11),255-_PIF_PER_TRAP
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100536 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100537 larl %r14,.Lsysc_return
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100538 jg do_per_trap
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540#
Martin Schwidefsky23fefe12017-06-07 14:10:24 +0200541# _PIF_SYSCALL_RESTART is set, repeat the current system call
542#
543.Lsysc_syscall_restart:
544 ni __PT_FLAGS+7(%r11),255-_PIF_SYSCALL_RESTART
545 lmg %r1,%r7,__PT_R1(%r11) # load svc arguments
546 lg %r2,__PT_ORIG_GPR2(%r11)
547 j .Lsysc_do_svc
548
549#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200550# call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
551# and after the system call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100553.Lsysc_tracesys:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100554 lgr %r2,%r11 # pass pointer to pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 la %r3,0
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100556 llgh %r0,__PT_INT_CODE+2(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100557 stg %r0,__PT_R2(%r11)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200558 brasl %r14,do_syscall_trace_enter
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 lghi %r0,NR_syscalls
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200560 clgr %r0,%r2
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100561 jnh .Lsysc_tracenogo
Gerald Schaeferff4a7422019-02-03 21:36:13 +0100562 sllg %r8,%r2,3
563 lg %r9,0(%r8,%r10)
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100564.Lsysc_tracego:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100565 lmg %r3,%r7,__PT_R3(%r11)
566 stg %r7,STACK_FRAME_OVERHEAD(%r15)
567 lg %r2,__PT_ORIG_GPR2(%r11)
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200568 BASR_EX %r14,%r9 # call sys_xxx
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100569 stg %r2,__PT_R2(%r11) # store return value
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100570.Lsysc_tracenogo:
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200571 TSTMSK __TI_flags(%r12),_TIF_TRACE
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100572 jz .Lsysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100573 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100574 larl %r14,.Lsysc_return
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200575 jg do_syscall_trace_exit
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100576ENDPROC(system_call)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577
578#
579# a new process exits the kernel with ret_from_fork
580#
Jan Glauber144d6342011-07-24 10:48:19 +0200581ENTRY(ret_from_fork)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100582 la %r11,STACK_FRAME_OVERHEAD(%r15)
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100583 lg %r12,__LC_CURRENT
Al Viro30dcb092012-10-11 15:30:14 -0400584 brasl %r14,schedule_tail
585 TRACE_IRQS_ON
586 ssm __LC_SVC_NEW_PSW # reenable interrupts
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100587 tm __PT_PSW+1(%r11),0x01 # forking a kernel thread ?
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100588 jne .Lsysc_tracenogo
Al Viro30dcb092012-10-11 15:30:14 -0400589 # it's a kernel thread
590 lmg %r9,%r10,__PT_R9(%r11) # load gprs
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100591 la %r2,0(%r10)
592 BASR_EX %r14,%r9
593 j .Lsysc_tracenogo
594ENDPROC(ret_from_fork)
595
Al Viro37fe5d42012-09-10 18:03:41 -0400596ENTRY(kernel_thread_starter)
597 la %r2,0(%r10)
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200598 BASR_EX %r14,%r9
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100599 j .Lsysc_tracenogo
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100600ENDPROC(kernel_thread_starter)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601
602/*
603 * Program check handler routine
604 */
605
Jan Glauber144d6342011-07-24 10:48:19 +0200606ENTRY(pgm_check_handler)
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100607 stpt __LC_SYNC_ENTER_TIMER
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100608 BPOFF
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100609 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
610 lg %r10,__LC_LAST_BREAK
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100611 lg %r12,__LC_CURRENT
Martin Schwidefskyc7713202017-10-05 08:44:26 +0200612 lghi %r11,0
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200613 larl %r13,cleanup_critical
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100614 lmg %r8,%r9,__LC_PGM_OLD_PSW
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100615 tmhh %r8,0x0001 # test problem state bit
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200616 jnz 2f # -> fault in user space
617#if IS_ENABLED(CONFIG_KVM)
Martin Schwidefsky0a5e2ec2017-10-05 08:29:47 +0200618 # cleanup critical section for program checks in sie64a
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200619 lgr %r14,%r9
620 slg %r14,BASED(.Lsie_critical_start)
621 clg %r14,BASED(.Lsie_critical_length)
622 jhe 0f
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100623 lg %r14,__SF_SIE_CONTROL(%r15) # get control block pointer
Martin Schwidefsky0a5e2ec2017-10-05 08:29:47 +0200624 ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE
625 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
626 larl %r9,sie_exit # skip forward to sie_exit
Martin Schwidefskyc7713202017-10-05 08:44:26 +0200627 lghi %r11,_PIF_GUEST_FAULT
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200628#endif
6290: tmhh %r8,0x4000 # PER bit set in old PSW ?
630 jnz 1f # -> enabled, can't be a double fault
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100631 tm __LC_PGM_ILC+3,0x80 # check for per exception
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100632 jnz .Lpgm_svcper # -> single stepped svc
Martin Schwidefskyce3dc442017-09-12 16:37:33 +02006331: CHECK_STACK __LC_SAVE_AREA_SYNC
Martin Schwidefskydc7ee002013-04-24 10:20:43 +0200634 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
Martin Schwidefskyce3dc442017-09-12 16:37:33 +0200635 # CHECK_VMAP_STACK branches to stack_overflow or 4f
636 CHECK_VMAP_STACK __LC_SAVE_AREA_SYNC,4f
Martin Schwidefsky34525e12017-01-25 12:54:17 +01006372: UPDATE_VTIME %r14,%r15,__LC_SYNC_ENTER_TIMER
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100638 BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100639 lg %r15,__LC_KERNEL_STACK
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100640 lgr %r14,%r12
Martin Schwidefsky3827ec32015-07-20 10:01:46 +0200641 aghi %r14,__TASK_thread # pointer to thread_struct
Martin Schwidefskyd35339a2012-07-31 11:03:04 +0200642 lghi %r13,__LC_PGM_TDB
643 tm __LC_PGM_ILC+2,0x02 # check for transaction abort
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200644 jz 3f
Martin Schwidefskyd35339a2012-07-31 11:03:04 +0200645 mvc __THREAD_trap_tdb(256,%r14),0(%r13)
Martin Schwidefskyd9fcf2a2017-02-28 07:42:01 +01006463: stg %r10,__THREAD_last_break(%r14)
Martin Schwidefskyc7713202017-10-05 08:44:26 +02006474: lgr %r13,%r11
648 la %r11,STACK_FRAME_OVERHEAD(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100649 stmg %r0,%r7,__PT_R0(%r11)
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100650 # clear user controlled registers to prevent speculative use
651 xgr %r0,%r0
652 xgr %r1,%r1
653 xgr %r2,%r2
654 xgr %r3,%r3
655 xgr %r4,%r4
656 xgr %r5,%r5
657 xgr %r6,%r6
658 xgr %r7,%r7
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100659 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
660 stmg %r8,%r9,__PT_PSW(%r11)
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100661 mvc __PT_INT_CODE(4,%r11),__LC_PGM_ILC
662 mvc __PT_INT_PARM_LONG(8,%r11),__LC_TRANS_EXC_CODE
Martin Schwidefskyc7713202017-10-05 08:44:26 +0200663 stg %r13,__PT_FLAGS(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100664 stg %r10,__PT_ARGS(%r11)
665 tm __LC_PGM_ILC+3,0x80 # check for per exception
Martin Schwidefskyd9fcf2a2017-02-28 07:42:01 +0100666 jz 5f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100667 tmhh %r8,0x0001 # kernel per event ?
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100668 jz .Lpgm_kprobe
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200669 oi __PT_FLAGS+7(%r11),_PIF_PER_TRAP
Martin Schwidefskyd35339a2012-07-31 11:03:04 +0200670 mvc __THREAD_per_address(8,%r14),__LC_PER_ADDRESS
Jens Freimann21ee7ff2014-02-26 16:32:46 +0100671 mvc __THREAD_per_cause(2,%r14),__LC_PER_CODE
672 mvc __THREAD_per_paid(1,%r14),__LC_PER_ACCESS_ID
Martin Schwidefskyd9fcf2a2017-02-28 07:42:01 +01006735: REENABLE_IRQS
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100674 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200675 larl %r1,pgm_check_table
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100676 llgh %r10,__PT_INT_CODE+2(%r11)
677 nill %r10,0x007f
Gerald Schaeferff4a7422019-02-03 21:36:13 +0100678 sll %r10,3
Martin Schwidefskya359bb12015-06-22 17:27:48 +0200679 je .Lpgm_return
Gerald Schaeferff4a7422019-02-03 21:36:13 +0100680 lg %r9,0(%r10,%r1) # load address of handler routine
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100681 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200682 BASR_EX %r14,%r9 # branch to interrupt-handler
Martin Schwidefskya359bb12015-06-22 17:27:48 +0200683.Lpgm_return:
684 LOCKDEP_SYS_EXIT
685 tm __PT_PSW+1(%r11),0x01 # returning to user ?
686 jno .Lsysc_restore
Martin Schwidefsky57d7f932016-03-22 10:54:24 +0100687 TSTMSK __PT_FLAGS(%r11),_PIF_SYSCALL
688 jo .Lsysc_do_syscall
Martin Schwidefskya359bb12015-06-22 17:27:48 +0200689 j .Lsysc_tif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690
691#
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100692# PER event in supervisor state, must be kprobes
693#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100694.Lpgm_kprobe:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100695 REENABLE_IRQS
696 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
697 lgr %r2,%r11 # pass pointer to pt_regs
698 brasl %r14,do_per_trap
Martin Schwidefskya359bb12015-06-22 17:27:48 +0200699 j .Lpgm_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100700
701#
702# single stepped system call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100704.Lpgm_svcper:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100705 mvc __LC_RETURN_PSW(8),__LC_SVC_NEW_PSW
Martin Schwidefskyd24b98e2017-02-20 09:51:36 +0100706 lghi %r13,__TASK_thread
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100707 larl %r14,.Lsysc_per
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100708 stg %r14,__LC_RETURN_PSW+8
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200709 lghi %r14,_PIF_SYSCALL | _PIF_PER_TRAP
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100710 lpswe __LC_RETURN_PSW # branch to .Lsysc_per and enable irqs
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100711ENDPROC(pgm_check_handler)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200712
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713/*
714 * IO interrupt handler routine
715 */
Jan Glauber144d6342011-07-24 10:48:19 +0200716ENTRY(io_int_handler)
Heiko Carstens473e66b2012-05-09 16:27:39 +0200717 STCK __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100718 stpt __LC_ASYNC_ENTER_TIMER
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100719 BPOFF
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100720 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100721 lg %r12,__LC_CURRENT
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200722 larl %r13,cleanup_critical
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100723 lmg %r8,%r9,__LC_IO_OLD_PSW
Martin Schwidefsky2acb94f2015-06-22 17:28:14 +0200724 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100725 stmg %r0,%r7,__PT_R0(%r11)
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100726 # clear user controlled registers to prevent speculative use
727 xgr %r0,%r0
728 xgr %r1,%r1
729 xgr %r2,%r2
730 xgr %r3,%r3
731 xgr %r4,%r4
732 xgr %r5,%r5
733 xgr %r6,%r6
734 xgr %r7,%r7
735 xgr %r10,%r10
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100736 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
737 stmg %r8,%r9,__PT_PSW(%r11)
Martin Schwidefsky48f6b002013-06-17 14:54:02 +0200738 mvc __PT_INT_CODE(12,%r11),__LC_SUBCHANNEL_ID
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200739 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
Heiko Carstensdb7e0072015-08-15 11:42:21 +0200740 TSTMSK __LC_CPU_FLAGS,_CIF_IGNORE_IRQ
741 jo .Lio_restore
Heiko Carstens1f194a42006-07-03 00:24:46 -0700742 TRACE_IRQS_OFF
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100743 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100744.Lio_loop:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100745 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky1f44a2252013-06-27 09:01:09 +0200746 lghi %r3,IO_INTERRUPT
747 tm __PT_INT_CODE+8(%r11),0x80 # adapter interrupt ?
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100748 jz .Lio_call
Martin Schwidefsky1f44a2252013-06-27 09:01:09 +0200749 lghi %r3,THIN_INTERRUPT
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100750.Lio_call:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100751 brasl %r14,do_IRQ
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200752 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_LPAR
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100753 jz .Lio_return
Martin Schwidefsky48f6b002013-06-17 14:54:02 +0200754 tpi 0
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100755 jz .Lio_return
Martin Schwidefsky48f6b002013-06-17 14:54:02 +0200756 mvc __PT_INT_CODE(12,%r11),__LC_SUBCHANNEL_ID
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100757 j .Lio_loop
758.Lio_return:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200759 LOCKDEP_SYS_EXIT
760 TRACE_IRQS_ON
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100761.Lio_tif:
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200762 TSTMSK __TI_flags(%r12),_TIF_WORK
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100763 jnz .Lio_work # there is work to do (signals etc.)
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200764 TSTMSK __LC_CPU_FLAGS,_CIF_WORK
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100765 jnz .Lio_work
766.Lio_restore:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100767 lg %r14,__LC_VDSO_PER_CPU
768 lmg %r0,%r10,__PT_R0(%r11)
769 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100770 tm __PT_PSW+1(%r11),0x01 # returning to user ?
771 jno .Lio_exit_kernel
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100772 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
Martin Schwidefsky07a63cb2017-05-02 13:36:00 +0200773.Lio_exit_timer:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100774 stpt __LC_EXIT_TIMER
775 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100776.Lio_exit_kernel:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100777 lmg %r11,%r15,__PT_R11(%r11)
778 lpswe __LC_RETURN_PSW
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100779.Lio_done:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780
Martin Schwidefsky26889052008-05-07 09:22:52 +0200781#
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200782# There is work todo, find out in which context we have been interrupted:
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200783# 1) if we return to user space we can do all _TIF_WORK work
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200784# 2) if we return to kernel code and kvm is enabled check if we need to
785# modify the psw to leave SIE
786# 3) if we return to kernel code and preemptive scheduling is enabled check
787# the preemption counter and if it is zero call preempt_schedule_irq
788# Before any work can be done, a switch to the kernel stack is required.
Martin Schwidefsky26889052008-05-07 09:22:52 +0200789#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100790.Lio_work:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100791 tm __PT_PSW+1(%r11),0x01 # returning to user ?
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100792 jo .Lio_work_user # yes -> do resched & signal
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200793#ifdef CONFIG_PREEMPT
Martin Schwidefsky26889052008-05-07 09:22:52 +0200794 # check for preemptive scheduling
Martin Schwidefskyc3601922016-10-25 12:21:44 +0200795 icm %r0,15,__LC_PREEMPT_COUNT
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100796 jnz .Lio_restore # preemption is disabled
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200797 TSTMSK __TI_flags(%r12),_TIF_NEED_RESCHED
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100798 jno .Lio_restore
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799 # switch to kernel stack
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100800 lg %r1,__PT_R15(%r11)
801 aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
802 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
803 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
804 la %r11,STACK_FRAME_OVERHEAD(%r1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805 lgr %r15,%r1
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100806 # TRACE_IRQS_ON already done at .Lio_return, call
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200807 # TRACE_IRQS_OFF to keep things symmetrical
808 TRACE_IRQS_OFF
809 brasl %r14,preempt_schedule_irq
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100810 j .Lio_return
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200811#else
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100812 j .Lio_restore
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200813#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200815#
816# Need to do work before returning to userspace, switch to kernel stack
817#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100818.Lio_work_user:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819 lg %r1,__LC_KERNEL_STACK
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100820 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
821 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
822 la %r11,STACK_FRAME_OVERHEAD(%r1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700823 lgr %r15,%r1
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200824
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825#
826# One of the work bits is on. Find out which one.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100828.Lio_work_tif:
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200829 TSTMSK __LC_CPU_FLAGS,_CIF_MCCK_PENDING
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100830 jo .Lio_mcck_pending
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200831 TSTMSK __TI_flags(%r12),_TIF_NEED_RESCHED
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100832 jo .Lio_reschedule
Miroslav Benes2f09ca62017-02-13 19:42:34 -0600833#ifdef CONFIG_LIVEPATCH
834 TSTMSK __TI_flags(%r12),_TIF_PATCH_PENDING
835 jo .Lio_patch_pending
836#endif
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200837 TSTMSK __TI_flags(%r12),_TIF_SIGPENDING
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100838 jo .Lio_sigpending
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200839 TSTMSK __TI_flags(%r12),_TIF_NOTIFY_RESUME
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100840 jo .Lio_notify_resume
Martin Schwidefsky916cda12016-01-26 14:10:34 +0100841 TSTMSK __TI_flags(%r12),_TIF_GUARDED_STORAGE
842 jo .Lio_guarded_storage
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200843 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200844 jo .Lio_vxrs
Heiko Carstensb5a882f2017-02-17 08:13:28 +0100845 TSTMSK __LC_CPU_FLAGS,(_CIF_ASCE_PRIMARY|_CIF_ASCE_SECONDARY)
846 jnz .Lio_asce
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100847 j .Lio_return # beware of critical section cleanup
Christian Borntraeger0eaeafa2008-05-07 09:22:53 +0200848
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849#
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200850# _CIF_MCCK_PENDING is set, call handler
Heiko Carstens77fa2242005-06-25 14:55:30 -0700851#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100852.Lio_mcck_pending:
853 # TRACE_IRQS_ON already done at .Lio_return
Heiko Carstensb771aea2007-07-27 12:29:18 +0200854 brasl %r14,s390_handle_mcck # TIF bit will be cleared by handler
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200855 TRACE_IRQS_OFF
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100856 j .Lio_return
Heiko Carstens77fa2242005-06-25 14:55:30 -0700857
858#
Heiko Carstensb5a882f2017-02-17 08:13:28 +0100859# _CIF_ASCE_PRIMARY and/or CIF_ASCE_SECONDARY set, load user space asce
Heiko Carstens457f2182014-03-21 10:42:25 +0100860#
Heiko Carstensb5a882f2017-02-17 08:13:28 +0100861.Lio_asce:
Martin Schwidefsky0aaba412017-08-22 12:08:22 +0200862 ni __LC_CPU_FLAGS+7,255-_CIF_ASCE_SECONDARY
863 lctlg %c7,%c7,__LC_VDSO_ASCE # load secondary asce
864 TSTMSK __LC_CPU_FLAGS,_CIF_ASCE_PRIMARY
865 jz .Lio_return
866#ifndef CONFIG_HAVE_MARCH_Z10_FEATURES
867 tm __LC_STFLE_FAC_LIST+3,0x10 # has MVCOS ?
868 jnz .Lio_set_fs_fixup
Heiko Carstens606aa4a2017-02-17 08:12:30 +0100869 ni __LC_CPU_FLAGS+7,255-_CIF_ASCE_PRIMARY
Heiko Carstens457f2182014-03-21 10:42:25 +0100870 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
Martin Schwidefsky0aaba412017-08-22 12:08:22 +0200871 j .Lio_return
872.Lio_set_fs_fixup:
873#endif
Heiko Carstensb5a882f2017-02-17 08:13:28 +0100874 larl %r14,.Lio_return
875 jg set_fs_fixup
Heiko Carstens457f2182014-03-21 10:42:25 +0100876
877#
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200878# CIF_FPU is set, restore floating-point controls and floating-point registers.
879#
880.Lio_vxrs:
881 larl %r14,.Lio_return
882 jg load_fpu_regs
883
884#
Martin Schwidefsky916cda12016-01-26 14:10:34 +0100885# _TIF_GUARDED_STORAGE is set, call guarded_storage_load
886#
887.Lio_guarded_storage:
888 # TRACE_IRQS_ON already done at .Lio_return
889 ssm __LC_SVC_NEW_PSW # reenable interrupts
890 lgr %r2,%r11 # pass pointer to pt_regs
891 brasl %r14,gs_load_bc_cb
892 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
893 TRACE_IRQS_OFF
894 j .Lio_return
895
896#
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200898#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100899.Lio_reschedule:
900 # TRACE_IRQS_ON already done at .Lio_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100901 ssm __LC_SVC_NEW_PSW # reenable interrupts
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200902 brasl %r14,schedule # call scheduler
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100903 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100904 TRACE_IRQS_OFF
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100905 j .Lio_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906
907#
Miroslav Benes2f09ca62017-02-13 19:42:34 -0600908# _TIF_PATCH_PENDING is set, call klp_update_patch_state
909#
910#ifdef CONFIG_LIVEPATCH
911.Lio_patch_pending:
912 lg %r2,__LC_CURRENT # pass pointer to task struct
913 larl %r14,.Lio_return
914 jg klp_update_patch_state
915#endif
916
917#
Roland McGrath02a029b2008-04-30 00:53:08 -0700918# _TIF_SIGPENDING or is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700919#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100920.Lio_sigpending:
921 # TRACE_IRQS_ON already done at .Lio_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100922 ssm __LC_SVC_NEW_PSW # reenable interrupts
923 lgr %r2,%r11 # pass pointer to pt_regs
924 brasl %r14,do_signal
925 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100926 TRACE_IRQS_OFF
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100927 j .Lio_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700928
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200929#
930# _TIF_NOTIFY_RESUME or is set, call do_notify_resume
931#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100932.Lio_notify_resume:
933 # TRACE_IRQS_ON already done at .Lio_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100934 ssm __LC_SVC_NEW_PSW # reenable interrupts
935 lgr %r2,%r11 # pass pointer to pt_regs
936 brasl %r14,do_notify_resume
937 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200938 TRACE_IRQS_OFF
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100939 j .Lio_return
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100940ENDPROC(io_int_handler)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200941
Linus Torvalds1da177e2005-04-16 15:20:36 -0700942/*
943 * External interrupt handler routine
944 */
Jan Glauber144d6342011-07-24 10:48:19 +0200945ENTRY(ext_int_handler)
Heiko Carstens473e66b2012-05-09 16:27:39 +0200946 STCK __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100947 stpt __LC_ASYNC_ENTER_TIMER
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100948 BPOFF
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100949 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100950 lg %r12,__LC_CURRENT
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200951 larl %r13,cleanup_critical
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100952 lmg %r8,%r9,__LC_EXT_OLD_PSW
Martin Schwidefsky2acb94f2015-06-22 17:28:14 +0200953 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100954 stmg %r0,%r7,__PT_R0(%r11)
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100955 # clear user controlled registers to prevent speculative use
956 xgr %r0,%r0
957 xgr %r1,%r1
958 xgr %r2,%r2
959 xgr %r3,%r3
960 xgr %r4,%r4
961 xgr %r5,%r5
962 xgr %r6,%r6
963 xgr %r7,%r7
964 xgr %r10,%r10
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100965 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
966 stmg %r8,%r9,__PT_PSW(%r11)
Martin Schwidefsky48f6b002013-06-17 14:54:02 +0200967 lghi %r1,__LC_EXT_PARAMS2
968 mvc __PT_INT_CODE(4,%r11),__LC_EXT_CPU_ADDR
969 mvc __PT_INT_PARM(4,%r11),__LC_EXT_PARAMS
970 mvc __PT_INT_PARM_LONG(8,%r11),0(%r1)
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200971 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
Heiko Carstensdb7e0072015-08-15 11:42:21 +0200972 TSTMSK __LC_CPU_FLAGS,_CIF_IGNORE_IRQ
973 jo .Lio_restore
Heiko Carstens1f194a42006-07-03 00:24:46 -0700974 TRACE_IRQS_OFF
Michael Holzheu0de9db32012-05-09 16:27:35 +0200975 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100976 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky1f44a2252013-06-27 09:01:09 +0200977 lghi %r3,EXT_INTERRUPT
978 brasl %r14,do_IRQ
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100979 j .Lio_return
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100980ENDPROC(ext_int_handler)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700981
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400982/*
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100983 * Load idle PSW. The second "half" of this function is in .Lcleanup_idle.
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400984 */
985ENTRY(psw_idle)
Martin Schwidefsky27f6b412012-07-20 11:15:08 +0200986 stg %r3,__SF_EMPTY(%r15)
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100987 larl %r1,.Lpsw_idle_lpsw+4
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400988 stg %r1,__SF_EMPTY+8(%r15)
Martin Schwidefsky72d38b12015-09-18 16:41:36 +0200989#ifdef CONFIG_SMP
990 larl %r1,smp_cpu_mtid
991 llgf %r1,0(%r1)
992 ltgr %r1,%r1
993 jz .Lpsw_idle_stcctm
994 .insn rsy,0xeb0000000017,%r1,5,__SF_EMPTY+16(%r15)
995.Lpsw_idle_stcctm:
996#endif
Martin Schwidefsky419123f2015-11-19 11:09:45 +0100997 oi __LC_CPU_FLAGS+7,_CIF_ENABLED_WAIT
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100998 BPON
Martin Schwidefsky27f6b412012-07-20 11:15:08 +0200999 STCK __CLOCK_IDLE_ENTER(%r2)
1000 stpt __TIMER_IDLE_ENTER(%r2)
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001001.Lpsw_idle_lpsw:
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001002 lpswe __SF_EMPTY(%r15)
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +02001003 BR_EX %r14
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001004.Lpsw_idle_end:
Martin Schwidefsky26a374a2019-01-17 10:02:22 +01001005ENDPROC(psw_idle)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001006
Hendrik Bruecknerb5510d92015-09-29 10:04:41 +02001007/*
1008 * Store floating-point controls and floating-point or vector register
1009 * depending whether the vector facility is available. A critical section
1010 * cleanup assures that the registers are stored even if interrupted for
1011 * some other work. The CIF_FPU flag is set to trigger a lazy restore
1012 * of the register contents at return from io or a system call.
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001013 */
1014ENTRY(save_fpu_regs)
Hendrik Bruecknerd0164ee2015-06-29 16:43:06 +02001015 lg %r2,__LC_CURRENT
1016 aghi %r2,__TASK_thread
Hendrik Brueckner83abeff2015-10-01 17:02:48 +02001017 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +01001018 jo .Lsave_fpu_regs_exit
Hendrik Bruecknerd0164ee2015-06-29 16:43:06 +02001019 stfpc __THREAD_FPU_fpc(%r2)
Hendrik Bruecknerd0164ee2015-06-29 16:43:06 +02001020 lg %r3,__THREAD_FPU_regs(%r2)
Hendrik Brueckner83abeff2015-10-01 17:02:48 +02001021 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001022 jz .Lsave_fpu_regs_fp # no -> store FP regs
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001023 VSTM %v0,%v15,0,%r3 # vstm 0,15,0(3)
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001024 VSTM %v16,%v31,256,%r3 # vstm 16,31,256(3)
1025 j .Lsave_fpu_regs_done # -> set CIF_FPU flag
1026.Lsave_fpu_regs_fp:
1027 std 0,0(%r3)
1028 std 1,8(%r3)
1029 std 2,16(%r3)
1030 std 3,24(%r3)
1031 std 4,32(%r3)
1032 std 5,40(%r3)
1033 std 6,48(%r3)
1034 std 7,56(%r3)
1035 std 8,64(%r3)
1036 std 9,72(%r3)
1037 std 10,80(%r3)
1038 std 11,88(%r3)
1039 std 12,96(%r3)
1040 std 13,104(%r3)
1041 std 14,112(%r3)
1042 std 15,120(%r3)
1043.Lsave_fpu_regs_done:
1044 oi __LC_CPU_FLAGS+7,_CIF_FPU
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +01001045.Lsave_fpu_regs_exit:
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +02001046 BR_EX %r14
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001047.Lsave_fpu_regs_end:
Martin Schwidefsky26a374a2019-01-17 10:02:22 +01001048ENDPROC(save_fpu_regs)
Al Viro711f5df2016-01-12 13:30:03 -05001049EXPORT_SYMBOL(save_fpu_regs)
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001050
Hendrik Bruecknerb5510d92015-09-29 10:04:41 +02001051/*
1052 * Load floating-point controls and floating-point or vector registers.
1053 * A critical section cleanup assures that the register contents are
1054 * loaded even if interrupted for some other work.
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001055 *
1056 * There are special calling conventions to fit into sysc and io return work:
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001057 * %r15: <kernel stack>
1058 * The function requires:
Hendrik Bruecknerb5510d92015-09-29 10:04:41 +02001059 * %r4
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001060 */
1061load_fpu_regs:
Hendrik Bruecknerd0164ee2015-06-29 16:43:06 +02001062 lg %r4,__LC_CURRENT
1063 aghi %r4,__TASK_thread
Hendrik Brueckner83abeff2015-10-01 17:02:48 +02001064 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +01001065 jno .Lload_fpu_regs_exit
Hendrik Bruecknerd0164ee2015-06-29 16:43:06 +02001066 lfpc __THREAD_FPU_fpc(%r4)
Hendrik Brueckner83abeff2015-10-01 17:02:48 +02001067 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
Hendrik Bruecknerd0164ee2015-06-29 16:43:06 +02001068 lg %r4,__THREAD_FPU_regs(%r4) # %r4 <- reg save area
Hendrik Bruecknerb5510d92015-09-29 10:04:41 +02001069 jz .Lload_fpu_regs_fp # -> no VX, load FP regs
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001070 VLM %v0,%v15,0,%r4
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001071 VLM %v16,%v31,256,%r4
1072 j .Lload_fpu_regs_done
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001073.Lload_fpu_regs_fp:
1074 ld 0,0(%r4)
1075 ld 1,8(%r4)
1076 ld 2,16(%r4)
1077 ld 3,24(%r4)
1078 ld 4,32(%r4)
1079 ld 5,40(%r4)
1080 ld 6,48(%r4)
1081 ld 7,56(%r4)
1082 ld 8,64(%r4)
1083 ld 9,72(%r4)
1084 ld 10,80(%r4)
1085 ld 11,88(%r4)
1086 ld 12,96(%r4)
1087 ld 13,104(%r4)
1088 ld 14,112(%r4)
1089 ld 15,120(%r4)
1090.Lload_fpu_regs_done:
1091 ni __LC_CPU_FLAGS+7,255-_CIF_FPU
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +01001092.Lload_fpu_regs_exit:
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +02001093 BR_EX %r14
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001094.Lload_fpu_regs_end:
Martin Schwidefsky26a374a2019-01-17 10:02:22 +01001095ENDPROC(load_fpu_regs)
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001096
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001097.L__critical_end:
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001098
Linus Torvalds1da177e2005-04-16 15:20:36 -07001099/*
1100 * Machine check handler routines
1101 */
Jan Glauber144d6342011-07-24 10:48:19 +02001102ENTRY(mcck_int_handler)
Heiko Carstens473e66b2012-05-09 16:27:39 +02001103 STCK __LC_MCCK_CLOCK
Martin Schwidefskyd768bd82018-01-16 07:11:45 +01001104 BPOFF
Martin Schwidefsky3037a522017-10-12 13:24:48 +02001105 la %r1,4095 # validate r1
1106 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # validate cpu timer
1107 sckc __LC_CLOCK_COMPARATOR # validate comparator
1108 lam %a0,%a15,__LC_AREGS_SAVE_AREA-4095(%r1) # validate acrs
1109 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# validate gprs
Heiko Carstensd5c352c2016-11-08 11:08:26 +01001110 lg %r12,__LC_CURRENT
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001111 larl %r13,cleanup_critical
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001112 lmg %r8,%r9,__LC_MCK_OLD_PSW
Hendrik Brueckner83abeff2015-10-01 17:02:48 +02001113 TSTMSK __LC_MCCK_CODE,MCCK_CODE_SYSTEM_DAMAGE
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001114 jo .Lmcck_panic # yes -> rest of mcck code invalid
Martin Schwidefsky3037a522017-10-12 13:24:48 +02001115 TSTMSK __LC_MCCK_CODE,MCCK_CODE_CR_VALID
1116 jno .Lmcck_panic # control registers invalid -> panic
1117 la %r14,4095
1118 lctlg %c0,%c15,__LC_CREGS_SAVE_AREA-4095(%r14) # validate ctl regs
1119 ptlb
Vasily Gorbik2a2d7bef2017-10-27 12:44:48 +02001120 lg %r11,__LC_MCESAD-4095(%r14) # extended machine check save area
Martin Schwidefsky3037a522017-10-12 13:24:48 +02001121 nill %r11,0xfc00 # MCESA_ORIGIN_MASK
1122 TSTMSK __LC_CREGS_SAVE_AREA+16-4095(%r14),CR2_GUARDED_STORAGE
1123 jno 0f
1124 TSTMSK __LC_MCCK_CODE,MCCK_CODE_GS_VALID
1125 jno 0f
1126 .insn rxy,0xe3000000004d,0,__MCESA_GS_SAVE_AREA(%r11) # LGSC
11270: l %r14,__LC_FP_CREG_SAVE_AREA-4095(%r14)
1128 TSTMSK __LC_MCCK_CODE,MCCK_CODE_FC_VALID
1129 jo 0f
1130 sr %r14,%r14
11310: sfpc %r14
1132 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
1133 jo 0f
1134 lghi %r14,__LC_FPREGS_SAVE_AREA
1135 ld %f0,0(%r14)
1136 ld %f1,8(%r14)
1137 ld %f2,16(%r14)
1138 ld %f3,24(%r14)
1139 ld %f4,32(%r14)
1140 ld %f5,40(%r14)
1141 ld %f6,48(%r14)
1142 ld %f7,56(%r14)
1143 ld %f8,64(%r14)
1144 ld %f9,72(%r14)
1145 ld %f10,80(%r14)
1146 ld %f11,88(%r14)
1147 ld %f12,96(%r14)
1148 ld %f13,104(%r14)
1149 ld %f14,112(%r14)
1150 ld %f15,120(%r14)
1151 j 1f
11520: VLM %v0,%v15,0,%r11
1153 VLM %v16,%v31,256,%r11
11541: lghi %r14,__LC_CPU_TIMER_SAVE_AREA
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001155 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
Hendrik Brueckner83abeff2015-10-01 17:02:48 +02001156 TSTMSK __LC_MCCK_CODE,MCCK_CODE_CPU_TIMER_VALID
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001157 jo 3f
Martin Schwidefsky63b12242006-06-29 14:58:05 +02001158 la %r14,__LC_SYNC_ENTER_TIMER
1159 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
1160 jl 0f
1161 la %r14,__LC_ASYNC_ENTER_TIMER
11620: clc 0(8,%r14),__LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001163 jl 1f
Martin Schwidefsky63b12242006-06-29 14:58:05 +02001164 la %r14,__LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +010011651: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
1166 jl 2f
Martin Schwidefsky63b12242006-06-29 14:58:05 +02001167 la %r14,__LC_LAST_UPDATE_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +010011682: spt 0(%r14)
Martin Schwidefsky63779812010-05-17 10:00:03 +02001169 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
Martin Schwidefsky3037a522017-10-12 13:24:48 +020011703: TSTMSK __LC_MCCK_CODE,MCCK_CODE_PSW_MWP_VALID
1171 jno .Lmcck_panic
1172 tmhh %r8,0x0001 # interrupting from user ?
1173 jnz 4f
1174 TSTMSK __LC_MCCK_CODE,MCCK_CODE_PSW_IA_VALID
1175 jno .Lmcck_panic
Martin Schwidefskyce3dc442017-09-12 16:37:33 +020011764: ssm __LC_PGM_NEW_PSW # turn dat on, keep irqs off
1177 SWITCH_ASYNC __LC_GPREGS_SAVE_AREA+64,__LC_MCCK_ENTER_TIMER
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001178.Lmcck_skip:
Martin Schwidefsky6551fbd2013-02-28 16:28:41 +01001179 lghi %r14,__LC_GPREGS_SAVE_AREA+64
1180 stmg %r0,%r7,__PT_R0(%r11)
Martin Schwidefsky7041d282018-01-16 13:27:30 +01001181 # clear user controlled registers to prevent speculative use
1182 xgr %r0,%r0
1183 xgr %r1,%r1
1184 xgr %r2,%r2
1185 xgr %r3,%r3
1186 xgr %r4,%r4
1187 xgr %r5,%r5
1188 xgr %r6,%r6
1189 xgr %r7,%r7
1190 xgr %r10,%r10
Martin Schwidefsky6551fbd2013-02-28 16:28:41 +01001191 mvc __PT_R8(64,%r11),0(%r14)
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001192 stmg %r8,%r9,__PT_PSW(%r11)
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +02001193 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001194 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
1195 lgr %r2,%r11 # pass pointer to pt_regs
Heiko Carstens77fa2242005-06-25 14:55:30 -07001196 brasl %r14,s390_do_machine_check
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001197 tm __PT_PSW+1(%r11),0x01 # returning to user ?
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001198 jno .Lmcck_return
Heiko Carstens77fa2242005-06-25 14:55:30 -07001199 lg %r1,__LC_KERNEL_STACK # switch to kernel stack
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001200 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
1201 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
1202 la %r11,STACK_FRAME_OVERHEAD(%r1)
Heiko Carstens77fa2242005-06-25 14:55:30 -07001203 lgr %r15,%r1
Hendrik Brueckner83abeff2015-10-01 17:02:48 +02001204 TSTMSK __LC_CPU_FLAGS,_CIF_MCCK_PENDING
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001205 jno .Lmcck_return
Heiko Carstens1f194a42006-07-03 00:24:46 -07001206 TRACE_IRQS_OFF
Heiko Carstens77fa2242005-06-25 14:55:30 -07001207 brasl %r14,s390_handle_mcck
Heiko Carstens1f194a42006-07-03 00:24:46 -07001208 TRACE_IRQS_ON
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001209.Lmcck_return:
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001210 lg %r14,__LC_VDSO_PER_CPU
1211 lmg %r0,%r10,__PT_R0(%r11)
1212 mvc __LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW
Martin Schwidefsky63b12242006-06-29 14:58:05 +02001213 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
1214 jno 0f
Martin Schwidefsky6b730442018-01-16 07:36:46 +01001215 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
Martin Schwidefsky63b12242006-06-29 14:58:05 +02001216 stpt __LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001217 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
12180: lmg %r11,%r15,__PT_R11(%r11)
1219 lpswe __LC_RETURN_MCCK_PSW
1220
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001221.Lmcck_panic:
Martin Schwidefskyce3dc442017-09-12 16:37:33 +02001222 lg %r15,__LC_NODAT_STACK
Martin Schwidefskyce4dda32016-12-02 13:29:22 +01001223 la %r11,STACK_FRAME_OVERHEAD(%r15)
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001224 j .Lmcck_skip
Martin Schwidefsky26a374a2019-01-17 10:02:22 +01001225ENDPROC(mcck_int_handler)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001226
Michael Holzheu7dd6b332011-08-03 16:44:19 +02001227#
1228# PSW restart interrupt handler
1229#
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -04001230ENTRY(restart_int_handler)
Martin Schwidefskye5b98192018-03-26 15:23:33 +02001231 ALTERNATIVE "", ".insn s,0xb2800000,_LPP_OFFSET", 40
1232 stg %r15,__LC_SAVE_AREA_RESTART
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -04001233 lg %r15,__LC_RESTART_STACK
Martin Schwidefskyce3dc442017-09-12 16:37:33 +02001234 xc STACK_FRAME_OVERHEAD(__PT_SIZE,%r15),STACK_FRAME_OVERHEAD(%r15)
1235 stmg %r0,%r14,STACK_FRAME_OVERHEAD+__PT_R0(%r15)
1236 mvc STACK_FRAME_OVERHEAD+__PT_R15(8,%r15),__LC_SAVE_AREA_RESTART
1237 mvc STACK_FRAME_OVERHEAD+__PT_PSW(16,%r15),__LC_RST_OLD_PSW
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -04001238 xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15)
Heiko Carstensfbe76562012-06-05 09:59:52 +02001239 lg %r1,__LC_RESTART_FN # load fn, parm & source cpu
1240 lg %r2,__LC_RESTART_DATA
1241 lg %r3,__LC_RESTART_SOURCE
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -04001242 ltgr %r3,%r3 # test source cpu address
1243 jm 1f # negative -> skip source stop
Heiko Carstenseb546192012-06-04 15:05:43 +020012440: sigp %r4,%r3,SIGP_SENSE # sigp sense to source cpu
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -04001245 brc 10,0b # wait for status stored
12461: basr %r14,%r1 # call function
1247 stap __SF_EMPTY(%r15) # store cpu address
1248 llgh %r3,__SF_EMPTY(%r15)
Heiko Carstenseb546192012-06-04 15:05:43 +020012492: sigp %r4,%r3,SIGP_STOP # sigp stop to current cpu
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -04001250 brc 2,2b
12513: j 3b
Martin Schwidefsky26a374a2019-01-17 10:02:22 +01001252ENDPROC(restart_int_handler)
Michael Holzheu7dd6b332011-08-03 16:44:19 +02001253
Martin Schwidefsky860dba42011-01-05 12:47:25 +01001254 .section .kprobes.text, "ax"
1255
Martin Schwidefskyce3dc442017-09-12 16:37:33 +02001256#if defined(CONFIG_CHECK_STACK) || defined(CONFIG_VMAP_STACK)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001257/*
1258 * The synchronous or the asynchronous stack overflowed. We are dead.
1259 * No need to properly save the registers, we are going to panic anyway.
1260 * Setup a pt_regs so that show_trace can provide a good call trace.
1261 */
Martin Schwidefsky26a374a2019-01-17 10:02:22 +01001262ENTRY(stack_overflow)
Martin Schwidefskyce3dc442017-09-12 16:37:33 +02001263 lg %r15,__LC_NODAT_STACK # change to panic stack
Martin Schwidefskydc7ee002013-04-24 10:20:43 +02001264 la %r11,STACK_FRAME_OVERHEAD(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001265 stmg %r0,%r7,__PT_R0(%r11)
1266 stmg %r8,%r9,__PT_PSW(%r11)
1267 mvc __PT_R8(64,%r11),0(%r14)
1268 stg %r10,__PT_ORIG_GPR2(%r11) # store last break to orig_gpr2
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001269 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
1270 lgr %r2,%r11 # pass pointer to pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -07001271 jg kernel_stack_overflow
Martin Schwidefsky26a374a2019-01-17 10:02:22 +01001272ENDPROC(stack_overflow)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001273#endif
1274
Martin Schwidefsky26a374a2019-01-17 10:02:22 +01001275ENTRY(cleanup_critical)
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +02001276#if IS_ENABLED(CONFIG_KVM)
1277 clg %r9,BASED(.Lcleanup_table_sie) # .Lsie_gmap
1278 jl 0f
1279 clg %r9,BASED(.Lcleanup_table_sie+8)# .Lsie_done
1280 jl .Lcleanup_sie
1281#endif
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001282 clg %r9,BASED(.Lcleanup_table) # system_call
Linus Torvalds1da177e2005-04-16 15:20:36 -07001283 jl 0f
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001284 clg %r9,BASED(.Lcleanup_table+8) # .Lsysc_do_svc
1285 jl .Lcleanup_system_call
1286 clg %r9,BASED(.Lcleanup_table+16) # .Lsysc_tif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001287 jl 0f
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001288 clg %r9,BASED(.Lcleanup_table+24) # .Lsysc_restore
1289 jl .Lcleanup_sysc_tif
1290 clg %r9,BASED(.Lcleanup_table+32) # .Lsysc_done
1291 jl .Lcleanup_sysc_restore
1292 clg %r9,BASED(.Lcleanup_table+40) # .Lio_tif
Martin Schwidefsky63b12242006-06-29 14:58:05 +02001293 jl 0f
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001294 clg %r9,BASED(.Lcleanup_table+48) # .Lio_restore
1295 jl .Lcleanup_io_tif
1296 clg %r9,BASED(.Lcleanup_table+56) # .Lio_done
1297 jl .Lcleanup_io_restore
1298 clg %r9,BASED(.Lcleanup_table+64) # psw_idle
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001299 jl 0f
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001300 clg %r9,BASED(.Lcleanup_table+72) # .Lpsw_idle_end
1301 jl .Lcleanup_idle
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001302 clg %r9,BASED(.Lcleanup_table+80) # save_fpu_regs
1303 jl 0f
1304 clg %r9,BASED(.Lcleanup_table+88) # .Lsave_fpu_regs_end
1305 jl .Lcleanup_save_fpu_regs
1306 clg %r9,BASED(.Lcleanup_table+96) # load_fpu_regs
1307 jl 0f
1308 clg %r9,BASED(.Lcleanup_table+104) # .Lload_fpu_regs_end
1309 jl .Lcleanup_load_fpu_regs
Christian Borntraeger891f6a722018-06-21 14:49:38 +020013100: BR_EX %r14,%r11
Martin Schwidefsky26a374a2019-01-17 10:02:22 +01001311ENDPROC(cleanup_critical)
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001312
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +02001313 .align 8
1314.Lcleanup_table:
1315 .quad system_call
1316 .quad .Lsysc_do_svc
1317 .quad .Lsysc_tif
1318 .quad .Lsysc_restore
1319 .quad .Lsysc_done
1320 .quad .Lio_tif
1321 .quad .Lio_restore
1322 .quad .Lio_done
1323 .quad psw_idle
1324 .quad .Lpsw_idle_end
1325 .quad save_fpu_regs
1326 .quad .Lsave_fpu_regs_end
1327 .quad load_fpu_regs
1328 .quad .Lload_fpu_regs_end
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +02001329
1330#if IS_ENABLED(CONFIG_KVM)
1331.Lcleanup_table_sie:
1332 .quad .Lsie_gmap
1333 .quad .Lsie_done
1334
1335.Lcleanup_sie:
QingFeng Haoc9295002017-06-07 11:30:42 +02001336 cghi %r11,__LC_SAVE_AREA_ASYNC #Is this in normal interrupt?
1337 je 1f
1338 slg %r9,BASED(.Lsie_crit_mcck_start)
1339 clg %r9,BASED(.Lsie_crit_mcck_length)
1340 jh 1f
1341 oi __LC_CPU_FLAGS+7, _CIF_MCCK_GUEST
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +010013421: BPENTER __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
1343 lg %r9,__SF_SIE_CONTROL(%r15) # get control block pointer
Christian Borntraegere22cf8c2015-10-06 18:06:15 +02001344 ni __SIE_PROG0C+3(%r9),0xfe # no longer in SIE
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +02001345 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
1346 larl %r9,sie_exit # skip forward to sie_exit
Christian Borntraeger891f6a722018-06-21 14:49:38 +02001347 BR_EX %r14,%r11
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +02001348#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001349
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001350.Lcleanup_system_call:
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001351 # check if stpt has been executed
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001352 clg %r9,BASED(.Lcleanup_system_call_insn)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001353 jh 0f
1354 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001355 cghi %r11,__LC_SAVE_AREA_ASYNC
Martin Schwidefsky63779812010-05-17 10:00:03 +02001356 je 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001357 mvc __LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER
13580: # check if stmg has been executed
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001359 clg %r9,BASED(.Lcleanup_system_call_insn+8)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001360 jh 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001361 mvc __LC_SAVE_AREA_SYNC(64),0(%r11)
13620: # check if base register setup + TIF bit load has been done
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001363 clg %r9,BASED(.Lcleanup_system_call_insn+16)
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001364 jhe 0f
Martin Schwidefsky34525e12017-01-25 12:54:17 +01001365 # set up saved register r12 task struct pointer
1366 stg %r12,32(%r11)
1367 # set up saved register r13 __TASK_thread offset
1368 mvc 40(8,%r11),BASED(.Lcleanup_system_call_const)
Martin Schwidefskyc5328902011-12-27 11:27:15 +010013690: # check if the user time update has been done
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001370 clg %r9,BASED(.Lcleanup_system_call_insn+24)
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001371 jh 0f
1372 lg %r15,__LC_EXIT_TIMER
1373 slg %r15,__LC_SYNC_ENTER_TIMER
1374 alg %r15,__LC_USER_TIMER
1375 stg %r15,__LC_USER_TIMER
13760: # check if the system time update has been done
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001377 clg %r9,BASED(.Lcleanup_system_call_insn+32)
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001378 jh 0f
1379 lg %r15,__LC_LAST_UPDATE_TIMER
1380 slg %r15,__LC_EXIT_TIMER
1381 alg %r15,__LC_SYSTEM_TIMER
1382 stg %r15,__LC_SYSTEM_TIMER
13830: # update accounting time stamp
Linus Torvalds1da177e2005-04-16 15:20:36 -07001384 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Martin Schwidefskyd5feec02018-02-22 13:42:29 +01001385 BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
Martin Schwidefsky34525e12017-01-25 12:54:17 +01001386 # set up saved register r11
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001387 lg %r15,__LC_KERNEL_STACK
Martin Schwidefskydc7ee002013-04-24 10:20:43 +02001388 la %r9,STACK_FRAME_OVERHEAD(%r15)
1389 stg %r9,24(%r11) # r11 pt_regs pointer
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001390 # fill pt_regs
Martin Schwidefskydc7ee002013-04-24 10:20:43 +02001391 mvc __PT_R8(64,%r9),__LC_SAVE_AREA_SYNC
1392 stmg %r0,%r7,__PT_R0(%r9)
1393 mvc __PT_PSW(16,%r9),__LC_SVC_OLD_PSW
1394 mvc __PT_INT_CODE(4,%r9),__LC_SVC_ILC
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +02001395 xc __PT_FLAGS(8,%r9),__PT_FLAGS(%r9)
1396 mvi __PT_FLAGS+7(%r9),_PIF_SYSCALL
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001397 # setup saved register r15
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001398 stg %r15,56(%r11) # r15 stack pointer
1399 # set new psw address and exit
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001400 larl %r9,.Lsysc_do_svc
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +02001401 BR_EX %r14,%r11
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001402.Lcleanup_system_call_insn:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001403 .quad system_call
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001404 .quad .Lsysc_stmg
1405 .quad .Lsysc_per
Martin Schwidefskya359bb12015-06-22 17:27:48 +02001406 .quad .Lsysc_vtime+36
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001407 .quad .Lsysc_vtime+42
Martin Schwidefsky34525e12017-01-25 12:54:17 +01001408.Lcleanup_system_call_const:
1409 .quad __TASK_thread
Linus Torvalds1da177e2005-04-16 15:20:36 -07001410
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001411.Lcleanup_sysc_tif:
1412 larl %r9,.Lsysc_tif
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +02001413 BR_EX %r14,%r11
Linus Torvalds1da177e2005-04-16 15:20:36 -07001414
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001415.Lcleanup_sysc_restore:
Martin Schwidefsky07a63cb2017-05-02 13:36:00 +02001416 # check if stpt has been executed
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001417 clg %r9,BASED(.Lcleanup_sysc_restore_insn)
Martin Schwidefsky07a63cb2017-05-02 13:36:00 +02001418 jh 0f
1419 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
1420 cghi %r11,__LC_SAVE_AREA_ASYNC
Martin Schwidefsky63779812010-05-17 10:00:03 +02001421 je 0f
Martin Schwidefsky07a63cb2017-05-02 13:36:00 +02001422 mvc __LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
14230: clg %r9,BASED(.Lcleanup_sysc_restore_insn+8)
1424 je 1f
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001425 lg %r9,24(%r11) # get saved pointer to pt_regs
1426 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
1427 mvc 0(64,%r11),__PT_R8(%r9)
1428 lmg %r0,%r7,__PT_R0(%r9)
Martin Schwidefsky07a63cb2017-05-02 13:36:00 +020014291: lmg %r8,%r9,__LC_RETURN_PSW
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +02001430 BR_EX %r14,%r11
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001431.Lcleanup_sysc_restore_insn:
Martin Schwidefsky07a63cb2017-05-02 13:36:00 +02001432 .quad .Lsysc_exit_timer
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001433 .quad .Lsysc_done - 4
Linus Torvalds1da177e2005-04-16 15:20:36 -07001434
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001435.Lcleanup_io_tif:
1436 larl %r9,.Lio_tif
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +02001437 BR_EX %r14,%r11
Martin Schwidefsky176b1802010-04-09 13:43:00 +02001438
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001439.Lcleanup_io_restore:
Martin Schwidefsky07a63cb2017-05-02 13:36:00 +02001440 # check if stpt has been executed
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001441 clg %r9,BASED(.Lcleanup_io_restore_insn)
Martin Schwidefsky07a63cb2017-05-02 13:36:00 +02001442 jh 0f
1443 mvc __LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
14440: clg %r9,BASED(.Lcleanup_io_restore_insn+8)
1445 je 1f
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001446 lg %r9,24(%r11) # get saved r11 pointer to pt_regs
1447 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001448 mvc 0(64,%r11),__PT_R8(%r9)
1449 lmg %r0,%r7,__PT_R0(%r9)
Martin Schwidefsky07a63cb2017-05-02 13:36:00 +020014501: lmg %r8,%r9,__LC_RETURN_PSW
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +02001451 BR_EX %r14,%r11
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001452.Lcleanup_io_restore_insn:
Martin Schwidefsky07a63cb2017-05-02 13:36:00 +02001453 .quad .Lio_exit_timer
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001454 .quad .Lio_done - 4
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001455
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001456.Lcleanup_idle:
Martin Schwidefsky419123f2015-11-19 11:09:45 +01001457 ni __LC_CPU_FLAGS+7,255-_CIF_ENABLED_WAIT
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001458 # copy interrupt clock & cpu timer
Martin Schwidefsky27f6b412012-07-20 11:15:08 +02001459 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_INT_CLOCK
1460 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_ASYNC_ENTER_TIMER
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001461 cghi %r11,__LC_SAVE_AREA_ASYNC
1462 je 0f
Martin Schwidefsky27f6b412012-07-20 11:15:08 +02001463 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_MCCK_CLOCK
1464 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_MCCK_ENTER_TIMER
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -040014650: # check if stck & stpt have been executed
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001466 clg %r9,BASED(.Lcleanup_idle_insn)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001467 jhe 1f
Martin Schwidefsky27f6b412012-07-20 11:15:08 +02001468 mvc __CLOCK_IDLE_ENTER(8,%r2),__CLOCK_IDLE_EXIT(%r2)
1469 mvc __TIMER_IDLE_ENTER(8,%r2),__TIMER_IDLE_EXIT(%r2)
Martin Schwidefsky72d38b12015-09-18 16:41:36 +020014701: # calculate idle cycles
1471#ifdef CONFIG_SMP
1472 clg %r9,BASED(.Lcleanup_idle_insn)
1473 jl 3f
1474 larl %r1,smp_cpu_mtid
1475 llgf %r1,0(%r1)
1476 ltgr %r1,%r1
1477 jz 3f
1478 .insn rsy,0xeb0000000017,%r1,5,__SF_EMPTY+80(%r15)
1479 larl %r3,mt_cycles
1480 ag %r3,__LC_PERCPU_OFFSET
1481 la %r4,__SF_EMPTY+16(%r15)
14822: lg %r0,0(%r3)
1483 slg %r0,0(%r4)
1484 alg %r0,64(%r4)
1485 stg %r0,0(%r3)
1486 la %r3,8(%r3)
1487 la %r4,8(%r4)
1488 brct %r1,2b
1489#endif
14903: # account system time going idle
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001491 lg %r9,__LC_STEAL_TIMER
Martin Schwidefsky27f6b412012-07-20 11:15:08 +02001492 alg %r9,__CLOCK_IDLE_ENTER(%r2)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001493 slg %r9,__LC_LAST_UPDATE_CLOCK
1494 stg %r9,__LC_STEAL_TIMER
Martin Schwidefsky27f6b412012-07-20 11:15:08 +02001495 mvc __LC_LAST_UPDATE_CLOCK(8),__CLOCK_IDLE_EXIT(%r2)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001496 lg %r9,__LC_SYSTEM_TIMER
1497 alg %r9,__LC_LAST_UPDATE_TIMER
Martin Schwidefsky27f6b412012-07-20 11:15:08 +02001498 slg %r9,__TIMER_IDLE_ENTER(%r2)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001499 stg %r9,__LC_SYSTEM_TIMER
Martin Schwidefsky27f6b412012-07-20 11:15:08 +02001500 mvc __LC_LAST_UPDATE_TIMER(8),__TIMER_IDLE_EXIT(%r2)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001501 # prepare return psw
Martin Schwidefsky0587d402013-08-23 14:45:58 +02001502 nihh %r8,0xfcfd # clear irq & wait state bits
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001503 lg %r9,48(%r11) # return from psw_idle
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +02001504 BR_EX %r14,%r11
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001505.Lcleanup_idle_insn:
1506 .quad .Lpsw_idle_lpsw
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001507
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001508.Lcleanup_save_fpu_regs:
Martin Schwidefskye370e472016-03-10 09:52:55 +01001509 larl %r9,save_fpu_regs
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +02001510 BR_EX %r14,%r11
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001511
1512.Lcleanup_load_fpu_regs:
Martin Schwidefskye370e472016-03-10 09:52:55 +01001513 larl %r9,load_fpu_regs
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +02001514 BR_EX %r14,%r11
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001515
Linus Torvalds1da177e2005-04-16 15:20:36 -07001516/*
1517 * Integer constants
1518 */
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001519 .align 8
Linus Torvalds1da177e2005-04-16 15:20:36 -07001520.Lcritical_start:
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001521 .quad .L__critical_start
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001522.Lcritical_length:
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001523 .quad .L__critical_end - .L__critical_start
Heiko Carstens61aa4882013-11-01 10:08:20 +01001524#if IS_ENABLED(CONFIG_KVM)
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +02001525.Lsie_critical_start:
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001526 .quad .Lsie_gmap
Martin Schwidefsky7c470532013-05-17 14:41:37 +02001527.Lsie_critical_length:
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001528 .quad .Lsie_done - .Lsie_gmap
QingFeng Haoc9295002017-06-07 11:30:42 +02001529.Lsie_crit_mcck_start:
1530 .quad .Lsie_entry
1531.Lsie_crit_mcck_length:
1532 .quad .Lsie_skip - .Lsie_entry
Martin Schwidefsky603d1a52011-07-24 10:48:18 +02001533#endif
Heiko Carstensa876cb32015-02-13 14:44:29 +01001534 .section .rodata, "a"
Gerald Schaeferff4a7422019-02-03 21:36:13 +01001535#define SYSCALL(esame,emu) .quad __s390x_ ## esame
Heiko Carstens9bf12262009-06-12 10:26:47 +02001536 .globl sys_call_table
Linus Torvalds1da177e2005-04-16 15:20:36 -07001537sys_call_table:
Hendrik Brueckner4381f9f2017-12-11 14:47:27 +01001538#include "asm/syscall_table.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -07001539#undef SYSCALL
1540
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -08001541#ifdef CONFIG_COMPAT
Linus Torvalds1da177e2005-04-16 15:20:36 -07001542
Gerald Schaeferff4a7422019-02-03 21:36:13 +01001543#define SYSCALL(esame,emu) .quad __s390_ ## emu
Martin Schwidefsky61649882013-04-24 12:58:39 +02001544 .globl sys_call_table_emu
Linus Torvalds1da177e2005-04-16 15:20:36 -07001545sys_call_table_emu:
Hendrik Brueckner4381f9f2017-12-11 14:47:27 +01001546#include "asm/syscall_table.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -07001547#undef SYSCALL
1548#endif