blob: 39191a0feed1cdedd692e68826b3b19db581cbbb [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 Schwidefskyd768bd82018-01-16 07:11:45 +0100227
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228/*
229 * Scheduler resume function, called by switch_to
230 * gpr2 = (task_struct *) prev
231 * gpr3 = (task_struct *) next
232 * Returns:
233 * gpr2 = prev
234 */
Jan Glauber144d6342011-07-24 10:48:19 +0200235ENTRY(__switch_to)
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +0200236 stmg %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task
Heiko Carstens3241d3e2017-11-16 14:54:04 +0100237 lghi %r4,__TASK_stack
238 lghi %r1,__TASK_thread
Vasily Gorbik9fed9202018-10-26 15:29:59 +0200239 llill %r5,STACK_INIT
Heiko Carstens3241d3e2017-11-16 14:54:04 +0100240 stg %r15,__THREAD_ksp(%r1,%r2) # store kernel stack of prev
Vasily Gorbik9fed9202018-10-26 15:29:59 +0200241 lg %r15,0(%r4,%r3) # start of kernel stack of next
242 agr %r15,%r5 # end of kernel stack of next
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +0200243 stg %r3,__LC_CURRENT # store task struct of next
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +0200244 stg %r15,__LC_KERNEL_STACK # store end of kernel stack
Heiko Carstens3241d3e2017-11-16 14:54:04 +0100245 lg %r15,__THREAD_ksp(%r1,%r3) # load kernel stack of next
246 aghi %r3,__TASK_pid
247 mvc __LC_CURRENT_PID(4,%r0),0(%r3) # store pid of next
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200248 lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task
Martin Schwidefskye5b98192018-03-26 15:23:33 +0200249 ALTERNATIVE "", ".insn s,0xb2800000,_LPP_OFFSET", 40
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200250 BR_EX %r14
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100252.L__critical_start:
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200253
254#if IS_ENABLED(CONFIG_KVM)
255/*
256 * sie64a calling convention:
257 * %r2 pointer to sie control block
258 * %r3 guest register save area
259 */
260ENTRY(sie64a)
261 stmg %r6,%r14,__SF_GPRS(%r15) # save kernel registers
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100262 lg %r12,__LC_CURRENT
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100263 stg %r2,__SF_SIE_CONTROL(%r15) # save control block pointer
264 stg %r3,__SF_SIE_SAVEAREA(%r15) # save guest register save area
265 xc __SF_SIE_REASON(8,%r15),__SF_SIE_REASON(%r15) # reason code = 0
266 mvc __SF_SIE_FLAGS(8,%r15),__TI_flags(%r12) # copy thread flags
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200267 TSTMSK __LC_CPU_FLAGS,_CIF_FPU # load guest fp/vx registers ?
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200268 jno .Lsie_load_guest_gprs
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200269 brasl %r14,load_fpu_regs # load guest fp/vx regs
270.Lsie_load_guest_gprs:
271 lmg %r0,%r13,0(%r3) # load guest gprs 0-13
272 lg %r14,__LC_GMAP # get gmap pointer
273 ltgr %r14,%r14
274 jz .Lsie_gmap
275 lctlg %c1,%c1,__GMAP_ASCE(%r14) # load primary asce
276.Lsie_gmap:
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100277 lg %r14,__SF_SIE_CONTROL(%r15) # get control block pointer
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200278 oi __SIE_PROG0C+3(%r14),1 # we are going into SIE now
279 tm __SIE_PROG20+3(%r14),3 # last exit...
280 jnz .Lsie_skip
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200281 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200282 jo .Lsie_skip # exit if fp/vx regs changed
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100283 BPEXIT __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
QingFeng Haoc9295002017-06-07 11:30:42 +0200284.Lsie_entry:
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200285 sie 0(%r14)
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100286.Lsie_exit:
287 BPOFF
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100288 BPENTER __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200289.Lsie_skip:
290 ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE
291 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
292.Lsie_done:
293# some program checks are suppressing. C code (e.g. do_protection_exception)
Christian Borntraegerc0e7bb32017-05-15 14:11:03 +0200294# will rewind the PSW by the ILC, which is often 4 bytes in case of SIE. There
295# are some corner cases (e.g. runtime instrumentation) where ILC is unpredictable.
296# Other instructions between sie64a and .Lsie_done should not cause program
297# interrupts. So lets use 3 nops as a landing pad for all possible rewinds.
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200298# See also .Lcleanup_sie
Christian Borntraegerc0e7bb32017-05-15 14:11:03 +0200299.Lrewind_pad6:
300 nopr 7
301.Lrewind_pad4:
302 nopr 7
303.Lrewind_pad2:
304 nopr 7
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200305 .globl sie_exit
306sie_exit:
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100307 lg %r14,__SF_SIE_SAVEAREA(%r15) # load guest register save area
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200308 stmg %r0,%r13,0(%r14) # save guest gprs 0-13
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100309 xgr %r0,%r0 # clear guest registers to
310 xgr %r1,%r1 # prevent speculative use
311 xgr %r2,%r2
312 xgr %r3,%r3
313 xgr %r4,%r4
314 xgr %r5,%r5
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200315 lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100316 lg %r2,__SF_SIE_REASON(%r15) # return exit reason code
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200317 BR_EX %r14
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200318.Lsie_fault:
319 lghi %r14,-EFAULT
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100320 stg %r14,__SF_SIE_REASON(%r15) # set exit reason code
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200321 j sie_exit
322
Christian Borntraegerc0e7bb32017-05-15 14:11:03 +0200323 EX_TABLE(.Lrewind_pad6,.Lsie_fault)
324 EX_TABLE(.Lrewind_pad4,.Lsie_fault)
325 EX_TABLE(.Lrewind_pad2,.Lsie_fault)
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200326 EX_TABLE(sie_exit,.Lsie_fault)
Al Viro711f5df2016-01-12 13:30:03 -0500327EXPORT_SYMBOL(sie64a)
328EXPORT_SYMBOL(sie_exit)
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200329#endif
330
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331/*
332 * SVC interrupt handler routine. System calls are synchronous events and
333 * are executed with interrupts enabled.
334 */
335
Jan Glauber144d6342011-07-24 10:48:19 +0200336ENTRY(system_call)
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100337 stpt __LC_SYNC_ENTER_TIMER
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100338.Lsysc_stmg:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100339 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100340 BPOFF
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100341 lg %r12,__LC_CURRENT
Martin Schwidefsky34525e12017-01-25 12:54:17 +0100342 lghi %r13,__TASK_thread
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200343 lghi %r14,_PIF_SYSCALL
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100344.Lsysc_per:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100345 lg %r15,__LC_KERNEL_STACK
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100346 la %r11,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs
Martin Schwidefskya359bb12015-06-22 17:27:48 +0200347.Lsysc_vtime:
Martin Schwidefsky34525e12017-01-25 12:54:17 +0100348 UPDATE_VTIME %r8,%r9,__LC_SYNC_ENTER_TIMER
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100349 BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100350 stmg %r0,%r7,__PT_R0(%r11)
351 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
352 mvc __PT_PSW(16,%r11),__LC_SVC_OLD_PSW
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100353 mvc __PT_INT_CODE(4,%r11),__LC_SVC_ILC
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200354 stg %r14,__PT_FLAGS(%r11)
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100355.Lsysc_do_svc:
Christian Borntraegerd3f46892018-03-05 19:18:47 +0000356 # clear user controlled register to prevent speculative use
357 xgr %r0,%r0
Martin Schwidefskyef280c82016-11-08 12:33:38 +0100358 # load address of system call table
Martin Schwidefskyef280c82016-11-08 12:33:38 +0100359 lg %r10,__THREAD_sysc_table(%r13,%r12)
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100360 llgh %r8,__PT_INT_CODE+2(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100361 slag %r8,%r8,2 # shift and test for svc 0
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100362 jnz .Lsysc_nr_ok
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 # svc 0: system call number in %r1
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100364 llgfr %r1,%r1 # clear high word in r1
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200365 cghi %r1,NR_syscalls
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100366 jnl .Lsysc_nr_ok
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100367 sth %r1,__PT_INT_CODE+2(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100368 slag %r8,%r1,2
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100369.Lsysc_nr_ok:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100370 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
371 stg %r2,__PT_ORIG_GPR2(%r11)
372 stg %r7,STACK_FRAME_OVERHEAD(%r15)
373 lgf %r9,0(%r8,%r10) # get system call add.
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200374 TSTMSK __TI_flags(%r12),_TIF_TRACE
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100375 jnz .Lsysc_tracesys
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200376 BASR_EX %r14,%r9 # call sys_xxxx
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100377 stg %r2,__PT_R2(%r11) # store return value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100379.Lsysc_return:
Heiko Carstens9d6d99e2018-06-30 10:54:15 +0200380#ifdef CONFIG_DEBUG_RSEQ
381 lgr %r2,%r11
382 brasl %r14,rseq_syscall
383#endif
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200384 LOCKDEP_SYS_EXIT
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100385.Lsysc_tif:
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200386 TSTMSK __PT_FLAGS(%r11),_PIF_WORK
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100387 jnz .Lsysc_work
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200388 TSTMSK __TI_flags(%r12),_TIF_WORK
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100389 jnz .Lsysc_work # check for work
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200390 TSTMSK __LC_CPU_FLAGS,_CIF_WORK
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100391 jnz .Lsysc_work
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100392 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100393.Lsysc_restore:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100394 lg %r14,__LC_VDSO_PER_CPU
395 lmg %r0,%r10,__PT_R0(%r11)
396 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
Martin Schwidefsky07a63cb2017-05-02 13:36:00 +0200397.Lsysc_exit_timer:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100398 stpt __LC_EXIT_TIMER
399 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
400 lmg %r11,%r15,__PT_R11(%r11)
401 lpswe __LC_RETURN_PSW
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100402.Lsysc_done:
Heiko Carstens411788e2007-11-20 11:13:32 +0100403
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404#
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200405# One of the work bits is on. Find out which one.
406#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100407.Lsysc_work:
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200408 TSTMSK __LC_CPU_FLAGS,_CIF_MCCK_PENDING
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100409 jo .Lsysc_mcck_pending
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200410 TSTMSK __TI_flags(%r12),_TIF_NEED_RESCHED
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100411 jo .Lsysc_reschedule
Martin Schwidefsky23fefe12017-06-07 14:10:24 +0200412 TSTMSK __PT_FLAGS(%r11),_PIF_SYSCALL_RESTART
413 jo .Lsysc_syscall_restart
Jan Willeke2a0a5b22014-09-22 16:39:06 +0200414#ifdef CONFIG_UPROBES
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200415 TSTMSK __TI_flags(%r12),_TIF_UPROBE
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100416 jo .Lsysc_uprobe_notify
Jan Willeke2a0a5b22014-09-22 16:39:06 +0200417#endif
Martin Schwidefsky916cda12016-01-26 14:10:34 +0100418 TSTMSK __TI_flags(%r12),_TIF_GUARDED_STORAGE
419 jo .Lsysc_guarded_storage
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200420 TSTMSK __PT_FLAGS(%r11),_PIF_PER_TRAP
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100421 jo .Lsysc_singlestep
Miroslav Benes2f09ca62017-02-13 19:42:34 -0600422#ifdef CONFIG_LIVEPATCH
423 TSTMSK __TI_flags(%r12),_TIF_PATCH_PENDING
424 jo .Lsysc_patch_pending # handle live patching just before
425 # signals and possible syscall restart
426#endif
Martin Schwidefsky23fefe12017-06-07 14:10:24 +0200427 TSTMSK __PT_FLAGS(%r11),_PIF_SYSCALL_RESTART
428 jo .Lsysc_syscall_restart
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200429 TSTMSK __TI_flags(%r12),_TIF_SIGPENDING
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100430 jo .Lsysc_sigpending
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200431 TSTMSK __TI_flags(%r12),_TIF_NOTIFY_RESUME
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100432 jo .Lsysc_notify_resume
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200433 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200434 jo .Lsysc_vxrs
Heiko Carstensb5a882f2017-02-17 08:13:28 +0100435 TSTMSK __LC_CPU_FLAGS,(_CIF_ASCE_PRIMARY|_CIF_ASCE_SECONDARY)
436 jnz .Lsysc_asce
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100437 j .Lsysc_return # beware of critical section cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438
439#
440# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200441#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100442.Lsysc_reschedule:
443 larl %r14,.Lsysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100444 jg schedule
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445
446#
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200447# _CIF_MCCK_PENDING is set, call handler
Heiko Carstens77fa2242005-06-25 14:55:30 -0700448#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100449.Lsysc_mcck_pending:
450 larl %r14,.Lsysc_return
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200451 jg s390_handle_mcck # TIF bit will be cleared by handler
Heiko Carstens77fa2242005-06-25 14:55:30 -0700452
453#
Martin Schwidefsky0aaba412017-08-22 12:08:22 +0200454# _CIF_ASCE_PRIMARY and/or _CIF_ASCE_SECONDARY set, load user space asce
Heiko Carstens457f2182014-03-21 10:42:25 +0100455#
Heiko Carstensb5a882f2017-02-17 08:13:28 +0100456.Lsysc_asce:
Martin Schwidefsky0aaba412017-08-22 12:08:22 +0200457 ni __LC_CPU_FLAGS+7,255-_CIF_ASCE_SECONDARY
458 lctlg %c7,%c7,__LC_VDSO_ASCE # load secondary asce
459 TSTMSK __LC_CPU_FLAGS,_CIF_ASCE_PRIMARY
460 jz .Lsysc_return
461#ifndef CONFIG_HAVE_MARCH_Z10_FEATURES
462 tm __LC_STFLE_FAC_LIST+3,0x10 # has MVCOS ?
463 jnz .Lsysc_set_fs_fixup
Heiko Carstens606aa4a2017-02-17 08:12:30 +0100464 ni __LC_CPU_FLAGS+7,255-_CIF_ASCE_PRIMARY
Heiko Carstens457f2182014-03-21 10:42:25 +0100465 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
Martin Schwidefsky0aaba412017-08-22 12:08:22 +0200466 j .Lsysc_return
467.Lsysc_set_fs_fixup:
468#endif
Heiko Carstensb5a882f2017-02-17 08:13:28 +0100469 larl %r14,.Lsysc_return
470 jg set_fs_fixup
Heiko Carstens457f2182014-03-21 10:42:25 +0100471
472#
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200473# CIF_FPU is set, restore floating-point controls and floating-point registers.
474#
475.Lsysc_vxrs:
476 larl %r14,.Lsysc_return
477 jg load_fpu_regs
478
479#
Roland McGrath02a029b2008-04-30 00:53:08 -0700480# _TIF_SIGPENDING is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100482.Lsysc_sigpending:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100483 lgr %r2,%r11 # pass pointer to pt_regs
484 brasl %r14,do_signal
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200485 TSTMSK __PT_FLAGS(%r11),_PIF_SYSCALL
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100486 jno .Lsysc_return
Martin Schwidefsky57d7f932016-03-22 10:54:24 +0100487.Lsysc_do_syscall:
488 lghi %r13,__TASK_thread
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100489 lmg %r2,%r7,__PT_R2(%r11) # load svc arguments
Martin Schwidefsky57d7f932016-03-22 10:54:24 +0100490 lghi %r1,0 # svc 0 returns -ENOSYS
491 j .Lsysc_do_svc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492
493#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200494# _TIF_NOTIFY_RESUME is set, call do_notify_resume
495#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100496.Lsysc_notify_resume:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100497 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100498 larl %r14,.Lsysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100499 jg do_notify_resume
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200500
501#
Jan Willeke2a0a5b22014-09-22 16:39:06 +0200502# _TIF_UPROBE is set, call uprobe_notify_resume
503#
504#ifdef CONFIG_UPROBES
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100505.Lsysc_uprobe_notify:
Jan Willeke2a0a5b22014-09-22 16:39:06 +0200506 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100507 larl %r14,.Lsysc_return
Jan Willeke2a0a5b22014-09-22 16:39:06 +0200508 jg uprobe_notify_resume
509#endif
510
511#
Martin Schwidefsky916cda12016-01-26 14:10:34 +0100512# _TIF_GUARDED_STORAGE is set, call guarded_storage_load
513#
514.Lsysc_guarded_storage:
515 lgr %r2,%r11 # pass pointer to pt_regs
516 larl %r14,.Lsysc_return
517 jg gs_load_bc_cb
Linus Torvalds76f19482017-05-02 18:24:16 -0700518#
Miroslav Benes2f09ca62017-02-13 19:42:34 -0600519# _TIF_PATCH_PENDING is set, call klp_update_patch_state
520#
521#ifdef CONFIG_LIVEPATCH
522.Lsysc_patch_pending:
523 lg %r2,__LC_CURRENT # pass pointer to task struct
524 larl %r14,.Lsysc_return
525 jg klp_update_patch_state
526#endif
Martin Schwidefsky916cda12016-01-26 14:10:34 +0100527
528#
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200529# _PIF_PER_TRAP is set, call do_per_trap
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100531.Lsysc_singlestep:
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200532 ni __PT_FLAGS+7(%r11),255-_PIF_PER_TRAP
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100533 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100534 larl %r14,.Lsysc_return
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100535 jg do_per_trap
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537#
Martin Schwidefsky23fefe12017-06-07 14:10:24 +0200538# _PIF_SYSCALL_RESTART is set, repeat the current system call
539#
540.Lsysc_syscall_restart:
541 ni __PT_FLAGS+7(%r11),255-_PIF_SYSCALL_RESTART
542 lmg %r1,%r7,__PT_R1(%r11) # load svc arguments
543 lg %r2,__PT_ORIG_GPR2(%r11)
544 j .Lsysc_do_svc
545
546#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200547# call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
548# and after the system call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100550.Lsysc_tracesys:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100551 lgr %r2,%r11 # pass pointer to pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 la %r3,0
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100553 llgh %r0,__PT_INT_CODE+2(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100554 stg %r0,__PT_R2(%r11)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200555 brasl %r14,do_syscall_trace_enter
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 lghi %r0,NR_syscalls
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200557 clgr %r0,%r2
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100558 jnh .Lsysc_tracenogo
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100559 sllg %r8,%r2,2
560 lgf %r9,0(%r8,%r10)
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100561.Lsysc_tracego:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100562 lmg %r3,%r7,__PT_R3(%r11)
563 stg %r7,STACK_FRAME_OVERHEAD(%r15)
564 lg %r2,__PT_ORIG_GPR2(%r11)
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200565 BASR_EX %r14,%r9 # call sys_xxx
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100566 stg %r2,__PT_R2(%r11) # store return value
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100567.Lsysc_tracenogo:
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200568 TSTMSK __TI_flags(%r12),_TIF_TRACE
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100569 jz .Lsysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100570 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100571 larl %r14,.Lsysc_return
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200572 jg do_syscall_trace_exit
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573
574#
575# a new process exits the kernel with ret_from_fork
576#
Jan Glauber144d6342011-07-24 10:48:19 +0200577ENTRY(ret_from_fork)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100578 la %r11,STACK_FRAME_OVERHEAD(%r15)
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100579 lg %r12,__LC_CURRENT
Al Viro30dcb092012-10-11 15:30:14 -0400580 brasl %r14,schedule_tail
581 TRACE_IRQS_ON
582 ssm __LC_SVC_NEW_PSW # reenable interrupts
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100583 tm __PT_PSW+1(%r11),0x01 # forking a kernel thread ?
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100584 jne .Lsysc_tracenogo
Al Viro30dcb092012-10-11 15:30:14 -0400585 # it's a kernel thread
586 lmg %r9,%r10,__PT_R9(%r11) # load gprs
Al Viro37fe5d42012-09-10 18:03:41 -0400587ENTRY(kernel_thread_starter)
588 la %r2,0(%r10)
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200589 BASR_EX %r14,%r9
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100590 j .Lsysc_tracenogo
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591
592/*
593 * Program check handler routine
594 */
595
Jan Glauber144d6342011-07-24 10:48:19 +0200596ENTRY(pgm_check_handler)
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100597 stpt __LC_SYNC_ENTER_TIMER
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100598 BPOFF
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100599 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
600 lg %r10,__LC_LAST_BREAK
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100601 lg %r12,__LC_CURRENT
Martin Schwidefskyc7713202017-10-05 08:44:26 +0200602 lghi %r11,0
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200603 larl %r13,cleanup_critical
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100604 lmg %r8,%r9,__LC_PGM_OLD_PSW
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100605 tmhh %r8,0x0001 # test problem state bit
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200606 jnz 2f # -> fault in user space
607#if IS_ENABLED(CONFIG_KVM)
Martin Schwidefsky0a5e2ec2017-10-05 08:29:47 +0200608 # cleanup critical section for program checks in sie64a
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200609 lgr %r14,%r9
610 slg %r14,BASED(.Lsie_critical_start)
611 clg %r14,BASED(.Lsie_critical_length)
612 jhe 0f
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +0100613 lg %r14,__SF_SIE_CONTROL(%r15) # get control block pointer
Martin Schwidefsky0a5e2ec2017-10-05 08:29:47 +0200614 ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE
615 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
616 larl %r9,sie_exit # skip forward to sie_exit
Martin Schwidefskyc7713202017-10-05 08:44:26 +0200617 lghi %r11,_PIF_GUEST_FAULT
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200618#endif
6190: tmhh %r8,0x4000 # PER bit set in old PSW ?
620 jnz 1f # -> enabled, can't be a double fault
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100621 tm __LC_PGM_ILC+3,0x80 # check for per exception
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100622 jnz .Lpgm_svcper # -> single stepped svc
Martin Schwidefskyce3dc442017-09-12 16:37:33 +02006231: CHECK_STACK __LC_SAVE_AREA_SYNC
Martin Schwidefskydc7ee002013-04-24 10:20:43 +0200624 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
Martin Schwidefskyce3dc442017-09-12 16:37:33 +0200625 # CHECK_VMAP_STACK branches to stack_overflow or 4f
626 CHECK_VMAP_STACK __LC_SAVE_AREA_SYNC,4f
Martin Schwidefsky34525e12017-01-25 12:54:17 +01006272: UPDATE_VTIME %r14,%r15,__LC_SYNC_ENTER_TIMER
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100628 BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100629 lg %r15,__LC_KERNEL_STACK
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100630 lgr %r14,%r12
Martin Schwidefsky3827ec32015-07-20 10:01:46 +0200631 aghi %r14,__TASK_thread # pointer to thread_struct
Martin Schwidefskyd35339a2012-07-31 11:03:04 +0200632 lghi %r13,__LC_PGM_TDB
633 tm __LC_PGM_ILC+2,0x02 # check for transaction abort
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200634 jz 3f
Martin Schwidefskyd35339a2012-07-31 11:03:04 +0200635 mvc __THREAD_trap_tdb(256,%r14),0(%r13)
Martin Schwidefskyd9fcf2a2017-02-28 07:42:01 +01006363: stg %r10,__THREAD_last_break(%r14)
Martin Schwidefskyc7713202017-10-05 08:44:26 +02006374: lgr %r13,%r11
638 la %r11,STACK_FRAME_OVERHEAD(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100639 stmg %r0,%r7,__PT_R0(%r11)
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100640 # clear user controlled registers to prevent speculative use
641 xgr %r0,%r0
642 xgr %r1,%r1
643 xgr %r2,%r2
644 xgr %r3,%r3
645 xgr %r4,%r4
646 xgr %r5,%r5
647 xgr %r6,%r6
648 xgr %r7,%r7
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100649 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
650 stmg %r8,%r9,__PT_PSW(%r11)
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100651 mvc __PT_INT_CODE(4,%r11),__LC_PGM_ILC
652 mvc __PT_INT_PARM_LONG(8,%r11),__LC_TRANS_EXC_CODE
Martin Schwidefskyc7713202017-10-05 08:44:26 +0200653 stg %r13,__PT_FLAGS(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100654 stg %r10,__PT_ARGS(%r11)
655 tm __LC_PGM_ILC+3,0x80 # check for per exception
Martin Schwidefskyd9fcf2a2017-02-28 07:42:01 +0100656 jz 5f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100657 tmhh %r8,0x0001 # kernel per event ?
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100658 jz .Lpgm_kprobe
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200659 oi __PT_FLAGS+7(%r11),_PIF_PER_TRAP
Martin Schwidefskyd35339a2012-07-31 11:03:04 +0200660 mvc __THREAD_per_address(8,%r14),__LC_PER_ADDRESS
Jens Freimann21ee7ff2014-02-26 16:32:46 +0100661 mvc __THREAD_per_cause(2,%r14),__LC_PER_CODE
662 mvc __THREAD_per_paid(1,%r14),__LC_PER_ACCESS_ID
Martin Schwidefskyd9fcf2a2017-02-28 07:42:01 +01006635: REENABLE_IRQS
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100664 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200665 larl %r1,pgm_check_table
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100666 llgh %r10,__PT_INT_CODE+2(%r11)
667 nill %r10,0x007f
Heiko Carstensb01a37a2012-10-18 18:10:06 +0200668 sll %r10,2
Martin Schwidefskya359bb12015-06-22 17:27:48 +0200669 je .Lpgm_return
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +0100670 lgf %r9,0(%r10,%r1) # load address of handler routine
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100671 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200672 BASR_EX %r14,%r9 # branch to interrupt-handler
Martin Schwidefskya359bb12015-06-22 17:27:48 +0200673.Lpgm_return:
674 LOCKDEP_SYS_EXIT
675 tm __PT_PSW+1(%r11),0x01 # returning to user ?
676 jno .Lsysc_restore
Martin Schwidefsky57d7f932016-03-22 10:54:24 +0100677 TSTMSK __PT_FLAGS(%r11),_PIF_SYSCALL
678 jo .Lsysc_do_syscall
Martin Schwidefskya359bb12015-06-22 17:27:48 +0200679 j .Lsysc_tif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680
681#
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100682# PER event in supervisor state, must be kprobes
683#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100684.Lpgm_kprobe:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100685 REENABLE_IRQS
686 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
687 lgr %r2,%r11 # pass pointer to pt_regs
688 brasl %r14,do_per_trap
Martin Schwidefskya359bb12015-06-22 17:27:48 +0200689 j .Lpgm_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100690
691#
692# single stepped system call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100694.Lpgm_svcper:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100695 mvc __LC_RETURN_PSW(8),__LC_SVC_NEW_PSW
Martin Schwidefskyd24b98e2017-02-20 09:51:36 +0100696 lghi %r13,__TASK_thread
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100697 larl %r14,.Lsysc_per
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100698 stg %r14,__LC_RETURN_PSW+8
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200699 lghi %r14,_PIF_SYSCALL | _PIF_PER_TRAP
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100700 lpswe __LC_RETURN_PSW # branch to .Lsysc_per and enable irqs
Michael Grundy4ba069b2006-09-20 15:58:39 +0200701
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702/*
703 * IO interrupt handler routine
704 */
Jan Glauber144d6342011-07-24 10:48:19 +0200705ENTRY(io_int_handler)
Heiko Carstens473e66b2012-05-09 16:27:39 +0200706 STCK __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100707 stpt __LC_ASYNC_ENTER_TIMER
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100708 BPOFF
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100709 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100710 lg %r12,__LC_CURRENT
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200711 larl %r13,cleanup_critical
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100712 lmg %r8,%r9,__LC_IO_OLD_PSW
Martin Schwidefsky2acb94f2015-06-22 17:28:14 +0200713 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100714 stmg %r0,%r7,__PT_R0(%r11)
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100715 # clear user controlled registers to prevent speculative use
716 xgr %r0,%r0
717 xgr %r1,%r1
718 xgr %r2,%r2
719 xgr %r3,%r3
720 xgr %r4,%r4
721 xgr %r5,%r5
722 xgr %r6,%r6
723 xgr %r7,%r7
724 xgr %r10,%r10
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100725 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
726 stmg %r8,%r9,__PT_PSW(%r11)
Martin Schwidefsky48f6b002013-06-17 14:54:02 +0200727 mvc __PT_INT_CODE(12,%r11),__LC_SUBCHANNEL_ID
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200728 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
Heiko Carstensdb7e0072015-08-15 11:42:21 +0200729 TSTMSK __LC_CPU_FLAGS,_CIF_IGNORE_IRQ
730 jo .Lio_restore
Heiko Carstens1f194a42006-07-03 00:24:46 -0700731 TRACE_IRQS_OFF
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100732 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100733.Lio_loop:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100734 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky1f44a2252013-06-27 09:01:09 +0200735 lghi %r3,IO_INTERRUPT
736 tm __PT_INT_CODE+8(%r11),0x80 # adapter interrupt ?
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100737 jz .Lio_call
Martin Schwidefsky1f44a2252013-06-27 09:01:09 +0200738 lghi %r3,THIN_INTERRUPT
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100739.Lio_call:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100740 brasl %r14,do_IRQ
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200741 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_LPAR
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100742 jz .Lio_return
Martin Schwidefsky48f6b002013-06-17 14:54:02 +0200743 tpi 0
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100744 jz .Lio_return
Martin Schwidefsky48f6b002013-06-17 14:54:02 +0200745 mvc __PT_INT_CODE(12,%r11),__LC_SUBCHANNEL_ID
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100746 j .Lio_loop
747.Lio_return:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200748 LOCKDEP_SYS_EXIT
749 TRACE_IRQS_ON
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100750.Lio_tif:
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200751 TSTMSK __TI_flags(%r12),_TIF_WORK
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100752 jnz .Lio_work # there is work to do (signals etc.)
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200753 TSTMSK __LC_CPU_FLAGS,_CIF_WORK
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100754 jnz .Lio_work
755.Lio_restore:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100756 lg %r14,__LC_VDSO_PER_CPU
757 lmg %r0,%r10,__PT_R0(%r11)
758 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100759 tm __PT_PSW+1(%r11),0x01 # returning to user ?
760 jno .Lio_exit_kernel
Martin Schwidefsky6b730442018-01-16 07:36:46 +0100761 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
Martin Schwidefsky07a63cb2017-05-02 13:36:00 +0200762.Lio_exit_timer:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100763 stpt __LC_EXIT_TIMER
764 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100765.Lio_exit_kernel:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100766 lmg %r11,%r15,__PT_R11(%r11)
767 lpswe __LC_RETURN_PSW
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100768.Lio_done:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769
Martin Schwidefsky26889052008-05-07 09:22:52 +0200770#
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200771# There is work todo, find out in which context we have been interrupted:
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200772# 1) if we return to user space we can do all _TIF_WORK work
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200773# 2) if we return to kernel code and kvm is enabled check if we need to
774# modify the psw to leave SIE
775# 3) if we return to kernel code and preemptive scheduling is enabled check
776# the preemption counter and if it is zero call preempt_schedule_irq
777# Before any work can be done, a switch to the kernel stack is required.
Martin Schwidefsky26889052008-05-07 09:22:52 +0200778#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100779.Lio_work:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100780 tm __PT_PSW+1(%r11),0x01 # returning to user ?
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100781 jo .Lio_work_user # yes -> do resched & signal
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200782#ifdef CONFIG_PREEMPT
Martin Schwidefsky26889052008-05-07 09:22:52 +0200783 # check for preemptive scheduling
Martin Schwidefskyc3601922016-10-25 12:21:44 +0200784 icm %r0,15,__LC_PREEMPT_COUNT
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100785 jnz .Lio_restore # preemption is disabled
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200786 TSTMSK __TI_flags(%r12),_TIF_NEED_RESCHED
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100787 jno .Lio_restore
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 # switch to kernel stack
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100789 lg %r1,__PT_R15(%r11)
790 aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
791 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
792 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
793 la %r11,STACK_FRAME_OVERHEAD(%r1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 lgr %r15,%r1
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100795 # TRACE_IRQS_ON already done at .Lio_return, call
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200796 # TRACE_IRQS_OFF to keep things symmetrical
797 TRACE_IRQS_OFF
798 brasl %r14,preempt_schedule_irq
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100799 j .Lio_return
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200800#else
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100801 j .Lio_restore
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200802#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200804#
805# Need to do work before returning to userspace, switch to kernel stack
806#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100807.Lio_work_user:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808 lg %r1,__LC_KERNEL_STACK
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100809 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
810 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
811 la %r11,STACK_FRAME_OVERHEAD(%r1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812 lgr %r15,%r1
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200813
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814#
815# One of the work bits is on. Find out which one.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100817.Lio_work_tif:
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200818 TSTMSK __LC_CPU_FLAGS,_CIF_MCCK_PENDING
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100819 jo .Lio_mcck_pending
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200820 TSTMSK __TI_flags(%r12),_TIF_NEED_RESCHED
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100821 jo .Lio_reschedule
Miroslav Benes2f09ca62017-02-13 19:42:34 -0600822#ifdef CONFIG_LIVEPATCH
823 TSTMSK __TI_flags(%r12),_TIF_PATCH_PENDING
824 jo .Lio_patch_pending
825#endif
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200826 TSTMSK __TI_flags(%r12),_TIF_SIGPENDING
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100827 jo .Lio_sigpending
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200828 TSTMSK __TI_flags(%r12),_TIF_NOTIFY_RESUME
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100829 jo .Lio_notify_resume
Martin Schwidefsky916cda12016-01-26 14:10:34 +0100830 TSTMSK __TI_flags(%r12),_TIF_GUARDED_STORAGE
831 jo .Lio_guarded_storage
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200832 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200833 jo .Lio_vxrs
Heiko Carstensb5a882f2017-02-17 08:13:28 +0100834 TSTMSK __LC_CPU_FLAGS,(_CIF_ASCE_PRIMARY|_CIF_ASCE_SECONDARY)
835 jnz .Lio_asce
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100836 j .Lio_return # beware of critical section cleanup
Christian Borntraeger0eaeafa2008-05-07 09:22:53 +0200837
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838#
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200839# _CIF_MCCK_PENDING is set, call handler
Heiko Carstens77fa2242005-06-25 14:55:30 -0700840#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100841.Lio_mcck_pending:
842 # TRACE_IRQS_ON already done at .Lio_return
Heiko Carstensb771aea2007-07-27 12:29:18 +0200843 brasl %r14,s390_handle_mcck # TIF bit will be cleared by handler
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200844 TRACE_IRQS_OFF
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100845 j .Lio_return
Heiko Carstens77fa2242005-06-25 14:55:30 -0700846
847#
Heiko Carstensb5a882f2017-02-17 08:13:28 +0100848# _CIF_ASCE_PRIMARY and/or CIF_ASCE_SECONDARY set, load user space asce
Heiko Carstens457f2182014-03-21 10:42:25 +0100849#
Heiko Carstensb5a882f2017-02-17 08:13:28 +0100850.Lio_asce:
Martin Schwidefsky0aaba412017-08-22 12:08:22 +0200851 ni __LC_CPU_FLAGS+7,255-_CIF_ASCE_SECONDARY
852 lctlg %c7,%c7,__LC_VDSO_ASCE # load secondary asce
853 TSTMSK __LC_CPU_FLAGS,_CIF_ASCE_PRIMARY
854 jz .Lio_return
855#ifndef CONFIG_HAVE_MARCH_Z10_FEATURES
856 tm __LC_STFLE_FAC_LIST+3,0x10 # has MVCOS ?
857 jnz .Lio_set_fs_fixup
Heiko Carstens606aa4a2017-02-17 08:12:30 +0100858 ni __LC_CPU_FLAGS+7,255-_CIF_ASCE_PRIMARY
Heiko Carstens457f2182014-03-21 10:42:25 +0100859 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
Martin Schwidefsky0aaba412017-08-22 12:08:22 +0200860 j .Lio_return
861.Lio_set_fs_fixup:
862#endif
Heiko Carstensb5a882f2017-02-17 08:13:28 +0100863 larl %r14,.Lio_return
864 jg set_fs_fixup
Heiko Carstens457f2182014-03-21 10:42:25 +0100865
866#
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200867# CIF_FPU is set, restore floating-point controls and floating-point registers.
868#
869.Lio_vxrs:
870 larl %r14,.Lio_return
871 jg load_fpu_regs
872
873#
Martin Schwidefsky916cda12016-01-26 14:10:34 +0100874# _TIF_GUARDED_STORAGE is set, call guarded_storage_load
875#
876.Lio_guarded_storage:
877 # TRACE_IRQS_ON already done at .Lio_return
878 ssm __LC_SVC_NEW_PSW # reenable interrupts
879 lgr %r2,%r11 # pass pointer to pt_regs
880 brasl %r14,gs_load_bc_cb
881 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
882 TRACE_IRQS_OFF
883 j .Lio_return
884
885#
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200887#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100888.Lio_reschedule:
889 # TRACE_IRQS_ON already done at .Lio_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100890 ssm __LC_SVC_NEW_PSW # reenable interrupts
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200891 brasl %r14,schedule # call scheduler
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100892 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100893 TRACE_IRQS_OFF
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100894 j .Lio_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700895
896#
Miroslav Benes2f09ca62017-02-13 19:42:34 -0600897# _TIF_PATCH_PENDING is set, call klp_update_patch_state
898#
899#ifdef CONFIG_LIVEPATCH
900.Lio_patch_pending:
901 lg %r2,__LC_CURRENT # pass pointer to task struct
902 larl %r14,.Lio_return
903 jg klp_update_patch_state
904#endif
905
906#
Roland McGrath02a029b2008-04-30 00:53:08 -0700907# _TIF_SIGPENDING or is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700908#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100909.Lio_sigpending:
910 # TRACE_IRQS_ON already done at .Lio_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100911 ssm __LC_SVC_NEW_PSW # reenable interrupts
912 lgr %r2,%r11 # pass pointer to pt_regs
913 brasl %r14,do_signal
914 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100915 TRACE_IRQS_OFF
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100916 j .Lio_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700917
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200918#
919# _TIF_NOTIFY_RESUME or is set, call do_notify_resume
920#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100921.Lio_notify_resume:
922 # TRACE_IRQS_ON already done at .Lio_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100923 ssm __LC_SVC_NEW_PSW # reenable interrupts
924 lgr %r2,%r11 # pass pointer to pt_regs
925 brasl %r14,do_notify_resume
926 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200927 TRACE_IRQS_OFF
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100928 j .Lio_return
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200929
Linus Torvalds1da177e2005-04-16 15:20:36 -0700930/*
931 * External interrupt handler routine
932 */
Jan Glauber144d6342011-07-24 10:48:19 +0200933ENTRY(ext_int_handler)
Heiko Carstens473e66b2012-05-09 16:27:39 +0200934 STCK __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100935 stpt __LC_ASYNC_ENTER_TIMER
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100936 BPOFF
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100937 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100938 lg %r12,__LC_CURRENT
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200939 larl %r13,cleanup_critical
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100940 lmg %r8,%r9,__LC_EXT_OLD_PSW
Martin Schwidefsky2acb94f2015-06-22 17:28:14 +0200941 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100942 stmg %r0,%r7,__PT_R0(%r11)
Martin Schwidefsky7041d282018-01-16 13:27:30 +0100943 # clear user controlled registers to prevent speculative use
944 xgr %r0,%r0
945 xgr %r1,%r1
946 xgr %r2,%r2
947 xgr %r3,%r3
948 xgr %r4,%r4
949 xgr %r5,%r5
950 xgr %r6,%r6
951 xgr %r7,%r7
952 xgr %r10,%r10
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100953 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
954 stmg %r8,%r9,__PT_PSW(%r11)
Martin Schwidefsky48f6b002013-06-17 14:54:02 +0200955 lghi %r1,__LC_EXT_PARAMS2
956 mvc __PT_INT_CODE(4,%r11),__LC_EXT_CPU_ADDR
957 mvc __PT_INT_PARM(4,%r11),__LC_EXT_PARAMS
958 mvc __PT_INT_PARM_LONG(8,%r11),0(%r1)
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200959 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
Heiko Carstensdb7e0072015-08-15 11:42:21 +0200960 TSTMSK __LC_CPU_FLAGS,_CIF_IGNORE_IRQ
961 jo .Lio_restore
Heiko Carstens1f194a42006-07-03 00:24:46 -0700962 TRACE_IRQS_OFF
Michael Holzheu0de9db32012-05-09 16:27:35 +0200963 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100964 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky1f44a2252013-06-27 09:01:09 +0200965 lghi %r3,EXT_INTERRUPT
966 brasl %r14,do_IRQ
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100967 j .Lio_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700968
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400969/*
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100970 * Load idle PSW. The second "half" of this function is in .Lcleanup_idle.
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400971 */
972ENTRY(psw_idle)
Martin Schwidefsky27f6b412012-07-20 11:15:08 +0200973 stg %r3,__SF_EMPTY(%r15)
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100974 larl %r1,.Lpsw_idle_lpsw+4
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400975 stg %r1,__SF_EMPTY+8(%r15)
Martin Schwidefsky72d38b12015-09-18 16:41:36 +0200976#ifdef CONFIG_SMP
977 larl %r1,smp_cpu_mtid
978 llgf %r1,0(%r1)
979 ltgr %r1,%r1
980 jz .Lpsw_idle_stcctm
981 .insn rsy,0xeb0000000017,%r1,5,__SF_EMPTY+16(%r15)
982.Lpsw_idle_stcctm:
983#endif
Martin Schwidefsky419123f2015-11-19 11:09:45 +0100984 oi __LC_CPU_FLAGS+7,_CIF_ENABLED_WAIT
Martin Schwidefskyd768bd82018-01-16 07:11:45 +0100985 BPON
Martin Schwidefsky27f6b412012-07-20 11:15:08 +0200986 STCK __CLOCK_IDLE_ENTER(%r2)
987 stpt __TIMER_IDLE_ENTER(%r2)
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100988.Lpsw_idle_lpsw:
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400989 lpswe __SF_EMPTY(%r15)
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +0200990 BR_EX %r14
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100991.Lpsw_idle_end:
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400992
Hendrik Bruecknerb5510d92015-09-29 10:04:41 +0200993/*
994 * Store floating-point controls and floating-point or vector register
995 * depending whether the vector facility is available. A critical section
996 * cleanup assures that the registers are stored even if interrupted for
997 * some other work. The CIF_FPU flag is set to trigger a lazy restore
998 * of the register contents at return from io or a system call.
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200999 */
1000ENTRY(save_fpu_regs)
Hendrik Bruecknerd0164ee2015-06-29 16:43:06 +02001001 lg %r2,__LC_CURRENT
1002 aghi %r2,__TASK_thread
Hendrik Brueckner83abeff2015-10-01 17:02:48 +02001003 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +01001004 jo .Lsave_fpu_regs_exit
Hendrik Bruecknerd0164ee2015-06-29 16:43:06 +02001005 stfpc __THREAD_FPU_fpc(%r2)
Hendrik Bruecknerd0164ee2015-06-29 16:43:06 +02001006 lg %r3,__THREAD_FPU_regs(%r2)
Hendrik Brueckner83abeff2015-10-01 17:02:48 +02001007 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001008 jz .Lsave_fpu_regs_fp # no -> store FP regs
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001009 VSTM %v0,%v15,0,%r3 # vstm 0,15,0(3)
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001010 VSTM %v16,%v31,256,%r3 # vstm 16,31,256(3)
1011 j .Lsave_fpu_regs_done # -> set CIF_FPU flag
1012.Lsave_fpu_regs_fp:
1013 std 0,0(%r3)
1014 std 1,8(%r3)
1015 std 2,16(%r3)
1016 std 3,24(%r3)
1017 std 4,32(%r3)
1018 std 5,40(%r3)
1019 std 6,48(%r3)
1020 std 7,56(%r3)
1021 std 8,64(%r3)
1022 std 9,72(%r3)
1023 std 10,80(%r3)
1024 std 11,88(%r3)
1025 std 12,96(%r3)
1026 std 13,104(%r3)
1027 std 14,112(%r3)
1028 std 15,120(%r3)
1029.Lsave_fpu_regs_done:
1030 oi __LC_CPU_FLAGS+7,_CIF_FPU
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +01001031.Lsave_fpu_regs_exit:
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +02001032 BR_EX %r14
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001033.Lsave_fpu_regs_end:
Al Viro711f5df2016-01-12 13:30:03 -05001034EXPORT_SYMBOL(save_fpu_regs)
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001035
Hendrik Bruecknerb5510d92015-09-29 10:04:41 +02001036/*
1037 * Load floating-point controls and floating-point or vector registers.
1038 * A critical section cleanup assures that the register contents are
1039 * loaded even if interrupted for some other work.
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001040 *
1041 * There are special calling conventions to fit into sysc and io return work:
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001042 * %r15: <kernel stack>
1043 * The function requires:
Hendrik Bruecknerb5510d92015-09-29 10:04:41 +02001044 * %r4
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001045 */
1046load_fpu_regs:
Hendrik Bruecknerd0164ee2015-06-29 16:43:06 +02001047 lg %r4,__LC_CURRENT
1048 aghi %r4,__TASK_thread
Hendrik Brueckner83abeff2015-10-01 17:02:48 +02001049 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +01001050 jno .Lload_fpu_regs_exit
Hendrik Bruecknerd0164ee2015-06-29 16:43:06 +02001051 lfpc __THREAD_FPU_fpc(%r4)
Hendrik Brueckner83abeff2015-10-01 17:02:48 +02001052 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
Hendrik Bruecknerd0164ee2015-06-29 16:43:06 +02001053 lg %r4,__THREAD_FPU_regs(%r4) # %r4 <- reg save area
Hendrik Bruecknerb5510d92015-09-29 10:04:41 +02001054 jz .Lload_fpu_regs_fp # -> no VX, load FP regs
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001055 VLM %v0,%v15,0,%r4
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001056 VLM %v16,%v31,256,%r4
1057 j .Lload_fpu_regs_done
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001058.Lload_fpu_regs_fp:
1059 ld 0,0(%r4)
1060 ld 1,8(%r4)
1061 ld 2,16(%r4)
1062 ld 3,24(%r4)
1063 ld 4,32(%r4)
1064 ld 5,40(%r4)
1065 ld 6,48(%r4)
1066 ld 7,56(%r4)
1067 ld 8,64(%r4)
1068 ld 9,72(%r4)
1069 ld 10,80(%r4)
1070 ld 11,88(%r4)
1071 ld 12,96(%r4)
1072 ld 13,104(%r4)
1073 ld 14,112(%r4)
1074 ld 15,120(%r4)
1075.Lload_fpu_regs_done:
1076 ni __LC_CPU_FLAGS+7,255-_CIF_FPU
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +01001077.Lload_fpu_regs_exit:
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +02001078 BR_EX %r14
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001079.Lload_fpu_regs_end:
1080
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001081.L__critical_end:
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001082
Linus Torvalds1da177e2005-04-16 15:20:36 -07001083/*
1084 * Machine check handler routines
1085 */
Jan Glauber144d6342011-07-24 10:48:19 +02001086ENTRY(mcck_int_handler)
Heiko Carstens473e66b2012-05-09 16:27:39 +02001087 STCK __LC_MCCK_CLOCK
Martin Schwidefskyd768bd82018-01-16 07:11:45 +01001088 BPOFF
Martin Schwidefsky3037a522017-10-12 13:24:48 +02001089 la %r1,4095 # validate r1
1090 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # validate cpu timer
1091 sckc __LC_CLOCK_COMPARATOR # validate comparator
1092 lam %a0,%a15,__LC_AREGS_SAVE_AREA-4095(%r1) # validate acrs
1093 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# validate gprs
Heiko Carstensd5c352c2016-11-08 11:08:26 +01001094 lg %r12,__LC_CURRENT
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001095 larl %r13,cleanup_critical
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001096 lmg %r8,%r9,__LC_MCK_OLD_PSW
Hendrik Brueckner83abeff2015-10-01 17:02:48 +02001097 TSTMSK __LC_MCCK_CODE,MCCK_CODE_SYSTEM_DAMAGE
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001098 jo .Lmcck_panic # yes -> rest of mcck code invalid
Martin Schwidefsky3037a522017-10-12 13:24:48 +02001099 TSTMSK __LC_MCCK_CODE,MCCK_CODE_CR_VALID
1100 jno .Lmcck_panic # control registers invalid -> panic
1101 la %r14,4095
1102 lctlg %c0,%c15,__LC_CREGS_SAVE_AREA-4095(%r14) # validate ctl regs
1103 ptlb
Vasily Gorbik2a2d7bef2017-10-27 12:44:48 +02001104 lg %r11,__LC_MCESAD-4095(%r14) # extended machine check save area
Martin Schwidefsky3037a522017-10-12 13:24:48 +02001105 nill %r11,0xfc00 # MCESA_ORIGIN_MASK
1106 TSTMSK __LC_CREGS_SAVE_AREA+16-4095(%r14),CR2_GUARDED_STORAGE
1107 jno 0f
1108 TSTMSK __LC_MCCK_CODE,MCCK_CODE_GS_VALID
1109 jno 0f
1110 .insn rxy,0xe3000000004d,0,__MCESA_GS_SAVE_AREA(%r11) # LGSC
11110: l %r14,__LC_FP_CREG_SAVE_AREA-4095(%r14)
1112 TSTMSK __LC_MCCK_CODE,MCCK_CODE_FC_VALID
1113 jo 0f
1114 sr %r14,%r14
11150: sfpc %r14
1116 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
1117 jo 0f
1118 lghi %r14,__LC_FPREGS_SAVE_AREA
1119 ld %f0,0(%r14)
1120 ld %f1,8(%r14)
1121 ld %f2,16(%r14)
1122 ld %f3,24(%r14)
1123 ld %f4,32(%r14)
1124 ld %f5,40(%r14)
1125 ld %f6,48(%r14)
1126 ld %f7,56(%r14)
1127 ld %f8,64(%r14)
1128 ld %f9,72(%r14)
1129 ld %f10,80(%r14)
1130 ld %f11,88(%r14)
1131 ld %f12,96(%r14)
1132 ld %f13,104(%r14)
1133 ld %f14,112(%r14)
1134 ld %f15,120(%r14)
1135 j 1f
11360: VLM %v0,%v15,0,%r11
1137 VLM %v16,%v31,256,%r11
11381: lghi %r14,__LC_CPU_TIMER_SAVE_AREA
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001139 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
Hendrik Brueckner83abeff2015-10-01 17:02:48 +02001140 TSTMSK __LC_MCCK_CODE,MCCK_CODE_CPU_TIMER_VALID
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001141 jo 3f
Martin Schwidefsky63b12242006-06-29 14:58:05 +02001142 la %r14,__LC_SYNC_ENTER_TIMER
1143 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
1144 jl 0f
1145 la %r14,__LC_ASYNC_ENTER_TIMER
11460: clc 0(8,%r14),__LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001147 jl 1f
Martin Schwidefsky63b12242006-06-29 14:58:05 +02001148 la %r14,__LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +010011491: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
1150 jl 2f
Martin Schwidefsky63b12242006-06-29 14:58:05 +02001151 la %r14,__LC_LAST_UPDATE_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +010011522: spt 0(%r14)
Martin Schwidefsky63779812010-05-17 10:00:03 +02001153 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
Martin Schwidefsky3037a522017-10-12 13:24:48 +020011543: TSTMSK __LC_MCCK_CODE,MCCK_CODE_PSW_MWP_VALID
1155 jno .Lmcck_panic
1156 tmhh %r8,0x0001 # interrupting from user ?
1157 jnz 4f
1158 TSTMSK __LC_MCCK_CODE,MCCK_CODE_PSW_IA_VALID
1159 jno .Lmcck_panic
Martin Schwidefskyce3dc442017-09-12 16:37:33 +020011604: ssm __LC_PGM_NEW_PSW # turn dat on, keep irqs off
1161 SWITCH_ASYNC __LC_GPREGS_SAVE_AREA+64,__LC_MCCK_ENTER_TIMER
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001162.Lmcck_skip:
Martin Schwidefsky6551fbd2013-02-28 16:28:41 +01001163 lghi %r14,__LC_GPREGS_SAVE_AREA+64
1164 stmg %r0,%r7,__PT_R0(%r11)
Martin Schwidefsky7041d282018-01-16 13:27:30 +01001165 # clear user controlled registers to prevent speculative use
1166 xgr %r0,%r0
1167 xgr %r1,%r1
1168 xgr %r2,%r2
1169 xgr %r3,%r3
1170 xgr %r4,%r4
1171 xgr %r5,%r5
1172 xgr %r6,%r6
1173 xgr %r7,%r7
1174 xgr %r10,%r10
Martin Schwidefsky6551fbd2013-02-28 16:28:41 +01001175 mvc __PT_R8(64,%r11),0(%r14)
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001176 stmg %r8,%r9,__PT_PSW(%r11)
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +02001177 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001178 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
1179 lgr %r2,%r11 # pass pointer to pt_regs
Heiko Carstens77fa2242005-06-25 14:55:30 -07001180 brasl %r14,s390_do_machine_check
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001181 tm __PT_PSW+1(%r11),0x01 # returning to user ?
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001182 jno .Lmcck_return
Heiko Carstens77fa2242005-06-25 14:55:30 -07001183 lg %r1,__LC_KERNEL_STACK # switch to kernel stack
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001184 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
1185 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
1186 la %r11,STACK_FRAME_OVERHEAD(%r1)
Heiko Carstens77fa2242005-06-25 14:55:30 -07001187 lgr %r15,%r1
Hendrik Brueckner83abeff2015-10-01 17:02:48 +02001188 TSTMSK __LC_CPU_FLAGS,_CIF_MCCK_PENDING
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001189 jno .Lmcck_return
Heiko Carstens1f194a42006-07-03 00:24:46 -07001190 TRACE_IRQS_OFF
Heiko Carstens77fa2242005-06-25 14:55:30 -07001191 brasl %r14,s390_handle_mcck
Heiko Carstens1f194a42006-07-03 00:24:46 -07001192 TRACE_IRQS_ON
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001193.Lmcck_return:
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001194 lg %r14,__LC_VDSO_PER_CPU
1195 lmg %r0,%r10,__PT_R0(%r11)
1196 mvc __LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW
Martin Schwidefsky63b12242006-06-29 14:58:05 +02001197 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
1198 jno 0f
Martin Schwidefsky6b730442018-01-16 07:36:46 +01001199 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
Martin Schwidefsky63b12242006-06-29 14:58:05 +02001200 stpt __LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001201 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
12020: lmg %r11,%r15,__PT_R11(%r11)
1203 lpswe __LC_RETURN_MCCK_PSW
1204
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001205.Lmcck_panic:
Martin Schwidefskyce3dc442017-09-12 16:37:33 +02001206 lg %r15,__LC_NODAT_STACK
Martin Schwidefskyce4dda32016-12-02 13:29:22 +01001207 la %r11,STACK_FRAME_OVERHEAD(%r15)
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001208 j .Lmcck_skip
Linus Torvalds1da177e2005-04-16 15:20:36 -07001209
Michael Holzheu7dd6b332011-08-03 16:44:19 +02001210#
1211# PSW restart interrupt handler
1212#
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -04001213ENTRY(restart_int_handler)
Martin Schwidefskye5b98192018-03-26 15:23:33 +02001214 ALTERNATIVE "", ".insn s,0xb2800000,_LPP_OFFSET", 40
1215 stg %r15,__LC_SAVE_AREA_RESTART
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -04001216 lg %r15,__LC_RESTART_STACK
Martin Schwidefskyce3dc442017-09-12 16:37:33 +02001217 xc STACK_FRAME_OVERHEAD(__PT_SIZE,%r15),STACK_FRAME_OVERHEAD(%r15)
1218 stmg %r0,%r14,STACK_FRAME_OVERHEAD+__PT_R0(%r15)
1219 mvc STACK_FRAME_OVERHEAD+__PT_R15(8,%r15),__LC_SAVE_AREA_RESTART
1220 mvc STACK_FRAME_OVERHEAD+__PT_PSW(16,%r15),__LC_RST_OLD_PSW
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -04001221 xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15)
Heiko Carstensfbe76562012-06-05 09:59:52 +02001222 lg %r1,__LC_RESTART_FN # load fn, parm & source cpu
1223 lg %r2,__LC_RESTART_DATA
1224 lg %r3,__LC_RESTART_SOURCE
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -04001225 ltgr %r3,%r3 # test source cpu address
1226 jm 1f # negative -> skip source stop
Heiko Carstenseb546192012-06-04 15:05:43 +020012270: sigp %r4,%r3,SIGP_SENSE # sigp sense to source cpu
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -04001228 brc 10,0b # wait for status stored
12291: basr %r14,%r1 # call function
1230 stap __SF_EMPTY(%r15) # store cpu address
1231 llgh %r3,__SF_EMPTY(%r15)
Heiko Carstenseb546192012-06-04 15:05:43 +020012322: sigp %r4,%r3,SIGP_STOP # sigp stop to current cpu
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -04001233 brc 2,2b
12343: j 3b
Michael Holzheu7dd6b332011-08-03 16:44:19 +02001235
Martin Schwidefsky860dba42011-01-05 12:47:25 +01001236 .section .kprobes.text, "ax"
1237
Martin Schwidefskyce3dc442017-09-12 16:37:33 +02001238#if defined(CONFIG_CHECK_STACK) || defined(CONFIG_VMAP_STACK)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001239/*
1240 * The synchronous or the asynchronous stack overflowed. We are dead.
1241 * No need to properly save the registers, we are going to panic anyway.
1242 * Setup a pt_regs so that show_trace can provide a good call trace.
1243 */
1244stack_overflow:
Martin Schwidefskyce3dc442017-09-12 16:37:33 +02001245 lg %r15,__LC_NODAT_STACK # change to panic stack
Martin Schwidefskydc7ee002013-04-24 10:20:43 +02001246 la %r11,STACK_FRAME_OVERHEAD(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001247 stmg %r0,%r7,__PT_R0(%r11)
1248 stmg %r8,%r9,__PT_PSW(%r11)
1249 mvc __PT_R8(64,%r11),0(%r14)
1250 stg %r10,__PT_ORIG_GPR2(%r11) # store last break to orig_gpr2
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001251 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
1252 lgr %r2,%r11 # pass pointer to pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -07001253 jg kernel_stack_overflow
1254#endif
1255
Linus Torvalds1da177e2005-04-16 15:20:36 -07001256cleanup_critical:
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +02001257#if IS_ENABLED(CONFIG_KVM)
1258 clg %r9,BASED(.Lcleanup_table_sie) # .Lsie_gmap
1259 jl 0f
1260 clg %r9,BASED(.Lcleanup_table_sie+8)# .Lsie_done
1261 jl .Lcleanup_sie
1262#endif
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001263 clg %r9,BASED(.Lcleanup_table) # system_call
Linus Torvalds1da177e2005-04-16 15:20:36 -07001264 jl 0f
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001265 clg %r9,BASED(.Lcleanup_table+8) # .Lsysc_do_svc
1266 jl .Lcleanup_system_call
1267 clg %r9,BASED(.Lcleanup_table+16) # .Lsysc_tif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001268 jl 0f
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001269 clg %r9,BASED(.Lcleanup_table+24) # .Lsysc_restore
1270 jl .Lcleanup_sysc_tif
1271 clg %r9,BASED(.Lcleanup_table+32) # .Lsysc_done
1272 jl .Lcleanup_sysc_restore
1273 clg %r9,BASED(.Lcleanup_table+40) # .Lio_tif
Martin Schwidefsky63b12242006-06-29 14:58:05 +02001274 jl 0f
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001275 clg %r9,BASED(.Lcleanup_table+48) # .Lio_restore
1276 jl .Lcleanup_io_tif
1277 clg %r9,BASED(.Lcleanup_table+56) # .Lio_done
1278 jl .Lcleanup_io_restore
1279 clg %r9,BASED(.Lcleanup_table+64) # psw_idle
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001280 jl 0f
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001281 clg %r9,BASED(.Lcleanup_table+72) # .Lpsw_idle_end
1282 jl .Lcleanup_idle
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001283 clg %r9,BASED(.Lcleanup_table+80) # save_fpu_regs
1284 jl 0f
1285 clg %r9,BASED(.Lcleanup_table+88) # .Lsave_fpu_regs_end
1286 jl .Lcleanup_save_fpu_regs
1287 clg %r9,BASED(.Lcleanup_table+96) # load_fpu_regs
1288 jl 0f
1289 clg %r9,BASED(.Lcleanup_table+104) # .Lload_fpu_regs_end
1290 jl .Lcleanup_load_fpu_regs
Christian Borntraeger891f6a722018-06-21 14:49:38 +020012910: BR_EX %r14,%r11
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001292
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +02001293 .align 8
1294.Lcleanup_table:
1295 .quad system_call
1296 .quad .Lsysc_do_svc
1297 .quad .Lsysc_tif
1298 .quad .Lsysc_restore
1299 .quad .Lsysc_done
1300 .quad .Lio_tif
1301 .quad .Lio_restore
1302 .quad .Lio_done
1303 .quad psw_idle
1304 .quad .Lpsw_idle_end
1305 .quad save_fpu_regs
1306 .quad .Lsave_fpu_regs_end
1307 .quad load_fpu_regs
1308 .quad .Lload_fpu_regs_end
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +02001309
1310#if IS_ENABLED(CONFIG_KVM)
1311.Lcleanup_table_sie:
1312 .quad .Lsie_gmap
1313 .quad .Lsie_done
1314
1315.Lcleanup_sie:
QingFeng Haoc9295002017-06-07 11:30:42 +02001316 cghi %r11,__LC_SAVE_AREA_ASYNC #Is this in normal interrupt?
1317 je 1f
1318 slg %r9,BASED(.Lsie_crit_mcck_start)
1319 clg %r9,BASED(.Lsie_crit_mcck_length)
1320 jh 1f
1321 oi __LC_CPU_FLAGS+7, _CIF_MCCK_GUEST
Martin Schwidefsky92fa7a12018-03-20 13:33:43 +010013221: BPENTER __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
1323 lg %r9,__SF_SIE_CONTROL(%r15) # get control block pointer
Christian Borntraegere22cf8c2015-10-06 18:06:15 +02001324 ni __SIE_PROG0C+3(%r9),0xfe # no longer in SIE
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +02001325 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
1326 larl %r9,sie_exit # skip forward to sie_exit
Christian Borntraeger891f6a722018-06-21 14:49:38 +02001327 BR_EX %r14,%r11
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +02001328#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001329
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001330.Lcleanup_system_call:
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001331 # check if stpt has been executed
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001332 clg %r9,BASED(.Lcleanup_system_call_insn)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001333 jh 0f
1334 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001335 cghi %r11,__LC_SAVE_AREA_ASYNC
Martin Schwidefsky63779812010-05-17 10:00:03 +02001336 je 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001337 mvc __LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER
13380: # check if stmg has been executed
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001339 clg %r9,BASED(.Lcleanup_system_call_insn+8)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001340 jh 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001341 mvc __LC_SAVE_AREA_SYNC(64),0(%r11)
13420: # check if base register setup + TIF bit load has been done
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001343 clg %r9,BASED(.Lcleanup_system_call_insn+16)
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001344 jhe 0f
Martin Schwidefsky34525e12017-01-25 12:54:17 +01001345 # set up saved register r12 task struct pointer
1346 stg %r12,32(%r11)
1347 # set up saved register r13 __TASK_thread offset
1348 mvc 40(8,%r11),BASED(.Lcleanup_system_call_const)
Martin Schwidefskyc5328902011-12-27 11:27:15 +010013490: # check if the user time update has been done
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001350 clg %r9,BASED(.Lcleanup_system_call_insn+24)
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001351 jh 0f
1352 lg %r15,__LC_EXIT_TIMER
1353 slg %r15,__LC_SYNC_ENTER_TIMER
1354 alg %r15,__LC_USER_TIMER
1355 stg %r15,__LC_USER_TIMER
13560: # check if the system time update has been done
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001357 clg %r9,BASED(.Lcleanup_system_call_insn+32)
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001358 jh 0f
1359 lg %r15,__LC_LAST_UPDATE_TIMER
1360 slg %r15,__LC_EXIT_TIMER
1361 alg %r15,__LC_SYSTEM_TIMER
1362 stg %r15,__LC_SYSTEM_TIMER
13630: # update accounting time stamp
Linus Torvalds1da177e2005-04-16 15:20:36 -07001364 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Martin Schwidefskyd5feec02018-02-22 13:42:29 +01001365 BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
Martin Schwidefsky34525e12017-01-25 12:54:17 +01001366 # set up saved register r11
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001367 lg %r15,__LC_KERNEL_STACK
Martin Schwidefskydc7ee002013-04-24 10:20:43 +02001368 la %r9,STACK_FRAME_OVERHEAD(%r15)
1369 stg %r9,24(%r11) # r11 pt_regs pointer
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001370 # fill pt_regs
Martin Schwidefskydc7ee002013-04-24 10:20:43 +02001371 mvc __PT_R8(64,%r9),__LC_SAVE_AREA_SYNC
1372 stmg %r0,%r7,__PT_R0(%r9)
1373 mvc __PT_PSW(16,%r9),__LC_SVC_OLD_PSW
1374 mvc __PT_INT_CODE(4,%r9),__LC_SVC_ILC
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +02001375 xc __PT_FLAGS(8,%r9),__PT_FLAGS(%r9)
1376 mvi __PT_FLAGS+7(%r9),_PIF_SYSCALL
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001377 # setup saved register r15
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001378 stg %r15,56(%r11) # r15 stack pointer
1379 # set new psw address and exit
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001380 larl %r9,.Lsysc_do_svc
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +02001381 BR_EX %r14,%r11
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001382.Lcleanup_system_call_insn:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001383 .quad system_call
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001384 .quad .Lsysc_stmg
1385 .quad .Lsysc_per
Martin Schwidefskya359bb12015-06-22 17:27:48 +02001386 .quad .Lsysc_vtime+36
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001387 .quad .Lsysc_vtime+42
Martin Schwidefsky34525e12017-01-25 12:54:17 +01001388.Lcleanup_system_call_const:
1389 .quad __TASK_thread
Linus Torvalds1da177e2005-04-16 15:20:36 -07001390
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001391.Lcleanup_sysc_tif:
1392 larl %r9,.Lsysc_tif
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +02001393 BR_EX %r14,%r11
Linus Torvalds1da177e2005-04-16 15:20:36 -07001394
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001395.Lcleanup_sysc_restore:
Martin Schwidefsky07a63cb2017-05-02 13:36:00 +02001396 # check if stpt has been executed
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001397 clg %r9,BASED(.Lcleanup_sysc_restore_insn)
Martin Schwidefsky07a63cb2017-05-02 13:36:00 +02001398 jh 0f
1399 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
1400 cghi %r11,__LC_SAVE_AREA_ASYNC
Martin Schwidefsky63779812010-05-17 10:00:03 +02001401 je 0f
Martin Schwidefsky07a63cb2017-05-02 13:36:00 +02001402 mvc __LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
14030: clg %r9,BASED(.Lcleanup_sysc_restore_insn+8)
1404 je 1f
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001405 lg %r9,24(%r11) # get saved pointer to pt_regs
1406 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
1407 mvc 0(64,%r11),__PT_R8(%r9)
1408 lmg %r0,%r7,__PT_R0(%r9)
Martin Schwidefsky07a63cb2017-05-02 13:36:00 +020014091: lmg %r8,%r9,__LC_RETURN_PSW
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +02001410 BR_EX %r14,%r11
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001411.Lcleanup_sysc_restore_insn:
Martin Schwidefsky07a63cb2017-05-02 13:36:00 +02001412 .quad .Lsysc_exit_timer
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001413 .quad .Lsysc_done - 4
Linus Torvalds1da177e2005-04-16 15:20:36 -07001414
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001415.Lcleanup_io_tif:
1416 larl %r9,.Lio_tif
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +02001417 BR_EX %r14,%r11
Martin Schwidefsky176b1802010-04-09 13:43:00 +02001418
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001419.Lcleanup_io_restore:
Martin Schwidefsky07a63cb2017-05-02 13:36:00 +02001420 # check if stpt has been executed
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001421 clg %r9,BASED(.Lcleanup_io_restore_insn)
Martin Schwidefsky07a63cb2017-05-02 13:36:00 +02001422 jh 0f
1423 mvc __LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
14240: clg %r9,BASED(.Lcleanup_io_restore_insn+8)
1425 je 1f
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001426 lg %r9,24(%r11) # get saved r11 pointer to pt_regs
1427 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001428 mvc 0(64,%r11),__PT_R8(%r9)
1429 lmg %r0,%r7,__PT_R0(%r9)
Martin Schwidefsky07a63cb2017-05-02 13:36:00 +020014301: lmg %r8,%r9,__LC_RETURN_PSW
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +02001431 BR_EX %r14,%r11
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001432.Lcleanup_io_restore_insn:
Martin Schwidefsky07a63cb2017-05-02 13:36:00 +02001433 .quad .Lio_exit_timer
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001434 .quad .Lio_done - 4
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001435
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001436.Lcleanup_idle:
Martin Schwidefsky419123f2015-11-19 11:09:45 +01001437 ni __LC_CPU_FLAGS+7,255-_CIF_ENABLED_WAIT
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001438 # copy interrupt clock & cpu timer
Martin Schwidefsky27f6b412012-07-20 11:15:08 +02001439 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_INT_CLOCK
1440 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_ASYNC_ENTER_TIMER
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001441 cghi %r11,__LC_SAVE_AREA_ASYNC
1442 je 0f
Martin Schwidefsky27f6b412012-07-20 11:15:08 +02001443 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_MCCK_CLOCK
1444 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_MCCK_ENTER_TIMER
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -040014450: # check if stck & stpt have been executed
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001446 clg %r9,BASED(.Lcleanup_idle_insn)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001447 jhe 1f
Martin Schwidefsky27f6b412012-07-20 11:15:08 +02001448 mvc __CLOCK_IDLE_ENTER(8,%r2),__CLOCK_IDLE_EXIT(%r2)
1449 mvc __TIMER_IDLE_ENTER(8,%r2),__TIMER_IDLE_EXIT(%r2)
Martin Schwidefsky72d38b12015-09-18 16:41:36 +020014501: # calculate idle cycles
1451#ifdef CONFIG_SMP
1452 clg %r9,BASED(.Lcleanup_idle_insn)
1453 jl 3f
1454 larl %r1,smp_cpu_mtid
1455 llgf %r1,0(%r1)
1456 ltgr %r1,%r1
1457 jz 3f
1458 .insn rsy,0xeb0000000017,%r1,5,__SF_EMPTY+80(%r15)
1459 larl %r3,mt_cycles
1460 ag %r3,__LC_PERCPU_OFFSET
1461 la %r4,__SF_EMPTY+16(%r15)
14622: lg %r0,0(%r3)
1463 slg %r0,0(%r4)
1464 alg %r0,64(%r4)
1465 stg %r0,0(%r3)
1466 la %r3,8(%r3)
1467 la %r4,8(%r4)
1468 brct %r1,2b
1469#endif
14703: # account system time going idle
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001471 lg %r9,__LC_STEAL_TIMER
Martin Schwidefsky27f6b412012-07-20 11:15:08 +02001472 alg %r9,__CLOCK_IDLE_ENTER(%r2)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001473 slg %r9,__LC_LAST_UPDATE_CLOCK
1474 stg %r9,__LC_STEAL_TIMER
Martin Schwidefsky27f6b412012-07-20 11:15:08 +02001475 mvc __LC_LAST_UPDATE_CLOCK(8),__CLOCK_IDLE_EXIT(%r2)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001476 lg %r9,__LC_SYSTEM_TIMER
1477 alg %r9,__LC_LAST_UPDATE_TIMER
Martin Schwidefsky27f6b412012-07-20 11:15:08 +02001478 slg %r9,__TIMER_IDLE_ENTER(%r2)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001479 stg %r9,__LC_SYSTEM_TIMER
Martin Schwidefsky27f6b412012-07-20 11:15:08 +02001480 mvc __LC_LAST_UPDATE_TIMER(8),__TIMER_IDLE_EXIT(%r2)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001481 # prepare return psw
Martin Schwidefsky0587d402013-08-23 14:45:58 +02001482 nihh %r8,0xfcfd # clear irq & wait state bits
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001483 lg %r9,48(%r11) # return from psw_idle
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +02001484 BR_EX %r14,%r11
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001485.Lcleanup_idle_insn:
1486 .quad .Lpsw_idle_lpsw
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001487
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001488.Lcleanup_save_fpu_regs:
Martin Schwidefskye370e472016-03-10 09:52:55 +01001489 larl %r9,save_fpu_regs
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +02001490 BR_EX %r14,%r11
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001491
1492.Lcleanup_load_fpu_regs:
Martin Schwidefskye370e472016-03-10 09:52:55 +01001493 larl %r9,load_fpu_regs
Martin Schwidefsky6dd85fb2018-04-20 16:49:46 +02001494 BR_EX %r14,%r11
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001495
Linus Torvalds1da177e2005-04-16 15:20:36 -07001496/*
1497 * Integer constants
1498 */
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001499 .align 8
Linus Torvalds1da177e2005-04-16 15:20:36 -07001500.Lcritical_start:
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001501 .quad .L__critical_start
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001502.Lcritical_length:
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001503 .quad .L__critical_end - .L__critical_start
Heiko Carstens61aa4882013-11-01 10:08:20 +01001504#if IS_ENABLED(CONFIG_KVM)
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +02001505.Lsie_critical_start:
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001506 .quad .Lsie_gmap
Martin Schwidefsky7c470532013-05-17 14:41:37 +02001507.Lsie_critical_length:
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001508 .quad .Lsie_done - .Lsie_gmap
QingFeng Haoc9295002017-06-07 11:30:42 +02001509.Lsie_crit_mcck_start:
1510 .quad .Lsie_entry
1511.Lsie_crit_mcck_length:
1512 .quad .Lsie_skip - .Lsie_entry
Martin Schwidefsky603d1a52011-07-24 10:48:18 +02001513#endif
Heiko Carstensa876cb32015-02-13 14:44:29 +01001514 .section .rodata, "a"
1515#define SYSCALL(esame,emu) .long esame
Heiko Carstens9bf12262009-06-12 10:26:47 +02001516 .globl sys_call_table
Linus Torvalds1da177e2005-04-16 15:20:36 -07001517sys_call_table:
Hendrik Brueckner4381f9f2017-12-11 14:47:27 +01001518#include "asm/syscall_table.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -07001519#undef SYSCALL
1520
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -08001521#ifdef CONFIG_COMPAT
Linus Torvalds1da177e2005-04-16 15:20:36 -07001522
Heiko Carstensa876cb32015-02-13 14:44:29 +01001523#define SYSCALL(esame,emu) .long emu
Martin Schwidefsky61649882013-04-24 12:58:39 +02001524 .globl sys_call_table_emu
Linus Torvalds1da177e2005-04-16 15:20:36 -07001525sys_call_table_emu:
Hendrik Brueckner4381f9f2017-12-11 14:47:27 +01001526#include "asm/syscall_table.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -07001527#undef SYSCALL
1528#endif