blob: 9b3aea98f886cbb5a2803ff3649f3d1b9ea6a364 [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
Martin Schwidefskye5b98192018-03-26 15:23:33 +020054_LPP_OFFSET = __LC_LPP
55
Martin Schwidefskyce3dc442017-09-12 16:37:33 +020056 .macro CHECK_STACK savearea
Martin Schwidefsky63b12242006-06-29 14:58:05 +020057#ifdef CONFIG_CHECK_STACK
Martin Schwidefskyce3dc442017-09-12 16:37:33 +020058 tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
Martin Schwidefskyc5328902011-12-27 11:27:15 +010059 lghi %r14,\savearea
60 jz stack_overflow
Martin Schwidefsky63b12242006-06-29 14:58:05 +020061#endif
Martin Schwidefsky63b12242006-06-29 14:58:05 +020062 .endm
63
Martin Schwidefskyce3dc442017-09-12 16:37:33 +020064 .macro CHECK_VMAP_STACK savearea,oklabel
65#ifdef CONFIG_VMAP_STACK
66 lgr %r14,%r15
67 nill %r14,0x10000 - STACK_SIZE
68 oill %r14,STACK_INIT
69 clg %r14,__LC_KERNEL_STACK
70 je \oklabel
71 clg %r14,__LC_ASYNC_STACK
72 je \oklabel
73 clg %r14,__LC_NODAT_STACK
74 je \oklabel
75 clg %r14,__LC_RESTART_STACK
76 je \oklabel
77 lghi %r14,\savearea
78 j stack_overflow
79#else
80 j \oklabel
81#endif
82 .endm
83
Sven Schnelle56e62a72020-11-21 11:14:56 +010084 .macro SWITCH_KERNEL savearea
Martin Schwidefskyc5328902011-12-27 11:27:15 +010085 tmhh %r8,0x0001 # interrupting from user ?
Sven Schnelle56e62a72020-11-21 11:14:56 +010086 jnz 1f
Sven Schnelle0b0ed652020-02-20 12:09:36 +010087#if IS_ENABLED(CONFIG_KVM)
Martin Schwidefskyc5328902011-12-27 11:27:15 +010088 lgr %r14,%r9
Sven Schnelle0b0ed652020-02-20 12:09:36 +010089 larl %r13,.Lsie_gmap
90 slgr %r14,%r13
91 lghi %r13,.Lsie_done - .Lsie_gmap
92 clgr %r14,%r13
93 jhe 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +010094 lghi %r11,\savearea # inside critical section, do cleanup
Sven Schnelle0b0ed652020-02-20 12:09:36 +010095 brasl %r14,.Lcleanup_sie
96#endif
Sven Schnelle56e62a72020-11-21 11:14:56 +0100970: CHECK_STACK \savearea
98 lgr %r11,%r15
Martin Schwidefskydc7ee002013-04-24 10:20:43 +020099 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
Sven Schnelle56e62a72020-11-21 11:14:56 +0100100 stg %r11,__SF_BACKCHAIN(%r15)
101 j 2f
1021: BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
103 lctlg %c1,%c1,__LC_KERNEL_ASCE
104 lg %r15,__LC_KERNEL_STACK
105 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
1062: la %r11,STACK_FRAME_OVERHEAD(%r15)
Sven Schnelle0b0ed652020-02-20 12:09:36 +0100107 .endm
108
Heiko Carstens78f65702021-02-02 13:46:47 +0100109 # Use STORE CLOCK by default, switch to STORE CLOCK FAST if available.
Heiko Carstens473e66b2012-05-09 16:27:39 +0200110 .macro STCK savearea
Heiko Carstens78f65702021-02-02 13:46:47 +0100111 ALTERNATIVE ".insn s,0xb2050000,\savearea", \
112 ".insn s,0xb27c0000,\savearea", 25
Heiko Carstens473e66b2012-05-09 16:27:39 +0200113 .endm
114
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200115 /*
116 * The TSTMSK macro generates a test-under-mask instruction by
117 * calculating the memory offset for the specified mask value.
118 * Mask value can be any constant. The macro shifts the mask
119 * value to calculate the memory offset for the test-under-mask
120 * instruction.
121 */
122 .macro TSTMSK addr, mask, size=8, bytepos=0
123 .if (\bytepos < \size) && (\mask >> 8)
124 .if (\mask & 0xff)
125 .error "Mask exceeds byte boundary"
126 .endif
127 TSTMSK \addr, "(\mask >> 8)", \size, "(\bytepos + 1)"
128 .exitm
129 .endif
130 .ifeq \mask
131 .error "Mask must not be zero"
132 .endif
133 off = \size - \bytepos - 1
134 tm off+\addr, \mask
135 .endm
136
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100137 .macro BPOFF
Martin Schwidefskyb0586612018-03-26 15:27:36 +0200138 ALTERNATIVE "", ".long 0xb2e8c000", 82
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100139 .endm
140
141 .macro BPON
Martin Schwidefskyb0586612018-03-26 15:27:36 +0200142 ALTERNATIVE "", ".long 0xb2e8d000", 82
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100143 .endm
144
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100145 .macro BPENTER tif_ptr,tif_mask
Martin Schwidefskyb0586612018-03-26 15:27:36 +0200146 ALTERNATIVE "TSTMSK \tif_ptr,\tif_mask; jz .+8; .long 0xb2e8d000", \
147 "", 82
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100148 .endm
149
150 .macro BPEXIT tif_ptr,tif_mask
151 TSTMSK \tif_ptr,\tif_mask
Martin Schwidefskyb0586612018-03-26 15:27:36 +0200152 ALTERNATIVE "jz .+8; .long 0xb2e8c000", \
153 "jnz .+8; .long 0xb2e8d000", 82
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100154 .endm
155
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200156 GEN_BR_THUNK %r14
157 GEN_BR_THUNK %r14,%r11
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +0100158
Martin Schwidefsky860dba42011-01-05 12:47:25 +0100159 .section .kprobes.text, "ax"
Heiko Carstens46210c42016-06-30 12:40:25 +0200160.Ldummy:
161 /*
Sven Schnelle56e62a72020-11-21 11:14:56 +0100162 * This nop exists only in order to avoid that __bpon starts at
Heiko Carstens46210c42016-06-30 12:40:25 +0200163 * the beginning of the kprobes text section. In that case we would
164 * have several symbols at the same address. E.g. objdump would take
165 * an arbitrary symbol name when disassembling this code.
Sven Schnelle56e62a72020-11-21 11:14:56 +0100166 * With the added nop in between the __bpon symbol is unique
Heiko Carstens46210c42016-06-30 12:40:25 +0200167 * again.
168 */
169 nop 0
Martin Schwidefsky860dba42011-01-05 12:47:25 +0100170
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100171ENTRY(__bpon)
172 .globl __bpon
173 BPON
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200174 BR_EX %r14
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100175ENDPROC(__bpon)
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100176
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177/*
178 * Scheduler resume function, called by switch_to
179 * gpr2 = (task_struct *) prev
180 * gpr3 = (task_struct *) next
181 * Returns:
182 * gpr2 = prev
183 */
Jan Glauber144d6342011-07-24 10:48:19 +0200184ENTRY(__switch_to)
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +0200185 stmg %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task
Heiko Carstens3241d3e2017-11-16 14:54:04 +0100186 lghi %r4,__TASK_stack
187 lghi %r1,__TASK_thread
Vasily Gorbik9fed9202018-10-26 15:29:59 +0200188 llill %r5,STACK_INIT
Heiko Carstens3241d3e2017-11-16 14:54:04 +0100189 stg %r15,__THREAD_ksp(%r1,%r2) # store kernel stack of prev
Vasily Gorbik9fed9202018-10-26 15:29:59 +0200190 lg %r15,0(%r4,%r3) # start of kernel stack of next
191 agr %r15,%r5 # end of kernel stack of next
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +0200192 stg %r3,__LC_CURRENT # store task struct of next
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +0200193 stg %r15,__LC_KERNEL_STACK # store end of kernel stack
Heiko Carstens3241d3e2017-11-16 14:54:04 +0100194 lg %r15,__THREAD_ksp(%r1,%r3) # load kernel stack of next
195 aghi %r3,__TASK_pid
196 mvc __LC_CURRENT_PID(4,%r0),0(%r3) # store pid of next
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200197 lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task
Martin Schwidefskye5b98192018-03-26 15:23:33 +0200198 ALTERNATIVE "", ".insn s,0xb2800000,_LPP_OFFSET", 40
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200199 BR_EX %r14
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100200ENDPROC(__switch_to)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200202#if IS_ENABLED(CONFIG_KVM)
203/*
204 * sie64a calling convention:
205 * %r2 pointer to sie control block
206 * %r3 guest register save area
207 */
208ENTRY(sie64a)
209 stmg %r6,%r14,__SF_GPRS(%r15) # save kernel registers
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100210 lg %r12,__LC_CURRENT
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100211 stg %r2,__SF_SIE_CONTROL(%r15) # save control block pointer
212 stg %r3,__SF_SIE_SAVEAREA(%r15) # save guest register save area
213 xc __SF_SIE_REASON(8,%r15),__SF_SIE_REASON(%r15) # reason code = 0
214 mvc __SF_SIE_FLAGS(8,%r15),__TI_flags(%r12) # copy thread flags
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200215 lmg %r0,%r13,0(%r3) # load guest gprs 0-13
216 lg %r14,__LC_GMAP # get gmap pointer
217 ltgr %r14,%r14
218 jz .Lsie_gmap
219 lctlg %c1,%c1,__GMAP_ASCE(%r14) # load primary asce
220.Lsie_gmap:
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100221 lg %r14,__SF_SIE_CONTROL(%r15) # get control block pointer
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200222 oi __SIE_PROG0C+3(%r14),1 # we are going into SIE now
223 tm __SIE_PROG20+3(%r14),3 # last exit...
224 jnz .Lsie_skip
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200225 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200226 jo .Lsie_skip # exit if fp/vx regs changed
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100227 BPEXIT __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
QingFeng Haoc9295002017-06-07 11:30:42 +0200228.Lsie_entry:
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200229 sie 0(%r14)
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100230 BPOFF
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100231 BPENTER __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200232.Lsie_skip:
233 ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE
Heiko Carstens87d59862020-11-16 08:06:40 +0100234 lctlg %c1,%c1,__LC_KERNEL_ASCE # load primary asce
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200235.Lsie_done:
236# some program checks are suppressing. C code (e.g. do_protection_exception)
Christian Borntraegerc0e7bb32017-05-15 14:11:03 +0200237# will rewind the PSW by the ILC, which is often 4 bytes in case of SIE. There
238# are some corner cases (e.g. runtime instrumentation) where ILC is unpredictable.
239# Other instructions between sie64a and .Lsie_done should not cause program
240# interrupts. So lets use 3 nops as a landing pad for all possible rewinds.
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200241# See also .Lcleanup_sie
Christian Borntraegerc0e7bb32017-05-15 14:11:03 +0200242.Lrewind_pad6:
243 nopr 7
244.Lrewind_pad4:
245 nopr 7
246.Lrewind_pad2:
247 nopr 7
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200248 .globl sie_exit
249sie_exit:
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100250 lg %r14,__SF_SIE_SAVEAREA(%r15) # load guest register save area
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200251 stmg %r0,%r13,0(%r14) # save guest gprs 0-13
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100252 xgr %r0,%r0 # clear guest registers to
253 xgr %r1,%r1 # prevent speculative use
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100254 xgr %r3,%r3
255 xgr %r4,%r4
256 xgr %r5,%r5
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200257 lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100258 lg %r2,__SF_SIE_REASON(%r15) # return exit reason code
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200259 BR_EX %r14
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200260.Lsie_fault:
261 lghi %r14,-EFAULT
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100262 stg %r14,__SF_SIE_REASON(%r15) # set exit reason code
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200263 j sie_exit
264
Christian Borntraegerc0e7bb32017-05-15 14:11:03 +0200265 EX_TABLE(.Lrewind_pad6,.Lsie_fault)
266 EX_TABLE(.Lrewind_pad4,.Lsie_fault)
267 EX_TABLE(.Lrewind_pad2,.Lsie_fault)
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200268 EX_TABLE(sie_exit,.Lsie_fault)
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100269ENDPROC(sie64a)
Al Viro711f5df2016-01-12 13:30:03 -0500270EXPORT_SYMBOL(sie64a)
271EXPORT_SYMBOL(sie_exit)
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200272#endif
273
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274/*
275 * SVC interrupt handler routine. System calls are synchronous events and
Christian Borntraeger7b7735c2020-07-07 14:07:53 +0200276 * are entered with interrupts disabled.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 */
278
Jan Glauber144d6342011-07-24 10:48:19 +0200279ENTRY(system_call)
Sven Schnelle56e62a72020-11-21 11:14:56 +0100280 stpt __LC_SYS_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100281 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100282 BPOFF
Sven Schnelle56e62a72020-11-21 11:14:56 +0100283 lghi %r14,0
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100284.Lsysc_per:
Heiko Carstens87d59862020-11-16 08:06:40 +0100285 lctlg %c1,%c1,__LC_KERNEL_ASCE
Sven Schnelle56e62a72020-11-21 11:14:56 +0100286 lg %r12,__LC_CURRENT
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100287 lg %r15,__LC_KERNEL_STACK
Heiko Carstens93659652020-12-04 17:56:57 +0100288 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Sven Schnelle56e62a72020-11-21 11:14:56 +0100289 stmg %r0,%r7,STACK_FRAME_OVERHEAD+__PT_R0(%r15)
290 BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
Christian Borntraegerd3f46892018-03-05 19:18:47 +0000291 # clear user controlled register to prevent speculative use
292 xgr %r0,%r0
Sven Schnelle56e62a72020-11-21 11:14:56 +0100293 xgr %r1,%r1
294 xgr %r4,%r4
295 xgr %r5,%r5
296 xgr %r6,%r6
297 xgr %r7,%r7
298 xgr %r8,%r8
299 xgr %r9,%r9
300 xgr %r10,%r10
301 xgr %r11,%r11
302 la %r2,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs
303 lgr %r3,%r14
304 brasl %r14,__do_syscall
Heiko Carstens87d59862020-11-16 08:06:40 +0100305 lctlg %c1,%c1,__LC_USER_ASCE
Sven Schnelle56e62a72020-11-21 11:14:56 +0100306 mvc __LC_RETURN_PSW(16),STACK_FRAME_OVERHEAD+__PT_PSW(%r15)
307 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
308 lmg %r0,%r15,STACK_FRAME_OVERHEAD+__PT_R0(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100309 stpt __LC_EXIT_TIMER
Sven Schnelle0b0ed652020-02-20 12:09:36 +0100310 b __LC_RETURN_LPSWE
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100311ENDPROC(system_call)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312
313#
314# a new process exits the kernel with ret_from_fork
315#
Jan Glauber144d6342011-07-24 10:48:19 +0200316ENTRY(ret_from_fork)
Sven Schnelle56e62a72020-11-21 11:14:56 +0100317 lgr %r3,%r11
318 brasl %r14,__ret_from_fork
319 lctlg %c1,%c1,__LC_USER_ASCE
320 mvc __LC_RETURN_PSW(16),STACK_FRAME_OVERHEAD+__PT_PSW(%r15)
321 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
322 lmg %r0,%r15,STACK_FRAME_OVERHEAD+__PT_R0(%r15)
323 stpt __LC_EXIT_TIMER
324 b __LC_RETURN_LPSWE
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100325ENDPROC(ret_from_fork)
326
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327/*
328 * Program check handler routine
329 */
330
Jan Glauber144d6342011-07-24 10:48:19 +0200331ENTRY(pgm_check_handler)
Sven Schnelle56e62a72020-11-21 11:14:56 +0100332 stpt __LC_SYS_ENTER_TIMER
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100333 BPOFF
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100334 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
Sven Schnelle56e62a72020-11-21 11:14:56 +0100335 lg %r12,__LC_CURRENT
336 lghi %r10,0
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100337 lmg %r8,%r9,__LC_PGM_OLD_PSW
Heiko Carstens87d59862020-11-16 08:06:40 +0100338 tmhh %r8,0x0001 # coming from user space?
339 jno .Lpgm_skip_asce
340 lctlg %c1,%c1,__LC_KERNEL_ASCE
Sven Schnelle56e62a72020-11-21 11:14:56 +0100341 j 3f # -> fault in user space
Heiko Carstens87d59862020-11-16 08:06:40 +0100342.Lpgm_skip_asce:
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200343#if IS_ENABLED(CONFIG_KVM)
Martin Schwidefsky0a5e2ec2017-10-05 08:29:47 +0200344 # cleanup critical section for program checks in sie64a
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200345 lgr %r14,%r9
Sven Schnelle0b0ed652020-02-20 12:09:36 +0100346 larl %r13,.Lsie_gmap
347 slgr %r14,%r13
348 lghi %r13,.Lsie_done - .Lsie_gmap
349 clgr %r14,%r13
Sven Schnelle0b38b5e2020-01-22 13:38:22 +0100350 jhe 1f
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100351 lg %r14,__SF_SIE_CONTROL(%r15) # get control block pointer
Martin Schwidefsky0a5e2ec2017-10-05 08:29:47 +0200352 ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE
Heiko Carstens87d59862020-11-16 08:06:40 +0100353 lctlg %c1,%c1,__LC_KERNEL_ASCE # load primary asce
Martin Schwidefsky0a5e2ec2017-10-05 08:29:47 +0200354 larl %r9,sie_exit # skip forward to sie_exit
Sven Schnelle56e62a72020-11-21 11:14:56 +0100355 lghi %r10,_PIF_GUEST_FAULT
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200356#endif
Sven Schnelle0b38b5e2020-01-22 13:38:22 +01003571: tmhh %r8,0x4000 # PER bit set in old PSW ?
358 jnz 2f # -> enabled, can't be a double fault
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100359 tm __LC_PGM_ILC+3,0x80 # check for per exception
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100360 jnz .Lpgm_svcper # -> single stepped svc
Sven Schnelle0b38b5e2020-01-22 13:38:22 +01003612: CHECK_STACK __LC_SAVE_AREA_SYNC
Martin Schwidefskydc7ee002013-04-24 10:20:43 +0200362 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
Sven Schnelle56e62a72020-11-21 11:14:56 +0100363 # CHECK_VMAP_STACK branches to stack_overflow or 4f
364 CHECK_VMAP_STACK __LC_SAVE_AREA_SYNC,4f
3653: BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100366 lg %r15,__LC_KERNEL_STACK
Sven Schnelle56e62a72020-11-21 11:14:56 +01003674: la %r11,STACK_FRAME_OVERHEAD(%r15)
368 stg %r10,__PT_FLAGS(%r11)
369 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100370 stmg %r0,%r7,__PT_R0(%r11)
Sven Schnelle56e62a72020-11-21 11:14:56 +0100371 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
372 stmg %r8,%r9,__PT_PSW(%r11)
373
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100374 # clear user controlled registers to prevent speculative use
375 xgr %r0,%r0
376 xgr %r1,%r1
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100377 xgr %r3,%r3
378 xgr %r4,%r4
379 xgr %r5,%r5
380 xgr %r6,%r6
381 xgr %r7,%r7
Sven Schnelle56e62a72020-11-21 11:14:56 +0100382 lgr %r2,%r11
383 brasl %r14,__do_pgm_check
384 tmhh %r8,0x0001 # returning to user space?
385 jno .Lpgm_exit_kernel
386 lctlg %c1,%c1,__LC_USER_ASCE
387 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
Heiko Carstens0cd9b722020-11-11 18:46:26 +0100388 stpt __LC_EXIT_TIMER
Sven Schnelle56e62a72020-11-21 11:14:56 +0100389.Lpgm_exit_kernel:
390 mvc __LC_RETURN_PSW(16),STACK_FRAME_OVERHEAD+__PT_PSW(%r15)
391 lmg %r0,%r15,STACK_FRAME_OVERHEAD+__PT_R0(%r15)
Heiko Carstens0cd9b722020-11-11 18:46:26 +0100392 b __LC_RETURN_LPSWE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393
394#
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100395# single stepped system call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100397.Lpgm_svcper:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100398 mvc __LC_RETURN_PSW(8),__LC_SVC_NEW_PSW
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100399 larl %r14,.Lsysc_per
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100400 stg %r14,__LC_RETURN_PSW+8
Sven Schnelle56e62a72020-11-21 11:14:56 +0100401 lghi %r14,1
Sven Schnelle0b0ed652020-02-20 12:09:36 +0100402 lpswe __LC_RETURN_PSW # branch to .Lsysc_per
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100403ENDPROC(pgm_check_handler)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200404
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405/*
Sven Schnelle56e62a72020-11-21 11:14:56 +0100406 * Interrupt handler macro used for external and IO interrupts.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 */
Sven Schnelle56e62a72020-11-21 11:14:56 +0100408.macro INT_HANDLER name,lc_old_psw,handler
409ENTRY(\name)
Heiko Carstens473e66b2012-05-09 16:27:39 +0200410 STCK __LC_INT_CLOCK
Sven Schnelle56e62a72020-11-21 11:14:56 +0100411 stpt __LC_SYS_ENTER_TIMER
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100412 BPOFF
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100413 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100414 lg %r12,__LC_CURRENT
Sven Schnelle56e62a72020-11-21 11:14:56 +0100415 lmg %r8,%r9,\lc_old_psw
416 SWITCH_KERNEL __LC_SAVE_AREA_ASYNC
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100417 stmg %r0,%r7,__PT_R0(%r11)
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100418 # clear user controlled registers to prevent speculative use
419 xgr %r0,%r0
420 xgr %r1,%r1
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100421 xgr %r3,%r3
422 xgr %r4,%r4
423 xgr %r5,%r5
424 xgr %r6,%r6
425 xgr %r7,%r7
426 xgr %r10,%r10
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100427 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
428 stmg %r8,%r9,__PT_PSW(%r11)
Sven Schnelle56e62a72020-11-21 11:14:56 +0100429 tm %r8,0x0001 # coming from user space?
430 jno 1f
Heiko Carstens87d59862020-11-16 08:06:40 +0100431 lctlg %c1,%c1,__LC_KERNEL_ASCE
Sven Schnelle56e62a72020-11-21 11:14:56 +01004321: lgr %r2,%r11 # pass pointer to pt_regs
433 brasl %r14,\handler
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100434 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
Sven Schnelle56e62a72020-11-21 11:14:56 +0100435 tmhh %r8,0x0001 # returning to user ?
436 jno 2f
Heiko Carstens87d59862020-11-16 08:06:40 +0100437 lctlg %c1,%c1,__LC_USER_ASCE
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100438 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100439 stpt __LC_EXIT_TIMER
Sven Schnelle56e62a72020-11-21 11:14:56 +01004402: lmg %r0,%r15,__PT_R0(%r11)
Sven Schnelle0b0ed652020-02-20 12:09:36 +0100441 b __LC_RETURN_LPSWE
Sven Schnelle56e62a72020-11-21 11:14:56 +0100442ENDPROC(\name)
443.endm
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444
Sven Schnelle56e62a72020-11-21 11:14:56 +0100445INT_HANDLER ext_int_handler,__LC_EXT_OLD_PSW,do_ext_irq
446INT_HANDLER io_int_handler,__LC_IO_OLD_PSW,do_io_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400448/*
Sven Schnelle0b0ed652020-02-20 12:09:36 +0100449 * Load idle PSW.
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400450 */
451ENTRY(psw_idle)
Martin Schwidefsky27f6b412012-07-20 11:15:08 +0200452 stg %r3,__SF_EMPTY(%r15)
Sven Schnelle56e62a72020-11-21 11:14:56 +0100453 larl %r1,psw_idle_exit
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400454 stg %r1,__SF_EMPTY+8(%r15)
Martin Schwidefsky72d38b12015-09-18 16:41:36 +0200455 larl %r1,smp_cpu_mtid
456 llgf %r1,0(%r1)
457 ltgr %r1,%r1
458 jz .Lpsw_idle_stcctm
Sven Schnelle56e62a72020-11-21 11:14:56 +0100459 .insn rsy,0xeb0000000017,%r1,5,__MT_CYCLES_ENTER(%r2)
Martin Schwidefsky72d38b12015-09-18 16:41:36 +0200460.Lpsw_idle_stcctm:
Martin Schwidefsky419123f2015-11-19 11:09:45 +0100461 oi __LC_CPU_FLAGS+7,_CIF_ENABLED_WAIT
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100462 BPON
Martin Schwidefsky27f6b412012-07-20 11:15:08 +0200463 STCK __CLOCK_IDLE_ENTER(%r2)
464 stpt __TIMER_IDLE_ENTER(%r2)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400465 lpswe __SF_EMPTY(%r15)
Sven Schnelle56e62a72020-11-21 11:14:56 +0100466.globl psw_idle_exit
467psw_idle_exit:
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200468 BR_EX %r14
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100469ENDPROC(psw_idle)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400470
Hendrik Bruecknerb5510d92015-09-29 10:04:41 +0200471/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 * Machine check handler routines
473 */
Jan Glauber144d6342011-07-24 10:48:19 +0200474ENTRY(mcck_int_handler)
Heiko Carstens473e66b2012-05-09 16:27:39 +0200475 STCK __LC_MCCK_CLOCK
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100476 BPOFF
Martin Schwidefsky3037a522017-10-12 13:24:48 +0200477 la %r1,4095 # validate r1
478 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # validate cpu timer
479 sckc __LC_CLOCK_COMPARATOR # validate comparator
480 lam %a0,%a15,__LC_AREGS_SAVE_AREA-4095(%r1) # validate acrs
481 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# validate gprs
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100482 lg %r12,__LC_CURRENT
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100483 lmg %r8,%r9,__LC_MCK_OLD_PSW
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200484 TSTMSK __LC_MCCK_CODE,MCCK_CODE_SYSTEM_DAMAGE
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100485 jo .Lmcck_panic # yes -> rest of mcck code invalid
Martin Schwidefsky3037a522017-10-12 13:24:48 +0200486 TSTMSK __LC_MCCK_CODE,MCCK_CODE_CR_VALID
487 jno .Lmcck_panic # control registers invalid -> panic
488 la %r14,4095
489 lctlg %c0,%c15,__LC_CREGS_SAVE_AREA-4095(%r14) # validate ctl regs
490 ptlb
Vasily Gorbik2a2d7bef2017-10-27 12:44:48 +0200491 lg %r11,__LC_MCESAD-4095(%r14) # extended machine check save area
Martin Schwidefsky3037a522017-10-12 13:24:48 +0200492 nill %r11,0xfc00 # MCESA_ORIGIN_MASK
493 TSTMSK __LC_CREGS_SAVE_AREA+16-4095(%r14),CR2_GUARDED_STORAGE
494 jno 0f
495 TSTMSK __LC_MCCK_CODE,MCCK_CODE_GS_VALID
496 jno 0f
497 .insn rxy,0xe3000000004d,0,__MCESA_GS_SAVE_AREA(%r11) # LGSC
4980: l %r14,__LC_FP_CREG_SAVE_AREA-4095(%r14)
499 TSTMSK __LC_MCCK_CODE,MCCK_CODE_FC_VALID
500 jo 0f
501 sr %r14,%r14
5020: sfpc %r14
503 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
504 jo 0f
505 lghi %r14,__LC_FPREGS_SAVE_AREA
506 ld %f0,0(%r14)
507 ld %f1,8(%r14)
508 ld %f2,16(%r14)
509 ld %f3,24(%r14)
510 ld %f4,32(%r14)
511 ld %f5,40(%r14)
512 ld %f6,48(%r14)
513 ld %f7,56(%r14)
514 ld %f8,64(%r14)
515 ld %f9,72(%r14)
516 ld %f10,80(%r14)
517 ld %f11,88(%r14)
518 ld %f12,96(%r14)
519 ld %f13,104(%r14)
520 ld %f14,112(%r14)
521 ld %f15,120(%r14)
522 j 1f
5230: VLM %v0,%v15,0,%r11
524 VLM %v16,%v31,256,%r11
5251: lghi %r14,__LC_CPU_TIMER_SAVE_AREA
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100526 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200527 TSTMSK __LC_MCCK_CODE,MCCK_CODE_CPU_TIMER_VALID
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100528 jo 3f
Sven Schnelle56e62a72020-11-21 11:14:56 +0100529 la %r14,__LC_SYS_ENTER_TIMER
530 clc 0(8,%r14),__LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100531 jl 1f
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200532 la %r14,__LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +01005331: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
534 jl 2f
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200535 la %r14,__LC_LAST_UPDATE_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +01005362: spt 0(%r14)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200537 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
Martin Schwidefsky3037a522017-10-12 13:24:48 +02005383: TSTMSK __LC_MCCK_CODE,MCCK_CODE_PSW_MWP_VALID
539 jno .Lmcck_panic
540 tmhh %r8,0x0001 # interrupting from user ?
541 jnz 4f
542 TSTMSK __LC_MCCK_CODE,MCCK_CODE_PSW_IA_VALID
543 jno .Lmcck_panic
Martin Schwidefskyce3dc442017-09-12 16:37:33 +02005444: ssm __LC_PGM_NEW_PSW # turn dat on, keep irqs off
Sven Schnelle56e62a72020-11-21 11:14:56 +0100545 SWITCH_KERNEL __LC_GPREGS_SAVE_AREA+64
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100546.Lmcck_skip:
Martin Schwidefsky6551fbd2013-02-28 16:28:41 +0100547 lghi %r14,__LC_GPREGS_SAVE_AREA+64
548 stmg %r0,%r7,__PT_R0(%r11)
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100549 # clear user controlled registers to prevent speculative use
550 xgr %r0,%r0
551 xgr %r1,%r1
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100552 xgr %r3,%r3
553 xgr %r4,%r4
554 xgr %r5,%r5
555 xgr %r6,%r6
556 xgr %r7,%r7
557 xgr %r10,%r10
Martin Schwidefsky6551fbd2013-02-28 16:28:41 +0100558 mvc __PT_R8(64,%r11),0(%r14)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100559 stmg %r8,%r9,__PT_PSW(%r11)
Heiko Carstens87d59862020-11-16 08:06:40 +0100560 la %r14,4095
561 mvc __PT_CR1(8,%r11),__LC_CREGS_SAVE_AREA-4095+8(%r14)
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200562 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100563 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
564 lgr %r2,%r11 # pass pointer to pt_regs
Heiko Carstens77fa2242005-06-25 14:55:30 -0700565 brasl %r14,s390_do_machine_check
Sven Schnelle0b0ed652020-02-20 12:09:36 +0100566 cghi %r2,0
567 je .Lmcck_return
Heiko Carstens77fa2242005-06-25 14:55:30 -0700568 lg %r1,__LC_KERNEL_STACK # switch to kernel stack
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100569 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
570 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
571 la %r11,STACK_FRAME_OVERHEAD(%r1)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700572 lgr %r15,%r1
Heiko Carstens77fa2242005-06-25 14:55:30 -0700573 brasl %r14,s390_handle_mcck
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100574.Lmcck_return:
Heiko Carstens87d59862020-11-16 08:06:40 +0100575 lctlg %c1,%c1,__PT_CR1(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100576 lmg %r0,%r10,__PT_R0(%r11)
577 mvc __LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200578 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
579 jno 0f
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100580 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200581 stpt __LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +01005820: lmg %r11,%r15,__PT_R11(%r11)
Sven Schnelle0b38b5e2020-01-22 13:38:22 +0100583 b __LC_RETURN_MCCK_LPSWE
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100584
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100585.Lmcck_panic:
Martin Schwidefskyce3dc442017-09-12 16:37:33 +0200586 lg %r15,__LC_NODAT_STACK
Martin Schwidefskyce4dda32016-12-02 13:29:22 +0100587 la %r11,STACK_FRAME_OVERHEAD(%r15)
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100588 j .Lmcck_skip
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100589ENDPROC(mcck_int_handler)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590
Michael Holzheu7dd6b332011-08-03 16:44:19 +0200591#
592# PSW restart interrupt handler
593#
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400594ENTRY(restart_int_handler)
Martin Schwidefskye5b98192018-03-26 15:23:33 +0200595 ALTERNATIVE "", ".insn s,0xb2800000,_LPP_OFFSET", 40
596 stg %r15,__LC_SAVE_AREA_RESTART
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400597 lg %r15,__LC_RESTART_STACK
Martin Schwidefskyce3dc442017-09-12 16:37:33 +0200598 xc STACK_FRAME_OVERHEAD(__PT_SIZE,%r15),STACK_FRAME_OVERHEAD(%r15)
599 stmg %r0,%r14,STACK_FRAME_OVERHEAD+__PT_R0(%r15)
600 mvc STACK_FRAME_OVERHEAD+__PT_R15(8,%r15),__LC_SAVE_AREA_RESTART
601 mvc STACK_FRAME_OVERHEAD+__PT_PSW(16,%r15),__LC_RST_OLD_PSW
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400602 xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15)
Heiko Carstensfbe76562012-06-05 09:59:52 +0200603 lg %r1,__LC_RESTART_FN # load fn, parm & source cpu
604 lg %r2,__LC_RESTART_DATA
605 lg %r3,__LC_RESTART_SOURCE
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400606 ltgr %r3,%r3 # test source cpu address
607 jm 1f # negative -> skip source stop
Heiko Carstenseb546192012-06-04 15:05:43 +02006080: sigp %r4,%r3,SIGP_SENSE # sigp sense to source cpu
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400609 brc 10,0b # wait for status stored
6101: basr %r14,%r1 # call function
611 stap __SF_EMPTY(%r15) # store cpu address
612 llgh %r3,__SF_EMPTY(%r15)
Heiko Carstenseb546192012-06-04 15:05:43 +02006132: sigp %r4,%r3,SIGP_STOP # sigp stop to current cpu
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400614 brc 2,2b
6153: j 3b
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100616ENDPROC(restart_int_handler)
Michael Holzheu7dd6b332011-08-03 16:44:19 +0200617
Martin Schwidefsky860dba42011-01-05 12:47:25 +0100618 .section .kprobes.text, "ax"
619
Martin Schwidefskyce3dc442017-09-12 16:37:33 +0200620#if defined(CONFIG_CHECK_STACK) || defined(CONFIG_VMAP_STACK)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621/*
622 * The synchronous or the asynchronous stack overflowed. We are dead.
623 * No need to properly save the registers, we are going to panic anyway.
624 * Setup a pt_regs so that show_trace can provide a good call trace.
625 */
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100626ENTRY(stack_overflow)
Martin Schwidefskyce3dc442017-09-12 16:37:33 +0200627 lg %r15,__LC_NODAT_STACK # change to panic stack
Martin Schwidefskydc7ee002013-04-24 10:20:43 +0200628 la %r11,STACK_FRAME_OVERHEAD(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100629 stmg %r0,%r7,__PT_R0(%r11)
630 stmg %r8,%r9,__PT_PSW(%r11)
631 mvc __PT_R8(64,%r11),0(%r14)
632 stg %r10,__PT_ORIG_GPR2(%r11) # store last break to orig_gpr2
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100633 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
634 lgr %r2,%r11 # pass pointer to pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 jg kernel_stack_overflow
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100636ENDPROC(stack_overflow)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637#endif
638
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200639#if IS_ENABLED(CONFIG_KVM)
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200640.Lcleanup_sie:
Sven Schnelle0b0ed652020-02-20 12:09:36 +0100641 cghi %r11,__LC_SAVE_AREA_ASYNC #Is this in normal interrupt?
642 je 1f
643 larl %r13,.Lsie_entry
644 slgr %r9,%r13
645 larl %r13,.Lsie_skip
646 clgr %r9,%r13
647 jh 1f
648 oi __LC_CPU_FLAGS+7, _CIF_MCCK_GUEST
6491: BPENTER __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100650 lg %r9,__SF_SIE_CONTROL(%r15) # get control block pointer
Christian Borntraegere22cf8c2015-10-06 18:06:15 +0200651 ni __SIE_PROG0C+3(%r9),0xfe # no longer in SIE
Heiko Carstens87d59862020-11-16 08:06:40 +0100652 lctlg %c1,%c1,__LC_KERNEL_ASCE
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200653 larl %r9,sie_exit # skip forward to sie_exit
Christian Borntraeger891f6a722018-06-21 14:49:38 +0200654 BR_EX %r14,%r11
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200656#endif
Heiko Carstensa876cb32015-02-13 14:44:29 +0100657 .section .rodata, "a"
Gerald Schaeferff4a7422019-02-03 21:36:13 +0100658#define SYSCALL(esame,emu) .quad __s390x_ ## esame
Heiko Carstens9bf12262009-06-12 10:26:47 +0200659 .globl sys_call_table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660sys_call_table:
Hendrik Brueckner4381f9f2017-12-11 14:47:27 +0100661#include "asm/syscall_table.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662#undef SYSCALL
663
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800664#ifdef CONFIG_COMPAT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665
Gerald Schaeferff4a7422019-02-03 21:36:13 +0100666#define SYSCALL(esame,emu) .quad __s390_ ## emu
Martin Schwidefsky61649882013-04-24 12:58:39 +0200667 .globl sys_call_table_emu
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668sys_call_table_emu:
Hendrik Brueckner4381f9f2017-12-11 14:47:27 +0100669#include "asm/syscall_table.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670#undef SYSCALL
671#endif