blob: f687f168c94d50030082654373b35d178da4930b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * S390 low-level entry points.
3 *
Heiko Carstensa53c8fa2012-07-20 11:15:04 +02004 * Copyright IBM Corp. 1999, 2012
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
Heiko Carstens25d83cb2006-09-28 16:56:37 +02006 * Hartmut Penner (hp@de.ibm.com),
7 * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
Heiko Carstens77fa2242005-06-25 14:55:30 -07008 * Heiko Carstens <heiko.carstens@de.ibm.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 */
10
Heiko Carstens2bc89b52008-02-05 16:50:40 +010011#include <linux/init.h>
Jan Glauber144d6342011-07-24 10:48:19 +020012#include <linux/linkage.h>
Heiko Carstenseb608fb2012-09-05 13:26:11 +020013#include <asm/processor.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <asm/cache.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <asm/errno.h>
16#include <asm/ptrace.h>
17#include <asm/thread_info.h>
Sam Ravnborg0013a852005-09-09 20:57:26 +020018#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <asm/unistd.h>
20#include <asm/page.h>
Heiko Carstenseb546192012-06-04 15:05:43 +020021#include <asm/sigp.h>
Martin Schwidefsky1f44a2252013-06-27 09:01:09 +020022#include <asm/irq.h>
Hendrik Brueckner9977e882015-06-10 12:53:42 +020023#include <asm/vx-insn.h>
Hendrik Brueckner83abeff2015-10-01 17:02:48 +020024#include <asm/setup.h>
25#include <asm/nmi.h>
Al Viro711f5df2016-01-12 13:30:03 -050026#include <asm/export.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
Martin Schwidefskyc5328902011-12-27 11:27:15 +010028__PT_R0 = __PT_GPRS
29__PT_R1 = __PT_GPRS + 8
30__PT_R2 = __PT_GPRS + 16
31__PT_R3 = __PT_GPRS + 24
32__PT_R4 = __PT_GPRS + 32
33__PT_R5 = __PT_GPRS + 40
34__PT_R6 = __PT_GPRS + 48
35__PT_R7 = __PT_GPRS + 56
36__PT_R8 = __PT_GPRS + 64
37__PT_R9 = __PT_GPRS + 72
38__PT_R10 = __PT_GPRS + 80
39__PT_R11 = __PT_GPRS + 88
40__PT_R12 = __PT_GPRS + 96
41__PT_R13 = __PT_GPRS + 104
42__PT_R14 = __PT_GPRS + 112
43__PT_R15 = __PT_GPRS + 120
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
Heiko Carstens3a890382016-11-14 14:39:16 +010045STACK_SHIFT = PAGE_SHIFT + THREAD_SIZE_ORDER
Linus Torvalds1da177e2005-04-16 15:20:36 -070046STACK_SIZE = 1 << STACK_SHIFT
Martin Schwidefskydc7ee002013-04-24 10:20:43 +020047STACK_INIT = STACK_SIZE - STACK_FRAME_OVERHEAD - __PT_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
Jan Willeke2a0a5b22014-09-22 16:39:06 +020049_TIF_WORK = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
50 _TIF_UPROBE)
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +020051_TIF_TRACE = (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | \
52 _TIF_SYSCALL_TRACEPOINT)
Hendrik Brueckner9977e882015-06-10 12:53:42 +020053_CIF_WORK = (_CIF_MCCK_PENDING | _CIF_ASCE | _CIF_FPU)
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +020054_PIF_WORK = (_PIF_PER_TRAP)
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
Hendrik Brueckner9977e882015-06-10 12:53:42 +020056#define BASED(name) name-cleanup_critical(%r13)
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
Martin Schwidefskyc5328902011-12-27 11:27:15 +010058 .macro TRACE_IRQS_ON
59#ifdef CONFIG_TRACE_IRQFLAGS
60 basr %r2,%r0
61 brasl %r14,trace_hardirqs_on_caller
62#endif
63 .endm
64
65 .macro TRACE_IRQS_OFF
66#ifdef CONFIG_TRACE_IRQFLAGS
67 basr %r2,%r0
68 brasl %r14,trace_hardirqs_off_caller
69#endif
70 .endm
71
72 .macro LOCKDEP_SYS_EXIT
73#ifdef CONFIG_LOCKDEP
74 tm __PT_PSW+1(%r11),0x01 # returning to user ?
75 jz .+10
76 brasl %r14,lockdep_sys_exit
77#endif
78 .endm
79
Martin Schwidefskyc5328902011-12-27 11:27:15 +010080 .macro CHECK_STACK stacksize,savearea
Martin Schwidefsky63b12242006-06-29 14:58:05 +020081#ifdef CONFIG_CHECK_STACK
Martin Schwidefskyc5328902011-12-27 11:27:15 +010082 tml %r15,\stacksize - CONFIG_STACK_GUARD
83 lghi %r14,\savearea
84 jz stack_overflow
Martin Schwidefsky63b12242006-06-29 14:58:05 +020085#endif
Martin Schwidefsky63b12242006-06-29 14:58:05 +020086 .endm
87
Martin Schwidefsky2acb94f2015-06-22 17:28:14 +020088 .macro SWITCH_ASYNC savearea,timer
Martin Schwidefskyc5328902011-12-27 11:27:15 +010089 tmhh %r8,0x0001 # interrupting from user ?
90 jnz 1f
91 lgr %r14,%r9
92 slg %r14,BASED(.Lcritical_start)
93 clg %r14,BASED(.Lcritical_length)
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 jhe 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +010095 lghi %r11,\savearea # inside critical section, do cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 brasl %r14,cleanup_critical
Martin Schwidefskyc5328902011-12-27 11:27:15 +010097 tmhh %r8,0x0001 # retest problem state after cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 jnz 1f
Martin Schwidefsky2acb94f2015-06-22 17:28:14 +0200990: lg %r14,__LC_ASYNC_STACK # are we already on the async stack?
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 slgr %r14,%r15
Martin Schwidefsky2acb94f2015-06-22 17:28:14 +0200101 srag %r14,%r14,STACK_SHIFT
Martin Schwidefskya359bb12015-06-22 17:27:48 +0200102 jnz 2f
Martin Schwidefsky2acb94f2015-06-22 17:28:14 +0200103 CHECK_STACK 1<<STACK_SHIFT,\savearea
Martin Schwidefskydc7ee002013-04-24 10:20:43 +0200104 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
Martin Schwidefskya359bb12015-06-22 17:27:48 +0200105 j 3f
Martin Schwidefsky34525e12017-01-25 12:54:17 +01001061: UPDATE_VTIME %r14,%r15,\timer
Martin Schwidefsky2acb94f2015-06-22 17:28:14 +02001072: lg %r15,__LC_ASYNC_STACK # load async stack
Martin Schwidefskya359bb12015-06-22 17:27:48 +02001083: la %r11,STACK_FRAME_OVERHEAD(%r15)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700109 .endm
110
Martin Schwidefskya359bb12015-06-22 17:27:48 +0200111 .macro UPDATE_VTIME w1,w2,enter_timer
112 lg \w1,__LC_EXIT_TIMER
113 lg \w2,__LC_LAST_UPDATE_TIMER
114 slg \w1,\enter_timer
115 slg \w2,__LC_EXIT_TIMER
116 alg \w1,__LC_USER_TIMER
117 alg \w2,__LC_SYSTEM_TIMER
118 stg \w1,__LC_USER_TIMER
119 stg \w2,__LC_SYSTEM_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100120 mvc __LC_LAST_UPDATE_TIMER(8),\enter_timer
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200121 .endm
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
Martin Schwidefsky1e546222010-10-25 16:10:37 +0200123 .macro REENABLE_IRQS
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100124 stg %r8,__LC_RETURN_PSW
125 ni __LC_RETURN_PSW,0xbf
126 ssm __LC_RETURN_PSW
Martin Schwidefsky1e546222010-10-25 16:10:37 +0200127 .endm
128
Heiko Carstens473e66b2012-05-09 16:27:39 +0200129 .macro STCK savearea
Heiko Carstensd652d592012-05-14 10:35:22 +0200130#ifdef CONFIG_HAVE_MARCH_Z9_109_FEATURES
Heiko Carstens473e66b2012-05-09 16:27:39 +0200131 .insn s,0xb27c0000,\savearea # store clock fast
132#else
133 .insn s,0xb2050000,\savearea # store clock
134#endif
135 .endm
136
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200137 /*
138 * The TSTMSK macro generates a test-under-mask instruction by
139 * calculating the memory offset for the specified mask value.
140 * Mask value can be any constant. The macro shifts the mask
141 * value to calculate the memory offset for the test-under-mask
142 * instruction.
143 */
144 .macro TSTMSK addr, mask, size=8, bytepos=0
145 .if (\bytepos < \size) && (\mask >> 8)
146 .if (\mask & 0xff)
147 .error "Mask exceeds byte boundary"
148 .endif
149 TSTMSK \addr, "(\mask >> 8)", \size, "(\bytepos + 1)"
150 .exitm
151 .endif
152 .ifeq \mask
153 .error "Mask must not be zero"
154 .endif
155 off = \size - \bytepos - 1
156 tm off+\addr, \mask
157 .endm
158
Martin Schwidefsky860dba42011-01-05 12:47:25 +0100159 .section .kprobes.text, "ax"
Heiko Carstens46210c42016-06-30 12:40:25 +0200160.Ldummy:
161 /*
162 * This nop exists only in order to avoid that __switch_to starts at
163 * the beginning of the kprobes text section. In that case we would
164 * have several symbols at the same address. E.g. objdump would take
165 * an arbitrary symbol name when disassembling this code.
166 * With the added nop in between the __switch_to symbol is unique
167 * again.
168 */
169 nop 0
Martin Schwidefsky860dba42011-01-05 12:47:25 +0100170
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171/*
172 * Scheduler resume function, called by switch_to
173 * gpr2 = (task_struct *) prev
174 * gpr3 = (task_struct *) next
175 * Returns:
176 * gpr2 = prev
177 */
Jan Glauber144d6342011-07-24 10:48:19 +0200178ENTRY(__switch_to)
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +0200179 stmg %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task
Martin Schwidefsky3827ec32015-07-20 10:01:46 +0200180 lgr %r1,%r2
181 aghi %r1,__TASK_thread # thread_struct of prev task
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100182 lg %r5,__TASK_stack(%r3) # start of kernel stack of next
Martin Schwidefsky3827ec32015-07-20 10:01:46 +0200183 stg %r15,__THREAD_ksp(%r1) # store kernel stack of prev
184 lgr %r1,%r3
185 aghi %r1,__TASK_thread # thread_struct of next task
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +0200186 lgr %r15,%r5
Martin Schwidefskydc7ee002013-04-24 10:20:43 +0200187 aghi %r15,STACK_INIT # end of kernel stack of next
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +0200188 stg %r3,__LC_CURRENT # store task struct of next
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +0200189 stg %r15,__LC_KERNEL_STACK # store end of kernel stack
Martin Schwidefsky3827ec32015-07-20 10:01:46 +0200190 lg %r15,__THREAD_ksp(%r1) # load kernel stack of next
Christian Borntraegerb1685ab2016-02-29 16:05:35 +0100191 /* c4 is used in guest detection: arch/s390/kernel/perf_cpum_sf.c */
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +0200192 lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4
Christian Borntraegere22cf8c2015-10-06 18:06:15 +0200193 mvc __LC_CURRENT_PID(4,%r0),__TASK_pid(%r3) # store pid of next
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200194 lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task
Christian Borntraegere22cf8c2015-10-06 18:06:15 +0200195 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_LPP
196 bzr %r14
197 .insn s,0xb2800000,__LC_LPP # set program parameter
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 br %r14
199
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100200.L__critical_start:
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200201
202#if IS_ENABLED(CONFIG_KVM)
203/*
204 * sie64a calling convention:
205 * %r2 pointer to sie control block
206 * %r3 guest register save area
207 */
208ENTRY(sie64a)
209 stmg %r6,%r14,__SF_GPRS(%r15) # save kernel registers
210 stg %r2,__SF_EMPTY(%r15) # save control block pointer
211 stg %r3,__SF_EMPTY+8(%r15) # save guest register save area
Christian Borntraegere22cf8c2015-10-06 18:06:15 +0200212 xc __SF_EMPTY+16(8,%r15),__SF_EMPTY+16(%r15) # reason code = 0
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200213 TSTMSK __LC_CPU_FLAGS,_CIF_FPU # load guest fp/vx registers ?
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200214 jno .Lsie_load_guest_gprs
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200215 brasl %r14,load_fpu_regs # load guest fp/vx regs
216.Lsie_load_guest_gprs:
217 lmg %r0,%r13,0(%r3) # load guest gprs 0-13
218 lg %r14,__LC_GMAP # get gmap pointer
219 ltgr %r14,%r14
220 jz .Lsie_gmap
221 lctlg %c1,%c1,__GMAP_ASCE(%r14) # load primary asce
222.Lsie_gmap:
223 lg %r14,__SF_EMPTY(%r15) # get control block pointer
224 oi __SIE_PROG0C+3(%r14),1 # we are going into SIE now
225 tm __SIE_PROG20+3(%r14),3 # last exit...
226 jnz .Lsie_skip
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200227 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200228 jo .Lsie_skip # exit if fp/vx regs changed
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200229 sie 0(%r14)
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200230.Lsie_skip:
231 ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE
232 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
233.Lsie_done:
234# some program checks are suppressing. C code (e.g. do_protection_exception)
235# will rewind the PSW by the ILC, which is 4 bytes in case of SIE. Other
236# instructions between sie64a and .Lsie_done should not cause program
237# interrupts. So lets use a nop (47 00 00 00) as a landing pad.
238# See also .Lcleanup_sie
239.Lrewind_pad:
240 nop 0
241 .globl sie_exit
242sie_exit:
243 lg %r14,__SF_EMPTY+8(%r15) # load guest register save area
244 stmg %r0,%r13,0(%r14) # save guest gprs 0-13
245 lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers
Christian Borntraegere22cf8c2015-10-06 18:06:15 +0200246 lg %r2,__SF_EMPTY+16(%r15) # return exit reason code
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200247 br %r14
248.Lsie_fault:
249 lghi %r14,-EFAULT
Christian Borntraegere22cf8c2015-10-06 18:06:15 +0200250 stg %r14,__SF_EMPTY+16(%r15) # set exit reason code
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200251 j sie_exit
252
253 EX_TABLE(.Lrewind_pad,.Lsie_fault)
254 EX_TABLE(sie_exit,.Lsie_fault)
Al Viro711f5df2016-01-12 13:30:03 -0500255EXPORT_SYMBOL(sie64a)
256EXPORT_SYMBOL(sie_exit)
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200257#endif
258
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259/*
260 * SVC interrupt handler routine. System calls are synchronous events and
261 * are executed with interrupts enabled.
262 */
263
Jan Glauber144d6342011-07-24 10:48:19 +0200264ENTRY(system_call)
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100265 stpt __LC_SYNC_ENTER_TIMER
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100266.Lsysc_stmg:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100267 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100268 lg %r12,__LC_CURRENT
Martin Schwidefsky34525e12017-01-25 12:54:17 +0100269 lghi %r13,__TASK_thread
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200270 lghi %r14,_PIF_SYSCALL
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100271.Lsysc_per:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100272 lg %r15,__LC_KERNEL_STACK
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100273 la %r11,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs
Martin Schwidefskya359bb12015-06-22 17:27:48 +0200274.Lsysc_vtime:
Martin Schwidefsky34525e12017-01-25 12:54:17 +0100275 UPDATE_VTIME %r8,%r9,__LC_SYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100276 stmg %r0,%r7,__PT_R0(%r11)
277 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
278 mvc __PT_PSW(16,%r11),__LC_SVC_OLD_PSW
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100279 mvc __PT_INT_CODE(4,%r11),__LC_SVC_ILC
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200280 stg %r14,__PT_FLAGS(%r11)
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100281.Lsysc_do_svc:
Martin Schwidefskyef280c82016-11-08 12:33:38 +0100282 # load address of system call table
Martin Schwidefskyef280c82016-11-08 12:33:38 +0100283 lg %r10,__THREAD_sysc_table(%r13,%r12)
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100284 llgh %r8,__PT_INT_CODE+2(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100285 slag %r8,%r8,2 # shift and test for svc 0
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100286 jnz .Lsysc_nr_ok
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287 # svc 0: system call number in %r1
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100288 llgfr %r1,%r1 # clear high word in r1
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200289 cghi %r1,NR_syscalls
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100290 jnl .Lsysc_nr_ok
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100291 sth %r1,__PT_INT_CODE+2(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100292 slag %r8,%r1,2
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100293.Lsysc_nr_ok:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100294 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
295 stg %r2,__PT_ORIG_GPR2(%r11)
296 stg %r7,STACK_FRAME_OVERHEAD(%r15)
297 lgf %r9,0(%r8,%r10) # get system call add.
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200298 TSTMSK __TI_flags(%r12),_TIF_TRACE
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100299 jnz .Lsysc_tracesys
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100300 basr %r14,%r9 # call sys_xxxx
301 stg %r2,__PT_R2(%r11) # store return value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100303.Lsysc_return:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200304 LOCKDEP_SYS_EXIT
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100305.Lsysc_tif:
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200306 TSTMSK __PT_FLAGS(%r11),_PIF_WORK
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100307 jnz .Lsysc_work
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200308 TSTMSK __TI_flags(%r12),_TIF_WORK
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100309 jnz .Lsysc_work # check for work
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200310 TSTMSK __LC_CPU_FLAGS,_CIF_WORK
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100311 jnz .Lsysc_work
312.Lsysc_restore:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100313 lg %r14,__LC_VDSO_PER_CPU
314 lmg %r0,%r10,__PT_R0(%r11)
315 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
316 stpt __LC_EXIT_TIMER
317 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
318 lmg %r11,%r15,__PT_R11(%r11)
319 lpswe __LC_RETURN_PSW
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100320.Lsysc_done:
Heiko Carstens411788e2007-11-20 11:13:32 +0100321
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322#
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200323# One of the work bits is on. Find out which one.
324#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100325.Lsysc_work:
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200326 TSTMSK __LC_CPU_FLAGS,_CIF_MCCK_PENDING
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100327 jo .Lsysc_mcck_pending
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200328 TSTMSK __TI_flags(%r12),_TIF_NEED_RESCHED
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100329 jo .Lsysc_reschedule
Jan Willeke2a0a5b22014-09-22 16:39:06 +0200330#ifdef CONFIG_UPROBES
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200331 TSTMSK __TI_flags(%r12),_TIF_UPROBE
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100332 jo .Lsysc_uprobe_notify
Jan Willeke2a0a5b22014-09-22 16:39:06 +0200333#endif
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200334 TSTMSK __PT_FLAGS(%r11),_PIF_PER_TRAP
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100335 jo .Lsysc_singlestep
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200336 TSTMSK __TI_flags(%r12),_TIF_SIGPENDING
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100337 jo .Lsysc_sigpending
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200338 TSTMSK __TI_flags(%r12),_TIF_NOTIFY_RESUME
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100339 jo .Lsysc_notify_resume
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200340 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200341 jo .Lsysc_vxrs
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200342 TSTMSK __LC_CPU_FLAGS,_CIF_ASCE
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100343 jo .Lsysc_uaccess
344 j .Lsysc_return # beware of critical section cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345
346#
347# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200348#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100349.Lsysc_reschedule:
350 larl %r14,.Lsysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100351 jg schedule
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352
353#
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200354# _CIF_MCCK_PENDING is set, call handler
Heiko Carstens77fa2242005-06-25 14:55:30 -0700355#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100356.Lsysc_mcck_pending:
357 larl %r14,.Lsysc_return
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200358 jg s390_handle_mcck # TIF bit will be cleared by handler
Heiko Carstens77fa2242005-06-25 14:55:30 -0700359
360#
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200361# _CIF_ASCE is set, load user space asce
Heiko Carstens457f2182014-03-21 10:42:25 +0100362#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100363.Lsysc_uaccess:
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200364 ni __LC_CPU_FLAGS+7,255-_CIF_ASCE
Heiko Carstens457f2182014-03-21 10:42:25 +0100365 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100366 j .Lsysc_return
Heiko Carstens457f2182014-03-21 10:42:25 +0100367
368#
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200369# CIF_FPU is set, restore floating-point controls and floating-point registers.
370#
371.Lsysc_vxrs:
372 larl %r14,.Lsysc_return
373 jg load_fpu_regs
374
375#
Roland McGrath02a029b2008-04-30 00:53:08 -0700376# _TIF_SIGPENDING is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100378.Lsysc_sigpending:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100379 lgr %r2,%r11 # pass pointer to pt_regs
380 brasl %r14,do_signal
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200381 TSTMSK __PT_FLAGS(%r11),_PIF_SYSCALL
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100382 jno .Lsysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100383 lmg %r2,%r7,__PT_R2(%r11) # load svc arguments
384 lghi %r8,0 # svc 0 returns -ENOSYS
Martin Schwidefsky450e47d2012-10-09 13:33:53 +0200385 llgh %r1,__PT_INT_CODE+2(%r11) # load new svc number
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100386 cghi %r1,NR_syscalls
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100387 jnl .Lsysc_nr_ok # invalid svc number -> do svc 0
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100388 slag %r8,%r1,2
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100389 j .Lsysc_nr_ok # restart svc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390
391#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200392# _TIF_NOTIFY_RESUME is set, call do_notify_resume
393#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100394.Lsysc_notify_resume:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100395 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100396 larl %r14,.Lsysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100397 jg do_notify_resume
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200398
399#
Jan Willeke2a0a5b22014-09-22 16:39:06 +0200400# _TIF_UPROBE is set, call uprobe_notify_resume
401#
402#ifdef CONFIG_UPROBES
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100403.Lsysc_uprobe_notify:
Jan Willeke2a0a5b22014-09-22 16:39:06 +0200404 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100405 larl %r14,.Lsysc_return
Jan Willeke2a0a5b22014-09-22 16:39:06 +0200406 jg uprobe_notify_resume
407#endif
408
409#
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200410# _PIF_PER_TRAP is set, call do_per_trap
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100412.Lsysc_singlestep:
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200413 ni __PT_FLAGS+7(%r11),255-_PIF_PER_TRAP
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100414 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100415 larl %r14,.Lsysc_return
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100416 jg do_per_trap
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200419# call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
420# and after the system call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100422.Lsysc_tracesys:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100423 lgr %r2,%r11 # pass pointer to pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424 la %r3,0
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100425 llgh %r0,__PT_INT_CODE+2(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100426 stg %r0,__PT_R2(%r11)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200427 brasl %r14,do_syscall_trace_enter
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428 lghi %r0,NR_syscalls
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200429 clgr %r0,%r2
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100430 jnh .Lsysc_tracenogo
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100431 sllg %r8,%r2,2
432 lgf %r9,0(%r8,%r10)
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100433.Lsysc_tracego:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100434 lmg %r3,%r7,__PT_R3(%r11)
435 stg %r7,STACK_FRAME_OVERHEAD(%r15)
436 lg %r2,__PT_ORIG_GPR2(%r11)
437 basr %r14,%r9 # call sys_xxx
438 stg %r2,__PT_R2(%r11) # store return value
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100439.Lsysc_tracenogo:
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200440 TSTMSK __TI_flags(%r12),_TIF_TRACE
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100441 jz .Lsysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100442 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100443 larl %r14,.Lsysc_return
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200444 jg do_syscall_trace_exit
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445
446#
447# a new process exits the kernel with ret_from_fork
448#
Jan Glauber144d6342011-07-24 10:48:19 +0200449ENTRY(ret_from_fork)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100450 la %r11,STACK_FRAME_OVERHEAD(%r15)
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100451 lg %r12,__LC_CURRENT
Al Viro30dcb092012-10-11 15:30:14 -0400452 brasl %r14,schedule_tail
453 TRACE_IRQS_ON
454 ssm __LC_SVC_NEW_PSW # reenable interrupts
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100455 tm __PT_PSW+1(%r11),0x01 # forking a kernel thread ?
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100456 jne .Lsysc_tracenogo
Al Viro30dcb092012-10-11 15:30:14 -0400457 # it's a kernel thread
458 lmg %r9,%r10,__PT_R9(%r11) # load gprs
Al Viro37fe5d42012-09-10 18:03:41 -0400459ENTRY(kernel_thread_starter)
460 la %r2,0(%r10)
461 basr %r14,%r9
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100462 j .Lsysc_tracenogo
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463
464/*
465 * Program check handler routine
466 */
467
Jan Glauber144d6342011-07-24 10:48:19 +0200468ENTRY(pgm_check_handler)
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100469 stpt __LC_SYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100470 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
471 lg %r10,__LC_LAST_BREAK
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100472 lg %r12,__LC_CURRENT
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200473 larl %r13,cleanup_critical
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100474 lmg %r8,%r9,__LC_PGM_OLD_PSW
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100475 tmhh %r8,0x0001 # test problem state bit
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200476 jnz 2f # -> fault in user space
477#if IS_ENABLED(CONFIG_KVM)
478 # cleanup critical section for sie64a
479 lgr %r14,%r9
480 slg %r14,BASED(.Lsie_critical_start)
481 clg %r14,BASED(.Lsie_critical_length)
482 jhe 0f
483 brasl %r14,.Lcleanup_sie
484#endif
4850: tmhh %r8,0x4000 # PER bit set in old PSW ?
486 jnz 1f # -> enabled, can't be a double fault
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100487 tm __LC_PGM_ILC+3,0x80 # check for per exception
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100488 jnz .Lpgm_svcper # -> single stepped svc
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +02004891: CHECK_STACK STACK_SIZE,__LC_SAVE_AREA_SYNC
Martin Schwidefskydc7ee002013-04-24 10:20:43 +0200490 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200491 j 3f
Martin Schwidefsky34525e12017-01-25 12:54:17 +01004922: UPDATE_VTIME %r14,%r15,__LC_SYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100493 lg %r15,__LC_KERNEL_STACK
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100494 lgr %r14,%r12
Martin Schwidefsky3827ec32015-07-20 10:01:46 +0200495 aghi %r14,__TASK_thread # pointer to thread_struct
Martin Schwidefskyd35339a2012-07-31 11:03:04 +0200496 lghi %r13,__LC_PGM_TDB
497 tm __LC_PGM_ILC+2,0x02 # check for transaction abort
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200498 jz 3f
Martin Schwidefskyd35339a2012-07-31 11:03:04 +0200499 mvc __THREAD_trap_tdb(256,%r14),0(%r13)
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +02005003: la %r11,STACK_FRAME_OVERHEAD(%r15)
Martin Schwidefsky34525e12017-01-25 12:54:17 +0100501 stg %r10,__THREAD_last_break(%r14)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100502 stmg %r0,%r7,__PT_R0(%r11)
503 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
504 stmg %r8,%r9,__PT_PSW(%r11)
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100505 mvc __PT_INT_CODE(4,%r11),__LC_PGM_ILC
506 mvc __PT_INT_PARM_LONG(8,%r11),__LC_TRANS_EXC_CODE
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200507 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100508 stg %r10,__PT_ARGS(%r11)
509 tm __LC_PGM_ILC+3,0x80 # check for per exception
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200510 jz 4f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100511 tmhh %r8,0x0001 # kernel per event ?
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100512 jz .Lpgm_kprobe
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200513 oi __PT_FLAGS+7(%r11),_PIF_PER_TRAP
Martin Schwidefskyd35339a2012-07-31 11:03:04 +0200514 mvc __THREAD_per_address(8,%r14),__LC_PER_ADDRESS
Jens Freimann21ee7ff2014-02-26 16:32:46 +0100515 mvc __THREAD_per_cause(2,%r14),__LC_PER_CODE
516 mvc __THREAD_per_paid(1,%r14),__LC_PER_ACCESS_ID
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +02005174: REENABLE_IRQS
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100518 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200519 larl %r1,pgm_check_table
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100520 llgh %r10,__PT_INT_CODE+2(%r11)
521 nill %r10,0x007f
Heiko Carstensb01a37a2012-10-18 18:10:06 +0200522 sll %r10,2
Martin Schwidefskya359bb12015-06-22 17:27:48 +0200523 je .Lpgm_return
Heiko Carstensb01a37a2012-10-18 18:10:06 +0200524 lgf %r1,0(%r10,%r1) # load address of handler routine
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100525 lgr %r2,%r11 # pass pointer to pt_regs
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200526 basr %r14,%r1 # branch to interrupt-handler
Martin Schwidefskya359bb12015-06-22 17:27:48 +0200527.Lpgm_return:
528 LOCKDEP_SYS_EXIT
529 tm __PT_PSW+1(%r11),0x01 # returning to user ?
530 jno .Lsysc_restore
531 j .Lsysc_tif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532
533#
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100534# PER event in supervisor state, must be kprobes
535#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100536.Lpgm_kprobe:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100537 REENABLE_IRQS
538 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
539 lgr %r2,%r11 # pass pointer to pt_regs
540 brasl %r14,do_per_trap
Martin Schwidefskya359bb12015-06-22 17:27:48 +0200541 j .Lpgm_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100542
543#
544# single stepped system call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100546.Lpgm_svcper:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100547 mvc __LC_RETURN_PSW(8),__LC_SVC_NEW_PSW
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100548 larl %r14,.Lsysc_per
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100549 stg %r14,__LC_RETURN_PSW+8
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200550 lghi %r14,_PIF_SYSCALL | _PIF_PER_TRAP
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100551 lpswe __LC_RETURN_PSW # branch to .Lsysc_per and enable irqs
Michael Grundy4ba069b2006-09-20 15:58:39 +0200552
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553/*
554 * IO interrupt handler routine
555 */
Jan Glauber144d6342011-07-24 10:48:19 +0200556ENTRY(io_int_handler)
Heiko Carstens473e66b2012-05-09 16:27:39 +0200557 STCK __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100558 stpt __LC_ASYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100559 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100560 lg %r12,__LC_CURRENT
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200561 larl %r13,cleanup_critical
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100562 lmg %r8,%r9,__LC_IO_OLD_PSW
Martin Schwidefsky2acb94f2015-06-22 17:28:14 +0200563 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100564 stmg %r0,%r7,__PT_R0(%r11)
565 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
566 stmg %r8,%r9,__PT_PSW(%r11)
Martin Schwidefsky48f6b002013-06-17 14:54:02 +0200567 mvc __PT_INT_CODE(12,%r11),__LC_SUBCHANNEL_ID
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200568 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
Heiko Carstensdb7e0072015-08-15 11:42:21 +0200569 TSTMSK __LC_CPU_FLAGS,_CIF_IGNORE_IRQ
570 jo .Lio_restore
Heiko Carstens1f194a42006-07-03 00:24:46 -0700571 TRACE_IRQS_OFF
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100572 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100573.Lio_loop:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100574 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky1f44a2252013-06-27 09:01:09 +0200575 lghi %r3,IO_INTERRUPT
576 tm __PT_INT_CODE+8(%r11),0x80 # adapter interrupt ?
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100577 jz .Lio_call
Martin Schwidefsky1f44a2252013-06-27 09:01:09 +0200578 lghi %r3,THIN_INTERRUPT
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100579.Lio_call:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100580 brasl %r14,do_IRQ
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200581 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_LPAR
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100582 jz .Lio_return
Martin Schwidefsky48f6b002013-06-17 14:54:02 +0200583 tpi 0
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100584 jz .Lio_return
Martin Schwidefsky48f6b002013-06-17 14:54:02 +0200585 mvc __PT_INT_CODE(12,%r11),__LC_SUBCHANNEL_ID
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100586 j .Lio_loop
587.Lio_return:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200588 LOCKDEP_SYS_EXIT
589 TRACE_IRQS_ON
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100590.Lio_tif:
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200591 TSTMSK __TI_flags(%r12),_TIF_WORK
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100592 jnz .Lio_work # there is work to do (signals etc.)
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200593 TSTMSK __LC_CPU_FLAGS,_CIF_WORK
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100594 jnz .Lio_work
595.Lio_restore:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100596 lg %r14,__LC_VDSO_PER_CPU
597 lmg %r0,%r10,__PT_R0(%r11)
598 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100599 stpt __LC_EXIT_TIMER
600 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
601 lmg %r11,%r15,__PT_R11(%r11)
602 lpswe __LC_RETURN_PSW
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100603.Lio_done:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604
Martin Schwidefsky26889052008-05-07 09:22:52 +0200605#
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200606# There is work todo, find out in which context we have been interrupted:
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200607# 1) if we return to user space we can do all _TIF_WORK work
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200608# 2) if we return to kernel code and kvm is enabled check if we need to
609# modify the psw to leave SIE
610# 3) if we return to kernel code and preemptive scheduling is enabled check
611# the preemption counter and if it is zero call preempt_schedule_irq
612# Before any work can be done, a switch to the kernel stack is required.
Martin Schwidefsky26889052008-05-07 09:22:52 +0200613#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100614.Lio_work:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100615 tm __PT_PSW+1(%r11),0x01 # returning to user ?
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100616 jo .Lio_work_user # yes -> do resched & signal
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200617#ifdef CONFIG_PREEMPT
Martin Schwidefsky26889052008-05-07 09:22:52 +0200618 # check for preemptive scheduling
Martin Schwidefskyc3601922016-10-25 12:21:44 +0200619 icm %r0,15,__LC_PREEMPT_COUNT
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100620 jnz .Lio_restore # preemption is disabled
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200621 TSTMSK __TI_flags(%r12),_TIF_NEED_RESCHED
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100622 jno .Lio_restore
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 # switch to kernel stack
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100624 lg %r1,__PT_R15(%r11)
625 aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
626 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
627 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
628 la %r11,STACK_FRAME_OVERHEAD(%r1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 lgr %r15,%r1
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100630 # TRACE_IRQS_ON already done at .Lio_return, call
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200631 # TRACE_IRQS_OFF to keep things symmetrical
632 TRACE_IRQS_OFF
633 brasl %r14,preempt_schedule_irq
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100634 j .Lio_return
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200635#else
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100636 j .Lio_restore
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200637#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200639#
640# Need to do work before returning to userspace, switch to kernel stack
641#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100642.Lio_work_user:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 lg %r1,__LC_KERNEL_STACK
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100644 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
645 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
646 la %r11,STACK_FRAME_OVERHEAD(%r1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 lgr %r15,%r1
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200648
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649#
650# One of the work bits is on. Find out which one.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100652.Lio_work_tif:
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200653 TSTMSK __LC_CPU_FLAGS,_CIF_MCCK_PENDING
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100654 jo .Lio_mcck_pending
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200655 TSTMSK __TI_flags(%r12),_TIF_NEED_RESCHED
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100656 jo .Lio_reschedule
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200657 TSTMSK __TI_flags(%r12),_TIF_SIGPENDING
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100658 jo .Lio_sigpending
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200659 TSTMSK __TI_flags(%r12),_TIF_NOTIFY_RESUME
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100660 jo .Lio_notify_resume
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200661 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200662 jo .Lio_vxrs
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200663 TSTMSK __LC_CPU_FLAGS,_CIF_ASCE
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100664 jo .Lio_uaccess
665 j .Lio_return # beware of critical section cleanup
Christian Borntraeger0eaeafa2008-05-07 09:22:53 +0200666
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667#
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200668# _CIF_MCCK_PENDING is set, call handler
Heiko Carstens77fa2242005-06-25 14:55:30 -0700669#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100670.Lio_mcck_pending:
671 # TRACE_IRQS_ON already done at .Lio_return
Heiko Carstensb771aea2007-07-27 12:29:18 +0200672 brasl %r14,s390_handle_mcck # TIF bit will be cleared by handler
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200673 TRACE_IRQS_OFF
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100674 j .Lio_return
Heiko Carstens77fa2242005-06-25 14:55:30 -0700675
676#
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200677# _CIF_ASCE is set, load user space asce
Heiko Carstens457f2182014-03-21 10:42:25 +0100678#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100679.Lio_uaccess:
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200680 ni __LC_CPU_FLAGS+7,255-_CIF_ASCE
Heiko Carstens457f2182014-03-21 10:42:25 +0100681 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100682 j .Lio_return
Heiko Carstens457f2182014-03-21 10:42:25 +0100683
684#
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200685# CIF_FPU is set, restore floating-point controls and floating-point registers.
686#
687.Lio_vxrs:
688 larl %r14,.Lio_return
689 jg load_fpu_regs
690
691#
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200693#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100694.Lio_reschedule:
695 # TRACE_IRQS_ON already done at .Lio_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100696 ssm __LC_SVC_NEW_PSW # reenable interrupts
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200697 brasl %r14,schedule # call scheduler
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100698 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100699 TRACE_IRQS_OFF
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100700 j .Lio_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701
702#
Roland McGrath02a029b2008-04-30 00:53:08 -0700703# _TIF_SIGPENDING or is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100705.Lio_sigpending:
706 # TRACE_IRQS_ON already done at .Lio_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100707 ssm __LC_SVC_NEW_PSW # reenable interrupts
708 lgr %r2,%r11 # pass pointer to pt_regs
709 brasl %r14,do_signal
710 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100711 TRACE_IRQS_OFF
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100712 j .Lio_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200714#
715# _TIF_NOTIFY_RESUME or is set, call do_notify_resume
716#
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100717.Lio_notify_resume:
718 # TRACE_IRQS_ON already done at .Lio_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100719 ssm __LC_SVC_NEW_PSW # reenable interrupts
720 lgr %r2,%r11 # pass pointer to pt_regs
721 brasl %r14,do_notify_resume
722 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200723 TRACE_IRQS_OFF
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100724 j .Lio_return
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200725
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726/*
727 * External interrupt handler routine
728 */
Jan Glauber144d6342011-07-24 10:48:19 +0200729ENTRY(ext_int_handler)
Heiko Carstens473e66b2012-05-09 16:27:39 +0200730 STCK __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100731 stpt __LC_ASYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100732 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100733 lg %r12,__LC_CURRENT
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200734 larl %r13,cleanup_critical
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100735 lmg %r8,%r9,__LC_EXT_OLD_PSW
Martin Schwidefsky2acb94f2015-06-22 17:28:14 +0200736 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100737 stmg %r0,%r7,__PT_R0(%r11)
738 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
739 stmg %r8,%r9,__PT_PSW(%r11)
Martin Schwidefsky48f6b002013-06-17 14:54:02 +0200740 lghi %r1,__LC_EXT_PARAMS2
741 mvc __PT_INT_CODE(4,%r11),__LC_EXT_CPU_ADDR
742 mvc __PT_INT_PARM(4,%r11),__LC_EXT_PARAMS
743 mvc __PT_INT_PARM_LONG(8,%r11),0(%r1)
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200744 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
Heiko Carstensdb7e0072015-08-15 11:42:21 +0200745 TSTMSK __LC_CPU_FLAGS,_CIF_IGNORE_IRQ
746 jo .Lio_restore
Heiko Carstens1f194a42006-07-03 00:24:46 -0700747 TRACE_IRQS_OFF
Michael Holzheu0de9db32012-05-09 16:27:35 +0200748 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100749 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky1f44a2252013-06-27 09:01:09 +0200750 lghi %r3,EXT_INTERRUPT
751 brasl %r14,do_IRQ
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100752 j .Lio_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400754/*
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100755 * Load idle PSW. The second "half" of this function is in .Lcleanup_idle.
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400756 */
757ENTRY(psw_idle)
Martin Schwidefsky27f6b412012-07-20 11:15:08 +0200758 stg %r3,__SF_EMPTY(%r15)
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100759 larl %r1,.Lpsw_idle_lpsw+4
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400760 stg %r1,__SF_EMPTY+8(%r15)
Martin Schwidefsky72d38b12015-09-18 16:41:36 +0200761#ifdef CONFIG_SMP
762 larl %r1,smp_cpu_mtid
763 llgf %r1,0(%r1)
764 ltgr %r1,%r1
765 jz .Lpsw_idle_stcctm
766 .insn rsy,0xeb0000000017,%r1,5,__SF_EMPTY+16(%r15)
767.Lpsw_idle_stcctm:
768#endif
Martin Schwidefsky419123f2015-11-19 11:09:45 +0100769 oi __LC_CPU_FLAGS+7,_CIF_ENABLED_WAIT
Martin Schwidefsky27f6b412012-07-20 11:15:08 +0200770 STCK __CLOCK_IDLE_ENTER(%r2)
771 stpt __TIMER_IDLE_ENTER(%r2)
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100772.Lpsw_idle_lpsw:
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400773 lpswe __SF_EMPTY(%r15)
774 br %r14
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100775.Lpsw_idle_end:
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400776
Hendrik Bruecknerb5510d92015-09-29 10:04:41 +0200777/*
778 * Store floating-point controls and floating-point or vector register
779 * depending whether the vector facility is available. A critical section
780 * cleanup assures that the registers are stored even if interrupted for
781 * some other work. The CIF_FPU flag is set to trigger a lazy restore
782 * of the register contents at return from io or a system call.
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200783 */
784ENTRY(save_fpu_regs)
Hendrik Bruecknerd0164ee2015-06-29 16:43:06 +0200785 lg %r2,__LC_CURRENT
786 aghi %r2,__TASK_thread
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200787 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200788 bor %r14
Hendrik Bruecknerd0164ee2015-06-29 16:43:06 +0200789 stfpc __THREAD_FPU_fpc(%r2)
Hendrik Bruecknerd0164ee2015-06-29 16:43:06 +0200790 lg %r3,__THREAD_FPU_regs(%r2)
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200791 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200792 jz .Lsave_fpu_regs_fp # no -> store FP regs
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200793 VSTM %v0,%v15,0,%r3 # vstm 0,15,0(3)
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200794 VSTM %v16,%v31,256,%r3 # vstm 16,31,256(3)
795 j .Lsave_fpu_regs_done # -> set CIF_FPU flag
796.Lsave_fpu_regs_fp:
797 std 0,0(%r3)
798 std 1,8(%r3)
799 std 2,16(%r3)
800 std 3,24(%r3)
801 std 4,32(%r3)
802 std 5,40(%r3)
803 std 6,48(%r3)
804 std 7,56(%r3)
805 std 8,64(%r3)
806 std 9,72(%r3)
807 std 10,80(%r3)
808 std 11,88(%r3)
809 std 12,96(%r3)
810 std 13,104(%r3)
811 std 14,112(%r3)
812 std 15,120(%r3)
813.Lsave_fpu_regs_done:
814 oi __LC_CPU_FLAGS+7,_CIF_FPU
815 br %r14
816.Lsave_fpu_regs_end:
Al Viro711f5df2016-01-12 13:30:03 -0500817#if IS_ENABLED(CONFIG_KVM)
818EXPORT_SYMBOL(save_fpu_regs)
819#endif
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200820
Hendrik Bruecknerb5510d92015-09-29 10:04:41 +0200821/*
822 * Load floating-point controls and floating-point or vector registers.
823 * A critical section cleanup assures that the register contents are
824 * loaded even if interrupted for some other work.
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200825 *
826 * There are special calling conventions to fit into sysc and io return work:
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200827 * %r15: <kernel stack>
828 * The function requires:
Hendrik Bruecknerb5510d92015-09-29 10:04:41 +0200829 * %r4
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200830 */
831load_fpu_regs:
Hendrik Bruecknerd0164ee2015-06-29 16:43:06 +0200832 lg %r4,__LC_CURRENT
833 aghi %r4,__TASK_thread
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200834 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200835 bnor %r14
Hendrik Bruecknerd0164ee2015-06-29 16:43:06 +0200836 lfpc __THREAD_FPU_fpc(%r4)
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200837 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
Hendrik Bruecknerd0164ee2015-06-29 16:43:06 +0200838 lg %r4,__THREAD_FPU_regs(%r4) # %r4 <- reg save area
Hendrik Bruecknerb5510d92015-09-29 10:04:41 +0200839 jz .Lload_fpu_regs_fp # -> no VX, load FP regs
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200840 VLM %v0,%v15,0,%r4
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200841 VLM %v16,%v31,256,%r4
842 j .Lload_fpu_regs_done
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200843.Lload_fpu_regs_fp:
844 ld 0,0(%r4)
845 ld 1,8(%r4)
846 ld 2,16(%r4)
847 ld 3,24(%r4)
848 ld 4,32(%r4)
849 ld 5,40(%r4)
850 ld 6,48(%r4)
851 ld 7,56(%r4)
852 ld 8,64(%r4)
853 ld 9,72(%r4)
854 ld 10,80(%r4)
855 ld 11,88(%r4)
856 ld 12,96(%r4)
857 ld 13,104(%r4)
858 ld 14,112(%r4)
859 ld 15,120(%r4)
860.Lload_fpu_regs_done:
861 ni __LC_CPU_FLAGS+7,255-_CIF_FPU
862 br %r14
863.Lload_fpu_regs_end:
864
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100865.L__critical_end:
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700866
Linus Torvalds1da177e2005-04-16 15:20:36 -0700867/*
868 * Machine check handler routines
869 */
Jan Glauber144d6342011-07-24 10:48:19 +0200870ENTRY(mcck_int_handler)
Heiko Carstens473e66b2012-05-09 16:27:39 +0200871 STCK __LC_MCCK_CLOCK
Heiko Carstens77fa2242005-06-25 14:55:30 -0700872 la %r1,4095 # revalidate r1
873 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # revalidate cpu timer
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200874 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# revalidate gprs
Heiko Carstensd5c352c2016-11-08 11:08:26 +0100875 lg %r12,__LC_CURRENT
Hendrik Brueckner9977e882015-06-10 12:53:42 +0200876 larl %r13,cleanup_critical
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100877 lmg %r8,%r9,__LC_MCK_OLD_PSW
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200878 TSTMSK __LC_MCCK_CODE,MCCK_CODE_SYSTEM_DAMAGE
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100879 jo .Lmcck_panic # yes -> rest of mcck code invalid
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100880 lghi %r14,__LC_CPU_TIMER_SAVE_AREA
881 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200882 TSTMSK __LC_MCCK_CODE,MCCK_CODE_CPU_TIMER_VALID
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100883 jo 3f
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200884 la %r14,__LC_SYNC_ENTER_TIMER
885 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
886 jl 0f
887 la %r14,__LC_ASYNC_ENTER_TIMER
8880: clc 0(8,%r14),__LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100889 jl 1f
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200890 la %r14,__LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +01008911: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
892 jl 2f
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200893 la %r14,__LC_LAST_UPDATE_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +01008942: spt 0(%r14)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200895 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
Hendrik Brueckner83abeff2015-10-01 17:02:48 +02008963: TSTMSK __LC_MCCK_CODE,(MCCK_CODE_PSW_MWP_VALID|MCCK_CODE_PSW_IA_VALID)
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100897 jno .Lmcck_panic # no -> skip cleanup critical
Martin Schwidefsky2acb94f2015-06-22 17:28:14 +0200898 SWITCH_ASYNC __LC_GPREGS_SAVE_AREA+64,__LC_MCCK_ENTER_TIMER
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100899.Lmcck_skip:
Martin Schwidefsky6551fbd2013-02-28 16:28:41 +0100900 lghi %r14,__LC_GPREGS_SAVE_AREA+64
901 stmg %r0,%r7,__PT_R0(%r11)
902 mvc __PT_R8(64,%r11),0(%r14)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100903 stmg %r8,%r9,__PT_PSW(%r11)
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +0200904 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100905 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
906 lgr %r2,%r11 # pass pointer to pt_regs
Heiko Carstens77fa2242005-06-25 14:55:30 -0700907 brasl %r14,s390_do_machine_check
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100908 tm __PT_PSW+1(%r11),0x01 # returning to user ?
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100909 jno .Lmcck_return
Heiko Carstens77fa2242005-06-25 14:55:30 -0700910 lg %r1,__LC_KERNEL_STACK # switch to kernel stack
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100911 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
912 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
913 la %r11,STACK_FRAME_OVERHEAD(%r1)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700914 lgr %r15,%r1
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100915 ssm __LC_PGM_NEW_PSW # turn dat on, keep irqs off
Hendrik Brueckner83abeff2015-10-01 17:02:48 +0200916 TSTMSK __LC_CPU_FLAGS,_CIF_MCCK_PENDING
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100917 jno .Lmcck_return
Heiko Carstens1f194a42006-07-03 00:24:46 -0700918 TRACE_IRQS_OFF
Heiko Carstens77fa2242005-06-25 14:55:30 -0700919 brasl %r14,s390_handle_mcck
Heiko Carstens1f194a42006-07-03 00:24:46 -0700920 TRACE_IRQS_ON
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100921.Lmcck_return:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100922 lg %r14,__LC_VDSO_PER_CPU
923 lmg %r0,%r10,__PT_R0(%r11)
924 mvc __LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200925 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
926 jno 0f
927 stpt __LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100928 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
9290: lmg %r11,%r15,__PT_R11(%r11)
930 lpswe __LC_RETURN_MCCK_PSW
931
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100932.Lmcck_panic:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100933 lg %r15,__LC_PANIC_STACK
Martin Schwidefskyce4dda32016-12-02 13:29:22 +0100934 la %r11,STACK_FRAME_OVERHEAD(%r15)
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100935 j .Lmcck_skip
Linus Torvalds1da177e2005-04-16 15:20:36 -0700936
Michael Holzheu7dd6b332011-08-03 16:44:19 +0200937#
938# PSW restart interrupt handler
939#
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400940ENTRY(restart_int_handler)
Christian Borntraegere22cf8c2015-10-06 18:06:15 +0200941 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_LPP
942 jz 0f
943 .insn s,0xb2800000,__LC_LPP
9440: stg %r15,__LC_SAVE_AREA_RESTART
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400945 lg %r15,__LC_RESTART_STACK
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100946 aghi %r15,-__PT_SIZE # create pt_regs on stack
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400947 xc 0(__PT_SIZE,%r15),0(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100948 stmg %r0,%r14,__PT_R0(%r15)
949 mvc __PT_R15(8,%r15),__LC_SAVE_AREA_RESTART
950 mvc __PT_PSW(16,%r15),__LC_RST_OLD_PSW # store restart old psw
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400951 aghi %r15,-STACK_FRAME_OVERHEAD # create stack frame on stack
952 xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15)
Heiko Carstensfbe76562012-06-05 09:59:52 +0200953 lg %r1,__LC_RESTART_FN # load fn, parm & source cpu
954 lg %r2,__LC_RESTART_DATA
955 lg %r3,__LC_RESTART_SOURCE
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400956 ltgr %r3,%r3 # test source cpu address
957 jm 1f # negative -> skip source stop
Heiko Carstenseb546192012-06-04 15:05:43 +02009580: sigp %r4,%r3,SIGP_SENSE # sigp sense to source cpu
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400959 brc 10,0b # wait for status stored
9601: basr %r14,%r1 # call function
961 stap __SF_EMPTY(%r15) # store cpu address
962 llgh %r3,__SF_EMPTY(%r15)
Heiko Carstenseb546192012-06-04 15:05:43 +02009632: sigp %r4,%r3,SIGP_STOP # sigp stop to current cpu
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400964 brc 2,2b
9653: j 3b
Michael Holzheu7dd6b332011-08-03 16:44:19 +0200966
Martin Schwidefsky860dba42011-01-05 12:47:25 +0100967 .section .kprobes.text, "ax"
968
Linus Torvalds1da177e2005-04-16 15:20:36 -0700969#ifdef CONFIG_CHECK_STACK
970/*
971 * The synchronous or the asynchronous stack overflowed. We are dead.
972 * No need to properly save the registers, we are going to panic anyway.
973 * Setup a pt_regs so that show_trace can provide a good call trace.
974 */
975stack_overflow:
Martin Schwidefskydc7ee002013-04-24 10:20:43 +0200976 lg %r15,__LC_PANIC_STACK # change to panic stack
977 la %r11,STACK_FRAME_OVERHEAD(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100978 stmg %r0,%r7,__PT_R0(%r11)
979 stmg %r8,%r9,__PT_PSW(%r11)
980 mvc __PT_R8(64,%r11),0(%r14)
981 stg %r10,__PT_ORIG_GPR2(%r11) # store last break to orig_gpr2
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100982 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
983 lgr %r2,%r11 # pass pointer to pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700984 jg kernel_stack_overflow
985#endif
986
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987cleanup_critical:
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +0200988#if IS_ENABLED(CONFIG_KVM)
989 clg %r9,BASED(.Lcleanup_table_sie) # .Lsie_gmap
990 jl 0f
991 clg %r9,BASED(.Lcleanup_table_sie+8)# .Lsie_done
992 jl .Lcleanup_sie
993#endif
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100994 clg %r9,BASED(.Lcleanup_table) # system_call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700995 jl 0f
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +0100996 clg %r9,BASED(.Lcleanup_table+8) # .Lsysc_do_svc
997 jl .Lcleanup_system_call
998 clg %r9,BASED(.Lcleanup_table+16) # .Lsysc_tif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700999 jl 0f
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001000 clg %r9,BASED(.Lcleanup_table+24) # .Lsysc_restore
1001 jl .Lcleanup_sysc_tif
1002 clg %r9,BASED(.Lcleanup_table+32) # .Lsysc_done
1003 jl .Lcleanup_sysc_restore
1004 clg %r9,BASED(.Lcleanup_table+40) # .Lio_tif
Martin Schwidefsky63b12242006-06-29 14:58:05 +02001005 jl 0f
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001006 clg %r9,BASED(.Lcleanup_table+48) # .Lio_restore
1007 jl .Lcleanup_io_tif
1008 clg %r9,BASED(.Lcleanup_table+56) # .Lio_done
1009 jl .Lcleanup_io_restore
1010 clg %r9,BASED(.Lcleanup_table+64) # psw_idle
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001011 jl 0f
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001012 clg %r9,BASED(.Lcleanup_table+72) # .Lpsw_idle_end
1013 jl .Lcleanup_idle
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001014 clg %r9,BASED(.Lcleanup_table+80) # save_fpu_regs
1015 jl 0f
1016 clg %r9,BASED(.Lcleanup_table+88) # .Lsave_fpu_regs_end
1017 jl .Lcleanup_save_fpu_regs
1018 clg %r9,BASED(.Lcleanup_table+96) # load_fpu_regs
1019 jl 0f
1020 clg %r9,BASED(.Lcleanup_table+104) # .Lload_fpu_regs_end
1021 jl .Lcleanup_load_fpu_regs
Martin Schwidefskyc5328902011-12-27 11:27:15 +010010220: br %r14
1023
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +02001024 .align 8
1025.Lcleanup_table:
1026 .quad system_call
1027 .quad .Lsysc_do_svc
1028 .quad .Lsysc_tif
1029 .quad .Lsysc_restore
1030 .quad .Lsysc_done
1031 .quad .Lio_tif
1032 .quad .Lio_restore
1033 .quad .Lio_done
1034 .quad psw_idle
1035 .quad .Lpsw_idle_end
1036 .quad save_fpu_regs
1037 .quad .Lsave_fpu_regs_end
1038 .quad load_fpu_regs
1039 .quad .Lload_fpu_regs_end
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +02001040
1041#if IS_ENABLED(CONFIG_KVM)
1042.Lcleanup_table_sie:
1043 .quad .Lsie_gmap
1044 .quad .Lsie_done
1045
1046.Lcleanup_sie:
1047 lg %r9,__SF_EMPTY(%r15) # get control block pointer
Christian Borntraegere22cf8c2015-10-06 18:06:15 +02001048 ni __SIE_PROG0C+3(%r9),0xfe # no longer in SIE
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +02001049 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
1050 larl %r9,sie_exit # skip forward to sie_exit
1051 br %r14
1052#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001053
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001054.Lcleanup_system_call:
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001055 # check if stpt has been executed
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001056 clg %r9,BASED(.Lcleanup_system_call_insn)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001057 jh 0f
1058 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001059 cghi %r11,__LC_SAVE_AREA_ASYNC
Martin Schwidefsky63779812010-05-17 10:00:03 +02001060 je 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001061 mvc __LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER
10620: # check if stmg has been executed
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001063 clg %r9,BASED(.Lcleanup_system_call_insn+8)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001064 jh 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001065 mvc __LC_SAVE_AREA_SYNC(64),0(%r11)
10660: # check if base register setup + TIF bit load has been done
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001067 clg %r9,BASED(.Lcleanup_system_call_insn+16)
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001068 jhe 0f
Martin Schwidefsky34525e12017-01-25 12:54:17 +01001069 # set up saved register r12 task struct pointer
1070 stg %r12,32(%r11)
1071 # set up saved register r13 __TASK_thread offset
1072 mvc 40(8,%r11),BASED(.Lcleanup_system_call_const)
Martin Schwidefskyc5328902011-12-27 11:27:15 +010010730: # check if the user time update has been done
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001074 clg %r9,BASED(.Lcleanup_system_call_insn+24)
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001075 jh 0f
1076 lg %r15,__LC_EXIT_TIMER
1077 slg %r15,__LC_SYNC_ENTER_TIMER
1078 alg %r15,__LC_USER_TIMER
1079 stg %r15,__LC_USER_TIMER
10800: # check if the system time update has been done
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001081 clg %r9,BASED(.Lcleanup_system_call_insn+32)
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001082 jh 0f
1083 lg %r15,__LC_LAST_UPDATE_TIMER
1084 slg %r15,__LC_EXIT_TIMER
1085 alg %r15,__LC_SYSTEM_TIMER
1086 stg %r15,__LC_SYSTEM_TIMER
10870: # update accounting time stamp
Linus Torvalds1da177e2005-04-16 15:20:36 -07001088 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Martin Schwidefsky34525e12017-01-25 12:54:17 +01001089 # set up saved register r11
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001090 lg %r15,__LC_KERNEL_STACK
Martin Schwidefskydc7ee002013-04-24 10:20:43 +02001091 la %r9,STACK_FRAME_OVERHEAD(%r15)
1092 stg %r9,24(%r11) # r11 pt_regs pointer
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001093 # fill pt_regs
Martin Schwidefskydc7ee002013-04-24 10:20:43 +02001094 mvc __PT_R8(64,%r9),__LC_SAVE_AREA_SYNC
1095 stmg %r0,%r7,__PT_R0(%r9)
1096 mvc __PT_PSW(16,%r9),__LC_SVC_OLD_PSW
1097 mvc __PT_INT_CODE(4,%r9),__LC_SVC_ILC
Martin Schwidefskyd3a73ac2014-04-15 12:55:07 +02001098 xc __PT_FLAGS(8,%r9),__PT_FLAGS(%r9)
1099 mvi __PT_FLAGS+7(%r9),_PIF_SYSCALL
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001100 # setup saved register r15
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001101 stg %r15,56(%r11) # r15 stack pointer
1102 # set new psw address and exit
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001103 larl %r9,.Lsysc_do_svc
Linus Torvalds1da177e2005-04-16 15:20:36 -07001104 br %r14
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001105.Lcleanup_system_call_insn:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001106 .quad system_call
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001107 .quad .Lsysc_stmg
1108 .quad .Lsysc_per
Martin Schwidefskya359bb12015-06-22 17:27:48 +02001109 .quad .Lsysc_vtime+36
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001110 .quad .Lsysc_vtime+42
Martin Schwidefsky34525e12017-01-25 12:54:17 +01001111.Lcleanup_system_call_const:
1112 .quad __TASK_thread
Linus Torvalds1da177e2005-04-16 15:20:36 -07001113
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001114.Lcleanup_sysc_tif:
1115 larl %r9,.Lsysc_tif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001116 br %r14
1117
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001118.Lcleanup_sysc_restore:
1119 clg %r9,BASED(.Lcleanup_sysc_restore_insn)
Martin Schwidefsky63779812010-05-17 10:00:03 +02001120 je 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001121 lg %r9,24(%r11) # get saved pointer to pt_regs
1122 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
1123 mvc 0(64,%r11),__PT_R8(%r9)
1124 lmg %r0,%r7,__PT_R0(%r9)
11250: lmg %r8,%r9,__LC_RETURN_PSW
Linus Torvalds1da177e2005-04-16 15:20:36 -07001126 br %r14
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001127.Lcleanup_sysc_restore_insn:
1128 .quad .Lsysc_done - 4
Linus Torvalds1da177e2005-04-16 15:20:36 -07001129
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001130.Lcleanup_io_tif:
1131 larl %r9,.Lio_tif
Martin Schwidefsky176b1802010-04-09 13:43:00 +02001132 br %r14
1133
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001134.Lcleanup_io_restore:
1135 clg %r9,BASED(.Lcleanup_io_restore_insn)
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001136 je 0f
1137 lg %r9,24(%r11) # get saved r11 pointer to pt_regs
1138 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001139 mvc 0(64,%r11),__PT_R8(%r9)
1140 lmg %r0,%r7,__PT_R0(%r9)
11410: lmg %r8,%r9,__LC_RETURN_PSW
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001142 br %r14
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001143.Lcleanup_io_restore_insn:
1144 .quad .Lio_done - 4
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001145
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001146.Lcleanup_idle:
Martin Schwidefsky419123f2015-11-19 11:09:45 +01001147 ni __LC_CPU_FLAGS+7,255-_CIF_ENABLED_WAIT
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001148 # copy interrupt clock & cpu timer
Martin Schwidefsky27f6b412012-07-20 11:15:08 +02001149 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_INT_CLOCK
1150 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_ASYNC_ENTER_TIMER
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001151 cghi %r11,__LC_SAVE_AREA_ASYNC
1152 je 0f
Martin Schwidefsky27f6b412012-07-20 11:15:08 +02001153 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_MCCK_CLOCK
1154 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_MCCK_ENTER_TIMER
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -040011550: # check if stck & stpt have been executed
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001156 clg %r9,BASED(.Lcleanup_idle_insn)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001157 jhe 1f
Martin Schwidefsky27f6b412012-07-20 11:15:08 +02001158 mvc __CLOCK_IDLE_ENTER(8,%r2),__CLOCK_IDLE_EXIT(%r2)
1159 mvc __TIMER_IDLE_ENTER(8,%r2),__TIMER_IDLE_EXIT(%r2)
Martin Schwidefsky72d38b12015-09-18 16:41:36 +020011601: # calculate idle cycles
1161#ifdef CONFIG_SMP
1162 clg %r9,BASED(.Lcleanup_idle_insn)
1163 jl 3f
1164 larl %r1,smp_cpu_mtid
1165 llgf %r1,0(%r1)
1166 ltgr %r1,%r1
1167 jz 3f
1168 .insn rsy,0xeb0000000017,%r1,5,__SF_EMPTY+80(%r15)
1169 larl %r3,mt_cycles
1170 ag %r3,__LC_PERCPU_OFFSET
1171 la %r4,__SF_EMPTY+16(%r15)
11722: lg %r0,0(%r3)
1173 slg %r0,0(%r4)
1174 alg %r0,64(%r4)
1175 stg %r0,0(%r3)
1176 la %r3,8(%r3)
1177 la %r4,8(%r4)
1178 brct %r1,2b
1179#endif
11803: # account system time going idle
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001181 lg %r9,__LC_STEAL_TIMER
Martin Schwidefsky27f6b412012-07-20 11:15:08 +02001182 alg %r9,__CLOCK_IDLE_ENTER(%r2)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001183 slg %r9,__LC_LAST_UPDATE_CLOCK
1184 stg %r9,__LC_STEAL_TIMER
Martin Schwidefsky27f6b412012-07-20 11:15:08 +02001185 mvc __LC_LAST_UPDATE_CLOCK(8),__CLOCK_IDLE_EXIT(%r2)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001186 lg %r9,__LC_SYSTEM_TIMER
1187 alg %r9,__LC_LAST_UPDATE_TIMER
Martin Schwidefsky27f6b412012-07-20 11:15:08 +02001188 slg %r9,__TIMER_IDLE_ENTER(%r2)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001189 stg %r9,__LC_SYSTEM_TIMER
Martin Schwidefsky27f6b412012-07-20 11:15:08 +02001190 mvc __LC_LAST_UPDATE_TIMER(8),__TIMER_IDLE_EXIT(%r2)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001191 # prepare return psw
Martin Schwidefsky0587d402013-08-23 14:45:58 +02001192 nihh %r8,0xfcfd # clear irq & wait state bits
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001193 lg %r9,48(%r11) # return from psw_idle
1194 br %r14
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001195.Lcleanup_idle_insn:
1196 .quad .Lpsw_idle_lpsw
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04001197
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001198.Lcleanup_save_fpu_regs:
Martin Schwidefskye370e472016-03-10 09:52:55 +01001199 larl %r9,save_fpu_regs
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001200 br %r14
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001201
1202.Lcleanup_load_fpu_regs:
Martin Schwidefskye370e472016-03-10 09:52:55 +01001203 larl %r9,load_fpu_regs
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001204 br %r14
Hendrik Brueckner9977e882015-06-10 12:53:42 +02001205
Linus Torvalds1da177e2005-04-16 15:20:36 -07001206/*
1207 * Integer constants
1208 */
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001209 .align 8
Linus Torvalds1da177e2005-04-16 15:20:36 -07001210.Lcritical_start:
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001211 .quad .L__critical_start
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001212.Lcritical_length:
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001213 .quad .L__critical_end - .L__critical_start
Heiko Carstens61aa4882013-11-01 10:08:20 +01001214#if IS_ENABLED(CONFIG_KVM)
Martin Schwidefskyd0fc4102015-06-22 17:26:40 +02001215.Lsie_critical_start:
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001216 .quad .Lsie_gmap
Martin Schwidefsky7c470532013-05-17 14:41:37 +02001217.Lsie_critical_length:
Martin Schwidefsky86ed42f2014-12-03 17:00:08 +01001218 .quad .Lsie_done - .Lsie_gmap
Martin Schwidefsky603d1a52011-07-24 10:48:18 +02001219#endif
1220
Heiko Carstensa876cb32015-02-13 14:44:29 +01001221 .section .rodata, "a"
1222#define SYSCALL(esame,emu) .long esame
Heiko Carstens9bf12262009-06-12 10:26:47 +02001223 .globl sys_call_table
Linus Torvalds1da177e2005-04-16 15:20:36 -07001224sys_call_table:
1225#include "syscalls.S"
1226#undef SYSCALL
1227
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -08001228#ifdef CONFIG_COMPAT
Linus Torvalds1da177e2005-04-16 15:20:36 -07001229
Heiko Carstensa876cb32015-02-13 14:44:29 +01001230#define SYSCALL(esame,emu) .long emu
Martin Schwidefsky61649882013-04-24 12:58:39 +02001231 .globl sys_call_table_emu
Linus Torvalds1da177e2005-04-16 15:20:36 -07001232sys_call_table_emu:
1233#include "syscalls.S"
1234#undef SYSCALL
1235#endif