blob: 12de7a9c85b3583b98559b9d0b31377e05fb8c8b [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
Sven Schnelleb61b1592021-02-03 09:02:51 +010073 clg %r14,__LC_MCCK_STACK
74 je \oklabel
Martin Schwidefskyce3dc442017-09-12 16:37:33 +020075 clg %r14,__LC_NODAT_STACK
76 je \oklabel
77 clg %r14,__LC_RESTART_STACK
78 je \oklabel
79 lghi %r14,\savearea
80 j stack_overflow
81#else
82 j \oklabel
83#endif
84 .endm
85
Heiko Carstens473e66b2012-05-09 16:27:39 +020086 .macro STCK savearea
Heiko Carstens78f65702021-02-02 13:46:47 +010087 ALTERNATIVE ".insn s,0xb2050000,\savearea", \
88 ".insn s,0xb27c0000,\savearea", 25
Heiko Carstens473e66b2012-05-09 16:27:39 +020089 .endm
90
Hendrik Brueckner83abeff2015-10-01 17:02:48 +020091 /*
92 * The TSTMSK macro generates a test-under-mask instruction by
93 * calculating the memory offset for the specified mask value.
94 * Mask value can be any constant. The macro shifts the mask
95 * value to calculate the memory offset for the test-under-mask
96 * instruction.
97 */
98 .macro TSTMSK addr, mask, size=8, bytepos=0
99 .if (\bytepos < \size) && (\mask >> 8)
100 .if (\mask & 0xff)
101 .error "Mask exceeds byte boundary"
102 .endif
103 TSTMSK \addr, "(\mask >> 8)", \size, "(\bytepos + 1)"
104 .exitm
105 .endif
106 .ifeq \mask
107 .error "Mask must not be zero"
108 .endif
109 off = \size - \bytepos - 1
110 tm off+\addr, \mask
111 .endm
112
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100113 .macro BPOFF
Martin Schwidefskyb0586612018-03-26 15:27:36 +0200114 ALTERNATIVE "", ".long 0xb2e8c000", 82
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100115 .endm
116
117 .macro BPON
Martin Schwidefskyb0586612018-03-26 15:27:36 +0200118 ALTERNATIVE "", ".long 0xb2e8d000", 82
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100119 .endm
120
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100121 .macro BPENTER tif_ptr,tif_mask
Martin Schwidefskyb0586612018-03-26 15:27:36 +0200122 ALTERNATIVE "TSTMSK \tif_ptr,\tif_mask; jz .+8; .long 0xb2e8d000", \
123 "", 82
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100124 .endm
125
126 .macro BPEXIT tif_ptr,tif_mask
127 TSTMSK \tif_ptr,\tif_mask
Martin Schwidefskyb0586612018-03-26 15:27:36 +0200128 ALTERNATIVE "jz .+8; .long 0xb2e8c000", \
129 "jnz .+8; .long 0xb2e8d000", 82
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100130 .endm
131
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200132 GEN_BR_THUNK %r14
Sven Schnelle33ea0482021-02-03 17:46:12 +0100133 GEN_BR_THUNK %r14,%r13
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +0100134
Martin Schwidefsky860dba42011-01-05 12:47:25 +0100135 .section .kprobes.text, "ax"
Heiko Carstens46210c42016-06-30 12:40:25 +0200136.Ldummy:
137 /*
Sven Schnelle56e62a72020-11-21 11:14:56 +0100138 * This nop exists only in order to avoid that __bpon starts at
Heiko Carstens46210c42016-06-30 12:40:25 +0200139 * the beginning of the kprobes text section. In that case we would
140 * have several symbols at the same address. E.g. objdump would take
141 * an arbitrary symbol name when disassembling this code.
Sven Schnelle56e62a72020-11-21 11:14:56 +0100142 * With the added nop in between the __bpon symbol is unique
Heiko Carstens46210c42016-06-30 12:40:25 +0200143 * again.
144 */
145 nop 0
Martin Schwidefsky860dba42011-01-05 12:47:25 +0100146
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100147ENTRY(__bpon)
148 .globl __bpon
149 BPON
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200150 BR_EX %r14
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100151ENDPROC(__bpon)
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100152
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153/*
154 * Scheduler resume function, called by switch_to
155 * gpr2 = (task_struct *) prev
156 * gpr3 = (task_struct *) next
157 * Returns:
158 * gpr2 = prev
159 */
Jan Glauber144d6342011-07-24 10:48:19 +0200160ENTRY(__switch_to)
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +0200161 stmg %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task
Heiko Carstens3241d3e2017-11-16 14:54:04 +0100162 lghi %r4,__TASK_stack
163 lghi %r1,__TASK_thread
Vasily Gorbik9fed9202018-10-26 15:29:59 +0200164 llill %r5,STACK_INIT
Heiko Carstens3241d3e2017-11-16 14:54:04 +0100165 stg %r15,__THREAD_ksp(%r1,%r2) # store kernel stack of prev
Vasily Gorbik9fed9202018-10-26 15:29:59 +0200166 lg %r15,0(%r4,%r3) # start of kernel stack of next
167 agr %r15,%r5 # end of kernel stack of next
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +0200168 stg %r3,__LC_CURRENT # store task struct of next
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +0200169 stg %r15,__LC_KERNEL_STACK # store end of kernel stack
Heiko Carstens3241d3e2017-11-16 14:54:04 +0100170 lg %r15,__THREAD_ksp(%r1,%r3) # load kernel stack of next
171 aghi %r3,__TASK_pid
172 mvc __LC_CURRENT_PID(4,%r0),0(%r3) # store pid of next
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200173 lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task
Martin Schwidefskye5b98192018-03-26 15:23:33 +0200174 ALTERNATIVE "", ".insn s,0xb2800000,_LPP_OFFSET", 40
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200175 BR_EX %r14
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100176ENDPROC(__switch_to)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200178#if IS_ENABLED(CONFIG_KVM)
179/*
180 * sie64a calling convention:
181 * %r2 pointer to sie control block
182 * %r3 guest register save area
183 */
184ENTRY(sie64a)
185 stmg %r6,%r14,__SF_GPRS(%r15) # save kernel registers
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100186 lg %r12,__LC_CURRENT
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100187 stg %r2,__SF_SIE_CONTROL(%r15) # save control block pointer
188 stg %r3,__SF_SIE_SAVEAREA(%r15) # save guest register save area
189 xc __SF_SIE_REASON(8,%r15),__SF_SIE_REASON(%r15) # reason code = 0
190 mvc __SF_SIE_FLAGS(8,%r15),__TI_flags(%r12) # copy thread flags
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200191 lmg %r0,%r13,0(%r3) # load guest gprs 0-13
192 lg %r14,__LC_GMAP # get gmap pointer
193 ltgr %r14,%r14
194 jz .Lsie_gmap
195 lctlg %c1,%c1,__GMAP_ASCE(%r14) # load primary asce
196.Lsie_gmap:
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100197 lg %r14,__SF_SIE_CONTROL(%r15) # get control block pointer
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200198 oi __SIE_PROG0C+3(%r14),1 # we are going into SIE now
199 tm __SIE_PROG20+3(%r14),3 # last exit...
200 jnz .Lsie_skip
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200201 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200202 jo .Lsie_skip # exit if fp/vx regs changed
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100203 BPEXIT __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
QingFeng Haoc9295002017-06-07 11:30:42 +0200204.Lsie_entry:
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200205 sie 0(%r14)
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100206 BPOFF
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100207 BPENTER __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200208.Lsie_skip:
209 ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE
Heiko Carstens87d59862020-11-16 08:06:40 +0100210 lctlg %c1,%c1,__LC_KERNEL_ASCE # load primary asce
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200211.Lsie_done:
212# some program checks are suppressing. C code (e.g. do_protection_exception)
Christian Borntraegerc0e7bb32017-05-15 14:11:03 +0200213# will rewind the PSW by the ILC, which is often 4 bytes in case of SIE. There
214# are some corner cases (e.g. runtime instrumentation) where ILC is unpredictable.
215# Other instructions between sie64a and .Lsie_done should not cause program
216# interrupts. So lets use 3 nops as a landing pad for all possible rewinds.
Sven Schnelleefa54732021-02-03 17:50:00 +0100217# See also .Lcleanup_sie_mcck/.Lcleanup_sie_int
Christian Borntraegerc0e7bb32017-05-15 14:11:03 +0200218.Lrewind_pad6:
219 nopr 7
220.Lrewind_pad4:
221 nopr 7
222.Lrewind_pad2:
223 nopr 7
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200224 .globl sie_exit
225sie_exit:
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100226 lg %r14,__SF_SIE_SAVEAREA(%r15) # load guest register save area
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200227 stmg %r0,%r13,0(%r14) # save guest gprs 0-13
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100228 xgr %r0,%r0 # clear guest registers to
229 xgr %r1,%r1 # prevent speculative use
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100230 xgr %r3,%r3
231 xgr %r4,%r4
232 xgr %r5,%r5
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200233 lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100234 lg %r2,__SF_SIE_REASON(%r15) # return exit reason code
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200235 BR_EX %r14
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200236.Lsie_fault:
237 lghi %r14,-EFAULT
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100238 stg %r14,__SF_SIE_REASON(%r15) # set exit reason code
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200239 j sie_exit
240
Christian Borntraegerc0e7bb32017-05-15 14:11:03 +0200241 EX_TABLE(.Lrewind_pad6,.Lsie_fault)
242 EX_TABLE(.Lrewind_pad4,.Lsie_fault)
243 EX_TABLE(.Lrewind_pad2,.Lsie_fault)
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200244 EX_TABLE(sie_exit,.Lsie_fault)
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100245ENDPROC(sie64a)
Al Viro711f5df2016-01-12 13:30:03 -0500246EXPORT_SYMBOL(sie64a)
247EXPORT_SYMBOL(sie_exit)
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200248#endif
249
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250/*
251 * SVC interrupt handler routine. System calls are synchronous events and
Christian Borntraeger7b7735c2020-07-07 14:07:53 +0200252 * are entered with interrupts disabled.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253 */
254
Jan Glauber144d6342011-07-24 10:48:19 +0200255ENTRY(system_call)
Sven Schnelle56e62a72020-11-21 11:14:56 +0100256 stpt __LC_SYS_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100257 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100258 BPOFF
Sven Schnelle56e62a72020-11-21 11:14:56 +0100259 lghi %r14,0
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100260.Lsysc_per:
Heiko Carstens87d59862020-11-16 08:06:40 +0100261 lctlg %c1,%c1,__LC_KERNEL_ASCE
Sven Schnelle56e62a72020-11-21 11:14:56 +0100262 lg %r12,__LC_CURRENT
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100263 lg %r15,__LC_KERNEL_STACK
Heiko Carstens93659652020-12-04 17:56:57 +0100264 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Sven Schnelle56e62a72020-11-21 11:14:56 +0100265 stmg %r0,%r7,STACK_FRAME_OVERHEAD+__PT_R0(%r15)
266 BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
Christian Borntraegerd3f46892018-03-05 19:18:47 +0000267 # clear user controlled register to prevent speculative use
268 xgr %r0,%r0
Sven Schnelle56e62a72020-11-21 11:14:56 +0100269 xgr %r1,%r1
270 xgr %r4,%r4
271 xgr %r5,%r5
272 xgr %r6,%r6
273 xgr %r7,%r7
274 xgr %r8,%r8
275 xgr %r9,%r9
276 xgr %r10,%r10
277 xgr %r11,%r11
278 la %r2,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs
279 lgr %r3,%r14
280 brasl %r14,__do_syscall
Heiko Carstens87d59862020-11-16 08:06:40 +0100281 lctlg %c1,%c1,__LC_USER_ASCE
Sven Schnelle56e62a72020-11-21 11:14:56 +0100282 mvc __LC_RETURN_PSW(16),STACK_FRAME_OVERHEAD+__PT_PSW(%r15)
283 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
284 lmg %r0,%r15,STACK_FRAME_OVERHEAD+__PT_R0(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100285 stpt __LC_EXIT_TIMER
Sven Schnelle0b0ed652020-02-20 12:09:36 +0100286 b __LC_RETURN_LPSWE
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100287ENDPROC(system_call)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288
289#
290# a new process exits the kernel with ret_from_fork
291#
Jan Glauber144d6342011-07-24 10:48:19 +0200292ENTRY(ret_from_fork)
Sven Schnelle56e62a72020-11-21 11:14:56 +0100293 lgr %r3,%r11
294 brasl %r14,__ret_from_fork
295 lctlg %c1,%c1,__LC_USER_ASCE
296 mvc __LC_RETURN_PSW(16),STACK_FRAME_OVERHEAD+__PT_PSW(%r15)
297 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
298 lmg %r0,%r15,STACK_FRAME_OVERHEAD+__PT_R0(%r15)
299 stpt __LC_EXIT_TIMER
300 b __LC_RETURN_LPSWE
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100301ENDPROC(ret_from_fork)
302
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303/*
304 * Program check handler routine
305 */
306
Jan Glauber144d6342011-07-24 10:48:19 +0200307ENTRY(pgm_check_handler)
Sven Schnelle56e62a72020-11-21 11:14:56 +0100308 stpt __LC_SYS_ENTER_TIMER
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100309 BPOFF
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100310 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
Sven Schnelle56e62a72020-11-21 11:14:56 +0100311 lg %r12,__LC_CURRENT
312 lghi %r10,0
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100313 lmg %r8,%r9,__LC_PGM_OLD_PSW
Heiko Carstens87d59862020-11-16 08:06:40 +0100314 tmhh %r8,0x0001 # coming from user space?
315 jno .Lpgm_skip_asce
316 lctlg %c1,%c1,__LC_KERNEL_ASCE
Sven Schnelle56e62a72020-11-21 11:14:56 +0100317 j 3f # -> fault in user space
Heiko Carstens87d59862020-11-16 08:06:40 +0100318.Lpgm_skip_asce:
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200319#if IS_ENABLED(CONFIG_KVM)
Martin Schwidefsky0a5e2ec2017-10-05 08:29:47 +0200320 # cleanup critical section for program checks in sie64a
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200321 lgr %r14,%r9
Sven Schnelle0b0ed652020-02-20 12:09:36 +0100322 larl %r13,.Lsie_gmap
323 slgr %r14,%r13
324 lghi %r13,.Lsie_done - .Lsie_gmap
325 clgr %r14,%r13
Sven Schnelle0b38b5e2020-01-22 13:38:22 +0100326 jhe 1f
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100327 lg %r14,__SF_SIE_CONTROL(%r15) # get control block pointer
Martin Schwidefsky0a5e2ec2017-10-05 08:29:47 +0200328 ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE
Heiko Carstens87d59862020-11-16 08:06:40 +0100329 lctlg %c1,%c1,__LC_KERNEL_ASCE # load primary asce
Martin Schwidefsky0a5e2ec2017-10-05 08:29:47 +0200330 larl %r9,sie_exit # skip forward to sie_exit
Sven Schnelle56e62a72020-11-21 11:14:56 +0100331 lghi %r10,_PIF_GUEST_FAULT
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200332#endif
Sven Schnelle0b38b5e2020-01-22 13:38:22 +01003331: tmhh %r8,0x4000 # PER bit set in old PSW ?
334 jnz 2f # -> enabled, can't be a double fault
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100335 tm __LC_PGM_ILC+3,0x80 # check for per exception
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100336 jnz .Lpgm_svcper # -> single stepped svc
Sven Schnelle0b38b5e2020-01-22 13:38:22 +01003372: CHECK_STACK __LC_SAVE_AREA_SYNC
Martin Schwidefskydc7ee002013-04-24 10:20:43 +0200338 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
Sven Schnelle56e62a72020-11-21 11:14:56 +0100339 # CHECK_VMAP_STACK branches to stack_overflow or 4f
340 CHECK_VMAP_STACK __LC_SAVE_AREA_SYNC,4f
3413: BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100342 lg %r15,__LC_KERNEL_STACK
Sven Schnelle56e62a72020-11-21 11:14:56 +01003434: la %r11,STACK_FRAME_OVERHEAD(%r15)
344 stg %r10,__PT_FLAGS(%r11)
345 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100346 stmg %r0,%r7,__PT_R0(%r11)
Sven Schnelle56e62a72020-11-21 11:14:56 +0100347 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
348 stmg %r8,%r9,__PT_PSW(%r11)
349
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100350 # clear user controlled registers to prevent speculative use
351 xgr %r0,%r0
352 xgr %r1,%r1
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100353 xgr %r3,%r3
354 xgr %r4,%r4
355 xgr %r5,%r5
356 xgr %r6,%r6
357 xgr %r7,%r7
Sven Schnelle56e62a72020-11-21 11:14:56 +0100358 lgr %r2,%r11
359 brasl %r14,__do_pgm_check
360 tmhh %r8,0x0001 # returning to user space?
361 jno .Lpgm_exit_kernel
362 lctlg %c1,%c1,__LC_USER_ASCE
363 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
Heiko Carstens0cd9b722020-11-11 18:46:26 +0100364 stpt __LC_EXIT_TIMER
Sven Schnelle56e62a72020-11-21 11:14:56 +0100365.Lpgm_exit_kernel:
366 mvc __LC_RETURN_PSW(16),STACK_FRAME_OVERHEAD+__PT_PSW(%r15)
367 lmg %r0,%r15,STACK_FRAME_OVERHEAD+__PT_R0(%r15)
Heiko Carstens0cd9b722020-11-11 18:46:26 +0100368 b __LC_RETURN_LPSWE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369
370#
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100371# single stepped system call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100373.Lpgm_svcper:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100374 mvc __LC_RETURN_PSW(8),__LC_SVC_NEW_PSW
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100375 larl %r14,.Lsysc_per
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100376 stg %r14,__LC_RETURN_PSW+8
Sven Schnelle56e62a72020-11-21 11:14:56 +0100377 lghi %r14,1
Sven Schnelle0b0ed652020-02-20 12:09:36 +0100378 lpswe __LC_RETURN_PSW # branch to .Lsysc_per
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100379ENDPROC(pgm_check_handler)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200380
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381/*
Sven Schnelle56e62a72020-11-21 11:14:56 +0100382 * Interrupt handler macro used for external and IO interrupts.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383 */
Sven Schnelle56e62a72020-11-21 11:14:56 +0100384.macro INT_HANDLER name,lc_old_psw,handler
385ENTRY(\name)
Heiko Carstens473e66b2012-05-09 16:27:39 +0200386 STCK __LC_INT_CLOCK
Sven Schnelle56e62a72020-11-21 11:14:56 +0100387 stpt __LC_SYS_ENTER_TIMER
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100388 BPOFF
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100389 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100390 lg %r12,__LC_CURRENT
Sven Schnelle56e62a72020-11-21 11:14:56 +0100391 lmg %r8,%r9,\lc_old_psw
Sven Schnelleb0d31152021-01-28 13:06:05 +0100392 tmhh %r8,0x0001 # interrupting from user ?
393 jnz 1f
394#if IS_ENABLED(CONFIG_KVM)
395 lgr %r14,%r9
396 larl %r13,.Lsie_gmap
397 slgr %r14,%r13
398 lghi %r13,.Lsie_done - .Lsie_gmap
399 clgr %r14,%r13
400 jhe 0f
Sven Schnelleefa54732021-02-03 17:50:00 +0100401 brasl %r14,.Lcleanup_sie_int
Sven Schnelleb0d31152021-01-28 13:06:05 +0100402#endif
4030: CHECK_STACK __LC_SAVE_AREA_ASYNC
Sven Schnelleb0d31152021-01-28 13:06:05 +0100404 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
Sven Schnelleb0d31152021-01-28 13:06:05 +0100405 j 2f
4061: BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
407 lctlg %c1,%c1,__LC_KERNEL_ASCE
408 lg %r15,__LC_KERNEL_STACK
Vasily Gorbikb74e4092021-04-09 00:13:18 +02004092: xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
410 la %r11,STACK_FRAME_OVERHEAD(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100411 stmg %r0,%r7,__PT_R0(%r11)
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100412 # clear user controlled registers to prevent speculative use
413 xgr %r0,%r0
414 xgr %r1,%r1
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100415 xgr %r3,%r3
416 xgr %r4,%r4
417 xgr %r5,%r5
418 xgr %r6,%r6
419 xgr %r7,%r7
420 xgr %r10,%r10
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100421 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
422 stmg %r8,%r9,__PT_PSW(%r11)
Sven Schnelle56e62a72020-11-21 11:14:56 +0100423 tm %r8,0x0001 # coming from user space?
424 jno 1f
Heiko Carstens87d59862020-11-16 08:06:40 +0100425 lctlg %c1,%c1,__LC_KERNEL_ASCE
Sven Schnelle56e62a72020-11-21 11:14:56 +01004261: lgr %r2,%r11 # pass pointer to pt_regs
427 brasl %r14,\handler
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100428 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
Sven Schnelle56e62a72020-11-21 11:14:56 +0100429 tmhh %r8,0x0001 # returning to user ?
430 jno 2f
Heiko Carstens87d59862020-11-16 08:06:40 +0100431 lctlg %c1,%c1,__LC_USER_ASCE
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100432 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100433 stpt __LC_EXIT_TIMER
Sven Schnelle56e62a72020-11-21 11:14:56 +01004342: lmg %r0,%r15,__PT_R0(%r11)
Sven Schnelle0b0ed652020-02-20 12:09:36 +0100435 b __LC_RETURN_LPSWE
Sven Schnelle56e62a72020-11-21 11:14:56 +0100436ENDPROC(\name)
437.endm
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438
Sven Schnelle56e62a72020-11-21 11:14:56 +0100439INT_HANDLER ext_int_handler,__LC_EXT_OLD_PSW,do_ext_irq
440INT_HANDLER io_int_handler,__LC_IO_OLD_PSW,do_io_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400442/*
Sven Schnelle0b0ed652020-02-20 12:09:36 +0100443 * Load idle PSW.
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400444 */
445ENTRY(psw_idle)
Vasily Gorbika994edd2021-04-09 00:15:21 +0200446 stg %r14,(__SF_GPRS+8*8)(%r15)
Martin Schwidefsky27f6b412012-07-20 11:15:08 +0200447 stg %r3,__SF_EMPTY(%r15)
Sven Schnelle56e62a72020-11-21 11:14:56 +0100448 larl %r1,psw_idle_exit
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400449 stg %r1,__SF_EMPTY+8(%r15)
Martin Schwidefsky72d38b12015-09-18 16:41:36 +0200450 larl %r1,smp_cpu_mtid
451 llgf %r1,0(%r1)
452 ltgr %r1,%r1
453 jz .Lpsw_idle_stcctm
Sven Schnelle56e62a72020-11-21 11:14:56 +0100454 .insn rsy,0xeb0000000017,%r1,5,__MT_CYCLES_ENTER(%r2)
Martin Schwidefsky72d38b12015-09-18 16:41:36 +0200455.Lpsw_idle_stcctm:
Martin Schwidefsky419123f2015-11-19 11:09:45 +0100456 oi __LC_CPU_FLAGS+7,_CIF_ENABLED_WAIT
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100457 BPON
Martin Schwidefsky27f6b412012-07-20 11:15:08 +0200458 STCK __CLOCK_IDLE_ENTER(%r2)
459 stpt __TIMER_IDLE_ENTER(%r2)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400460 lpswe __SF_EMPTY(%r15)
Sven Schnelle56e62a72020-11-21 11:14:56 +0100461.globl psw_idle_exit
462psw_idle_exit:
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200463 BR_EX %r14
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100464ENDPROC(psw_idle)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400465
Hendrik Bruecknerb5510d92015-09-29 10:04:41 +0200466/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 * Machine check handler routines
468 */
Jan Glauber144d6342011-07-24 10:48:19 +0200469ENTRY(mcck_int_handler)
Heiko Carstens473e66b2012-05-09 16:27:39 +0200470 STCK __LC_MCCK_CLOCK
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100471 BPOFF
Martin Schwidefsky3037a522017-10-12 13:24:48 +0200472 la %r1,4095 # validate r1
473 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # validate cpu timer
474 sckc __LC_CLOCK_COMPARATOR # validate comparator
475 lam %a0,%a15,__LC_AREGS_SAVE_AREA-4095(%r1) # validate acrs
476 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# validate gprs
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100477 lg %r12,__LC_CURRENT
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100478 lmg %r8,%r9,__LC_MCK_OLD_PSW
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200479 TSTMSK __LC_MCCK_CODE,MCCK_CODE_SYSTEM_DAMAGE
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100480 jo .Lmcck_panic # yes -> rest of mcck code invalid
Martin Schwidefsky3037a522017-10-12 13:24:48 +0200481 TSTMSK __LC_MCCK_CODE,MCCK_CODE_CR_VALID
482 jno .Lmcck_panic # control registers invalid -> panic
483 la %r14,4095
484 lctlg %c0,%c15,__LC_CREGS_SAVE_AREA-4095(%r14) # validate ctl regs
485 ptlb
Vasily Gorbik2a2d7bef2017-10-27 12:44:48 +0200486 lg %r11,__LC_MCESAD-4095(%r14) # extended machine check save area
Martin Schwidefsky3037a522017-10-12 13:24:48 +0200487 nill %r11,0xfc00 # MCESA_ORIGIN_MASK
488 TSTMSK __LC_CREGS_SAVE_AREA+16-4095(%r14),CR2_GUARDED_STORAGE
489 jno 0f
490 TSTMSK __LC_MCCK_CODE,MCCK_CODE_GS_VALID
491 jno 0f
492 .insn rxy,0xe3000000004d,0,__MCESA_GS_SAVE_AREA(%r11) # LGSC
4930: l %r14,__LC_FP_CREG_SAVE_AREA-4095(%r14)
494 TSTMSK __LC_MCCK_CODE,MCCK_CODE_FC_VALID
495 jo 0f
496 sr %r14,%r14
4970: sfpc %r14
498 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
499 jo 0f
500 lghi %r14,__LC_FPREGS_SAVE_AREA
501 ld %f0,0(%r14)
502 ld %f1,8(%r14)
503 ld %f2,16(%r14)
504 ld %f3,24(%r14)
505 ld %f4,32(%r14)
506 ld %f5,40(%r14)
507 ld %f6,48(%r14)
508 ld %f7,56(%r14)
509 ld %f8,64(%r14)
510 ld %f9,72(%r14)
511 ld %f10,80(%r14)
512 ld %f11,88(%r14)
513 ld %f12,96(%r14)
514 ld %f13,104(%r14)
515 ld %f14,112(%r14)
516 ld %f15,120(%r14)
517 j 1f
5180: VLM %v0,%v15,0,%r11
519 VLM %v16,%v31,256,%r11
5201: lghi %r14,__LC_CPU_TIMER_SAVE_AREA
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100521 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200522 TSTMSK __LC_MCCK_CODE,MCCK_CODE_CPU_TIMER_VALID
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100523 jo 3f
Sven Schnelle56e62a72020-11-21 11:14:56 +0100524 la %r14,__LC_SYS_ENTER_TIMER
525 clc 0(8,%r14),__LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100526 jl 1f
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200527 la %r14,__LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +01005281: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
529 jl 2f
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200530 la %r14,__LC_LAST_UPDATE_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +01005312: spt 0(%r14)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200532 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
Martin Schwidefsky3037a522017-10-12 13:24:48 +02005333: TSTMSK __LC_MCCK_CODE,MCCK_CODE_PSW_MWP_VALID
534 jno .Lmcck_panic
535 tmhh %r8,0x0001 # interrupting from user ?
536 jnz 4f
537 TSTMSK __LC_MCCK_CODE,MCCK_CODE_PSW_IA_VALID
538 jno .Lmcck_panic
Martin Schwidefskyce3dc442017-09-12 16:37:33 +02005394: ssm __LC_PGM_NEW_PSW # turn dat on, keep irqs off
Sven Schnelleb0d31152021-01-28 13:06:05 +0100540 tmhh %r8,0x0001 # interrupting from user ?
541 jnz .Lmcck_user
542#if IS_ENABLED(CONFIG_KVM)
543 lgr %r14,%r9
544 larl %r13,.Lsie_gmap
545 slgr %r14,%r13
546 lghi %r13,.Lsie_done - .Lsie_gmap
547 clgr %r14,%r13
548 jhe .Lmcck_stack
Sven Schnelleefa54732021-02-03 17:50:00 +0100549 brasl %r14,.Lcleanup_sie_mcck
Sven Schnelleb0d31152021-01-28 13:06:05 +0100550#endif
Sven Schnelleb61b1592021-02-03 09:02:51 +0100551 j .Lmcck_stack
Sven Schnelleb0d31152021-01-28 13:06:05 +0100552.Lmcck_user:
553 BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
Sven Schnelleb61b1592021-02-03 09:02:51 +0100554.Lmcck_stack:
555 lg %r15,__LC_MCCK_STACK
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100556.Lmcck_skip:
Sven Schnelleb61b1592021-02-03 09:02:51 +0100557 la %r11,STACK_FRAME_OVERHEAD(%r15)
Sven Schnelle26521412021-02-03 09:16:45 +0100558 stctg %c1,%c1,__PT_CR1(%r11)
Sven Schnelleb61b1592021-02-03 09:02:51 +0100559 lctlg %c1,%c1,__LC_KERNEL_ASCE
560 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Martin Schwidefsky6551fbd2013-02-28 16:28:41 +0100561 lghi %r14,__LC_GPREGS_SAVE_AREA+64
562 stmg %r0,%r7,__PT_R0(%r11)
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100563 # clear user controlled registers to prevent speculative use
564 xgr %r0,%r0
565 xgr %r1,%r1
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100566 xgr %r3,%r3
567 xgr %r4,%r4
568 xgr %r5,%r5
569 xgr %r6,%r6
570 xgr %r7,%r7
571 xgr %r10,%r10
Martin Schwidefsky6551fbd2013-02-28 16:28:41 +0100572 mvc __PT_R8(64,%r11),0(%r14)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100573 stmg %r8,%r9,__PT_PSW(%r11)
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200574 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100575 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
576 lgr %r2,%r11 # pass pointer to pt_regs
Heiko Carstens77fa2242005-06-25 14:55:30 -0700577 brasl %r14,s390_do_machine_check
Sven Schnelle0b0ed652020-02-20 12:09:36 +0100578 cghi %r2,0
579 je .Lmcck_return
Heiko Carstens77fa2242005-06-25 14:55:30 -0700580 lg %r1,__LC_KERNEL_STACK # switch to kernel stack
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100581 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
582 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
583 la %r11,STACK_FRAME_OVERHEAD(%r1)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700584 lgr %r15,%r1
Heiko Carstens77fa2242005-06-25 14:55:30 -0700585 brasl %r14,s390_handle_mcck
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100586.Lmcck_return:
Heiko Carstens87d59862020-11-16 08:06:40 +0100587 lctlg %c1,%c1,__PT_CR1(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100588 lmg %r0,%r10,__PT_R0(%r11)
589 mvc __LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200590 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
591 jno 0f
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100592 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200593 stpt __LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +01005940: lmg %r11,%r15,__PT_R11(%r11)
Sven Schnelle0b38b5e2020-01-22 13:38:22 +0100595 b __LC_RETURN_MCCK_LPSWE
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100596
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100597.Lmcck_panic:
Martin Schwidefskyce3dc442017-09-12 16:37:33 +0200598 lg %r15,__LC_NODAT_STACK
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100599 j .Lmcck_skip
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100600ENDPROC(mcck_int_handler)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601
Michael Holzheu7dd6b332011-08-03 16:44:19 +0200602#
603# PSW restart interrupt handler
604#
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400605ENTRY(restart_int_handler)
Martin Schwidefskye5b98192018-03-26 15:23:33 +0200606 ALTERNATIVE "", ".insn s,0xb2800000,_LPP_OFFSET", 40
607 stg %r15,__LC_SAVE_AREA_RESTART
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400608 lg %r15,__LC_RESTART_STACK
Martin Schwidefskyce3dc442017-09-12 16:37:33 +0200609 xc STACK_FRAME_OVERHEAD(__PT_SIZE,%r15),STACK_FRAME_OVERHEAD(%r15)
610 stmg %r0,%r14,STACK_FRAME_OVERHEAD+__PT_R0(%r15)
611 mvc STACK_FRAME_OVERHEAD+__PT_R15(8,%r15),__LC_SAVE_AREA_RESTART
612 mvc STACK_FRAME_OVERHEAD+__PT_PSW(16,%r15),__LC_RST_OLD_PSW
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400613 xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15)
Heiko Carstensfbe76562012-06-05 09:59:52 +0200614 lg %r1,__LC_RESTART_FN # load fn, parm & source cpu
615 lg %r2,__LC_RESTART_DATA
616 lg %r3,__LC_RESTART_SOURCE
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400617 ltgr %r3,%r3 # test source cpu address
618 jm 1f # negative -> skip source stop
Heiko Carstenseb546192012-06-04 15:05:43 +02006190: sigp %r4,%r3,SIGP_SENSE # sigp sense to source cpu
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400620 brc 10,0b # wait for status stored
6211: basr %r14,%r1 # call function
622 stap __SF_EMPTY(%r15) # store cpu address
623 llgh %r3,__SF_EMPTY(%r15)
Heiko Carstenseb546192012-06-04 15:05:43 +02006242: sigp %r4,%r3,SIGP_STOP # sigp stop to current cpu
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400625 brc 2,2b
6263: j 3b
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100627ENDPROC(restart_int_handler)
Michael Holzheu7dd6b332011-08-03 16:44:19 +0200628
Martin Schwidefsky860dba42011-01-05 12:47:25 +0100629 .section .kprobes.text, "ax"
630
Martin Schwidefskyce3dc442017-09-12 16:37:33 +0200631#if defined(CONFIG_CHECK_STACK) || defined(CONFIG_VMAP_STACK)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632/*
633 * The synchronous or the asynchronous stack overflowed. We are dead.
634 * No need to properly save the registers, we are going to panic anyway.
635 * Setup a pt_regs so that show_trace can provide a good call trace.
636 */
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100637ENTRY(stack_overflow)
Martin Schwidefskyce3dc442017-09-12 16:37:33 +0200638 lg %r15,__LC_NODAT_STACK # change to panic stack
Martin Schwidefskydc7ee002013-04-24 10:20:43 +0200639 la %r11,STACK_FRAME_OVERHEAD(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100640 stmg %r0,%r7,__PT_R0(%r11)
641 stmg %r8,%r9,__PT_PSW(%r11)
642 mvc __PT_R8(64,%r11),0(%r14)
643 stg %r10,__PT_ORIG_GPR2(%r11) # store last break to orig_gpr2
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100644 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
645 lgr %r2,%r11 # pass pointer to pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 jg kernel_stack_overflow
Martin Schwidefsky26a374a2019-01-17 10:02:22 +0100647ENDPROC(stack_overflow)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648#endif
649
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200650#if IS_ENABLED(CONFIG_KVM)
Sven Schnelleefa54732021-02-03 17:50:00 +0100651.Lcleanup_sie_mcck:
Sven Schnelle0b0ed652020-02-20 12:09:36 +0100652 larl %r13,.Lsie_entry
653 slgr %r9,%r13
654 larl %r13,.Lsie_skip
655 clgr %r9,%r13
Sven Schnelleefa54732021-02-03 17:50:00 +0100656 jh .Lcleanup_sie_int
Sven Schnelle0b0ed652020-02-20 12:09:36 +0100657 oi __LC_CPU_FLAGS+7, _CIF_MCCK_GUEST
Sven Schnelleefa54732021-02-03 17:50:00 +0100658.Lcleanup_sie_int:
659 BPENTER __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100660 lg %r9,__SF_SIE_CONTROL(%r15) # get control block pointer
Christian Borntraegere22cf8c2015-10-06 18:06:15 +0200661 ni __SIE_PROG0C+3(%r9),0xfe # no longer in SIE
Heiko Carstens87d59862020-11-16 08:06:40 +0100662 lctlg %c1,%c1,__LC_KERNEL_ASCE
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200663 larl %r9,sie_exit # skip forward to sie_exit
Sven Schnelle33ea0482021-02-03 17:46:12 +0100664 BR_EX %r14,%r13
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200666#endif
Heiko Carstensa876cb32015-02-13 14:44:29 +0100667 .section .rodata, "a"
Gerald Schaeferff4a7422019-02-03 21:36:13 +0100668#define SYSCALL(esame,emu) .quad __s390x_ ## esame
Heiko Carstens9bf12262009-06-12 10:26:47 +0200669 .globl sys_call_table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670sys_call_table:
Hendrik Brueckner4381f9f2017-12-11 14:47:27 +0100671#include "asm/syscall_table.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672#undef SYSCALL
673
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800674#ifdef CONFIG_COMPAT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675
Gerald Schaeferff4a7422019-02-03 21:36:13 +0100676#define SYSCALL(esame,emu) .quad __s390_ ## emu
Martin Schwidefsky61649882013-04-24 12:58:39 +0200677 .globl sys_call_table_emu
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678sys_call_table_emu:
Hendrik Brueckner4381f9f2017-12-11 14:47:27 +0100679#include "asm/syscall_table.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680#undef SYSCALL
681#endif