xref: /openbmc/linux/arch/s390/kernel/entry.S (revision d768bd892fc8f066cd3aa000eb1867bcf32db0ee)
1b2441318SGreg Kroah-Hartman/* SPDX-License-Identifier: GPL-2.0 */
24bfc86ceSHeiko Carstens/*
34bfc86ceSHeiko Carstens *    S390 low-level entry points.
44bfc86ceSHeiko Carstens *
54bfc86ceSHeiko Carstens *    Copyright IBM Corp. 1999, 2012
64bfc86ceSHeiko Carstens *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
74bfc86ceSHeiko Carstens *		 Hartmut Penner (hp@de.ibm.com),
84bfc86ceSHeiko Carstens *		 Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
94bfc86ceSHeiko Carstens *		 Heiko Carstens <heiko.carstens@de.ibm.com>
104bfc86ceSHeiko Carstens */
114bfc86ceSHeiko Carstens
124bfc86ceSHeiko Carstens#include <linux/init.h>
134bfc86ceSHeiko Carstens#include <linux/linkage.h>
144bfc86ceSHeiko Carstens#include <asm/processor.h>
154bfc86ceSHeiko Carstens#include <asm/cache.h>
163037a52fSMartin Schwidefsky#include <asm/ctl_reg.h>
174bfc86ceSHeiko Carstens#include <asm/errno.h>
184bfc86ceSHeiko Carstens#include <asm/ptrace.h>
194bfc86ceSHeiko Carstens#include <asm/thread_info.h>
204bfc86ceSHeiko Carstens#include <asm/asm-offsets.h>
214bfc86ceSHeiko Carstens#include <asm/unistd.h>
224bfc86ceSHeiko Carstens#include <asm/page.h>
234bfc86ceSHeiko Carstens#include <asm/sigp.h>
244bfc86ceSHeiko Carstens#include <asm/irq.h>
259977e886SHendrik Brueckner#include <asm/vx-insn.h>
2683abeffbSHendrik Brueckner#include <asm/setup.h>
2783abeffbSHendrik Brueckner#include <asm/nmi.h>
28711f5df7SAl Viro#include <asm/export.h>
294bfc86ceSHeiko Carstens
304bfc86ceSHeiko Carstens__PT_R0      =	__PT_GPRS
314bfc86ceSHeiko Carstens__PT_R1      =	__PT_GPRS + 8
324bfc86ceSHeiko Carstens__PT_R2      =	__PT_GPRS + 16
334bfc86ceSHeiko Carstens__PT_R3      =	__PT_GPRS + 24
344bfc86ceSHeiko Carstens__PT_R4      =	__PT_GPRS + 32
354bfc86ceSHeiko Carstens__PT_R5      =	__PT_GPRS + 40
364bfc86ceSHeiko Carstens__PT_R6      =	__PT_GPRS + 48
374bfc86ceSHeiko Carstens__PT_R7      =	__PT_GPRS + 56
384bfc86ceSHeiko Carstens__PT_R8      =	__PT_GPRS + 64
394bfc86ceSHeiko Carstens__PT_R9      =	__PT_GPRS + 72
404bfc86ceSHeiko Carstens__PT_R10     =	__PT_GPRS + 80
414bfc86ceSHeiko Carstens__PT_R11     =	__PT_GPRS + 88
424bfc86ceSHeiko Carstens__PT_R12     =	__PT_GPRS + 96
434bfc86ceSHeiko Carstens__PT_R13     =	__PT_GPRS + 104
444bfc86ceSHeiko Carstens__PT_R14     =	__PT_GPRS + 112
454bfc86ceSHeiko Carstens__PT_R15     =	__PT_GPRS + 120
464bfc86ceSHeiko Carstens
473a890380SHeiko CarstensSTACK_SHIFT = PAGE_SHIFT + THREAD_SIZE_ORDER
484bfc86ceSHeiko CarstensSTACK_SIZE  = 1 << STACK_SHIFT
494bfc86ceSHeiko CarstensSTACK_INIT = STACK_SIZE - STACK_FRAME_OVERHEAD - __PT_SIZE
504bfc86ceSHeiko Carstens
514bfc86ceSHeiko Carstens_TIF_WORK	= (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
5276f1948aSLinus Torvalds		   _TIF_UPROBE | _TIF_GUARDED_STORAGE | _TIF_PATCH_PENDING)
534bfc86ceSHeiko Carstens_TIF_TRACE	= (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | \
544bfc86ceSHeiko Carstens		   _TIF_SYSCALL_TRACEPOINT)
55b5a882fcSHeiko Carstens_CIF_WORK	= (_CIF_MCCK_PENDING | _CIF_ASCE_PRIMARY | \
56b5a882fcSHeiko Carstens		   _CIF_ASCE_SECONDARY | _CIF_FPU)
5723fefe11SMartin Schwidefsky_PIF_WORK	= (_PIF_PER_TRAP | _PIF_SYSCALL_RESTART)
584bfc86ceSHeiko Carstens
599977e886SHendrik Brueckner#define BASED(name) name-cleanup_critical(%r13)
604bfc86ceSHeiko Carstens
614bfc86ceSHeiko Carstens	.macro	TRACE_IRQS_ON
624bfc86ceSHeiko Carstens#ifdef CONFIG_TRACE_IRQFLAGS
634bfc86ceSHeiko Carstens	basr	%r2,%r0
644bfc86ceSHeiko Carstens	brasl	%r14,trace_hardirqs_on_caller
654bfc86ceSHeiko Carstens#endif
664bfc86ceSHeiko Carstens	.endm
674bfc86ceSHeiko Carstens
684bfc86ceSHeiko Carstens	.macro	TRACE_IRQS_OFF
694bfc86ceSHeiko Carstens#ifdef CONFIG_TRACE_IRQFLAGS
704bfc86ceSHeiko Carstens	basr	%r2,%r0
714bfc86ceSHeiko Carstens	brasl	%r14,trace_hardirqs_off_caller
724bfc86ceSHeiko Carstens#endif
734bfc86ceSHeiko Carstens	.endm
744bfc86ceSHeiko Carstens
754bfc86ceSHeiko Carstens	.macro	LOCKDEP_SYS_EXIT
764bfc86ceSHeiko Carstens#ifdef CONFIG_LOCKDEP
774bfc86ceSHeiko Carstens	tm	__PT_PSW+1(%r11),0x01	# returning to user ?
784bfc86ceSHeiko Carstens	jz	.+10
794bfc86ceSHeiko Carstens	brasl	%r14,lockdep_sys_exit
804bfc86ceSHeiko Carstens#endif
814bfc86ceSHeiko Carstens	.endm
824bfc86ceSHeiko Carstens
834bfc86ceSHeiko Carstens	.macro	CHECK_STACK stacksize,savearea
844bfc86ceSHeiko Carstens#ifdef CONFIG_CHECK_STACK
854bfc86ceSHeiko Carstens	tml	%r15,\stacksize - CONFIG_STACK_GUARD
864bfc86ceSHeiko Carstens	lghi	%r14,\savearea
874bfc86ceSHeiko Carstens	jz	stack_overflow
884bfc86ceSHeiko Carstens#endif
894bfc86ceSHeiko Carstens	.endm
904bfc86ceSHeiko Carstens
912acb94f4SMartin Schwidefsky	.macro	SWITCH_ASYNC savearea,timer
924bfc86ceSHeiko Carstens	tmhh	%r8,0x0001		# interrupting from user ?
934bfc86ceSHeiko Carstens	jnz	1f
944bfc86ceSHeiko Carstens	lgr	%r14,%r9
954bfc86ceSHeiko Carstens	slg	%r14,BASED(.Lcritical_start)
964bfc86ceSHeiko Carstens	clg	%r14,BASED(.Lcritical_length)
974bfc86ceSHeiko Carstens	jhe	0f
984bfc86ceSHeiko Carstens	lghi	%r11,\savearea		# inside critical section, do cleanup
994bfc86ceSHeiko Carstens	brasl	%r14,cleanup_critical
1004bfc86ceSHeiko Carstens	tmhh	%r8,0x0001		# retest problem state after cleanup
1014bfc86ceSHeiko Carstens	jnz	1f
1022acb94f4SMartin Schwidefsky0:	lg	%r14,__LC_ASYNC_STACK	# are we already on the async stack?
1034bfc86ceSHeiko Carstens	slgr	%r14,%r15
1042acb94f4SMartin Schwidefsky	srag	%r14,%r14,STACK_SHIFT
105a359bb11SMartin Schwidefsky	jnz	2f
1062acb94f4SMartin Schwidefsky	CHECK_STACK 1<<STACK_SHIFT,\savearea
1074bfc86ceSHeiko Carstens	aghi	%r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
108a359bb11SMartin Schwidefsky	j	3f
10934525e1fSMartin Schwidefsky1:	UPDATE_VTIME %r14,%r15,\timer
1102acb94f4SMartin Schwidefsky2:	lg	%r15,__LC_ASYNC_STACK	# load async stack
111a359bb11SMartin Schwidefsky3:	la	%r11,STACK_FRAME_OVERHEAD(%r15)
1124bfc86ceSHeiko Carstens	.endm
1134bfc86ceSHeiko Carstens
114a359bb11SMartin Schwidefsky	.macro UPDATE_VTIME w1,w2,enter_timer
115a359bb11SMartin Schwidefsky	lg	\w1,__LC_EXIT_TIMER
116a359bb11SMartin Schwidefsky	lg	\w2,__LC_LAST_UPDATE_TIMER
117a359bb11SMartin Schwidefsky	slg	\w1,\enter_timer
118a359bb11SMartin Schwidefsky	slg	\w2,__LC_EXIT_TIMER
119a359bb11SMartin Schwidefsky	alg	\w1,__LC_USER_TIMER
120a359bb11SMartin Schwidefsky	alg	\w2,__LC_SYSTEM_TIMER
121a359bb11SMartin Schwidefsky	stg	\w1,__LC_USER_TIMER
122a359bb11SMartin Schwidefsky	stg	\w2,__LC_SYSTEM_TIMER
1234bfc86ceSHeiko Carstens	mvc	__LC_LAST_UPDATE_TIMER(8),\enter_timer
1244bfc86ceSHeiko Carstens	.endm
1254bfc86ceSHeiko Carstens
1264bfc86ceSHeiko Carstens	.macro REENABLE_IRQS
1274bfc86ceSHeiko Carstens	stg	%r8,__LC_RETURN_PSW
1284bfc86ceSHeiko Carstens	ni	__LC_RETURN_PSW,0xbf
1294bfc86ceSHeiko Carstens	ssm	__LC_RETURN_PSW
1304bfc86ceSHeiko Carstens	.endm
1314bfc86ceSHeiko Carstens
1324bfc86ceSHeiko Carstens	.macro STCK savearea
1334bfc86ceSHeiko Carstens#ifdef CONFIG_HAVE_MARCH_Z9_109_FEATURES
1344bfc86ceSHeiko Carstens	.insn	s,0xb27c0000,\savearea		# store clock fast
1354bfc86ceSHeiko Carstens#else
1364bfc86ceSHeiko Carstens	.insn	s,0xb2050000,\savearea		# store clock
1374bfc86ceSHeiko Carstens#endif
1384bfc86ceSHeiko Carstens	.endm
1394bfc86ceSHeiko Carstens
14083abeffbSHendrik Brueckner	/*
14183abeffbSHendrik Brueckner	 * The TSTMSK macro generates a test-under-mask instruction by
14283abeffbSHendrik Brueckner	 * calculating the memory offset for the specified mask value.
14383abeffbSHendrik Brueckner	 * Mask value can be any constant.  The macro shifts the mask
14483abeffbSHendrik Brueckner	 * value to calculate the memory offset for the test-under-mask
14583abeffbSHendrik Brueckner	 * instruction.
14683abeffbSHendrik Brueckner	 */
14783abeffbSHendrik Brueckner	.macro TSTMSK addr, mask, size=8, bytepos=0
14883abeffbSHendrik Brueckner		.if (\bytepos < \size) && (\mask >> 8)
14983abeffbSHendrik Brueckner			.if (\mask & 0xff)
15083abeffbSHendrik Brueckner				.error "Mask exceeds byte boundary"
15183abeffbSHendrik Brueckner			.endif
15283abeffbSHendrik Brueckner			TSTMSK \addr, "(\mask >> 8)", \size, "(\bytepos + 1)"
15383abeffbSHendrik Brueckner			.exitm
15483abeffbSHendrik Brueckner		.endif
15583abeffbSHendrik Brueckner		.ifeq \mask
15683abeffbSHendrik Brueckner			.error "Mask must not be zero"
15783abeffbSHendrik Brueckner		.endif
15883abeffbSHendrik Brueckner		off = \size - \bytepos - 1
15983abeffbSHendrik Brueckner		tm	off+\addr, \mask
16083abeffbSHendrik Brueckner	.endm
16183abeffbSHendrik Brueckner
162*d768bd89SMartin Schwidefsky	.macro BPOFF
163*d768bd89SMartin Schwidefsky	.pushsection .altinstr_replacement, "ax"
164*d768bd89SMartin Schwidefsky660:	.long	0xb2e8c000
165*d768bd89SMartin Schwidefsky	.popsection
166*d768bd89SMartin Schwidefsky661:	.long	0x47000000
167*d768bd89SMartin Schwidefsky	.pushsection .altinstructions, "a"
168*d768bd89SMartin Schwidefsky	.long 661b - .
169*d768bd89SMartin Schwidefsky	.long 660b - .
170*d768bd89SMartin Schwidefsky	.word 82
171*d768bd89SMartin Schwidefsky	.byte 4
172*d768bd89SMartin Schwidefsky	.byte 4
173*d768bd89SMartin Schwidefsky	.popsection
174*d768bd89SMartin Schwidefsky	.endm
175*d768bd89SMartin Schwidefsky
176*d768bd89SMartin Schwidefsky	.macro BPON
177*d768bd89SMartin Schwidefsky	.pushsection .altinstr_replacement, "ax"
178*d768bd89SMartin Schwidefsky662:	.long	0xb2e8d000
179*d768bd89SMartin Schwidefsky	.popsection
180*d768bd89SMartin Schwidefsky663:	.long	0x47000000
181*d768bd89SMartin Schwidefsky	.pushsection .altinstructions, "a"
182*d768bd89SMartin Schwidefsky	.long 663b - .
183*d768bd89SMartin Schwidefsky	.long 662b - .
184*d768bd89SMartin Schwidefsky	.word 82
185*d768bd89SMartin Schwidefsky	.byte 4
186*d768bd89SMartin Schwidefsky	.byte 4
187*d768bd89SMartin Schwidefsky	.popsection
188*d768bd89SMartin Schwidefsky	.endm
189*d768bd89SMartin Schwidefsky
1904bfc86ceSHeiko Carstens	.section .kprobes.text, "ax"
19146210c44SHeiko Carstens.Ldummy:
19246210c44SHeiko Carstens	/*
19346210c44SHeiko Carstens	 * This nop exists only in order to avoid that __switch_to starts at
19446210c44SHeiko Carstens	 * the beginning of the kprobes text section. In that case we would
19546210c44SHeiko Carstens	 * have several symbols at the same address. E.g. objdump would take
19646210c44SHeiko Carstens	 * an arbitrary symbol name when disassembling this code.
19746210c44SHeiko Carstens	 * With the added nop in between the __switch_to symbol is unique
19846210c44SHeiko Carstens	 * again.
19946210c44SHeiko Carstens	 */
20046210c44SHeiko Carstens	nop	0
2014bfc86ceSHeiko Carstens
202*d768bd89SMartin SchwidefskyENTRY(__bpon)
203*d768bd89SMartin Schwidefsky	.globl __bpon
204*d768bd89SMartin Schwidefsky	BPON
205*d768bd89SMartin Schwidefsky	br	%r14
206*d768bd89SMartin Schwidefsky
2074bfc86ceSHeiko Carstens/*
2084bfc86ceSHeiko Carstens * Scheduler resume function, called by switch_to
2094bfc86ceSHeiko Carstens *  gpr2 = (task_struct *) prev
2104bfc86ceSHeiko Carstens *  gpr3 = (task_struct *) next
2114bfc86ceSHeiko Carstens * Returns:
2124bfc86ceSHeiko Carstens *  gpr2 = prev
2134bfc86ceSHeiko Carstens */
2144bfc86ceSHeiko CarstensENTRY(__switch_to)
2154bfc86ceSHeiko Carstens	stmg	%r6,%r15,__SF_GPRS(%r15)	# store gprs of prev task
2163241d3ebSHeiko Carstens	lghi	%r4,__TASK_stack
2173241d3ebSHeiko Carstens	lghi	%r1,__TASK_thread
2183241d3ebSHeiko Carstens	lg	%r5,0(%r4,%r3)			# start of kernel stack of next
2193241d3ebSHeiko Carstens	stg	%r15,__THREAD_ksp(%r1,%r2)	# store kernel stack of prev
2204bfc86ceSHeiko Carstens	lgr	%r15,%r5
2214bfc86ceSHeiko Carstens	aghi	%r15,STACK_INIT			# end of kernel stack of next
2224bfc86ceSHeiko Carstens	stg	%r3,__LC_CURRENT		# store task struct of next
2234bfc86ceSHeiko Carstens	stg	%r15,__LC_KERNEL_STACK		# store end of kernel stack
2243241d3ebSHeiko Carstens	lg	%r15,__THREAD_ksp(%r1,%r3)	# load kernel stack of next
2253241d3ebSHeiko Carstens	aghi	%r3,__TASK_pid
2263241d3ebSHeiko Carstens	mvc	__LC_CURRENT_PID(4,%r0),0(%r3)	# store pid of next
2274bfc86ceSHeiko Carstens	lmg	%r6,%r15,__SF_GPRS(%r15)	# load gprs of next task
228e22cf8caSChristian Borntraeger	TSTMSK	__LC_MACHINE_FLAGS,MACHINE_FLAG_LPP
229e22cf8caSChristian Borntraeger	bzr	%r14
230e22cf8caSChristian Borntraeger	.insn	s,0xb2800000,__LC_LPP		# set program parameter
2314bfc86ceSHeiko Carstens	br	%r14
2324bfc86ceSHeiko Carstens
2334bfc86ceSHeiko Carstens.L__critical_start:
234d0fc4107SMartin Schwidefsky
235d0fc4107SMartin Schwidefsky#if IS_ENABLED(CONFIG_KVM)
236d0fc4107SMartin Schwidefsky/*
237d0fc4107SMartin Schwidefsky * sie64a calling convention:
238d0fc4107SMartin Schwidefsky * %r2 pointer to sie control block
239d0fc4107SMartin Schwidefsky * %r3 guest register save area
240d0fc4107SMartin Schwidefsky */
241d0fc4107SMartin SchwidefskyENTRY(sie64a)
242d0fc4107SMartin Schwidefsky	stmg	%r6,%r14,__SF_GPRS(%r15)	# save kernel registers
243d0fc4107SMartin Schwidefsky	stg	%r2,__SF_EMPTY(%r15)		# save control block pointer
244d0fc4107SMartin Schwidefsky	stg	%r3,__SF_EMPTY+8(%r15)		# save guest register save area
245e22cf8caSChristian Borntraeger	xc	__SF_EMPTY+16(8,%r15),__SF_EMPTY+16(%r15) # reason code = 0
24683abeffbSHendrik Brueckner	TSTMSK	__LC_CPU_FLAGS,_CIF_FPU		# load guest fp/vx registers ?
247d0fc4107SMartin Schwidefsky	jno	.Lsie_load_guest_gprs
248d0fc4107SMartin Schwidefsky	brasl	%r14,load_fpu_regs		# load guest fp/vx regs
249d0fc4107SMartin Schwidefsky.Lsie_load_guest_gprs:
250d0fc4107SMartin Schwidefsky	lmg	%r0,%r13,0(%r3)			# load guest gprs 0-13
251d0fc4107SMartin Schwidefsky	lg	%r14,__LC_GMAP			# get gmap pointer
252d0fc4107SMartin Schwidefsky	ltgr	%r14,%r14
253d0fc4107SMartin Schwidefsky	jz	.Lsie_gmap
254d0fc4107SMartin Schwidefsky	lctlg	%c1,%c1,__GMAP_ASCE(%r14)	# load primary asce
255d0fc4107SMartin Schwidefsky.Lsie_gmap:
256d0fc4107SMartin Schwidefsky	lg	%r14,__SF_EMPTY(%r15)		# get control block pointer
257d0fc4107SMartin Schwidefsky	oi	__SIE_PROG0C+3(%r14),1		# we are going into SIE now
258d0fc4107SMartin Schwidefsky	tm	__SIE_PROG20+3(%r14),3		# last exit...
259d0fc4107SMartin Schwidefsky	jnz	.Lsie_skip
26083abeffbSHendrik Brueckner	TSTMSK	__LC_CPU_FLAGS,_CIF_FPU
261d0fc4107SMartin Schwidefsky	jo	.Lsie_skip			# exit if fp/vx regs changed
262*d768bd89SMartin Schwidefsky	BPON
263c929500dSQingFeng Hao.Lsie_entry:
264d0fc4107SMartin Schwidefsky	sie	0(%r14)
265*d768bd89SMartin Schwidefsky.Lsie_exit:
266*d768bd89SMartin Schwidefsky	BPOFF
267d0fc4107SMartin Schwidefsky.Lsie_skip:
268d0fc4107SMartin Schwidefsky	ni	__SIE_PROG0C+3(%r14),0xfe	# no longer in SIE
269d0fc4107SMartin Schwidefsky	lctlg	%c1,%c1,__LC_USER_ASCE		# load primary asce
270d0fc4107SMartin Schwidefsky.Lsie_done:
271d0fc4107SMartin Schwidefsky# some program checks are suppressing. C code (e.g. do_protection_exception)
272c0e7bb38SChristian Borntraeger# will rewind the PSW by the ILC, which is often 4 bytes in case of SIE. There
273c0e7bb38SChristian Borntraeger# are some corner cases (e.g. runtime instrumentation) where ILC is unpredictable.
274c0e7bb38SChristian Borntraeger# Other instructions between sie64a and .Lsie_done should not cause program
275c0e7bb38SChristian Borntraeger# interrupts. So lets use 3 nops as a landing pad for all possible rewinds.
276d0fc4107SMartin Schwidefsky# See also .Lcleanup_sie
277c0e7bb38SChristian Borntraeger.Lrewind_pad6:
278c0e7bb38SChristian Borntraeger	nopr	7
279c0e7bb38SChristian Borntraeger.Lrewind_pad4:
280c0e7bb38SChristian Borntraeger	nopr	7
281c0e7bb38SChristian Borntraeger.Lrewind_pad2:
282c0e7bb38SChristian Borntraeger	nopr	7
283d0fc4107SMartin Schwidefsky	.globl sie_exit
284d0fc4107SMartin Schwidefskysie_exit:
285d0fc4107SMartin Schwidefsky	lg	%r14,__SF_EMPTY+8(%r15)		# load guest register save area
286d0fc4107SMartin Schwidefsky	stmg	%r0,%r13,0(%r14)		# save guest gprs 0-13
2877041d281SMartin Schwidefsky	xgr	%r0,%r0				# clear guest registers to
2887041d281SMartin Schwidefsky	xgr	%r1,%r1				# prevent speculative use
2897041d281SMartin Schwidefsky	xgr	%r2,%r2
2907041d281SMartin Schwidefsky	xgr	%r3,%r3
2917041d281SMartin Schwidefsky	xgr	%r4,%r4
2927041d281SMartin Schwidefsky	xgr	%r5,%r5
293d0fc4107SMartin Schwidefsky	lmg	%r6,%r14,__SF_GPRS(%r15)	# restore kernel registers
294e22cf8caSChristian Borntraeger	lg	%r2,__SF_EMPTY+16(%r15)		# return exit reason code
295d0fc4107SMartin Schwidefsky	br	%r14
296d0fc4107SMartin Schwidefsky.Lsie_fault:
297d0fc4107SMartin Schwidefsky	lghi	%r14,-EFAULT
298e22cf8caSChristian Borntraeger	stg	%r14,__SF_EMPTY+16(%r15)	# set exit reason code
299d0fc4107SMartin Schwidefsky	j	sie_exit
300d0fc4107SMartin Schwidefsky
301c0e7bb38SChristian Borntraeger	EX_TABLE(.Lrewind_pad6,.Lsie_fault)
302c0e7bb38SChristian Borntraeger	EX_TABLE(.Lrewind_pad4,.Lsie_fault)
303c0e7bb38SChristian Borntraeger	EX_TABLE(.Lrewind_pad2,.Lsie_fault)
304d0fc4107SMartin Schwidefsky	EX_TABLE(sie_exit,.Lsie_fault)
305711f5df7SAl ViroEXPORT_SYMBOL(sie64a)
306711f5df7SAl ViroEXPORT_SYMBOL(sie_exit)
307d0fc4107SMartin Schwidefsky#endif
308d0fc4107SMartin Schwidefsky
3094bfc86ceSHeiko Carstens/*
3104bfc86ceSHeiko Carstens * SVC interrupt handler routine. System calls are synchronous events and
3114bfc86ceSHeiko Carstens * are executed with interrupts enabled.
3124bfc86ceSHeiko Carstens */
3134bfc86ceSHeiko Carstens
3144bfc86ceSHeiko CarstensENTRY(system_call)
3154bfc86ceSHeiko Carstens	stpt	__LC_SYNC_ENTER_TIMER
3164bfc86ceSHeiko Carstens.Lsysc_stmg:
3174bfc86ceSHeiko Carstens	stmg	%r8,%r15,__LC_SAVE_AREA_SYNC
318*d768bd89SMartin Schwidefsky	BPOFF
319d5c352cdSHeiko Carstens	lg	%r12,__LC_CURRENT
32034525e1fSMartin Schwidefsky	lghi	%r13,__TASK_thread
3214bfc86ceSHeiko Carstens	lghi	%r14,_PIF_SYSCALL
3224bfc86ceSHeiko Carstens.Lsysc_per:
3234bfc86ceSHeiko Carstens	lg	%r15,__LC_KERNEL_STACK
3244bfc86ceSHeiko Carstens	la	%r11,STACK_FRAME_OVERHEAD(%r15)	# pointer to pt_regs
325a359bb11SMartin Schwidefsky.Lsysc_vtime:
32634525e1fSMartin Schwidefsky	UPDATE_VTIME %r8,%r9,__LC_SYNC_ENTER_TIMER
3274bfc86ceSHeiko Carstens	stmg	%r0,%r7,__PT_R0(%r11)
3287041d281SMartin Schwidefsky	# clear user controlled register to prevent speculative use
3297041d281SMartin Schwidefsky	xgr	%r0,%r0
3304bfc86ceSHeiko Carstens	mvc	__PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
3314bfc86ceSHeiko Carstens	mvc	__PT_PSW(16,%r11),__LC_SVC_OLD_PSW
3324bfc86ceSHeiko Carstens	mvc	__PT_INT_CODE(4,%r11),__LC_SVC_ILC
3334bfc86ceSHeiko Carstens	stg	%r14,__PT_FLAGS(%r11)
3344bfc86ceSHeiko Carstens.Lsysc_do_svc:
335ef280c85SMartin Schwidefsky	# load address of system call table
336ef280c85SMartin Schwidefsky	lg	%r10,__THREAD_sysc_table(%r13,%r12)
3374bfc86ceSHeiko Carstens	llgh	%r8,__PT_INT_CODE+2(%r11)
3384bfc86ceSHeiko Carstens	slag	%r8,%r8,2			# shift and test for svc 0
3394bfc86ceSHeiko Carstens	jnz	.Lsysc_nr_ok
3404bfc86ceSHeiko Carstens	# svc 0: system call number in %r1
3414bfc86ceSHeiko Carstens	llgfr	%r1,%r1				# clear high word in r1
3424bfc86ceSHeiko Carstens	cghi	%r1,NR_syscalls
3434bfc86ceSHeiko Carstens	jnl	.Lsysc_nr_ok
3444bfc86ceSHeiko Carstens	sth	%r1,__PT_INT_CODE+2(%r11)
3454bfc86ceSHeiko Carstens	slag	%r8,%r1,2
3464bfc86ceSHeiko Carstens.Lsysc_nr_ok:
3474bfc86ceSHeiko Carstens	xc	__SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
3484bfc86ceSHeiko Carstens	stg	%r2,__PT_ORIG_GPR2(%r11)
3494bfc86ceSHeiko Carstens	stg	%r7,STACK_FRAME_OVERHEAD(%r15)
3504bfc86ceSHeiko Carstens	lgf	%r9,0(%r8,%r10)			# get system call add.
35183abeffbSHendrik Brueckner	TSTMSK	__TI_flags(%r12),_TIF_TRACE
3524bfc86ceSHeiko Carstens	jnz	.Lsysc_tracesys
3534bfc86ceSHeiko Carstens	basr	%r14,%r9			# call sys_xxxx
3544bfc86ceSHeiko Carstens	stg	%r2,__PT_R2(%r11)		# store return value
3554bfc86ceSHeiko Carstens
3564bfc86ceSHeiko Carstens.Lsysc_return:
3574bfc86ceSHeiko Carstens	LOCKDEP_SYS_EXIT
3584bfc86ceSHeiko Carstens.Lsysc_tif:
35983abeffbSHendrik Brueckner	TSTMSK	__PT_FLAGS(%r11),_PIF_WORK
3604bfc86ceSHeiko Carstens	jnz	.Lsysc_work
36183abeffbSHendrik Brueckner	TSTMSK	__TI_flags(%r12),_TIF_WORK
3624bfc86ceSHeiko Carstens	jnz	.Lsysc_work			# check for work
36383abeffbSHendrik Brueckner	TSTMSK	__LC_CPU_FLAGS,_CIF_WORK
3644bfc86ceSHeiko Carstens	jnz	.Lsysc_work
365*d768bd89SMartin Schwidefsky	BPON
3664bfc86ceSHeiko Carstens.Lsysc_restore:
3674bfc86ceSHeiko Carstens	lg	%r14,__LC_VDSO_PER_CPU
3684bfc86ceSHeiko Carstens	lmg	%r0,%r10,__PT_R0(%r11)
3694bfc86ceSHeiko Carstens	mvc	__LC_RETURN_PSW(16),__PT_PSW(%r11)
37007a63cbeSMartin Schwidefsky.Lsysc_exit_timer:
3714bfc86ceSHeiko Carstens	stpt	__LC_EXIT_TIMER
3724bfc86ceSHeiko Carstens	mvc	__VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
3734bfc86ceSHeiko Carstens	lmg	%r11,%r15,__PT_R11(%r11)
3744bfc86ceSHeiko Carstens	lpswe	__LC_RETURN_PSW
3754bfc86ceSHeiko Carstens.Lsysc_done:
3764bfc86ceSHeiko Carstens
3774bfc86ceSHeiko Carstens#
3784bfc86ceSHeiko Carstens# One of the work bits is on. Find out which one.
3794bfc86ceSHeiko Carstens#
3804bfc86ceSHeiko Carstens.Lsysc_work:
38183abeffbSHendrik Brueckner	TSTMSK	__LC_CPU_FLAGS,_CIF_MCCK_PENDING
3824bfc86ceSHeiko Carstens	jo	.Lsysc_mcck_pending
38383abeffbSHendrik Brueckner	TSTMSK	__TI_flags(%r12),_TIF_NEED_RESCHED
3844bfc86ceSHeiko Carstens	jo	.Lsysc_reschedule
38523fefe11SMartin Schwidefsky	TSTMSK	__PT_FLAGS(%r11),_PIF_SYSCALL_RESTART
38623fefe11SMartin Schwidefsky	jo	.Lsysc_syscall_restart
3874bfc86ceSHeiko Carstens#ifdef CONFIG_UPROBES
38883abeffbSHendrik Brueckner	TSTMSK	__TI_flags(%r12),_TIF_UPROBE
3894bfc86ceSHeiko Carstens	jo	.Lsysc_uprobe_notify
3904bfc86ceSHeiko Carstens#endif
391916cda1aSMartin Schwidefsky	TSTMSK	__TI_flags(%r12),_TIF_GUARDED_STORAGE
392916cda1aSMartin Schwidefsky	jo	.Lsysc_guarded_storage
39383abeffbSHendrik Brueckner	TSTMSK	__PT_FLAGS(%r11),_PIF_PER_TRAP
3944bfc86ceSHeiko Carstens	jo	.Lsysc_singlestep
3952f09ca60SMiroslav Benes#ifdef CONFIG_LIVEPATCH
3962f09ca60SMiroslav Benes	TSTMSK	__TI_flags(%r12),_TIF_PATCH_PENDING
3972f09ca60SMiroslav Benes	jo	.Lsysc_patch_pending	# handle live patching just before
3982f09ca60SMiroslav Benes					# signals and possible syscall restart
3992f09ca60SMiroslav Benes#endif
40023fefe11SMartin Schwidefsky	TSTMSK	__PT_FLAGS(%r11),_PIF_SYSCALL_RESTART
40123fefe11SMartin Schwidefsky	jo	.Lsysc_syscall_restart
40283abeffbSHendrik Brueckner	TSTMSK	__TI_flags(%r12),_TIF_SIGPENDING
4034bfc86ceSHeiko Carstens	jo	.Lsysc_sigpending
40483abeffbSHendrik Brueckner	TSTMSK	__TI_flags(%r12),_TIF_NOTIFY_RESUME
4054bfc86ceSHeiko Carstens	jo	.Lsysc_notify_resume
40683abeffbSHendrik Brueckner	TSTMSK	__LC_CPU_FLAGS,_CIF_FPU
4079977e886SHendrik Brueckner	jo	.Lsysc_vxrs
408b5a882fcSHeiko Carstens	TSTMSK	__LC_CPU_FLAGS,(_CIF_ASCE_PRIMARY|_CIF_ASCE_SECONDARY)
409b5a882fcSHeiko Carstens	jnz	.Lsysc_asce
4104bfc86ceSHeiko Carstens	j	.Lsysc_return		# beware of critical section cleanup
4114bfc86ceSHeiko Carstens
4124bfc86ceSHeiko Carstens#
4134bfc86ceSHeiko Carstens# _TIF_NEED_RESCHED is set, call schedule
4144bfc86ceSHeiko Carstens#
4154bfc86ceSHeiko Carstens.Lsysc_reschedule:
4164bfc86ceSHeiko Carstens	larl	%r14,.Lsysc_return
4174bfc86ceSHeiko Carstens	jg	schedule
4184bfc86ceSHeiko Carstens
4194bfc86ceSHeiko Carstens#
4204bfc86ceSHeiko Carstens# _CIF_MCCK_PENDING is set, call handler
4214bfc86ceSHeiko Carstens#
4224bfc86ceSHeiko Carstens.Lsysc_mcck_pending:
4234bfc86ceSHeiko Carstens	larl	%r14,.Lsysc_return
4244bfc86ceSHeiko Carstens	jg	s390_handle_mcck	# TIF bit will be cleared by handler
4254bfc86ceSHeiko Carstens
4264bfc86ceSHeiko Carstens#
4270aaba41bSMartin Schwidefsky# _CIF_ASCE_PRIMARY and/or _CIF_ASCE_SECONDARY set, load user space asce
4284bfc86ceSHeiko Carstens#
429b5a882fcSHeiko Carstens.Lsysc_asce:
4300aaba41bSMartin Schwidefsky	ni	__LC_CPU_FLAGS+7,255-_CIF_ASCE_SECONDARY
4310aaba41bSMartin Schwidefsky	lctlg	%c7,%c7,__LC_VDSO_ASCE		# load secondary asce
4320aaba41bSMartin Schwidefsky	TSTMSK	__LC_CPU_FLAGS,_CIF_ASCE_PRIMARY
4330aaba41bSMartin Schwidefsky	jz	.Lsysc_return
4340aaba41bSMartin Schwidefsky#ifndef CONFIG_HAVE_MARCH_Z10_FEATURES
4350aaba41bSMartin Schwidefsky	tm	__LC_STFLE_FAC_LIST+3,0x10	# has MVCOS ?
4360aaba41bSMartin Schwidefsky	jnz	.Lsysc_set_fs_fixup
437606aa4aaSHeiko Carstens	ni	__LC_CPU_FLAGS+7,255-_CIF_ASCE_PRIMARY
4384bfc86ceSHeiko Carstens	lctlg	%c1,%c1,__LC_USER_ASCE		# load primary asce
4390aaba41bSMartin Schwidefsky	j	.Lsysc_return
4400aaba41bSMartin Schwidefsky.Lsysc_set_fs_fixup:
4410aaba41bSMartin Schwidefsky#endif
442b5a882fcSHeiko Carstens	larl	%r14,.Lsysc_return
443b5a882fcSHeiko Carstens	jg	set_fs_fixup
4444bfc86ceSHeiko Carstens
4454bfc86ceSHeiko Carstens#
4469977e886SHendrik Brueckner# CIF_FPU is set, restore floating-point controls and floating-point registers.
4479977e886SHendrik Brueckner#
4489977e886SHendrik Brueckner.Lsysc_vxrs:
4499977e886SHendrik Brueckner	larl	%r14,.Lsysc_return
4509977e886SHendrik Brueckner	jg	load_fpu_regs
4519977e886SHendrik Brueckner
4529977e886SHendrik Brueckner#
4534bfc86ceSHeiko Carstens# _TIF_SIGPENDING is set, call do_signal
4544bfc86ceSHeiko Carstens#
4554bfc86ceSHeiko Carstens.Lsysc_sigpending:
4564bfc86ceSHeiko Carstens	lgr	%r2,%r11		# pass pointer to pt_regs
4574bfc86ceSHeiko Carstens	brasl	%r14,do_signal
45883abeffbSHendrik Brueckner	TSTMSK	__PT_FLAGS(%r11),_PIF_SYSCALL
4594bfc86ceSHeiko Carstens	jno	.Lsysc_return
46057d7f939SMartin Schwidefsky.Lsysc_do_syscall:
46157d7f939SMartin Schwidefsky	lghi	%r13,__TASK_thread
4624bfc86ceSHeiko Carstens	lmg	%r2,%r7,__PT_R2(%r11)	# load svc arguments
46357d7f939SMartin Schwidefsky	lghi	%r1,0			# svc 0 returns -ENOSYS
46457d7f939SMartin Schwidefsky	j	.Lsysc_do_svc
4654bfc86ceSHeiko Carstens
4664bfc86ceSHeiko Carstens#
4674bfc86ceSHeiko Carstens# _TIF_NOTIFY_RESUME is set, call do_notify_resume
4684bfc86ceSHeiko Carstens#
4694bfc86ceSHeiko Carstens.Lsysc_notify_resume:
4704bfc86ceSHeiko Carstens	lgr	%r2,%r11		# pass pointer to pt_regs
4714bfc86ceSHeiko Carstens	larl	%r14,.Lsysc_return
4724bfc86ceSHeiko Carstens	jg	do_notify_resume
4734bfc86ceSHeiko Carstens
4744bfc86ceSHeiko Carstens#
4754bfc86ceSHeiko Carstens# _TIF_UPROBE is set, call uprobe_notify_resume
4764bfc86ceSHeiko Carstens#
4774bfc86ceSHeiko Carstens#ifdef CONFIG_UPROBES
4784bfc86ceSHeiko Carstens.Lsysc_uprobe_notify:
4794bfc86ceSHeiko Carstens	lgr	%r2,%r11		# pass pointer to pt_regs
4804bfc86ceSHeiko Carstens	larl	%r14,.Lsysc_return
4814bfc86ceSHeiko Carstens	jg	uprobe_notify_resume
4824bfc86ceSHeiko Carstens#endif
4834bfc86ceSHeiko Carstens
4844bfc86ceSHeiko Carstens#
485916cda1aSMartin Schwidefsky# _TIF_GUARDED_STORAGE is set, call guarded_storage_load
486916cda1aSMartin Schwidefsky#
487916cda1aSMartin Schwidefsky.Lsysc_guarded_storage:
488916cda1aSMartin Schwidefsky	lgr	%r2,%r11		# pass pointer to pt_regs
489916cda1aSMartin Schwidefsky	larl	%r14,.Lsysc_return
490916cda1aSMartin Schwidefsky	jg	gs_load_bc_cb
49176f1948aSLinus Torvalds#
4922f09ca60SMiroslav Benes# _TIF_PATCH_PENDING is set, call klp_update_patch_state
4932f09ca60SMiroslav Benes#
4942f09ca60SMiroslav Benes#ifdef CONFIG_LIVEPATCH
4952f09ca60SMiroslav Benes.Lsysc_patch_pending:
4962f09ca60SMiroslav Benes	lg	%r2,__LC_CURRENT	# pass pointer to task struct
4972f09ca60SMiroslav Benes	larl	%r14,.Lsysc_return
4982f09ca60SMiroslav Benes	jg	klp_update_patch_state
4992f09ca60SMiroslav Benes#endif
500916cda1aSMartin Schwidefsky
501916cda1aSMartin Schwidefsky#
5024bfc86ceSHeiko Carstens# _PIF_PER_TRAP is set, call do_per_trap
5034bfc86ceSHeiko Carstens#
5044bfc86ceSHeiko Carstens.Lsysc_singlestep:
5054bfc86ceSHeiko Carstens	ni	__PT_FLAGS+7(%r11),255-_PIF_PER_TRAP
5064bfc86ceSHeiko Carstens	lgr	%r2,%r11		# pass pointer to pt_regs
5074bfc86ceSHeiko Carstens	larl	%r14,.Lsysc_return
5084bfc86ceSHeiko Carstens	jg	do_per_trap
5094bfc86ceSHeiko Carstens
5104bfc86ceSHeiko Carstens#
51123fefe11SMartin Schwidefsky# _PIF_SYSCALL_RESTART is set, repeat the current system call
51223fefe11SMartin Schwidefsky#
51323fefe11SMartin Schwidefsky.Lsysc_syscall_restart:
51423fefe11SMartin Schwidefsky	ni	__PT_FLAGS+7(%r11),255-_PIF_SYSCALL_RESTART
51523fefe11SMartin Schwidefsky	lmg	%r1,%r7,__PT_R1(%r11)	# load svc arguments
51623fefe11SMartin Schwidefsky	lg	%r2,__PT_ORIG_GPR2(%r11)
51723fefe11SMartin Schwidefsky	j	.Lsysc_do_svc
51823fefe11SMartin Schwidefsky
51923fefe11SMartin Schwidefsky#
5204bfc86ceSHeiko Carstens# call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
5214bfc86ceSHeiko Carstens# and after the system call
5224bfc86ceSHeiko Carstens#
5234bfc86ceSHeiko Carstens.Lsysc_tracesys:
5244bfc86ceSHeiko Carstens	lgr	%r2,%r11		# pass pointer to pt_regs
5254bfc86ceSHeiko Carstens	la	%r3,0
5264bfc86ceSHeiko Carstens	llgh	%r0,__PT_INT_CODE+2(%r11)
5274bfc86ceSHeiko Carstens	stg	%r0,__PT_R2(%r11)
5284bfc86ceSHeiko Carstens	brasl	%r14,do_syscall_trace_enter
5294bfc86ceSHeiko Carstens	lghi	%r0,NR_syscalls
5304bfc86ceSHeiko Carstens	clgr	%r0,%r2
5314bfc86ceSHeiko Carstens	jnh	.Lsysc_tracenogo
5324bfc86ceSHeiko Carstens	sllg	%r8,%r2,2
5334bfc86ceSHeiko Carstens	lgf	%r9,0(%r8,%r10)
5344bfc86ceSHeiko Carstens.Lsysc_tracego:
5354bfc86ceSHeiko Carstens	lmg	%r3,%r7,__PT_R3(%r11)
5364bfc86ceSHeiko Carstens	stg	%r7,STACK_FRAME_OVERHEAD(%r15)
5374bfc86ceSHeiko Carstens	lg	%r2,__PT_ORIG_GPR2(%r11)
5384bfc86ceSHeiko Carstens	basr	%r14,%r9		# call sys_xxx
5394bfc86ceSHeiko Carstens	stg	%r2,__PT_R2(%r11)	# store return value
5404bfc86ceSHeiko Carstens.Lsysc_tracenogo:
54183abeffbSHendrik Brueckner	TSTMSK	__TI_flags(%r12),_TIF_TRACE
5424bfc86ceSHeiko Carstens	jz	.Lsysc_return
5434bfc86ceSHeiko Carstens	lgr	%r2,%r11		# pass pointer to pt_regs
5444bfc86ceSHeiko Carstens	larl	%r14,.Lsysc_return
5454bfc86ceSHeiko Carstens	jg	do_syscall_trace_exit
5464bfc86ceSHeiko Carstens
5474bfc86ceSHeiko Carstens#
5484bfc86ceSHeiko Carstens# a new process exits the kernel with ret_from_fork
5494bfc86ceSHeiko Carstens#
5504bfc86ceSHeiko CarstensENTRY(ret_from_fork)
5514bfc86ceSHeiko Carstens	la	%r11,STACK_FRAME_OVERHEAD(%r15)
552d5c352cdSHeiko Carstens	lg	%r12,__LC_CURRENT
5534bfc86ceSHeiko Carstens	brasl	%r14,schedule_tail
5544bfc86ceSHeiko Carstens	TRACE_IRQS_ON
5554bfc86ceSHeiko Carstens	ssm	__LC_SVC_NEW_PSW	# reenable interrupts
5564bfc86ceSHeiko Carstens	tm	__PT_PSW+1(%r11),0x01	# forking a kernel thread ?
5574bfc86ceSHeiko Carstens	jne	.Lsysc_tracenogo
5584bfc86ceSHeiko Carstens	# it's a kernel thread
5594bfc86ceSHeiko Carstens	lmg	%r9,%r10,__PT_R9(%r11)	# load gprs
5604bfc86ceSHeiko CarstensENTRY(kernel_thread_starter)
5614bfc86ceSHeiko Carstens	la	%r2,0(%r10)
5624bfc86ceSHeiko Carstens	basr	%r14,%r9
5634bfc86ceSHeiko Carstens	j	.Lsysc_tracenogo
5644bfc86ceSHeiko Carstens
5654bfc86ceSHeiko Carstens/*
5664bfc86ceSHeiko Carstens * Program check handler routine
5674bfc86ceSHeiko Carstens */
5684bfc86ceSHeiko Carstens
5694bfc86ceSHeiko CarstensENTRY(pgm_check_handler)
5704bfc86ceSHeiko Carstens	stpt	__LC_SYNC_ENTER_TIMER
571*d768bd89SMartin Schwidefsky	BPOFF
5724bfc86ceSHeiko Carstens	stmg	%r8,%r15,__LC_SAVE_AREA_SYNC
5734bfc86ceSHeiko Carstens	lg	%r10,__LC_LAST_BREAK
574d5c352cdSHeiko Carstens	lg	%r12,__LC_CURRENT
575c771320eSMartin Schwidefsky	lghi	%r11,0
5769977e886SHendrik Brueckner	larl	%r13,cleanup_critical
5774bfc86ceSHeiko Carstens	lmg	%r8,%r9,__LC_PGM_OLD_PSW
5784bfc86ceSHeiko Carstens	tmhh	%r8,0x0001		# test problem state bit
579d0fc4107SMartin Schwidefsky	jnz	2f			# -> fault in user space
580d0fc4107SMartin Schwidefsky#if IS_ENABLED(CONFIG_KVM)
5810a5e2ec2SMartin Schwidefsky	# cleanup critical section for program checks in sie64a
582d0fc4107SMartin Schwidefsky	lgr	%r14,%r9
583d0fc4107SMartin Schwidefsky	slg	%r14,BASED(.Lsie_critical_start)
584d0fc4107SMartin Schwidefsky	clg	%r14,BASED(.Lsie_critical_length)
585d0fc4107SMartin Schwidefsky	jhe	0f
5860a5e2ec2SMartin Schwidefsky	lg	%r14,__SF_EMPTY(%r15)		# get control block pointer
5870a5e2ec2SMartin Schwidefsky	ni	__SIE_PROG0C+3(%r14),0xfe	# no longer in SIE
5880a5e2ec2SMartin Schwidefsky	lctlg	%c1,%c1,__LC_USER_ASCE		# load primary asce
5890a5e2ec2SMartin Schwidefsky	larl	%r9,sie_exit			# skip forward to sie_exit
590c771320eSMartin Schwidefsky	lghi	%r11,_PIF_GUEST_FAULT
591d0fc4107SMartin Schwidefsky#endif
592d0fc4107SMartin Schwidefsky0:	tmhh	%r8,0x4000		# PER bit set in old PSW ?
593d0fc4107SMartin Schwidefsky	jnz	1f			# -> enabled, can't be a double fault
5944bfc86ceSHeiko Carstens	tm	__LC_PGM_ILC+3,0x80	# check for per exception
5954bfc86ceSHeiko Carstens	jnz	.Lpgm_svcper		# -> single stepped svc
596d0fc4107SMartin Schwidefsky1:	CHECK_STACK STACK_SIZE,__LC_SAVE_AREA_SYNC
5974bfc86ceSHeiko Carstens	aghi	%r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
598d9fcf2a1SMartin Schwidefsky	j	4f
59934525e1fSMartin Schwidefsky2:	UPDATE_VTIME %r14,%r15,__LC_SYNC_ENTER_TIMER
6004bfc86ceSHeiko Carstens	lg	%r15,__LC_KERNEL_STACK
601d5c352cdSHeiko Carstens	lgr	%r14,%r12
6023827ec3dSMartin Schwidefsky	aghi	%r14,__TASK_thread	# pointer to thread_struct
6034bfc86ceSHeiko Carstens	lghi	%r13,__LC_PGM_TDB
6044bfc86ceSHeiko Carstens	tm	__LC_PGM_ILC+2,0x02	# check for transaction abort
605d0fc4107SMartin Schwidefsky	jz	3f
6064bfc86ceSHeiko Carstens	mvc	__THREAD_trap_tdb(256,%r14),0(%r13)
607d9fcf2a1SMartin Schwidefsky3:	stg	%r10,__THREAD_last_break(%r14)
608c771320eSMartin Schwidefsky4:	lgr	%r13,%r11
609c771320eSMartin Schwidefsky	la	%r11,STACK_FRAME_OVERHEAD(%r15)
6104bfc86ceSHeiko Carstens	stmg	%r0,%r7,__PT_R0(%r11)
6117041d281SMartin Schwidefsky	# clear user controlled registers to prevent speculative use
6127041d281SMartin Schwidefsky	xgr	%r0,%r0
6137041d281SMartin Schwidefsky	xgr	%r1,%r1
6147041d281SMartin Schwidefsky	xgr	%r2,%r2
6157041d281SMartin Schwidefsky	xgr	%r3,%r3
6167041d281SMartin Schwidefsky	xgr	%r4,%r4
6177041d281SMartin Schwidefsky	xgr	%r5,%r5
6187041d281SMartin Schwidefsky	xgr	%r6,%r6
6197041d281SMartin Schwidefsky	xgr	%r7,%r7
6204bfc86ceSHeiko Carstens	mvc	__PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
6214bfc86ceSHeiko Carstens	stmg	%r8,%r9,__PT_PSW(%r11)
6224bfc86ceSHeiko Carstens	mvc	__PT_INT_CODE(4,%r11),__LC_PGM_ILC
6234bfc86ceSHeiko Carstens	mvc	__PT_INT_PARM_LONG(8,%r11),__LC_TRANS_EXC_CODE
624c771320eSMartin Schwidefsky	stg	%r13,__PT_FLAGS(%r11)
6254bfc86ceSHeiko Carstens	stg	%r10,__PT_ARGS(%r11)
6264bfc86ceSHeiko Carstens	tm	__LC_PGM_ILC+3,0x80	# check for per exception
627d9fcf2a1SMartin Schwidefsky	jz	5f
6284bfc86ceSHeiko Carstens	tmhh	%r8,0x0001		# kernel per event ?
6294bfc86ceSHeiko Carstens	jz	.Lpgm_kprobe
6304bfc86ceSHeiko Carstens	oi	__PT_FLAGS+7(%r11),_PIF_PER_TRAP
6314bfc86ceSHeiko Carstens	mvc	__THREAD_per_address(8,%r14),__LC_PER_ADDRESS
6324bfc86ceSHeiko Carstens	mvc	__THREAD_per_cause(2,%r14),__LC_PER_CODE
6334bfc86ceSHeiko Carstens	mvc	__THREAD_per_paid(1,%r14),__LC_PER_ACCESS_ID
634d9fcf2a1SMartin Schwidefsky5:	REENABLE_IRQS
6354bfc86ceSHeiko Carstens	xc	__SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
6364bfc86ceSHeiko Carstens	larl	%r1,pgm_check_table
6374bfc86ceSHeiko Carstens	llgh	%r10,__PT_INT_CODE+2(%r11)
6384bfc86ceSHeiko Carstens	nill	%r10,0x007f
6394bfc86ceSHeiko Carstens	sll	%r10,2
640a359bb11SMartin Schwidefsky	je	.Lpgm_return
6414bfc86ceSHeiko Carstens	lgf	%r1,0(%r10,%r1)		# load address of handler routine
6424bfc86ceSHeiko Carstens	lgr	%r2,%r11		# pass pointer to pt_regs
6434bfc86ceSHeiko Carstens	basr	%r14,%r1		# branch to interrupt-handler
644a359bb11SMartin Schwidefsky.Lpgm_return:
645a359bb11SMartin Schwidefsky	LOCKDEP_SYS_EXIT
646a359bb11SMartin Schwidefsky	tm	__PT_PSW+1(%r11),0x01	# returning to user ?
647a359bb11SMartin Schwidefsky	jno	.Lsysc_restore
64857d7f939SMartin Schwidefsky	TSTMSK	__PT_FLAGS(%r11),_PIF_SYSCALL
64957d7f939SMartin Schwidefsky	jo	.Lsysc_do_syscall
650a359bb11SMartin Schwidefsky	j	.Lsysc_tif
6514bfc86ceSHeiko Carstens
6524bfc86ceSHeiko Carstens#
6534bfc86ceSHeiko Carstens# PER event in supervisor state, must be kprobes
6544bfc86ceSHeiko Carstens#
6554bfc86ceSHeiko Carstens.Lpgm_kprobe:
6564bfc86ceSHeiko Carstens	REENABLE_IRQS
6574bfc86ceSHeiko Carstens	xc	__SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
6584bfc86ceSHeiko Carstens	lgr	%r2,%r11		# pass pointer to pt_regs
6594bfc86ceSHeiko Carstens	brasl	%r14,do_per_trap
660a359bb11SMartin Schwidefsky	j	.Lpgm_return
6614bfc86ceSHeiko Carstens
6624bfc86ceSHeiko Carstens#
6634bfc86ceSHeiko Carstens# single stepped system call
6644bfc86ceSHeiko Carstens#
6654bfc86ceSHeiko Carstens.Lpgm_svcper:
6664bfc86ceSHeiko Carstens	mvc	__LC_RETURN_PSW(8),__LC_SVC_NEW_PSW
667d24b98e3SMartin Schwidefsky	lghi	%r13,__TASK_thread
6684bfc86ceSHeiko Carstens	larl	%r14,.Lsysc_per
6694bfc86ceSHeiko Carstens	stg	%r14,__LC_RETURN_PSW+8
6704bfc86ceSHeiko Carstens	lghi	%r14,_PIF_SYSCALL | _PIF_PER_TRAP
6714bfc86ceSHeiko Carstens	lpswe	__LC_RETURN_PSW		# branch to .Lsysc_per and enable irqs
6724bfc86ceSHeiko Carstens
6734bfc86ceSHeiko Carstens/*
6744bfc86ceSHeiko Carstens * IO interrupt handler routine
6754bfc86ceSHeiko Carstens */
6764bfc86ceSHeiko CarstensENTRY(io_int_handler)
6774bfc86ceSHeiko Carstens	STCK	__LC_INT_CLOCK
6784bfc86ceSHeiko Carstens	stpt	__LC_ASYNC_ENTER_TIMER
679*d768bd89SMartin Schwidefsky	BPOFF
6804bfc86ceSHeiko Carstens	stmg	%r8,%r15,__LC_SAVE_AREA_ASYNC
681d5c352cdSHeiko Carstens	lg	%r12,__LC_CURRENT
6829977e886SHendrik Brueckner	larl	%r13,cleanup_critical
6834bfc86ceSHeiko Carstens	lmg	%r8,%r9,__LC_IO_OLD_PSW
6842acb94f4SMartin Schwidefsky	SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER
6854bfc86ceSHeiko Carstens	stmg	%r0,%r7,__PT_R0(%r11)
6867041d281SMartin Schwidefsky	# clear user controlled registers to prevent speculative use
6877041d281SMartin Schwidefsky	xgr	%r0,%r0
6887041d281SMartin Schwidefsky	xgr	%r1,%r1
6897041d281SMartin Schwidefsky	xgr	%r2,%r2
6907041d281SMartin Schwidefsky	xgr	%r3,%r3
6917041d281SMartin Schwidefsky	xgr	%r4,%r4
6927041d281SMartin Schwidefsky	xgr	%r5,%r5
6937041d281SMartin Schwidefsky	xgr	%r6,%r6
6947041d281SMartin Schwidefsky	xgr	%r7,%r7
6957041d281SMartin Schwidefsky	xgr	%r10,%r10
6964bfc86ceSHeiko Carstens	mvc	__PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
6974bfc86ceSHeiko Carstens	stmg	%r8,%r9,__PT_PSW(%r11)
6984bfc86ceSHeiko Carstens	mvc	__PT_INT_CODE(12,%r11),__LC_SUBCHANNEL_ID
6994bfc86ceSHeiko Carstens	xc	__PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
700db7e007fSHeiko Carstens	TSTMSK	__LC_CPU_FLAGS,_CIF_IGNORE_IRQ
701db7e007fSHeiko Carstens	jo	.Lio_restore
7024bfc86ceSHeiko Carstens	TRACE_IRQS_OFF
7034bfc86ceSHeiko Carstens	xc	__SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
7044bfc86ceSHeiko Carstens.Lio_loop:
7054bfc86ceSHeiko Carstens	lgr	%r2,%r11		# pass pointer to pt_regs
7064bfc86ceSHeiko Carstens	lghi	%r3,IO_INTERRUPT
7074bfc86ceSHeiko Carstens	tm	__PT_INT_CODE+8(%r11),0x80	# adapter interrupt ?
7084bfc86ceSHeiko Carstens	jz	.Lio_call
7094bfc86ceSHeiko Carstens	lghi	%r3,THIN_INTERRUPT
7104bfc86ceSHeiko Carstens.Lio_call:
7114bfc86ceSHeiko Carstens	brasl	%r14,do_IRQ
71283abeffbSHendrik Brueckner	TSTMSK	__LC_MACHINE_FLAGS,MACHINE_FLAG_LPAR
7134bfc86ceSHeiko Carstens	jz	.Lio_return
7144bfc86ceSHeiko Carstens	tpi	0
7154bfc86ceSHeiko Carstens	jz	.Lio_return
7164bfc86ceSHeiko Carstens	mvc	__PT_INT_CODE(12,%r11),__LC_SUBCHANNEL_ID
7174bfc86ceSHeiko Carstens	j	.Lio_loop
7184bfc86ceSHeiko Carstens.Lio_return:
7194bfc86ceSHeiko Carstens	LOCKDEP_SYS_EXIT
7204bfc86ceSHeiko Carstens	TRACE_IRQS_ON
7214bfc86ceSHeiko Carstens.Lio_tif:
72283abeffbSHendrik Brueckner	TSTMSK	__TI_flags(%r12),_TIF_WORK
7234bfc86ceSHeiko Carstens	jnz	.Lio_work		# there is work to do (signals etc.)
72483abeffbSHendrik Brueckner	TSTMSK	__LC_CPU_FLAGS,_CIF_WORK
7254bfc86ceSHeiko Carstens	jnz	.Lio_work
7264bfc86ceSHeiko Carstens.Lio_restore:
7274bfc86ceSHeiko Carstens	lg	%r14,__LC_VDSO_PER_CPU
7284bfc86ceSHeiko Carstens	lmg	%r0,%r10,__PT_R0(%r11)
7294bfc86ceSHeiko Carstens	mvc	__LC_RETURN_PSW(16),__PT_PSW(%r11)
730*d768bd89SMartin Schwidefsky	tm	__PT_PSW+1(%r11),0x01	# returning to user ?
731*d768bd89SMartin Schwidefsky	jno	.Lio_exit_kernel
732*d768bd89SMartin Schwidefsky	BPON
73307a63cbeSMartin Schwidefsky.Lio_exit_timer:
7344bfc86ceSHeiko Carstens	stpt	__LC_EXIT_TIMER
7354bfc86ceSHeiko Carstens	mvc	__VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
736*d768bd89SMartin Schwidefsky.Lio_exit_kernel:
7374bfc86ceSHeiko Carstens	lmg	%r11,%r15,__PT_R11(%r11)
7384bfc86ceSHeiko Carstens	lpswe	__LC_RETURN_PSW
7394bfc86ceSHeiko Carstens.Lio_done:
7404bfc86ceSHeiko Carstens
7414bfc86ceSHeiko Carstens#
7424bfc86ceSHeiko Carstens# There is work todo, find out in which context we have been interrupted:
7434bfc86ceSHeiko Carstens# 1) if we return to user space we can do all _TIF_WORK work
7444bfc86ceSHeiko Carstens# 2) if we return to kernel code and kvm is enabled check if we need to
7454bfc86ceSHeiko Carstens#    modify the psw to leave SIE
7464bfc86ceSHeiko Carstens# 3) if we return to kernel code and preemptive scheduling is enabled check
7474bfc86ceSHeiko Carstens#    the preemption counter and if it is zero call preempt_schedule_irq
7484bfc86ceSHeiko Carstens# Before any work can be done, a switch to the kernel stack is required.
7494bfc86ceSHeiko Carstens#
7504bfc86ceSHeiko Carstens.Lio_work:
7514bfc86ceSHeiko Carstens	tm	__PT_PSW+1(%r11),0x01	# returning to user ?
7524bfc86ceSHeiko Carstens	jo	.Lio_work_user		# yes -> do resched & signal
7534bfc86ceSHeiko Carstens#ifdef CONFIG_PREEMPT
7544bfc86ceSHeiko Carstens	# check for preemptive scheduling
755c360192bSMartin Schwidefsky	icm	%r0,15,__LC_PREEMPT_COUNT
7564bfc86ceSHeiko Carstens	jnz	.Lio_restore		# preemption is disabled
75783abeffbSHendrik Brueckner	TSTMSK	__TI_flags(%r12),_TIF_NEED_RESCHED
7584bfc86ceSHeiko Carstens	jno	.Lio_restore
7594bfc86ceSHeiko Carstens	# switch to kernel stack
7604bfc86ceSHeiko Carstens	lg	%r1,__PT_R15(%r11)
7614bfc86ceSHeiko Carstens	aghi	%r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
7624bfc86ceSHeiko Carstens	mvc	STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
7634bfc86ceSHeiko Carstens	xc	__SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
7644bfc86ceSHeiko Carstens	la	%r11,STACK_FRAME_OVERHEAD(%r1)
7654bfc86ceSHeiko Carstens	lgr	%r15,%r1
7664bfc86ceSHeiko Carstens	# TRACE_IRQS_ON already done at .Lio_return, call
7674bfc86ceSHeiko Carstens	# TRACE_IRQS_OFF to keep things symmetrical
7684bfc86ceSHeiko Carstens	TRACE_IRQS_OFF
7694bfc86ceSHeiko Carstens	brasl	%r14,preempt_schedule_irq
7704bfc86ceSHeiko Carstens	j	.Lio_return
7714bfc86ceSHeiko Carstens#else
7724bfc86ceSHeiko Carstens	j	.Lio_restore
7734bfc86ceSHeiko Carstens#endif
7744bfc86ceSHeiko Carstens
7754bfc86ceSHeiko Carstens#
7764bfc86ceSHeiko Carstens# Need to do work before returning to userspace, switch to kernel stack
7774bfc86ceSHeiko Carstens#
7784bfc86ceSHeiko Carstens.Lio_work_user:
7794bfc86ceSHeiko Carstens	lg	%r1,__LC_KERNEL_STACK
7804bfc86ceSHeiko Carstens	mvc	STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
7814bfc86ceSHeiko Carstens	xc	__SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
7824bfc86ceSHeiko Carstens	la	%r11,STACK_FRAME_OVERHEAD(%r1)
7834bfc86ceSHeiko Carstens	lgr	%r15,%r1
7844bfc86ceSHeiko Carstens
7854bfc86ceSHeiko Carstens#
7864bfc86ceSHeiko Carstens# One of the work bits is on. Find out which one.
7874bfc86ceSHeiko Carstens#
7884bfc86ceSHeiko Carstens.Lio_work_tif:
78983abeffbSHendrik Brueckner	TSTMSK	__LC_CPU_FLAGS,_CIF_MCCK_PENDING
7904bfc86ceSHeiko Carstens	jo	.Lio_mcck_pending
79183abeffbSHendrik Brueckner	TSTMSK	__TI_flags(%r12),_TIF_NEED_RESCHED
7924bfc86ceSHeiko Carstens	jo	.Lio_reschedule
7932f09ca60SMiroslav Benes#ifdef CONFIG_LIVEPATCH
7942f09ca60SMiroslav Benes	TSTMSK	__TI_flags(%r12),_TIF_PATCH_PENDING
7952f09ca60SMiroslav Benes	jo	.Lio_patch_pending
7962f09ca60SMiroslav Benes#endif
79783abeffbSHendrik Brueckner	TSTMSK	__TI_flags(%r12),_TIF_SIGPENDING
7984bfc86ceSHeiko Carstens	jo	.Lio_sigpending
79983abeffbSHendrik Brueckner	TSTMSK	__TI_flags(%r12),_TIF_NOTIFY_RESUME
8004bfc86ceSHeiko Carstens	jo	.Lio_notify_resume
801916cda1aSMartin Schwidefsky	TSTMSK	__TI_flags(%r12),_TIF_GUARDED_STORAGE
802916cda1aSMartin Schwidefsky	jo	.Lio_guarded_storage
80383abeffbSHendrik Brueckner	TSTMSK	__LC_CPU_FLAGS,_CIF_FPU
8049977e886SHendrik Brueckner	jo	.Lio_vxrs
805b5a882fcSHeiko Carstens	TSTMSK	__LC_CPU_FLAGS,(_CIF_ASCE_PRIMARY|_CIF_ASCE_SECONDARY)
806b5a882fcSHeiko Carstens	jnz	.Lio_asce
8074bfc86ceSHeiko Carstens	j	.Lio_return		# beware of critical section cleanup
8084bfc86ceSHeiko Carstens
8094bfc86ceSHeiko Carstens#
8104bfc86ceSHeiko Carstens# _CIF_MCCK_PENDING is set, call handler
8114bfc86ceSHeiko Carstens#
8124bfc86ceSHeiko Carstens.Lio_mcck_pending:
8134bfc86ceSHeiko Carstens	# TRACE_IRQS_ON already done at .Lio_return
8144bfc86ceSHeiko Carstens	brasl	%r14,s390_handle_mcck	# TIF bit will be cleared by handler
8154bfc86ceSHeiko Carstens	TRACE_IRQS_OFF
8164bfc86ceSHeiko Carstens	j	.Lio_return
8174bfc86ceSHeiko Carstens
8184bfc86ceSHeiko Carstens#
819b5a882fcSHeiko Carstens# _CIF_ASCE_PRIMARY and/or CIF_ASCE_SECONDARY set, load user space asce
8204bfc86ceSHeiko Carstens#
821b5a882fcSHeiko Carstens.Lio_asce:
8220aaba41bSMartin Schwidefsky	ni	__LC_CPU_FLAGS+7,255-_CIF_ASCE_SECONDARY
8230aaba41bSMartin Schwidefsky	lctlg	%c7,%c7,__LC_VDSO_ASCE		# load secondary asce
8240aaba41bSMartin Schwidefsky	TSTMSK	__LC_CPU_FLAGS,_CIF_ASCE_PRIMARY
8250aaba41bSMartin Schwidefsky	jz	.Lio_return
8260aaba41bSMartin Schwidefsky#ifndef CONFIG_HAVE_MARCH_Z10_FEATURES
8270aaba41bSMartin Schwidefsky	tm	__LC_STFLE_FAC_LIST+3,0x10	# has MVCOS ?
8280aaba41bSMartin Schwidefsky	jnz	.Lio_set_fs_fixup
829606aa4aaSHeiko Carstens	ni	__LC_CPU_FLAGS+7,255-_CIF_ASCE_PRIMARY
8304bfc86ceSHeiko Carstens	lctlg	%c1,%c1,__LC_USER_ASCE		# load primary asce
8310aaba41bSMartin Schwidefsky	j	.Lio_return
8320aaba41bSMartin Schwidefsky.Lio_set_fs_fixup:
8330aaba41bSMartin Schwidefsky#endif
834b5a882fcSHeiko Carstens	larl	%r14,.Lio_return
835b5a882fcSHeiko Carstens	jg	set_fs_fixup
8364bfc86ceSHeiko Carstens
8374bfc86ceSHeiko Carstens#
8389977e886SHendrik Brueckner# CIF_FPU is set, restore floating-point controls and floating-point registers.
8399977e886SHendrik Brueckner#
8409977e886SHendrik Brueckner.Lio_vxrs:
8419977e886SHendrik Brueckner	larl	%r14,.Lio_return
8429977e886SHendrik Brueckner	jg	load_fpu_regs
8439977e886SHendrik Brueckner
8449977e886SHendrik Brueckner#
845916cda1aSMartin Schwidefsky# _TIF_GUARDED_STORAGE is set, call guarded_storage_load
846916cda1aSMartin Schwidefsky#
847916cda1aSMartin Schwidefsky.Lio_guarded_storage:
848916cda1aSMartin Schwidefsky	# TRACE_IRQS_ON already done at .Lio_return
849916cda1aSMartin Schwidefsky	ssm	__LC_SVC_NEW_PSW	# reenable interrupts
850916cda1aSMartin Schwidefsky	lgr	%r2,%r11		# pass pointer to pt_regs
851916cda1aSMartin Schwidefsky	brasl	%r14,gs_load_bc_cb
852916cda1aSMartin Schwidefsky	ssm	__LC_PGM_NEW_PSW	# disable I/O and ext. interrupts
853916cda1aSMartin Schwidefsky	TRACE_IRQS_OFF
854916cda1aSMartin Schwidefsky	j	.Lio_return
855916cda1aSMartin Schwidefsky
856916cda1aSMartin Schwidefsky#
8574bfc86ceSHeiko Carstens# _TIF_NEED_RESCHED is set, call schedule
8584bfc86ceSHeiko Carstens#
8594bfc86ceSHeiko Carstens.Lio_reschedule:
8604bfc86ceSHeiko Carstens	# TRACE_IRQS_ON already done at .Lio_return
8614bfc86ceSHeiko Carstens	ssm	__LC_SVC_NEW_PSW	# reenable interrupts
8624bfc86ceSHeiko Carstens	brasl	%r14,schedule		# call scheduler
8634bfc86ceSHeiko Carstens	ssm	__LC_PGM_NEW_PSW	# disable I/O and ext. interrupts
8644bfc86ceSHeiko Carstens	TRACE_IRQS_OFF
8654bfc86ceSHeiko Carstens	j	.Lio_return
8664bfc86ceSHeiko Carstens
8674bfc86ceSHeiko Carstens#
8682f09ca60SMiroslav Benes# _TIF_PATCH_PENDING is set, call klp_update_patch_state
8692f09ca60SMiroslav Benes#
8702f09ca60SMiroslav Benes#ifdef CONFIG_LIVEPATCH
8712f09ca60SMiroslav Benes.Lio_patch_pending:
8722f09ca60SMiroslav Benes	lg	%r2,__LC_CURRENT	# pass pointer to task struct
8732f09ca60SMiroslav Benes	larl	%r14,.Lio_return
8742f09ca60SMiroslav Benes	jg	klp_update_patch_state
8752f09ca60SMiroslav Benes#endif
8762f09ca60SMiroslav Benes
8772f09ca60SMiroslav Benes#
8784bfc86ceSHeiko Carstens# _TIF_SIGPENDING or is set, call do_signal
8794bfc86ceSHeiko Carstens#
8804bfc86ceSHeiko Carstens.Lio_sigpending:
8814bfc86ceSHeiko Carstens	# TRACE_IRQS_ON already done at .Lio_return
8824bfc86ceSHeiko Carstens	ssm	__LC_SVC_NEW_PSW	# reenable interrupts
8834bfc86ceSHeiko Carstens	lgr	%r2,%r11		# pass pointer to pt_regs
8844bfc86ceSHeiko Carstens	brasl	%r14,do_signal
8854bfc86ceSHeiko Carstens	ssm	__LC_PGM_NEW_PSW	# disable I/O and ext. interrupts
8864bfc86ceSHeiko Carstens	TRACE_IRQS_OFF
8874bfc86ceSHeiko Carstens	j	.Lio_return
8884bfc86ceSHeiko Carstens
8894bfc86ceSHeiko Carstens#
8904bfc86ceSHeiko Carstens# _TIF_NOTIFY_RESUME or is set, call do_notify_resume
8914bfc86ceSHeiko Carstens#
8924bfc86ceSHeiko Carstens.Lio_notify_resume:
8934bfc86ceSHeiko Carstens	# TRACE_IRQS_ON already done at .Lio_return
8944bfc86ceSHeiko Carstens	ssm	__LC_SVC_NEW_PSW	# reenable interrupts
8954bfc86ceSHeiko Carstens	lgr	%r2,%r11		# pass pointer to pt_regs
8964bfc86ceSHeiko Carstens	brasl	%r14,do_notify_resume
8974bfc86ceSHeiko Carstens	ssm	__LC_PGM_NEW_PSW	# disable I/O and ext. interrupts
8984bfc86ceSHeiko Carstens	TRACE_IRQS_OFF
8994bfc86ceSHeiko Carstens	j	.Lio_return
9004bfc86ceSHeiko Carstens
9014bfc86ceSHeiko Carstens/*
9024bfc86ceSHeiko Carstens * External interrupt handler routine
9034bfc86ceSHeiko Carstens */
9044bfc86ceSHeiko CarstensENTRY(ext_int_handler)
9054bfc86ceSHeiko Carstens	STCK	__LC_INT_CLOCK
9064bfc86ceSHeiko Carstens	stpt	__LC_ASYNC_ENTER_TIMER
907*d768bd89SMartin Schwidefsky	BPOFF
9084bfc86ceSHeiko Carstens	stmg	%r8,%r15,__LC_SAVE_AREA_ASYNC
909d5c352cdSHeiko Carstens	lg	%r12,__LC_CURRENT
9109977e886SHendrik Brueckner	larl	%r13,cleanup_critical
9114bfc86ceSHeiko Carstens	lmg	%r8,%r9,__LC_EXT_OLD_PSW
9122acb94f4SMartin Schwidefsky	SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER
9134bfc86ceSHeiko Carstens	stmg	%r0,%r7,__PT_R0(%r11)
9147041d281SMartin Schwidefsky	# clear user controlled registers to prevent speculative use
9157041d281SMartin Schwidefsky	xgr	%r0,%r0
9167041d281SMartin Schwidefsky	xgr	%r1,%r1
9177041d281SMartin Schwidefsky	xgr	%r2,%r2
9187041d281SMartin Schwidefsky	xgr	%r3,%r3
9197041d281SMartin Schwidefsky	xgr	%r4,%r4
9207041d281SMartin Schwidefsky	xgr	%r5,%r5
9217041d281SMartin Schwidefsky	xgr	%r6,%r6
9227041d281SMartin Schwidefsky	xgr	%r7,%r7
9237041d281SMartin Schwidefsky	xgr	%r10,%r10
9244bfc86ceSHeiko Carstens	mvc	__PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
9254bfc86ceSHeiko Carstens	stmg	%r8,%r9,__PT_PSW(%r11)
9264bfc86ceSHeiko Carstens	lghi	%r1,__LC_EXT_PARAMS2
9274bfc86ceSHeiko Carstens	mvc	__PT_INT_CODE(4,%r11),__LC_EXT_CPU_ADDR
9284bfc86ceSHeiko Carstens	mvc	__PT_INT_PARM(4,%r11),__LC_EXT_PARAMS
9294bfc86ceSHeiko Carstens	mvc	__PT_INT_PARM_LONG(8,%r11),0(%r1)
9304bfc86ceSHeiko Carstens	xc	__PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
931db7e007fSHeiko Carstens	TSTMSK	__LC_CPU_FLAGS,_CIF_IGNORE_IRQ
932db7e007fSHeiko Carstens	jo	.Lio_restore
9334bfc86ceSHeiko Carstens	TRACE_IRQS_OFF
9344bfc86ceSHeiko Carstens	xc	__SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
9354bfc86ceSHeiko Carstens	lgr	%r2,%r11		# pass pointer to pt_regs
9364bfc86ceSHeiko Carstens	lghi	%r3,EXT_INTERRUPT
9374bfc86ceSHeiko Carstens	brasl	%r14,do_IRQ
9384bfc86ceSHeiko Carstens	j	.Lio_return
9394bfc86ceSHeiko Carstens
9404bfc86ceSHeiko Carstens/*
9414bfc86ceSHeiko Carstens * Load idle PSW. The second "half" of this function is in .Lcleanup_idle.
9424bfc86ceSHeiko Carstens */
9434bfc86ceSHeiko CarstensENTRY(psw_idle)
9444bfc86ceSHeiko Carstens	stg	%r3,__SF_EMPTY(%r15)
9454bfc86ceSHeiko Carstens	larl	%r1,.Lpsw_idle_lpsw+4
9464bfc86ceSHeiko Carstens	stg	%r1,__SF_EMPTY+8(%r15)
94772d38b19SMartin Schwidefsky#ifdef CONFIG_SMP
94872d38b19SMartin Schwidefsky	larl	%r1,smp_cpu_mtid
94972d38b19SMartin Schwidefsky	llgf	%r1,0(%r1)
95072d38b19SMartin Schwidefsky	ltgr	%r1,%r1
95172d38b19SMartin Schwidefsky	jz	.Lpsw_idle_stcctm
95272d38b19SMartin Schwidefsky	.insn	rsy,0xeb0000000017,%r1,5,__SF_EMPTY+16(%r15)
95372d38b19SMartin Schwidefsky.Lpsw_idle_stcctm:
95472d38b19SMartin Schwidefsky#endif
955419123f9SMartin Schwidefsky	oi	__LC_CPU_FLAGS+7,_CIF_ENABLED_WAIT
956*d768bd89SMartin Schwidefsky	BPON
9574bfc86ceSHeiko Carstens	STCK	__CLOCK_IDLE_ENTER(%r2)
9584bfc86ceSHeiko Carstens	stpt	__TIMER_IDLE_ENTER(%r2)
9594bfc86ceSHeiko Carstens.Lpsw_idle_lpsw:
9604bfc86ceSHeiko Carstens	lpswe	__SF_EMPTY(%r15)
9614bfc86ceSHeiko Carstens	br	%r14
9624bfc86ceSHeiko Carstens.Lpsw_idle_end:
9634bfc86ceSHeiko Carstens
964b5510d9bSHendrik Brueckner/*
965b5510d9bSHendrik Brueckner * Store floating-point controls and floating-point or vector register
966b5510d9bSHendrik Brueckner * depending whether the vector facility is available.	A critical section
967b5510d9bSHendrik Brueckner * cleanup assures that the registers are stored even if interrupted for
968b5510d9bSHendrik Brueckner * some other work.  The CIF_FPU flag is set to trigger a lazy restore
969b5510d9bSHendrik Brueckner * of the register contents at return from io or a system call.
9709977e886SHendrik Brueckner */
9719977e886SHendrik BruecknerENTRY(save_fpu_regs)
972d0164ee2SHendrik Brueckner	lg	%r2,__LC_CURRENT
973d0164ee2SHendrik Brueckner	aghi	%r2,__TASK_thread
97483abeffbSHendrik Brueckner	TSTMSK	__LC_CPU_FLAGS,_CIF_FPU
9759977e886SHendrik Brueckner	bor	%r14
976d0164ee2SHendrik Brueckner	stfpc	__THREAD_FPU_fpc(%r2)
977d0164ee2SHendrik Brueckner	lg	%r3,__THREAD_FPU_regs(%r2)
97883abeffbSHendrik Brueckner	TSTMSK	__LC_MACHINE_FLAGS,MACHINE_FLAG_VX
9799977e886SHendrik Brueckner	jz	.Lsave_fpu_regs_fp	  # no -> store FP regs
9809977e886SHendrik Brueckner	VSTM	%v0,%v15,0,%r3		  # vstm 0,15,0(3)
9819977e886SHendrik Brueckner	VSTM	%v16,%v31,256,%r3	  # vstm 16,31,256(3)
9829977e886SHendrik Brueckner	j	.Lsave_fpu_regs_done	  # -> set CIF_FPU flag
9839977e886SHendrik Brueckner.Lsave_fpu_regs_fp:
9849977e886SHendrik Brueckner	std	0,0(%r3)
9859977e886SHendrik Brueckner	std	1,8(%r3)
9869977e886SHendrik Brueckner	std	2,16(%r3)
9879977e886SHendrik Brueckner	std	3,24(%r3)
9889977e886SHendrik Brueckner	std	4,32(%r3)
9899977e886SHendrik Brueckner	std	5,40(%r3)
9909977e886SHendrik Brueckner	std	6,48(%r3)
9919977e886SHendrik Brueckner	std	7,56(%r3)
9929977e886SHendrik Brueckner	std	8,64(%r3)
9939977e886SHendrik Brueckner	std	9,72(%r3)
9949977e886SHendrik Brueckner	std	10,80(%r3)
9959977e886SHendrik Brueckner	std	11,88(%r3)
9969977e886SHendrik Brueckner	std	12,96(%r3)
9979977e886SHendrik Brueckner	std	13,104(%r3)
9989977e886SHendrik Brueckner	std	14,112(%r3)
9999977e886SHendrik Brueckner	std	15,120(%r3)
10009977e886SHendrik Brueckner.Lsave_fpu_regs_done:
10019977e886SHendrik Brueckner	oi	__LC_CPU_FLAGS+7,_CIF_FPU
10029977e886SHendrik Brueckner	br	%r14
10039977e886SHendrik Brueckner.Lsave_fpu_regs_end:
1004711f5df7SAl ViroEXPORT_SYMBOL(save_fpu_regs)
10059977e886SHendrik Brueckner
1006b5510d9bSHendrik Brueckner/*
1007b5510d9bSHendrik Brueckner * Load floating-point controls and floating-point or vector registers.
1008b5510d9bSHendrik Brueckner * A critical section cleanup assures that the register contents are
1009b5510d9bSHendrik Brueckner * loaded even if interrupted for some other work.
10109977e886SHendrik Brueckner *
10119977e886SHendrik Brueckner * There are special calling conventions to fit into sysc and io return work:
10129977e886SHendrik Brueckner *	%r15:	<kernel stack>
10139977e886SHendrik Brueckner * The function requires:
1014b5510d9bSHendrik Brueckner *	%r4
10159977e886SHendrik Brueckner */
10169977e886SHendrik Bruecknerload_fpu_regs:
1017d0164ee2SHendrik Brueckner	lg	%r4,__LC_CURRENT
1018d0164ee2SHendrik Brueckner	aghi	%r4,__TASK_thread
101983abeffbSHendrik Brueckner	TSTMSK	__LC_CPU_FLAGS,_CIF_FPU
10209977e886SHendrik Brueckner	bnor	%r14
1021d0164ee2SHendrik Brueckner	lfpc	__THREAD_FPU_fpc(%r4)
102283abeffbSHendrik Brueckner	TSTMSK	__LC_MACHINE_FLAGS,MACHINE_FLAG_VX
1023d0164ee2SHendrik Brueckner	lg	%r4,__THREAD_FPU_regs(%r4)	# %r4 <- reg save area
1024b5510d9bSHendrik Brueckner	jz	.Lload_fpu_regs_fp		# -> no VX, load FP regs
10259977e886SHendrik Brueckner	VLM	%v0,%v15,0,%r4
10269977e886SHendrik Brueckner	VLM	%v16,%v31,256,%r4
10279977e886SHendrik Brueckner	j	.Lload_fpu_regs_done
10289977e886SHendrik Brueckner.Lload_fpu_regs_fp:
10299977e886SHendrik Brueckner	ld	0,0(%r4)
10309977e886SHendrik Brueckner	ld	1,8(%r4)
10319977e886SHendrik Brueckner	ld	2,16(%r4)
10329977e886SHendrik Brueckner	ld	3,24(%r4)
10339977e886SHendrik Brueckner	ld	4,32(%r4)
10349977e886SHendrik Brueckner	ld	5,40(%r4)
10359977e886SHendrik Brueckner	ld	6,48(%r4)
10369977e886SHendrik Brueckner	ld	7,56(%r4)
10379977e886SHendrik Brueckner	ld	8,64(%r4)
10389977e886SHendrik Brueckner	ld	9,72(%r4)
10399977e886SHendrik Brueckner	ld	10,80(%r4)
10409977e886SHendrik Brueckner	ld	11,88(%r4)
10419977e886SHendrik Brueckner	ld	12,96(%r4)
10429977e886SHendrik Brueckner	ld	13,104(%r4)
10439977e886SHendrik Brueckner	ld	14,112(%r4)
10449977e886SHendrik Brueckner	ld	15,120(%r4)
10459977e886SHendrik Brueckner.Lload_fpu_regs_done:
10469977e886SHendrik Brueckner	ni	__LC_CPU_FLAGS+7,255-_CIF_FPU
10479977e886SHendrik Brueckner	br	%r14
10489977e886SHendrik Brueckner.Lload_fpu_regs_end:
10499977e886SHendrik Brueckner
10504bfc86ceSHeiko Carstens.L__critical_end:
10514bfc86ceSHeiko Carstens
10524bfc86ceSHeiko Carstens/*
10534bfc86ceSHeiko Carstens * Machine check handler routines
10544bfc86ceSHeiko Carstens */
10554bfc86ceSHeiko CarstensENTRY(mcck_int_handler)
10564bfc86ceSHeiko Carstens	STCK	__LC_MCCK_CLOCK
1057*d768bd89SMartin Schwidefsky	BPOFF
10583037a52fSMartin Schwidefsky	la	%r1,4095		# validate r1
10593037a52fSMartin Schwidefsky	spt	__LC_CPU_TIMER_SAVE_AREA-4095(%r1)	# validate cpu timer
10603037a52fSMartin Schwidefsky	sckc	__LC_CLOCK_COMPARATOR			# validate comparator
10613037a52fSMartin Schwidefsky	lam	%a0,%a15,__LC_AREGS_SAVE_AREA-4095(%r1) # validate acrs
10623037a52fSMartin Schwidefsky	lmg	%r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# validate gprs
1063d5c352cdSHeiko Carstens	lg	%r12,__LC_CURRENT
10649977e886SHendrik Brueckner	larl	%r13,cleanup_critical
10654bfc86ceSHeiko Carstens	lmg	%r8,%r9,__LC_MCK_OLD_PSW
106683abeffbSHendrik Brueckner	TSTMSK	__LC_MCCK_CODE,MCCK_CODE_SYSTEM_DAMAGE
10674bfc86ceSHeiko Carstens	jo	.Lmcck_panic		# yes -> rest of mcck code invalid
10683037a52fSMartin Schwidefsky	TSTMSK	__LC_MCCK_CODE,MCCK_CODE_CR_VALID
10693037a52fSMartin Schwidefsky	jno	.Lmcck_panic		# control registers invalid -> panic
10703037a52fSMartin Schwidefsky	la	%r14,4095
10713037a52fSMartin Schwidefsky	lctlg	%c0,%c15,__LC_CREGS_SAVE_AREA-4095(%r14) # validate ctl regs
10723037a52fSMartin Schwidefsky	ptlb
10732a2d7befSVasily Gorbik	lg	%r11,__LC_MCESAD-4095(%r14) # extended machine check save area
10743037a52fSMartin Schwidefsky	nill	%r11,0xfc00		# MCESA_ORIGIN_MASK
10753037a52fSMartin Schwidefsky	TSTMSK	__LC_CREGS_SAVE_AREA+16-4095(%r14),CR2_GUARDED_STORAGE
10763037a52fSMartin Schwidefsky	jno	0f
10773037a52fSMartin Schwidefsky	TSTMSK	__LC_MCCK_CODE,MCCK_CODE_GS_VALID
10783037a52fSMartin Schwidefsky	jno	0f
10793037a52fSMartin Schwidefsky	.insn	 rxy,0xe3000000004d,0,__MCESA_GS_SAVE_AREA(%r11) # LGSC
10803037a52fSMartin Schwidefsky0:	l	%r14,__LC_FP_CREG_SAVE_AREA-4095(%r14)
10813037a52fSMartin Schwidefsky	TSTMSK	__LC_MCCK_CODE,MCCK_CODE_FC_VALID
10823037a52fSMartin Schwidefsky	jo	0f
10833037a52fSMartin Schwidefsky	sr	%r14,%r14
10843037a52fSMartin Schwidefsky0:	sfpc	%r14
10853037a52fSMartin Schwidefsky	TSTMSK	__LC_MACHINE_FLAGS,MACHINE_FLAG_VX
10863037a52fSMartin Schwidefsky	jo	0f
10873037a52fSMartin Schwidefsky	lghi	%r14,__LC_FPREGS_SAVE_AREA
10883037a52fSMartin Schwidefsky	ld	%f0,0(%r14)
10893037a52fSMartin Schwidefsky	ld	%f1,8(%r14)
10903037a52fSMartin Schwidefsky	ld	%f2,16(%r14)
10913037a52fSMartin Schwidefsky	ld	%f3,24(%r14)
10923037a52fSMartin Schwidefsky	ld	%f4,32(%r14)
10933037a52fSMartin Schwidefsky	ld	%f5,40(%r14)
10943037a52fSMartin Schwidefsky	ld	%f6,48(%r14)
10953037a52fSMartin Schwidefsky	ld	%f7,56(%r14)
10963037a52fSMartin Schwidefsky	ld	%f8,64(%r14)
10973037a52fSMartin Schwidefsky	ld	%f9,72(%r14)
10983037a52fSMartin Schwidefsky	ld	%f10,80(%r14)
10993037a52fSMartin Schwidefsky	ld	%f11,88(%r14)
11003037a52fSMartin Schwidefsky	ld	%f12,96(%r14)
11013037a52fSMartin Schwidefsky	ld	%f13,104(%r14)
11023037a52fSMartin Schwidefsky	ld	%f14,112(%r14)
11033037a52fSMartin Schwidefsky	ld	%f15,120(%r14)
11043037a52fSMartin Schwidefsky	j	1f
11053037a52fSMartin Schwidefsky0:	VLM	%v0,%v15,0,%r11
11063037a52fSMartin Schwidefsky	VLM	%v16,%v31,256,%r11
11073037a52fSMartin Schwidefsky1:	lghi	%r14,__LC_CPU_TIMER_SAVE_AREA
11084bfc86ceSHeiko Carstens	mvc	__LC_MCCK_ENTER_TIMER(8),0(%r14)
110983abeffbSHendrik Brueckner	TSTMSK	__LC_MCCK_CODE,MCCK_CODE_CPU_TIMER_VALID
11104bfc86ceSHeiko Carstens	jo	3f
11114bfc86ceSHeiko Carstens	la	%r14,__LC_SYNC_ENTER_TIMER
11124bfc86ceSHeiko Carstens	clc	0(8,%r14),__LC_ASYNC_ENTER_TIMER
11134bfc86ceSHeiko Carstens	jl	0f
11144bfc86ceSHeiko Carstens	la	%r14,__LC_ASYNC_ENTER_TIMER
11154bfc86ceSHeiko Carstens0:	clc	0(8,%r14),__LC_EXIT_TIMER
11164bfc86ceSHeiko Carstens	jl	1f
11174bfc86ceSHeiko Carstens	la	%r14,__LC_EXIT_TIMER
11184bfc86ceSHeiko Carstens1:	clc	0(8,%r14),__LC_LAST_UPDATE_TIMER
11194bfc86ceSHeiko Carstens	jl	2f
11204bfc86ceSHeiko Carstens	la	%r14,__LC_LAST_UPDATE_TIMER
11214bfc86ceSHeiko Carstens2:	spt	0(%r14)
11224bfc86ceSHeiko Carstens	mvc	__LC_MCCK_ENTER_TIMER(8),0(%r14)
11233037a52fSMartin Schwidefsky3:	TSTMSK	__LC_MCCK_CODE,MCCK_CODE_PSW_MWP_VALID
11243037a52fSMartin Schwidefsky	jno	.Lmcck_panic
11253037a52fSMartin Schwidefsky	tmhh	%r8,0x0001		# interrupting from user ?
11263037a52fSMartin Schwidefsky	jnz	4f
11273037a52fSMartin Schwidefsky	TSTMSK	__LC_MCCK_CODE,MCCK_CODE_PSW_IA_VALID
11283037a52fSMartin Schwidefsky	jno	.Lmcck_panic
11293037a52fSMartin Schwidefsky4:	SWITCH_ASYNC __LC_GPREGS_SAVE_AREA+64,__LC_MCCK_ENTER_TIMER
11304bfc86ceSHeiko Carstens.Lmcck_skip:
11314bfc86ceSHeiko Carstens	lghi	%r14,__LC_GPREGS_SAVE_AREA+64
11324bfc86ceSHeiko Carstens	stmg	%r0,%r7,__PT_R0(%r11)
11337041d281SMartin Schwidefsky	# clear user controlled registers to prevent speculative use
11347041d281SMartin Schwidefsky	xgr	%r0,%r0
11357041d281SMartin Schwidefsky	xgr	%r1,%r1
11367041d281SMartin Schwidefsky	xgr	%r2,%r2
11377041d281SMartin Schwidefsky	xgr	%r3,%r3
11387041d281SMartin Schwidefsky	xgr	%r4,%r4
11397041d281SMartin Schwidefsky	xgr	%r5,%r5
11407041d281SMartin Schwidefsky	xgr	%r6,%r6
11417041d281SMartin Schwidefsky	xgr	%r7,%r7
11427041d281SMartin Schwidefsky	xgr	%r10,%r10
11434bfc86ceSHeiko Carstens	mvc	__PT_R8(64,%r11),0(%r14)
11444bfc86ceSHeiko Carstens	stmg	%r8,%r9,__PT_PSW(%r11)
11454bfc86ceSHeiko Carstens	xc	__PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
11464bfc86ceSHeiko Carstens	xc	__SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
11474bfc86ceSHeiko Carstens	lgr	%r2,%r11		# pass pointer to pt_regs
11484bfc86ceSHeiko Carstens	brasl	%r14,s390_do_machine_check
11494bfc86ceSHeiko Carstens	tm	__PT_PSW+1(%r11),0x01	# returning to user ?
11504bfc86ceSHeiko Carstens	jno	.Lmcck_return
11514bfc86ceSHeiko Carstens	lg	%r1,__LC_KERNEL_STACK	# switch to kernel stack
11524bfc86ceSHeiko Carstens	mvc	STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
11534bfc86ceSHeiko Carstens	xc	__SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
11544bfc86ceSHeiko Carstens	la	%r11,STACK_FRAME_OVERHEAD(%r1)
11554bfc86ceSHeiko Carstens	lgr	%r15,%r1
11564bfc86ceSHeiko Carstens	ssm	__LC_PGM_NEW_PSW	# turn dat on, keep irqs off
115783abeffbSHendrik Brueckner	TSTMSK	__LC_CPU_FLAGS,_CIF_MCCK_PENDING
11584bfc86ceSHeiko Carstens	jno	.Lmcck_return
11594bfc86ceSHeiko Carstens	TRACE_IRQS_OFF
11604bfc86ceSHeiko Carstens	brasl	%r14,s390_handle_mcck
11614bfc86ceSHeiko Carstens	TRACE_IRQS_ON
11624bfc86ceSHeiko Carstens.Lmcck_return:
11634bfc86ceSHeiko Carstens	lg	%r14,__LC_VDSO_PER_CPU
11644bfc86ceSHeiko Carstens	lmg	%r0,%r10,__PT_R0(%r11)
11654bfc86ceSHeiko Carstens	mvc	__LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW
11664bfc86ceSHeiko Carstens	tm	__LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
11674bfc86ceSHeiko Carstens	jno	0f
1168*d768bd89SMartin Schwidefsky	BPON
11694bfc86ceSHeiko Carstens	stpt	__LC_EXIT_TIMER
11704bfc86ceSHeiko Carstens	mvc	__VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
11714bfc86ceSHeiko Carstens0:	lmg	%r11,%r15,__PT_R11(%r11)
11724bfc86ceSHeiko Carstens	lpswe	__LC_RETURN_MCCK_PSW
11734bfc86ceSHeiko Carstens
11744bfc86ceSHeiko Carstens.Lmcck_panic:
11754bfc86ceSHeiko Carstens	lg	%r15,__LC_PANIC_STACK
1176ce4dda3fSMartin Schwidefsky	la	%r11,STACK_FRAME_OVERHEAD(%r15)
11774bfc86ceSHeiko Carstens	j	.Lmcck_skip
11784bfc86ceSHeiko Carstens
11794bfc86ceSHeiko Carstens#
11804bfc86ceSHeiko Carstens# PSW restart interrupt handler
11814bfc86ceSHeiko Carstens#
11824bfc86ceSHeiko CarstensENTRY(restart_int_handler)
1183e22cf8caSChristian Borntraeger	TSTMSK	__LC_MACHINE_FLAGS,MACHINE_FLAG_LPP
1184e22cf8caSChristian Borntraeger	jz	0f
1185e22cf8caSChristian Borntraeger	.insn	s,0xb2800000,__LC_LPP
1186e22cf8caSChristian Borntraeger0:	stg	%r15,__LC_SAVE_AREA_RESTART
11874bfc86ceSHeiko Carstens	lg	%r15,__LC_RESTART_STACK
11884bfc86ceSHeiko Carstens	aghi	%r15,-__PT_SIZE			# create pt_regs on stack
11894bfc86ceSHeiko Carstens	xc	0(__PT_SIZE,%r15),0(%r15)
11904bfc86ceSHeiko Carstens	stmg	%r0,%r14,__PT_R0(%r15)
11914bfc86ceSHeiko Carstens	mvc	__PT_R15(8,%r15),__LC_SAVE_AREA_RESTART
11924bfc86ceSHeiko Carstens	mvc	__PT_PSW(16,%r15),__LC_RST_OLD_PSW # store restart old psw
11934bfc86ceSHeiko Carstens	aghi	%r15,-STACK_FRAME_OVERHEAD	# create stack frame on stack
11944bfc86ceSHeiko Carstens	xc	0(STACK_FRAME_OVERHEAD,%r15),0(%r15)
11954bfc86ceSHeiko Carstens	lg	%r1,__LC_RESTART_FN		# load fn, parm & source cpu
11964bfc86ceSHeiko Carstens	lg	%r2,__LC_RESTART_DATA
11974bfc86ceSHeiko Carstens	lg	%r3,__LC_RESTART_SOURCE
11984bfc86ceSHeiko Carstens	ltgr	%r3,%r3				# test source cpu address
11994bfc86ceSHeiko Carstens	jm	1f				# negative -> skip source stop
12004bfc86ceSHeiko Carstens0:	sigp	%r4,%r3,SIGP_SENSE		# sigp sense to source cpu
12014bfc86ceSHeiko Carstens	brc	10,0b				# wait for status stored
12024bfc86ceSHeiko Carstens1:	basr	%r14,%r1			# call function
12034bfc86ceSHeiko Carstens	stap	__SF_EMPTY(%r15)		# store cpu address
12044bfc86ceSHeiko Carstens	llgh	%r3,__SF_EMPTY(%r15)
12054bfc86ceSHeiko Carstens2:	sigp	%r4,%r3,SIGP_STOP		# sigp stop to current cpu
12064bfc86ceSHeiko Carstens	brc	2,2b
12074bfc86ceSHeiko Carstens3:	j	3b
12084bfc86ceSHeiko Carstens
12094bfc86ceSHeiko Carstens	.section .kprobes.text, "ax"
12104bfc86ceSHeiko Carstens
12114bfc86ceSHeiko Carstens#ifdef CONFIG_CHECK_STACK
12124bfc86ceSHeiko Carstens/*
12134bfc86ceSHeiko Carstens * The synchronous or the asynchronous stack overflowed. We are dead.
12144bfc86ceSHeiko Carstens * No need to properly save the registers, we are going to panic anyway.
12154bfc86ceSHeiko Carstens * Setup a pt_regs so that show_trace can provide a good call trace.
12164bfc86ceSHeiko Carstens */
12174bfc86ceSHeiko Carstensstack_overflow:
12184bfc86ceSHeiko Carstens	lg	%r15,__LC_PANIC_STACK	# change to panic stack
12194bfc86ceSHeiko Carstens	la	%r11,STACK_FRAME_OVERHEAD(%r15)
12204bfc86ceSHeiko Carstens	stmg	%r0,%r7,__PT_R0(%r11)
12214bfc86ceSHeiko Carstens	stmg	%r8,%r9,__PT_PSW(%r11)
12224bfc86ceSHeiko Carstens	mvc	__PT_R8(64,%r11),0(%r14)
12234bfc86ceSHeiko Carstens	stg	%r10,__PT_ORIG_GPR2(%r11) # store last break to orig_gpr2
12244bfc86ceSHeiko Carstens	xc	__SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
12254bfc86ceSHeiko Carstens	lgr	%r2,%r11		# pass pointer to pt_regs
12264bfc86ceSHeiko Carstens	jg	kernel_stack_overflow
12274bfc86ceSHeiko Carstens#endif
12284bfc86ceSHeiko Carstens
12294bfc86ceSHeiko Carstenscleanup_critical:
1230d0fc4107SMartin Schwidefsky#if IS_ENABLED(CONFIG_KVM)
1231d0fc4107SMartin Schwidefsky	clg	%r9,BASED(.Lcleanup_table_sie)	# .Lsie_gmap
1232d0fc4107SMartin Schwidefsky	jl	0f
1233d0fc4107SMartin Schwidefsky	clg	%r9,BASED(.Lcleanup_table_sie+8)# .Lsie_done
1234d0fc4107SMartin Schwidefsky	jl	.Lcleanup_sie
1235d0fc4107SMartin Schwidefsky#endif
12364bfc86ceSHeiko Carstens	clg	%r9,BASED(.Lcleanup_table)	# system_call
12374bfc86ceSHeiko Carstens	jl	0f
12384bfc86ceSHeiko Carstens	clg	%r9,BASED(.Lcleanup_table+8)	# .Lsysc_do_svc
12394bfc86ceSHeiko Carstens	jl	.Lcleanup_system_call
12404bfc86ceSHeiko Carstens	clg	%r9,BASED(.Lcleanup_table+16)	# .Lsysc_tif
12414bfc86ceSHeiko Carstens	jl	0f
12424bfc86ceSHeiko Carstens	clg	%r9,BASED(.Lcleanup_table+24)	# .Lsysc_restore
12434bfc86ceSHeiko Carstens	jl	.Lcleanup_sysc_tif
12444bfc86ceSHeiko Carstens	clg	%r9,BASED(.Lcleanup_table+32)	# .Lsysc_done
12454bfc86ceSHeiko Carstens	jl	.Lcleanup_sysc_restore
12464bfc86ceSHeiko Carstens	clg	%r9,BASED(.Lcleanup_table+40)	# .Lio_tif
12474bfc86ceSHeiko Carstens	jl	0f
12484bfc86ceSHeiko Carstens	clg	%r9,BASED(.Lcleanup_table+48)	# .Lio_restore
12494bfc86ceSHeiko Carstens	jl	.Lcleanup_io_tif
12504bfc86ceSHeiko Carstens	clg	%r9,BASED(.Lcleanup_table+56)	# .Lio_done
12514bfc86ceSHeiko Carstens	jl	.Lcleanup_io_restore
12524bfc86ceSHeiko Carstens	clg	%r9,BASED(.Lcleanup_table+64)	# psw_idle
12534bfc86ceSHeiko Carstens	jl	0f
12544bfc86ceSHeiko Carstens	clg	%r9,BASED(.Lcleanup_table+72)	# .Lpsw_idle_end
12554bfc86ceSHeiko Carstens	jl	.Lcleanup_idle
12569977e886SHendrik Brueckner	clg	%r9,BASED(.Lcleanup_table+80)	# save_fpu_regs
12579977e886SHendrik Brueckner	jl	0f
12589977e886SHendrik Brueckner	clg	%r9,BASED(.Lcleanup_table+88)	# .Lsave_fpu_regs_end
12599977e886SHendrik Brueckner	jl	.Lcleanup_save_fpu_regs
12609977e886SHendrik Brueckner	clg	%r9,BASED(.Lcleanup_table+96)	# load_fpu_regs
12619977e886SHendrik Brueckner	jl	0f
12629977e886SHendrik Brueckner	clg	%r9,BASED(.Lcleanup_table+104)	# .Lload_fpu_regs_end
12639977e886SHendrik Brueckner	jl	.Lcleanup_load_fpu_regs
12644bfc86ceSHeiko Carstens0:	br	%r14
12654bfc86ceSHeiko Carstens
1266d0fc4107SMartin Schwidefsky	.align	8
1267d0fc4107SMartin Schwidefsky.Lcleanup_table:
1268d0fc4107SMartin Schwidefsky	.quad	system_call
1269d0fc4107SMartin Schwidefsky	.quad	.Lsysc_do_svc
1270d0fc4107SMartin Schwidefsky	.quad	.Lsysc_tif
1271d0fc4107SMartin Schwidefsky	.quad	.Lsysc_restore
1272d0fc4107SMartin Schwidefsky	.quad	.Lsysc_done
1273d0fc4107SMartin Schwidefsky	.quad	.Lio_tif
1274d0fc4107SMartin Schwidefsky	.quad	.Lio_restore
1275d0fc4107SMartin Schwidefsky	.quad	.Lio_done
1276d0fc4107SMartin Schwidefsky	.quad	psw_idle
1277d0fc4107SMartin Schwidefsky	.quad	.Lpsw_idle_end
1278d0fc4107SMartin Schwidefsky	.quad	save_fpu_regs
1279d0fc4107SMartin Schwidefsky	.quad	.Lsave_fpu_regs_end
1280d0fc4107SMartin Schwidefsky	.quad	load_fpu_regs
1281d0fc4107SMartin Schwidefsky	.quad	.Lload_fpu_regs_end
1282d0fc4107SMartin Schwidefsky
1283d0fc4107SMartin Schwidefsky#if IS_ENABLED(CONFIG_KVM)
1284d0fc4107SMartin Schwidefsky.Lcleanup_table_sie:
1285d0fc4107SMartin Schwidefsky	.quad	.Lsie_gmap
1286d0fc4107SMartin Schwidefsky	.quad	.Lsie_done
1287d0fc4107SMartin Schwidefsky
1288d0fc4107SMartin Schwidefsky.Lcleanup_sie:
1289c929500dSQingFeng Hao	cghi    %r11,__LC_SAVE_AREA_ASYNC 	#Is this in normal interrupt?
1290c929500dSQingFeng Hao	je      1f
1291c929500dSQingFeng Hao	slg     %r9,BASED(.Lsie_crit_mcck_start)
1292c929500dSQingFeng Hao	clg     %r9,BASED(.Lsie_crit_mcck_length)
1293c929500dSQingFeng Hao	jh      1f
1294c929500dSQingFeng Hao	oi      __LC_CPU_FLAGS+7, _CIF_MCCK_GUEST
1295c929500dSQingFeng Hao1:	lg	%r9,__SF_EMPTY(%r15)		# get control block pointer
1296e22cf8caSChristian Borntraeger	ni	__SIE_PROG0C+3(%r9),0xfe	# no longer in SIE
1297d0fc4107SMartin Schwidefsky	lctlg	%c1,%c1,__LC_USER_ASCE		# load primary asce
1298d0fc4107SMartin Schwidefsky	larl	%r9,sie_exit			# skip forward to sie_exit
1299d0fc4107SMartin Schwidefsky	br	%r14
1300d0fc4107SMartin Schwidefsky#endif
13014bfc86ceSHeiko Carstens
13024bfc86ceSHeiko Carstens.Lcleanup_system_call:
13034bfc86ceSHeiko Carstens	# check if stpt has been executed
13044bfc86ceSHeiko Carstens	clg	%r9,BASED(.Lcleanup_system_call_insn)
13054bfc86ceSHeiko Carstens	jh	0f
13064bfc86ceSHeiko Carstens	mvc	__LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
13074bfc86ceSHeiko Carstens	cghi	%r11,__LC_SAVE_AREA_ASYNC
13084bfc86ceSHeiko Carstens	je	0f
13094bfc86ceSHeiko Carstens	mvc	__LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER
13104bfc86ceSHeiko Carstens0:	# check if stmg has been executed
13114bfc86ceSHeiko Carstens	clg	%r9,BASED(.Lcleanup_system_call_insn+8)
13124bfc86ceSHeiko Carstens	jh	0f
13134bfc86ceSHeiko Carstens	mvc	__LC_SAVE_AREA_SYNC(64),0(%r11)
13144bfc86ceSHeiko Carstens0:	# check if base register setup + TIF bit load has been done
13154bfc86ceSHeiko Carstens	clg	%r9,BASED(.Lcleanup_system_call_insn+16)
13164bfc86ceSHeiko Carstens	jhe	0f
131734525e1fSMartin Schwidefsky	# set up saved register r12 task struct pointer
131834525e1fSMartin Schwidefsky	stg	%r12,32(%r11)
131934525e1fSMartin Schwidefsky	# set up saved register r13 __TASK_thread offset
132034525e1fSMartin Schwidefsky	mvc	40(8,%r11),BASED(.Lcleanup_system_call_const)
13214bfc86ceSHeiko Carstens0:	# check if the user time update has been done
13224bfc86ceSHeiko Carstens	clg	%r9,BASED(.Lcleanup_system_call_insn+24)
13234bfc86ceSHeiko Carstens	jh	0f
13244bfc86ceSHeiko Carstens	lg	%r15,__LC_EXIT_TIMER
13254bfc86ceSHeiko Carstens	slg	%r15,__LC_SYNC_ENTER_TIMER
13264bfc86ceSHeiko Carstens	alg	%r15,__LC_USER_TIMER
13274bfc86ceSHeiko Carstens	stg	%r15,__LC_USER_TIMER
13284bfc86ceSHeiko Carstens0:	# check if the system time update has been done
13294bfc86ceSHeiko Carstens	clg	%r9,BASED(.Lcleanup_system_call_insn+32)
13304bfc86ceSHeiko Carstens	jh	0f
13314bfc86ceSHeiko Carstens	lg	%r15,__LC_LAST_UPDATE_TIMER
13324bfc86ceSHeiko Carstens	slg	%r15,__LC_EXIT_TIMER
13334bfc86ceSHeiko Carstens	alg	%r15,__LC_SYSTEM_TIMER
13344bfc86ceSHeiko Carstens	stg	%r15,__LC_SYSTEM_TIMER
13354bfc86ceSHeiko Carstens0:	# update accounting time stamp
13364bfc86ceSHeiko Carstens	mvc	__LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
133734525e1fSMartin Schwidefsky	# set up saved register r11
13384bfc86ceSHeiko Carstens	lg	%r15,__LC_KERNEL_STACK
13394bfc86ceSHeiko Carstens	la	%r9,STACK_FRAME_OVERHEAD(%r15)
13404bfc86ceSHeiko Carstens	stg	%r9,24(%r11)		# r11 pt_regs pointer
13414bfc86ceSHeiko Carstens	# fill pt_regs
13424bfc86ceSHeiko Carstens	mvc	__PT_R8(64,%r9),__LC_SAVE_AREA_SYNC
13434bfc86ceSHeiko Carstens	stmg	%r0,%r7,__PT_R0(%r9)
13444bfc86ceSHeiko Carstens	mvc	__PT_PSW(16,%r9),__LC_SVC_OLD_PSW
13454bfc86ceSHeiko Carstens	mvc	__PT_INT_CODE(4,%r9),__LC_SVC_ILC
13464bfc86ceSHeiko Carstens	xc	__PT_FLAGS(8,%r9),__PT_FLAGS(%r9)
13474bfc86ceSHeiko Carstens	mvi	__PT_FLAGS+7(%r9),_PIF_SYSCALL
13484bfc86ceSHeiko Carstens	# setup saved register r15
13494bfc86ceSHeiko Carstens	stg	%r15,56(%r11)		# r15 stack pointer
13504bfc86ceSHeiko Carstens	# set new psw address and exit
13514bfc86ceSHeiko Carstens	larl	%r9,.Lsysc_do_svc
13524bfc86ceSHeiko Carstens	br	%r14
13534bfc86ceSHeiko Carstens.Lcleanup_system_call_insn:
13544bfc86ceSHeiko Carstens	.quad	system_call
13554bfc86ceSHeiko Carstens	.quad	.Lsysc_stmg
13564bfc86ceSHeiko Carstens	.quad	.Lsysc_per
1357a359bb11SMartin Schwidefsky	.quad	.Lsysc_vtime+36
13584bfc86ceSHeiko Carstens	.quad	.Lsysc_vtime+42
135934525e1fSMartin Schwidefsky.Lcleanup_system_call_const:
136034525e1fSMartin Schwidefsky	.quad	__TASK_thread
13614bfc86ceSHeiko Carstens
13624bfc86ceSHeiko Carstens.Lcleanup_sysc_tif:
13634bfc86ceSHeiko Carstens	larl	%r9,.Lsysc_tif
13644bfc86ceSHeiko Carstens	br	%r14
13654bfc86ceSHeiko Carstens
13664bfc86ceSHeiko Carstens.Lcleanup_sysc_restore:
136707a63cbeSMartin Schwidefsky	# check if stpt has been executed
13684bfc86ceSHeiko Carstens	clg	%r9,BASED(.Lcleanup_sysc_restore_insn)
136907a63cbeSMartin Schwidefsky	jh	0f
137007a63cbeSMartin Schwidefsky	mvc	__LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
137107a63cbeSMartin Schwidefsky	cghi	%r11,__LC_SAVE_AREA_ASYNC
13724bfc86ceSHeiko Carstens	je	0f
137307a63cbeSMartin Schwidefsky	mvc	__LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
137407a63cbeSMartin Schwidefsky0:	clg	%r9,BASED(.Lcleanup_sysc_restore_insn+8)
137507a63cbeSMartin Schwidefsky	je	1f
13764bfc86ceSHeiko Carstens	lg	%r9,24(%r11)		# get saved pointer to pt_regs
13774bfc86ceSHeiko Carstens	mvc	__LC_RETURN_PSW(16),__PT_PSW(%r9)
13784bfc86ceSHeiko Carstens	mvc	0(64,%r11),__PT_R8(%r9)
13794bfc86ceSHeiko Carstens	lmg	%r0,%r7,__PT_R0(%r9)
138007a63cbeSMartin Schwidefsky1:	lmg	%r8,%r9,__LC_RETURN_PSW
13814bfc86ceSHeiko Carstens	br	%r14
13824bfc86ceSHeiko Carstens.Lcleanup_sysc_restore_insn:
138307a63cbeSMartin Schwidefsky	.quad	.Lsysc_exit_timer
13844bfc86ceSHeiko Carstens	.quad	.Lsysc_done - 4
13854bfc86ceSHeiko Carstens
13864bfc86ceSHeiko Carstens.Lcleanup_io_tif:
13874bfc86ceSHeiko Carstens	larl	%r9,.Lio_tif
13884bfc86ceSHeiko Carstens	br	%r14
13894bfc86ceSHeiko Carstens
13904bfc86ceSHeiko Carstens.Lcleanup_io_restore:
139107a63cbeSMartin Schwidefsky	# check if stpt has been executed
13924bfc86ceSHeiko Carstens	clg	%r9,BASED(.Lcleanup_io_restore_insn)
139307a63cbeSMartin Schwidefsky	jh	0f
139407a63cbeSMartin Schwidefsky	mvc	__LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
139507a63cbeSMartin Schwidefsky0:	clg	%r9,BASED(.Lcleanup_io_restore_insn+8)
139607a63cbeSMartin Schwidefsky	je	1f
13974bfc86ceSHeiko Carstens	lg	%r9,24(%r11)		# get saved r11 pointer to pt_regs
13984bfc86ceSHeiko Carstens	mvc	__LC_RETURN_PSW(16),__PT_PSW(%r9)
13994bfc86ceSHeiko Carstens	mvc	0(64,%r11),__PT_R8(%r9)
14004bfc86ceSHeiko Carstens	lmg	%r0,%r7,__PT_R0(%r9)
140107a63cbeSMartin Schwidefsky1:	lmg	%r8,%r9,__LC_RETURN_PSW
14024bfc86ceSHeiko Carstens	br	%r14
14034bfc86ceSHeiko Carstens.Lcleanup_io_restore_insn:
140407a63cbeSMartin Schwidefsky	.quad	.Lio_exit_timer
14054bfc86ceSHeiko Carstens	.quad	.Lio_done - 4
14064bfc86ceSHeiko Carstens
14074bfc86ceSHeiko Carstens.Lcleanup_idle:
1408419123f9SMartin Schwidefsky	ni	__LC_CPU_FLAGS+7,255-_CIF_ENABLED_WAIT
14094bfc86ceSHeiko Carstens	# copy interrupt clock & cpu timer
14104bfc86ceSHeiko Carstens	mvc	__CLOCK_IDLE_EXIT(8,%r2),__LC_INT_CLOCK
14114bfc86ceSHeiko Carstens	mvc	__TIMER_IDLE_EXIT(8,%r2),__LC_ASYNC_ENTER_TIMER
14124bfc86ceSHeiko Carstens	cghi	%r11,__LC_SAVE_AREA_ASYNC
14134bfc86ceSHeiko Carstens	je	0f
14144bfc86ceSHeiko Carstens	mvc	__CLOCK_IDLE_EXIT(8,%r2),__LC_MCCK_CLOCK
14154bfc86ceSHeiko Carstens	mvc	__TIMER_IDLE_EXIT(8,%r2),__LC_MCCK_ENTER_TIMER
14164bfc86ceSHeiko Carstens0:	# check if stck & stpt have been executed
14174bfc86ceSHeiko Carstens	clg	%r9,BASED(.Lcleanup_idle_insn)
14184bfc86ceSHeiko Carstens	jhe	1f
14194bfc86ceSHeiko Carstens	mvc	__CLOCK_IDLE_ENTER(8,%r2),__CLOCK_IDLE_EXIT(%r2)
14204bfc86ceSHeiko Carstens	mvc	__TIMER_IDLE_ENTER(8,%r2),__TIMER_IDLE_EXIT(%r2)
142172d38b19SMartin Schwidefsky1:	# calculate idle cycles
142272d38b19SMartin Schwidefsky#ifdef CONFIG_SMP
142372d38b19SMartin Schwidefsky	clg	%r9,BASED(.Lcleanup_idle_insn)
142472d38b19SMartin Schwidefsky	jl	3f
142572d38b19SMartin Schwidefsky	larl	%r1,smp_cpu_mtid
142672d38b19SMartin Schwidefsky	llgf	%r1,0(%r1)
142772d38b19SMartin Schwidefsky	ltgr	%r1,%r1
142872d38b19SMartin Schwidefsky	jz	3f
142972d38b19SMartin Schwidefsky	.insn	rsy,0xeb0000000017,%r1,5,__SF_EMPTY+80(%r15)
143072d38b19SMartin Schwidefsky	larl	%r3,mt_cycles
143172d38b19SMartin Schwidefsky	ag	%r3,__LC_PERCPU_OFFSET
143272d38b19SMartin Schwidefsky	la	%r4,__SF_EMPTY+16(%r15)
143372d38b19SMartin Schwidefsky2:	lg	%r0,0(%r3)
143472d38b19SMartin Schwidefsky	slg	%r0,0(%r4)
143572d38b19SMartin Schwidefsky	alg	%r0,64(%r4)
143672d38b19SMartin Schwidefsky	stg	%r0,0(%r3)
143772d38b19SMartin Schwidefsky	la	%r3,8(%r3)
143872d38b19SMartin Schwidefsky	la	%r4,8(%r4)
143972d38b19SMartin Schwidefsky	brct	%r1,2b
144072d38b19SMartin Schwidefsky#endif
144172d38b19SMartin Schwidefsky3:	# account system time going idle
14424bfc86ceSHeiko Carstens	lg	%r9,__LC_STEAL_TIMER
14434bfc86ceSHeiko Carstens	alg	%r9,__CLOCK_IDLE_ENTER(%r2)
14444bfc86ceSHeiko Carstens	slg	%r9,__LC_LAST_UPDATE_CLOCK
14454bfc86ceSHeiko Carstens	stg	%r9,__LC_STEAL_TIMER
14464bfc86ceSHeiko Carstens	mvc	__LC_LAST_UPDATE_CLOCK(8),__CLOCK_IDLE_EXIT(%r2)
14474bfc86ceSHeiko Carstens	lg	%r9,__LC_SYSTEM_TIMER
14484bfc86ceSHeiko Carstens	alg	%r9,__LC_LAST_UPDATE_TIMER
14494bfc86ceSHeiko Carstens	slg	%r9,__TIMER_IDLE_ENTER(%r2)
14504bfc86ceSHeiko Carstens	stg	%r9,__LC_SYSTEM_TIMER
14514bfc86ceSHeiko Carstens	mvc	__LC_LAST_UPDATE_TIMER(8),__TIMER_IDLE_EXIT(%r2)
14524bfc86ceSHeiko Carstens	# prepare return psw
14534bfc86ceSHeiko Carstens	nihh	%r8,0xfcfd		# clear irq & wait state bits
14544bfc86ceSHeiko Carstens	lg	%r9,48(%r11)		# return from psw_idle
14554bfc86ceSHeiko Carstens	br	%r14
14564bfc86ceSHeiko Carstens.Lcleanup_idle_insn:
14574bfc86ceSHeiko Carstens	.quad	.Lpsw_idle_lpsw
14584bfc86ceSHeiko Carstens
14599977e886SHendrik Brueckner.Lcleanup_save_fpu_regs:
1460e370e476SMartin Schwidefsky	larl	%r9,save_fpu_regs
14619977e886SHendrik Brueckner	br	%r14
14629977e886SHendrik Brueckner
14639977e886SHendrik Brueckner.Lcleanup_load_fpu_regs:
1464e370e476SMartin Schwidefsky	larl	%r9,load_fpu_regs
14659977e886SHendrik Brueckner	br	%r14
14669977e886SHendrik Brueckner
14674bfc86ceSHeiko Carstens/*
14684bfc86ceSHeiko Carstens * Integer constants
14694bfc86ceSHeiko Carstens */
14704bfc86ceSHeiko Carstens	.align	8
14714bfc86ceSHeiko Carstens.Lcritical_start:
14724bfc86ceSHeiko Carstens	.quad	.L__critical_start
14734bfc86ceSHeiko Carstens.Lcritical_length:
14744bfc86ceSHeiko Carstens	.quad	.L__critical_end - .L__critical_start
14754bfc86ceSHeiko Carstens#if IS_ENABLED(CONFIG_KVM)
1476d0fc4107SMartin Schwidefsky.Lsie_critical_start:
14774bfc86ceSHeiko Carstens	.quad	.Lsie_gmap
14784bfc86ceSHeiko Carstens.Lsie_critical_length:
14794bfc86ceSHeiko Carstens	.quad	.Lsie_done - .Lsie_gmap
1480c929500dSQingFeng Hao.Lsie_crit_mcck_start:
1481c929500dSQingFeng Hao	.quad   .Lsie_entry
1482c929500dSQingFeng Hao.Lsie_crit_mcck_length:
1483c929500dSQingFeng Hao	.quad   .Lsie_skip - .Lsie_entry
14844bfc86ceSHeiko Carstens#endif
14854bfc86ceSHeiko Carstens
14864bfc86ceSHeiko Carstens	.section .rodata, "a"
1487a876cb3fSHeiko Carstens#define SYSCALL(esame,emu)	.long esame
14884bfc86ceSHeiko Carstens	.globl	sys_call_table
14894bfc86ceSHeiko Carstenssys_call_table:
14904381f9f1SHendrik Brueckner#include "asm/syscall_table.h"
14914bfc86ceSHeiko Carstens#undef SYSCALL
14924bfc86ceSHeiko Carstens
14934bfc86ceSHeiko Carstens#ifdef CONFIG_COMPAT
14944bfc86ceSHeiko Carstens
1495a876cb3fSHeiko Carstens#define SYSCALL(esame,emu)	.long emu
14964bfc86ceSHeiko Carstens	.globl	sys_call_table_emu
14974bfc86ceSHeiko Carstenssys_call_table_emu:
14984381f9f1SHendrik Brueckner#include "asm/syscall_table.h"
14994bfc86ceSHeiko Carstens#undef SYSCALL
15004bfc86ceSHeiko Carstens#endif
1501