blob: 9fd864563499bb7e46f0cd85d4a03550b32a15ac [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Heiko Carstens54dfe5dd2006-02-01 03:06:38 -08002 * arch/s390/kernel/entry64.S
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * S390 low-level entry points.
4 *
Carsten Ottecd3b70f2010-05-17 10:00:04 +02005 * Copyright (C) IBM Corp. 1999,2010
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
Heiko Carstens25d83cb2006-09-28 16:56:37 +02007 * Hartmut Penner (hp@de.ibm.com),
8 * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
Heiko Carstens77fa2242005-06-25 14:55:30 -07009 * Heiko Carstens <heiko.carstens@de.ibm.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 */
11
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/linkage.h>
Heiko Carstens2bc89b52008-02-05 16:50:40 +010013#include <linux/init.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>
21
22/*
23 * Stack layout for the system_call stack entry.
24 * The first few entries are identical to the user_regs_struct.
25 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +020026SP_PTREGS = STACK_FRAME_OVERHEAD
27SP_ARGS = STACK_FRAME_OVERHEAD + __PT_ARGS
28SP_PSW = STACK_FRAME_OVERHEAD + __PT_PSW
29SP_R0 = STACK_FRAME_OVERHEAD + __PT_GPRS
30SP_R1 = STACK_FRAME_OVERHEAD + __PT_GPRS + 8
31SP_R2 = STACK_FRAME_OVERHEAD + __PT_GPRS + 16
32SP_R3 = STACK_FRAME_OVERHEAD + __PT_GPRS + 24
33SP_R4 = STACK_FRAME_OVERHEAD + __PT_GPRS + 32
34SP_R5 = STACK_FRAME_OVERHEAD + __PT_GPRS + 40
35SP_R6 = STACK_FRAME_OVERHEAD + __PT_GPRS + 48
36SP_R7 = STACK_FRAME_OVERHEAD + __PT_GPRS + 56
37SP_R8 = STACK_FRAME_OVERHEAD + __PT_GPRS + 64
38SP_R9 = STACK_FRAME_OVERHEAD + __PT_GPRS + 72
39SP_R10 = STACK_FRAME_OVERHEAD + __PT_GPRS + 80
40SP_R11 = STACK_FRAME_OVERHEAD + __PT_GPRS + 88
41SP_R12 = STACK_FRAME_OVERHEAD + __PT_GPRS + 96
42SP_R13 = STACK_FRAME_OVERHEAD + __PT_GPRS + 104
43SP_R14 = STACK_FRAME_OVERHEAD + __PT_GPRS + 112
44SP_R15 = STACK_FRAME_OVERHEAD + __PT_GPRS + 120
45SP_ORIG_R2 = STACK_FRAME_OVERHEAD + __PT_ORIG_GPR2
46SP_ILC = STACK_FRAME_OVERHEAD + __PT_ILC
Martin Schwidefsky59da2132008-11-27 11:05:55 +010047SP_SVCNR = STACK_FRAME_OVERHEAD + __PT_SVCNR
Heiko Carstens25d83cb2006-09-28 16:56:37 +020048SP_SIZE = STACK_FRAME_OVERHEAD + __PT_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
51STACK_SIZE = 1 << STACK_SHIFT
52
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +020053_TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +010054 _TIF_MCCK_PENDING | _TIF_RESTART_SVC | _TIF_PER_TRAP )
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +020055_TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
Heiko Carstens54dfe5dd2006-02-01 03:06:38 -080056 _TIF_MCCK_PENDING)
Heiko Carstens9bf12262009-06-12 10:26:47 +020057_TIF_SYSCALL = (_TIF_SYSCALL_TRACE>>8 | _TIF_SYSCALL_AUDIT>>8 | \
Josh Stone66700002009-08-24 14:43:11 -070058 _TIF_SECCOMP>>8 | _TIF_SYSCALL_TRACEPOINT>>8)
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60#define BASED(name) name-system_call(%r13)
61
Carsten Ottecd3b70f2010-05-17 10:00:04 +020062 .macro HANDLE_SIE_INTERCEPT
63#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
64 lg %r3,__LC_SIE_HOOK
65 ltgr %r3,%r3
66 jz 0f
67 basr %r14,%r3
Heiko Carstens2ffbb3f2010-05-26 23:26:21 +0200680:
Carsten Ottecd3b70f2010-05-17 10:00:04 +020069#endif
70 .endm
71
Heiko Carstens1f194a42006-07-03 00:24:46 -070072#ifdef CONFIG_TRACE_IRQFLAGS
73 .macro TRACE_IRQS_ON
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +020074 basr %r2,%r0
75 brasl %r14,trace_hardirqs_on_caller
Heiko Carstens1f194a42006-07-03 00:24:46 -070076 .endm
77
78 .macro TRACE_IRQS_OFF
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +020079 basr %r2,%r0
80 brasl %r14,trace_hardirqs_off_caller
Heiko Carstens1f194a42006-07-03 00:24:46 -070081 .endm
82#else
83#define TRACE_IRQS_ON
84#define TRACE_IRQS_OFF
Heiko Carstens411788e2007-11-20 11:13:32 +010085#endif
86
87#ifdef CONFIG_LOCKDEP
88 .macro LOCKDEP_SYS_EXIT
89 tm SP_PSW+1(%r15),0x01 # returning to user ?
90 jz 0f
91 brasl %r14,lockdep_sys_exit
920:
93 .endm
94#else
Heiko Carstens523b44c2007-10-11 22:11:12 +020095#define LOCKDEP_SYS_EXIT
Heiko Carstens1f194a42006-07-03 00:24:46 -070096#endif
97
Heiko Carstens25d83cb2006-09-28 16:56:37 +020098 .macro UPDATE_VTIME lc_from,lc_to,lc_sum
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 lg %r10,\lc_from
100 slg %r10,\lc_to
101 alg %r10,\lc_sum
102 stg %r10,\lc_sum
103 .endm
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104
105/*
106 * Register usage in interrupt handlers:
107 * R9 - pointer to current task structure
108 * R13 - pointer to literal pool
109 * R14 - return register for function calls
110 * R15 - kernel stack pointer
111 */
112
Martin Schwidefsky987ad702007-07-10 11:24:18 +0200113 .macro SAVE_ALL_SVC psworg,savearea
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200114 stmg %r11,%r15,\savearea
Martin Schwidefsky987ad702007-07-10 11:24:18 +0200115 lg %r15,__LC_KERNEL_STACK # problem state -> load ksp
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200116 aghi %r15,-SP_SIZE # make room for registers & psw
117 lg %r11,__LC_LAST_BREAK
Martin Schwidefsky987ad702007-07-10 11:24:18 +0200118 .endm
119
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200120 .macro SAVE_ALL_PGM psworg,savearea
121 stmg %r11,%r15,\savearea
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 tm \psworg+1,0x01 # test problem state bit
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200123#ifdef CONFIG_CHECK_STACK
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200124 jnz 1f
125 tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
126 jnz 2f
127 la %r12,\psworg
128 j stack_overflow
129#else
130 jz 2f
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200131#endif
Martin Schwidefsky86f25522010-05-17 10:00:05 +02001321: lg %r15,__LC_KERNEL_STACK # problem state -> load ksp
1332: aghi %r15,-SP_SIZE # make room for registers & psw
134 larl %r13,system_call
135 lg %r11,__LC_LAST_BREAK
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200136 .endm
137
138 .macro SAVE_ALL_ASYNC psworg,savearea
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200139 stmg %r11,%r15,\savearea
140 larl %r13,system_call
141 lg %r11,__LC_LAST_BREAK
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200142 la %r12,\psworg
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 tm \psworg+1,0x01 # test problem state bit
144 jnz 1f # from user -> load kernel stack
145 clc \psworg+8(8),BASED(.Lcritical_end)
146 jhe 0f
147 clc \psworg+8(8),BASED(.Lcritical_start)
148 jl 0f
149 brasl %r14,cleanup_critical
Peter Oberparleiter6add9f72005-09-16 19:27:42 -0700150 tm 1(%r12),0x01 # retest problem state after cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 jnz 1f
1520: lg %r14,__LC_ASYNC_STACK # are we already on the async. stack ?
153 slgr %r14,%r15
154 srag %r14,%r14,STACK_SHIFT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155#ifdef CONFIG_CHECK_STACK
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200156 jnz 1f
157 tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
158 jnz 2f
159 j stack_overflow
160#else
161 jz 2f
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162#endif
Martin Schwidefsky86f25522010-05-17 10:00:05 +02001631: lg %r15,__LC_ASYNC_STACK # load async stack
1642: aghi %r15,-SP_SIZE # make room for registers & psw
Heiko Carstens77fa2242005-06-25 14:55:30 -0700165 .endm
166
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200167 .macro CREATE_STACK_FRAME savearea
168 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169 stg %r2,SP_ORIG_R2(%r15) # store original content of gpr 2
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200170 mvc SP_R11(40,%r15),\savearea # move %r11-%r15 to stack
171 stmg %r0,%r10,SP_R0(%r15) # store gprs %r0-%r10 to kernel stack
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200172 .endm
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700174 .macro RESTORE_ALL psworg,sync
175 mvc \psworg(16),SP_PSW(%r15) # move user PSW to lowcore
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 .if !\sync
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700177 ni \psworg+1,0xfd # clear wait state bit
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 .endif
Martin Schwidefskyc742b312008-12-31 15:11:42 +0100179 lg %r14,__LC_VDSO_PER_CPU
180 lmg %r0,%r13,SP_R0(%r15) # load gprs 0-13 of user
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100181 stpt __LC_EXIT_TIMER
Martin Schwidefskyc742b312008-12-31 15:11:42 +0100182 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
183 lmg %r14,%r15,SP_R14(%r15) # load grps 14-15 of user
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700184 lpswe \psworg # back to caller
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 .endm
186
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200187 .macro LAST_BREAK
188 srag %r10,%r11,23
189 jz 0f
190 stg %r11,__TI_last_break(%r12)
1910:
192 .endm
193
Martin Schwidefsky1e546222010-10-25 16:10:37 +0200194 .macro REENABLE_IRQS
195 mvc __SF_EMPTY(1,%r15),SP_PSW(%r15)
196 ni __SF_EMPTY(%r15),0xbf
197 ssm __SF_EMPTY(%r15)
198 .endm
199
Martin Schwidefsky860dba42011-01-05 12:47:25 +0100200 .section .kprobes.text, "ax"
201
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202/*
203 * Scheduler resume function, called by switch_to
204 * gpr2 = (task_struct *) prev
205 * gpr3 = (task_struct *) next
206 * Returns:
207 * gpr2 = prev
208 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200209 .globl __switch_to
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210__switch_to:
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100211 lg %r4,__THREAD_info(%r2) # get thread_info of prev
212 lg %r5,__THREAD_info(%r3) # get thread_info of next
Heiko Carstens77fa2242005-06-25 14:55:30 -0700213 tm __TI_flags+7(%r4),_TIF_MCCK_PENDING # machine check pending?
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100214 jz 0f
215 ni __TI_flags+7(%r4),255-_TIF_MCCK_PENDING # clear flag in prev
216 oi __TI_flags+7(%r5),_TIF_MCCK_PENDING # set it in next
2170: stmg %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task
218 stg %r15,__THREAD_ksp(%r2) # store kernel stack of prev
219 lg %r15,__THREAD_ksp(%r3) # load kernel stack of next
220 lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4
221 lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task
222 stg %r3,__LC_CURRENT # store task struct of next
223 stg %r5,__LC_THREAD_INFO # store thread info of next
224 aghi %r5,STACK_SIZE # end of kernel stack of next
225 stg %r5,__LC_KERNEL_STACK # store end of kernel stack
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 br %r14
227
228__critical_start:
229/*
230 * SVC interrupt handler routine. System calls are synchronous events and
231 * are executed with interrupts enabled.
232 */
233
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200234 .globl system_call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235system_call:
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100236 stpt __LC_SYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237sysc_saveall:
Martin Schwidefsky987ad702007-07-10 11:24:18 +0200238 SAVE_ALL_SVC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200239 CREATE_STACK_FRAME __LC_SAVE_AREA
240 mvc SP_PSW(16,%r15),__LC_SVC_OLD_PSW
241 mvc SP_ILC(4,%r15),__LC_SVC_ILC
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200242 lg %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243sysc_vtime:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
245sysc_stime:
246 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
247sysc_update:
248 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200249 LAST_BREAK
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250sysc_do_svc:
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200251 llgh %r7,SP_SVCNR(%r15)
252 slag %r7,%r7,2 # shift and test for svc 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253 jnz sysc_nr_ok
254 # svc 0: system call number in %r1
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200255 llgfr %r1,%r1 # clear high word in r1
256 cghi %r1,NR_syscalls
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 jnl sysc_nr_ok
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200258 sth %r1,SP_SVCNR(%r15)
259 slag %r7,%r1,2 # shift and test for svc 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260sysc_nr_ok:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200261 larl %r10,sys_call_table
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800262#ifdef CONFIG_COMPAT
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200263 tm __TI_flags+5(%r12),(_TIF_31BIT>>16) # running in 31 bit mode ?
Heiko Carstensc5630772005-09-03 15:58:04 -0700264 jno sysc_noemu
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200265 larl %r10,sys_call_table_emu # use 31 bit emulation system calls
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266sysc_noemu:
267#endif
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200268 tm __TI_flags+6(%r12),_TIF_SYSCALL
Martin Schwidefskybaa07152010-10-25 16:10:40 +0200269 mvc SP_ARGS(8,%r15),SP_R7(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200270 lgf %r8,0(%r7,%r10) # load address of system call routine
271 jnz sysc_tracesys
272 basr %r14,%r8 # call sys_xxxx
273 stg %r2,SP_R2(%r15) # store return value (change R2 on stack)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274
275sysc_return:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200276 LOCKDEP_SYS_EXIT
277sysc_tif:
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200278 tm __TI_flags+7(%r12),_TIF_WORK_SVC
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200279 jnz sysc_work # there is work to do (signals etc.)
Heiko Carstens411788e2007-11-20 11:13:32 +0100280sysc_restore:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200281 RESTORE_ALL __LC_RETURN_PSW,1
Heiko Carstens411788e2007-11-20 11:13:32 +0100282sysc_done:
283
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284#
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200285# There is work to do, but first we need to check if we return to userspace.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286#
287sysc_work:
Martin Schwidefsky26889052008-05-07 09:22:52 +0200288 tm SP_PSW+1(%r15),0x01 # returning to user ?
289 jno sysc_restore
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200290
291#
292# One of the work bits is on. Find out which one.
293#
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200294sysc_work_tif:
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200295 tm __TI_flags+7(%r12),_TIF_MCCK_PENDING
Heiko Carstens77fa2242005-06-25 14:55:30 -0700296 jo sysc_mcck_pending
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200297 tm __TI_flags+7(%r12),_TIF_NEED_RESCHED
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 jo sysc_reschedule
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200299 tm __TI_flags+7(%r12),_TIF_SIGPENDING
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200300 jo sysc_sigpending
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200301 tm __TI_flags+7(%r12),_TIF_NOTIFY_RESUME
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200302 jo sysc_notify_resume
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200303 tm __TI_flags+7(%r12),_TIF_RESTART_SVC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 jo sysc_restart
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100305 tm __TI_flags+7(%r12),_TIF_PER_TRAP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 jo sysc_singlestep
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200307 j sysc_return # beware of critical section cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308
309#
310# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200311#
312sysc_reschedule:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200313 larl %r14,sysc_return
314 jg schedule # return point is sysc_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315
316#
Heiko Carstens77fa2242005-06-25 14:55:30 -0700317# _TIF_MCCK_PENDING is set, call handler
318#
319sysc_mcck_pending:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200320 larl %r14,sysc_return
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200321 jg s390_handle_mcck # TIF bit will be cleared by handler
Heiko Carstens77fa2242005-06-25 14:55:30 -0700322
323#
Roland McGrath02a029b2008-04-30 00:53:08 -0700324# _TIF_SIGPENDING is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325#
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200326sysc_sigpending:
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100327 ni __TI_flags+7(%r12),255-_TIF_PER_TRAP # clear TIF_PER_TRAP
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200328 la %r2,SP_PTREGS(%r15) # load pt_regs
329 brasl %r14,do_signal # call do_signal
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200330 tm __TI_flags+7(%r12),_TIF_RESTART_SVC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 jo sysc_restart
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100332 tm __TI_flags+7(%r12),_TIF_PER_TRAP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 jo sysc_singlestep
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200334 j sysc_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335
336#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200337# _TIF_NOTIFY_RESUME is set, call do_notify_resume
338#
339sysc_notify_resume:
340 la %r2,SP_PTREGS(%r15) # load pt_regs
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200341 larl %r14,sysc_return
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200342 jg do_notify_resume # call do_notify_resume
343
344#
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345# _TIF_RESTART_SVC is set, set up registers and restart svc
346#
347sysc_restart:
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200348 ni __TI_flags+7(%r12),255-_TIF_RESTART_SVC # clear TIF_RESTART_SVC
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200349 lg %r7,SP_R2(%r15) # load new svc number
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 mvc SP_R2(8,%r15),SP_ORIG_R2(%r15) # restore first argument
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200351 lmg %r2,%r6,SP_R2(%r15) # load svc arguments
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200352 sth %r7,SP_SVCNR(%r15)
353 slag %r7,%r7,2
354 j sysc_nr_ok # restart svc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355
356#
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100357# _TIF_PER_TRAP is set, call do_per_trap
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358#
359sysc_singlestep:
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100360 ni __TI_flags+7(%r12),255-_TIF_PER_TRAP # clear TIF_PER_TRAP
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100361 xc SP_SVCNR(2,%r15),SP_SVCNR(%r15) # clear svc number
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 la %r2,SP_PTREGS(%r15) # address of register-save area
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200363 larl %r14,sysc_return # load adr. of system return
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100364 jg do_per_trap
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200367# call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
368# and after the system call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369#
370sysc_tracesys:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200371 la %r2,SP_PTREGS(%r15) # load pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 la %r3,0
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200373 llgh %r0,SP_SVCNR(%r15)
374 stg %r0,SP_R2(%r15)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200375 brasl %r14,do_syscall_trace_enter
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 lghi %r0,NR_syscalls
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200377 clgr %r0,%r2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 jnh sysc_tracenogo
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100379 sllg %r7,%r2,2 # svc number *4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380 lgf %r8,0(%r7,%r10)
381sysc_tracego:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200382 lmg %r3,%r6,SP_R3(%r15)
Martin Schwidefskybaa07152010-10-25 16:10:40 +0200383 mvc SP_ARGS(8,%r15),SP_R7(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200384 lg %r2,SP_ORIG_R2(%r15)
385 basr %r14,%r8 # call sys_xxx
386 stg %r2,SP_R2(%r15) # store return value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387sysc_tracenogo:
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200388 tm __TI_flags+6(%r12),_TIF_SYSCALL
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200389 jz sysc_return
390 la %r2,SP_PTREGS(%r15) # load pt_regs
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200391 larl %r14,sysc_return # return point is sysc_return
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200392 jg do_syscall_trace_exit
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393
394#
395# a new process exits the kernel with ret_from_fork
396#
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200397 .globl ret_from_fork
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398ret_from_fork:
399 lg %r13,__LC_SVC_NEW_PSW+8
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200400 lg %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401 tm SP_PSW+1(%r15),0x01 # forking a kernel thread ?
402 jo 0f
403 stg %r15,SP_R15(%r15) # store stack pointer for new kthread
Heiko Carstens25d83cb2006-09-28 16:56:37 +02004040: brasl %r14,schedule_tail
Heiko Carstens1f194a42006-07-03 00:24:46 -0700405 TRACE_IRQS_ON
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200406 stosm 24(%r15),0x03 # reenable interrupts
Al Viro8f2961c2008-12-25 13:37:58 +0100407 j sysc_tracenogo
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408
409#
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200410# kernel_execve function needs to deal with pt_regs that is not
411# at the usual place
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412#
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200413 .globl kernel_execve
414kernel_execve:
415 stmg %r12,%r15,96(%r15)
416 lgr %r14,%r15
417 aghi %r15,-SP_SIZE
418 stg %r14,__SF_BACKCHAIN(%r15)
419 la %r12,SP_PTREGS(%r15)
420 xc 0(__PT_SIZE,%r12),0(%r12)
421 lgr %r5,%r12
422 brasl %r14,do_execve
423 ltgfr %r2,%r2
424 je 0f
425 aghi %r15,SP_SIZE
426 lmg %r12,%r15,96(%r15)
427 br %r14
428 # execve succeeded.
4290: stnsm __SF_EMPTY(%r15),0xfc # disable interrupts
430 lg %r15,__LC_KERNEL_STACK # load ksp
431 aghi %r15,-SP_SIZE # make room for registers & psw
432 lg %r13,__LC_SVC_NEW_PSW+8
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200433 mvc SP_PTREGS(__PT_SIZE,%r15),0(%r12) # copy pt_regs
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200434 lg %r12,__LC_THREAD_INFO
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200435 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
436 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
437 brasl %r14,execve_tail
438 j sysc_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439
440/*
441 * Program check handler routine
442 */
443
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200444 .globl pgm_check_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445pgm_check_handler:
446/*
447 * First we need to check for a special case:
448 * Single stepping an instruction that disables the PER event mask will
449 * cause a PER event AFTER the mask has been set. Example: SVC or LPSW.
450 * For a single stepped SVC the program check handler gets control after
451 * the SVC new PSW has been loaded. But we want to execute the SVC first and
452 * then handle the PER event. Therefore we update the SVC old PSW to point
453 * to the pgm_check_handler and branch to the SVC handler after we checked
454 * if we have to load the kernel stack register.
455 * For every other possible cause for PER event without the PER mask set
456 * we just ignore the PER event (FIXME: is there anything we have to do
457 * for LPSW?).
458 */
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100459 stpt __LC_SYNC_ENTER_TIMER
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200460 tm __LC_PGM_INT_CODE+1,0x80 # check whether we got a per exception
461 jnz pgm_per # got per exception -> special case
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200462 SAVE_ALL_PGM __LC_PGM_OLD_PSW,__LC_SAVE_AREA
463 CREATE_STACK_FRAME __LC_SAVE_AREA
464 xc SP_ILC(4,%r15),SP_ILC(%r15)
465 mvc SP_PSW(16,%r15),__LC_PGM_OLD_PSW
466 lg %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
468 jz pgm_no_vtime
469 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
470 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
471 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200472 LAST_BREAK
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473pgm_no_vtime:
Carsten Ottecd3b70f2010-05-17 10:00:04 +0200474 HANDLE_SIE_INTERCEPT
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200475 stg %r11,SP_ARGS(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200476 lgf %r3,__LC_PGM_ILC # load program interruption code
Martin Schwidefsky1e546222010-10-25 16:10:37 +0200477 lg %r4,__LC_TRANS_EXC_CODE
478 REENABLE_IRQS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 lghi %r8,0x7f
480 ngr %r8,%r3
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200481 sll %r8,3
482 larl %r1,pgm_check_table
483 lg %r1,0(%r8,%r1) # load address of handler routine
484 la %r2,SP_PTREGS(%r15) # address of register-save area
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200485 basr %r14,%r1 # branch to interrupt-handler
486pgm_exit:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200487 j sysc_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488
489#
490# handle per exception
491#
492pgm_per:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200493 tm __LC_PGM_OLD_PSW,0x40 # test if per event recording is on
494 jnz pgm_per_std # ok, normal per event from user space
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495# ok its one of the special cases, now we need to find out which one
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200496 clc __LC_PGM_OLD_PSW(16),__LC_SVC_NEW_PSW
497 je pgm_svcper
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498# no interesting special case, ignore PER event
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200499 lpswe __LC_PGM_OLD_PSW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500
501#
502# Normal per exception
503#
504pgm_per_std:
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200505 SAVE_ALL_PGM __LC_PGM_OLD_PSW,__LC_SAVE_AREA
506 CREATE_STACK_FRAME __LC_SAVE_AREA
507 mvc SP_PSW(16,%r15),__LC_PGM_OLD_PSW
508 lg %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
510 jz pgm_no_vtime2
511 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
512 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
513 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200514 LAST_BREAK
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515pgm_no_vtime2:
Carsten Ottecd3b70f2010-05-17 10:00:04 +0200516 HANDLE_SIE_INTERCEPT
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200517 lg %r1,__TI_task(%r12)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200518 tm SP_PSW+1(%r15),0x01 # kernel per event ?
519 jz kernel_per
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100520 mvc __THREAD_per_cause(2,%r1),__LC_PER_CAUSE
521 mvc __THREAD_per_address(8,%r1),__LC_PER_ADDRESS
522 mvc __THREAD_per_paid(1,%r1),__LC_PER_PAID
523 oi __TI_flags+7(%r12),_TIF_PER_TRAP # set TIF_PER_TRAP
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200524 lgf %r3,__LC_PGM_ILC # load program interruption code
Martin Schwidefsky1e546222010-10-25 16:10:37 +0200525 lg %r4,__LC_TRANS_EXC_CODE
526 REENABLE_IRQS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 lghi %r8,0x7f
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200528 ngr %r8,%r3 # clear per-event-bit and ilc
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200529 je pgm_exit2
530 sll %r8,3
531 larl %r1,pgm_check_table
532 lg %r1,0(%r8,%r1) # load address of handler routine
533 la %r2,SP_PTREGS(%r15) # address of register-save area
534 basr %r14,%r1 # branch to interrupt-handler
535pgm_exit2:
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200536 j sysc_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537
538#
539# it was a single stepped SVC that is causing all the trouble
540#
541pgm_svcper:
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200542 SAVE_ALL_PGM __LC_SVC_OLD_PSW,__LC_SAVE_AREA
543 CREATE_STACK_FRAME __LC_SAVE_AREA
544 mvc SP_PSW(16,%r15),__LC_SVC_OLD_PSW
545 mvc SP_ILC(4,%r15),__LC_SVC_ILC
546 lg %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
548 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
549 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200550 LAST_BREAK
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200551 lg %r8,__TI_task(%r12)
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100552 mvc __THREAD_per_cause(2,%r8),__LC_PER_CAUSE
553 mvc __THREAD_per_address(8,%r8),__LC_PER_ADDRESS
554 mvc __THREAD_per_paid(1,%r8),__LC_PER_PAID
555 oi __TI_flags+7(%r12),_TIF_PER_TRAP # set TIF_PER_TRAP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200557 lmg %r2,%r6,SP_R2(%r15) # load svc arguments
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 j sysc_do_svc
559
Michael Grundy4ba069b2006-09-20 15:58:39 +0200560#
561# per was called from kernel, must be kprobes
562#
563kernel_per:
Martin Schwidefsky9ec27082010-10-29 16:50:45 +0200564 REENABLE_IRQS
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100565 xc SP_SVCNR(2,%r15),SP_SVCNR(%r15) # clear svc number
Michael Grundy4ba069b2006-09-20 15:58:39 +0200566 la %r2,SP_PTREGS(%r15) # address of register-save area
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100567 brasl %r14,do_per_trap
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200568 j pgm_exit
Michael Grundy4ba069b2006-09-20 15:58:39 +0200569
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570/*
571 * IO interrupt handler routine
572 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200573 .globl io_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574io_int_handler:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 stck __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100576 stpt __LC_ASYNC_ENTER_TIMER
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200577 SAVE_ALL_ASYNC __LC_IO_OLD_PSW,__LC_SAVE_AREA+40
578 CREATE_STACK_FRAME __LC_SAVE_AREA+40
579 mvc SP_PSW(16,%r15),0(%r12) # move user PSW to stack
580 lg %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
582 jz io_no_vtime
583 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
584 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
585 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200586 LAST_BREAK
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587io_no_vtime:
Carsten Ottecd3b70f2010-05-17 10:00:04 +0200588 HANDLE_SIE_INTERCEPT
Heiko Carstens1f194a42006-07-03 00:24:46 -0700589 TRACE_IRQS_OFF
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200590 la %r2,SP_PTREGS(%r15) # address of register-save area
591 brasl %r14,do_IRQ # call standard irq handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592io_return:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200593 LOCKDEP_SYS_EXIT
594 TRACE_IRQS_ON
595io_tif:
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200596 tm __TI_flags+7(%r12),_TIF_WORK_INT
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200597 jnz io_work # there is work to do (signals etc.)
Heiko Carstens411788e2007-11-20 11:13:32 +0100598io_restore:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200599 RESTORE_ALL __LC_RETURN_PSW,0
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700600io_done:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601
Martin Schwidefsky26889052008-05-07 09:22:52 +0200602#
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200603# There is work todo, find out in which context we have been interrupted:
604# 1) if we return to user space we can do all _TIF_WORK_INT work
605# 2) if we return to kernel code and kvm is enabled check if we need to
606# modify the psw to leave SIE
607# 3) if we return to kernel code and preemptive scheduling is enabled check
608# the preemption counter and if it is zero call preempt_schedule_irq
609# Before any work can be done, a switch to the kernel stack is required.
Martin Schwidefsky26889052008-05-07 09:22:52 +0200610#
611io_work:
612 tm SP_PSW+1(%r15),0x01 # returning to user ?
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200613 jo io_work_user # yes -> do resched & signal
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200614#ifdef CONFIG_PREEMPT
Martin Schwidefsky26889052008-05-07 09:22:52 +0200615 # check for preemptive scheduling
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200616 icm %r0,15,__TI_precount(%r12)
Martin Schwidefsky26889052008-05-07 09:22:52 +0200617 jnz io_restore # preemption is disabled
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200618 tm __TI_flags+7(%r12),_TIF_NEED_RESCHED
619 jno io_restore
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 # switch to kernel stack
621 lg %r1,SP_R15(%r15)
622 aghi %r1,-SP_SIZE
623 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200624 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) # clear back chain
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 lgr %r15,%r1
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200626 # TRACE_IRQS_ON already done at io_return, call
627 # TRACE_IRQS_OFF to keep things symmetrical
628 TRACE_IRQS_OFF
629 brasl %r14,preempt_schedule_irq
630 j io_return
631#else
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200632 j io_restore
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200633#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200635#
636# Need to do work before returning to userspace, switch to kernel stack
637#
Martin Schwidefsky26889052008-05-07 09:22:52 +0200638io_work_user:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 lg %r1,__LC_KERNEL_STACK
640 aghi %r1,-SP_SIZE
641 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200642 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) # clear back chain
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 lgr %r15,%r1
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200644
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645#
646# One of the work bits is on. Find out which one.
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200647# Checked are: _TIF_SIGPENDING, _TIF_NOTIFY_RESUME, _TIF_NEED_RESCHED
Heiko Carstens54dfe5dd2006-02-01 03:06:38 -0800648# and _TIF_MCCK_PENDING
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649#
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200650io_work_tif:
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200651 tm __TI_flags+7(%r12),_TIF_MCCK_PENDING
Heiko Carstens77fa2242005-06-25 14:55:30 -0700652 jo io_mcck_pending
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200653 tm __TI_flags+7(%r12),_TIF_NEED_RESCHED
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 jo io_reschedule
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200655 tm __TI_flags+7(%r12),_TIF_SIGPENDING
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200656 jo io_sigpending
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200657 tm __TI_flags+7(%r12),_TIF_NOTIFY_RESUME
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200658 jo io_notify_resume
659 j io_return # beware of critical section cleanup
Christian Borntraeger0eaeafa2008-05-07 09:22:53 +0200660
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661#
Heiko Carstens77fa2242005-06-25 14:55:30 -0700662# _TIF_MCCK_PENDING is set, call handler
663#
664io_mcck_pending:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200665 # TRACE_IRQS_ON already done at io_return
Heiko Carstensb771aea2007-07-27 12:29:18 +0200666 brasl %r14,s390_handle_mcck # TIF bit will be cleared by handler
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200667 TRACE_IRQS_OFF
668 j io_return
Heiko Carstens77fa2242005-06-25 14:55:30 -0700669
670#
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200672#
673io_reschedule:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200674 # TRACE_IRQS_ON already done at io_return
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200675 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
676 brasl %r14,schedule # call scheduler
677 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100678 TRACE_IRQS_OFF
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200679 j io_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680
681#
Roland McGrath02a029b2008-04-30 00:53:08 -0700682# _TIF_SIGPENDING or is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683#
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200684io_sigpending:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200685 # TRACE_IRQS_ON already done at io_return
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200686 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
687 la %r2,SP_PTREGS(%r15) # load pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 brasl %r14,do_signal # call do_signal
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200689 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100690 TRACE_IRQS_OFF
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200691 j io_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200693#
694# _TIF_NOTIFY_RESUME or is set, call do_notify_resume
695#
696io_notify_resume:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200697 # TRACE_IRQS_ON already done at io_return
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200698 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
699 la %r2,SP_PTREGS(%r15) # load pt_regs
700 brasl %r14,do_notify_resume # call do_notify_resume
701 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
702 TRACE_IRQS_OFF
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200703 j io_return
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200704
Linus Torvalds1da177e2005-04-16 15:20:36 -0700705/*
706 * External interrupt handler routine
707 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200708 .globl ext_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709ext_int_handler:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 stck __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100711 stpt __LC_ASYNC_ENTER_TIMER
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200712 SAVE_ALL_ASYNC __LC_EXT_OLD_PSW,__LC_SAVE_AREA+40
713 CREATE_STACK_FRAME __LC_SAVE_AREA+40
714 mvc SP_PSW(16,%r15),0(%r12) # move user PSW to stack
715 lg %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
717 jz ext_no_vtime
718 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
719 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
720 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200721 LAST_BREAK
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722ext_no_vtime:
Carsten Ottecd3b70f2010-05-17 10:00:04 +0200723 HANDLE_SIE_INTERCEPT
Heiko Carstens1f194a42006-07-03 00:24:46 -0700724 TRACE_IRQS_OFF
Martin Schwidefskyf6649a72010-10-25 16:10:38 +0200725 lghi %r1,4096
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200726 la %r2,SP_PTREGS(%r15) # address of register-save area
Martin Schwidefskyf6649a72010-10-25 16:10:38 +0200727 llgf %r3,__LC_CPU_ADDRESS # get cpu address + interruption code
728 llgf %r4,__LC_EXT_PARAMS # get external parameter
729 lg %r5,__LC_EXT_PARAMS2-4096(%r1) # get 64 bit external parameter
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200730 brasl %r14,do_extint
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 j io_return
732
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700733__critical_end:
734
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735/*
736 * Machine check handler routines
737 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200738 .globl mcck_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739mcck_int_handler:
Martin Schwidefsky63779812010-05-17 10:00:03 +0200740 stck __LC_MCCK_CLOCK
Heiko Carstens77fa2242005-06-25 14:55:30 -0700741 la %r1,4095 # revalidate r1
742 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # revalidate cpu timer
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200743 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# revalidate gprs
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200744 stmg %r11,%r15,__LC_SAVE_AREA+80
745 larl %r13,system_call
746 lg %r11,__LC_LAST_BREAK
Heiko Carstens77fa2242005-06-25 14:55:30 -0700747 la %r12,__LC_MCK_OLD_PSW
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200748 tm __LC_MCCK_CODE,0x80 # system damage?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700749 jo mcck_int_main # yes -> rest of mcck code invalid
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200750 la %r14,4095
Martin Schwidefsky63779812010-05-17 10:00:03 +0200751 mvc __LC_MCCK_ENTER_TIMER(8),__LC_CPU_TIMER_SAVE_AREA-4095(%r14)
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200752 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
753 jo 1f
754 la %r14,__LC_SYNC_ENTER_TIMER
755 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
756 jl 0f
757 la %r14,__LC_ASYNC_ENTER_TIMER
7580: clc 0(8,%r14),__LC_EXIT_TIMER
759 jl 0f
760 la %r14,__LC_EXIT_TIMER
7610: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
762 jl 0f
763 la %r14,__LC_LAST_UPDATE_TIMER
7640: spt 0(%r14)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200765 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
Martin Schwidefskyc185b782008-12-25 13:39:25 +01007661: tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700767 jno mcck_int_main # no -> skip cleanup critical
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200768 tm __LC_MCK_OLD_PSW+1,0x01 # test problem state bit
Heiko Carstens77fa2242005-06-25 14:55:30 -0700769 jnz mcck_int_main # from user -> load kernel stack
770 clc __LC_MCK_OLD_PSW+8(8),BASED(.Lcritical_end)
771 jhe mcck_int_main
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200772 clc __LC_MCK_OLD_PSW+8(8),BASED(.Lcritical_start)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700773 jl mcck_int_main
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200774 brasl %r14,cleanup_critical
Heiko Carstens77fa2242005-06-25 14:55:30 -0700775mcck_int_main:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200776 lg %r14,__LC_PANIC_STACK # are we already on the panic stack?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700777 slgr %r14,%r15
778 srag %r14,%r14,PAGE_SHIFT
779 jz 0f
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200780 lg %r15,__LC_PANIC_STACK # load panic stack
Martin Schwidefsky86f25522010-05-17 10:00:05 +02007810: aghi %r15,-SP_SIZE # make room for registers & psw
782 CREATE_STACK_FRAME __LC_SAVE_AREA+80
783 mvc SP_PSW(16,%r15),0(%r12)
784 lg %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700785 tm __LC_MCCK_CODE+2,0x08 # mwp of old psw valid?
786 jno mcck_no_vtime # no -> no timer update
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200787 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700788 jz mcck_no_vtime
Martin Schwidefsky63779812010-05-17 10:00:03 +0200789 UPDATE_VTIME __LC_EXIT_TIMER,__LC_MCCK_ENTER_TIMER,__LC_USER_TIMER
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700790 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
Martin Schwidefsky63779812010-05-17 10:00:03 +0200791 mvc __LC_LAST_UPDATE_TIMER(8),__LC_MCCK_ENTER_TIMER
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200792 LAST_BREAK
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700793mcck_no_vtime:
Heiko Carstens77fa2242005-06-25 14:55:30 -0700794 la %r2,SP_PTREGS(%r15) # load pt_regs
795 brasl %r14,s390_do_machine_check
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200796 tm SP_PSW+1(%r15),0x01 # returning to user ?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700797 jno mcck_return
798 lg %r1,__LC_KERNEL_STACK # switch to kernel stack
799 aghi %r1,-SP_SIZE
800 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
801 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) # clear back chain
802 lgr %r15,%r1
803 stosm __SF_EMPTY(%r15),0x04 # turn dat on
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200804 tm __TI_flags+7(%r12),_TIF_MCCK_PENDING
Heiko Carstens77fa2242005-06-25 14:55:30 -0700805 jno mcck_return
Carsten Ottecd3b70f2010-05-17 10:00:04 +0200806 HANDLE_SIE_INTERCEPT
Heiko Carstens1f194a42006-07-03 00:24:46 -0700807 TRACE_IRQS_OFF
Heiko Carstens77fa2242005-06-25 14:55:30 -0700808 brasl %r14,s390_handle_mcck
Heiko Carstens1f194a42006-07-03 00:24:46 -0700809 TRACE_IRQS_ON
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810mcck_return:
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200811 mvc __LC_RETURN_MCCK_PSW(16),SP_PSW(%r15) # move return PSW
812 ni __LC_RETURN_MCCK_PSW+1,0xfd # clear wait state bit
813 lmg %r0,%r15,SP_R0(%r15) # load gprs 0-15
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200814 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
815 jno 0f
816 stpt __LC_EXIT_TIMER
Martin Schwidefskyc185b782008-12-25 13:39:25 +01008170: lpswe __LC_RETURN_MCCK_PSW # back to caller
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200818mcck_done:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820/*
821 * Restart interruption handler, kick starter for additional CPUs
822 */
Heiko Carstens84b36a82007-06-19 13:10:03 +0200823#ifdef CONFIG_SMP
Heiko Carstens2bc89b52008-02-05 16:50:40 +0100824 __CPUINIT
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200825 .globl restart_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826restart_int_handler:
Martin Schwidefsky5b409ed2009-04-14 15:36:27 +0200827 basr %r1,0
828restart_base:
829 spt restart_vtime-restart_base(%r1)
830 stck __LC_LAST_UPDATE_CLOCK
831 mvc __LC_LAST_UPDATE_TIMER(8),restart_vtime-restart_base(%r1)
832 mvc __LC_EXIT_TIMER(8),restart_vtime-restart_base(%r1)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200833 lg %r15,__LC_SAVE_AREA+120 # load ksp
834 lghi %r10,__LC_CREGS_SAVE_AREA
835 lctlg %c0,%c15,0(%r10) # get new ctl regs
836 lghi %r10,__LC_AREGS_SAVE_AREA
837 lam %a0,%a15,0(%r10)
838 lmg %r6,%r15,__SF_GPRS(%r15) # load registers from clone
Martin Schwidefsky5b409ed2009-04-14 15:36:27 +0200839 lg %r1,__LC_THREAD_INFO
840 mvc __LC_USER_TIMER(8),__TI_user_timer(%r1)
841 mvc __LC_SYSTEM_TIMER(8),__TI_system_timer(%r1)
842 xc __LC_STEAL_TIMER(8),__LC_STEAL_TIMER
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200843 stosm __SF_EMPTY(%r15),0x04 # now we can turn dat on
Michael Holzheu8eb4bd62011-05-10 17:13:39 +0200844 brasl %r14,start_secondary
Martin Schwidefsky5b409ed2009-04-14 15:36:27 +0200845 .align 8
846restart_vtime:
847 .long 0x7fffffff,0xffffffff
Heiko Carstens84b36a82007-06-19 13:10:03 +0200848 .previous
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849#else
850/*
851 * If we do not run with SMP enabled, let the new CPU crash ...
852 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200853 .globl restart_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700854restart_int_handler:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200855 basr %r1,0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700856restart_base:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200857 lpswe restart_crash-restart_base(%r1)
858 .align 8
Linus Torvalds1da177e2005-04-16 15:20:36 -0700859restart_crash:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200860 .long 0x000a0000,0x00000000,0x00000000,0x00000000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700861restart_go:
862#endif
863
Martin Schwidefsky860dba42011-01-05 12:47:25 +0100864 .section .kprobes.text, "ax"
865
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866#ifdef CONFIG_CHECK_STACK
867/*
868 * The synchronous or the asynchronous stack overflowed. We are dead.
869 * No need to properly save the registers, we are going to panic anyway.
870 * Setup a pt_regs so that show_trace can provide a good call trace.
871 */
872stack_overflow:
873 lg %r15,__LC_PANIC_STACK # change to panic stack
Heiko Carstens9514e232006-09-20 15:59:22 +0200874 aghi %r15,-SP_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700875 mvc SP_PSW(16,%r15),0(%r12) # move user PSW to stack
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200876 stmg %r0,%r10,SP_R0(%r15) # store gprs %r0-%r10 to kernel stack
Linus Torvalds1da177e2005-04-16 15:20:36 -0700877 la %r1,__LC_SAVE_AREA
878 chi %r12,__LC_SVC_OLD_PSW
879 je 0f
880 chi %r12,__LC_PGM_OLD_PSW
881 je 0f
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200882 la %r1,__LC_SAVE_AREA+40
8830: mvc SP_R11(40,%r15),0(%r1) # move %r11-%r15 to stack
Christian Borntraeger9e74a6b82008-04-17 07:46:30 +0200884 mvc SP_ARGS(8,%r15),__LC_LAST_BREAK
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200885 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) # clear back chain
886 la %r2,SP_PTREGS(%r15) # load pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700887 jg kernel_stack_overflow
888#endif
889
890cleanup_table_system_call:
891 .quad system_call, sysc_do_svc
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200892cleanup_table_sysc_tif:
893 .quad sysc_tif, sysc_restore
894cleanup_table_sysc_restore:
895 .quad sysc_restore, sysc_done
896cleanup_table_io_tif:
897 .quad io_tif, io_restore
898cleanup_table_io_restore:
899 .quad io_restore, io_done
Linus Torvalds1da177e2005-04-16 15:20:36 -0700900
901cleanup_critical:
902 clc 8(8,%r12),BASED(cleanup_table_system_call)
903 jl 0f
904 clc 8(8,%r12),BASED(cleanup_table_system_call+8)
905 jl cleanup_system_call
9060:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200907 clc 8(8,%r12),BASED(cleanup_table_sysc_tif)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700908 jl 0f
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200909 clc 8(8,%r12),BASED(cleanup_table_sysc_tif+8)
910 jl cleanup_sysc_tif
Linus Torvalds1da177e2005-04-16 15:20:36 -07009110:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200912 clc 8(8,%r12),BASED(cleanup_table_sysc_restore)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700913 jl 0f
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200914 clc 8(8,%r12),BASED(cleanup_table_sysc_restore+8)
915 jl cleanup_sysc_restore
Linus Torvalds1da177e2005-04-16 15:20:36 -07009160:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200917 clc 8(8,%r12),BASED(cleanup_table_io_tif)
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200918 jl 0f
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200919 clc 8(8,%r12),BASED(cleanup_table_io_tif+8)
920 jl cleanup_io_tif
Martin Schwidefsky63b12242006-06-29 14:58:05 +02009210:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200922 clc 8(8,%r12),BASED(cleanup_table_io_restore)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700923 jl 0f
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200924 clc 8(8,%r12),BASED(cleanup_table_io_restore+8)
925 jl cleanup_io_restore
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07009260:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700927 br %r14
928
929cleanup_system_call:
930 mvc __LC_RETURN_PSW(16),0(%r12)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700931 clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn+8)
932 jh 0f
Martin Schwidefsky63779812010-05-17 10:00:03 +0200933 mvc __LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER
934 cghi %r12,__LC_MCK_OLD_PSW
935 je 0f
Linus Torvalds1da177e2005-04-16 15:20:36 -0700936 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
Martin Schwidefsky63779812010-05-17 10:00:03 +02009370: cghi %r12,__LC_MCK_OLD_PSW
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200938 la %r12,__LC_SAVE_AREA+80
Martin Schwidefsky63779812010-05-17 10:00:03 +0200939 je 0f
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200940 la %r12,__LC_SAVE_AREA+40
Linus Torvalds1da177e2005-04-16 15:20:36 -07009410: clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn+16)
942 jhe cleanup_vtime
Linus Torvalds1da177e2005-04-16 15:20:36 -0700943 clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn)
944 jh 0f
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200945 mvc __LC_SAVE_AREA(40),0(%r12)
9460: lg %r15,__LC_KERNEL_STACK # problem state -> load ksp
947 aghi %r15,-SP_SIZE # make room for registers & psw
948 stg %r15,32(%r12)
949 stg %r11,0(%r12)
950 CREATE_STACK_FRAME __LC_SAVE_AREA
951 mvc SP_PSW(16,%r15),__LC_SVC_OLD_PSW
952 mvc SP_ILC(4,%r15),__LC_SVC_ILC
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200953 mvc 8(8,%r12),__LC_THREAD_INFO
Linus Torvalds1da177e2005-04-16 15:20:36 -0700954cleanup_vtime:
955 clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn+24)
956 jhe cleanup_stime
Linus Torvalds1da177e2005-04-16 15:20:36 -0700957 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
958cleanup_stime:
959 clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn+32)
960 jh cleanup_update
961 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
962cleanup_update:
963 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200964 srag %r12,%r11,23
965 lg %r12,__LC_THREAD_INFO
966 jz 0f
967 stg %r11,__TI_last_break(%r12)
9680: mvc __LC_RETURN_PSW+8(8),BASED(cleanup_table_system_call+8)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700969 la %r12,__LC_RETURN_PSW
970 br %r14
971cleanup_system_call_insn:
972 .quad sysc_saveall
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200973 .quad system_call
974 .quad sysc_vtime
975 .quad sysc_stime
976 .quad sysc_update
Linus Torvalds1da177e2005-04-16 15:20:36 -0700977
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200978cleanup_sysc_tif:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700979 mvc __LC_RETURN_PSW(8),0(%r12)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200980 mvc __LC_RETURN_PSW+8(8),BASED(cleanup_table_sysc_tif)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700981 la %r12,__LC_RETURN_PSW
982 br %r14
983
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200984cleanup_sysc_restore:
985 clc 8(8,%r12),BASED(cleanup_sysc_restore_insn)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200986 je 2f
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200987 clc 8(8,%r12),BASED(cleanup_sysc_restore_insn+8)
Martin Schwidefskyc742b312008-12-31 15:11:42 +0100988 jhe 0f
Martin Schwidefsky63779812010-05-17 10:00:03 +0200989 mvc __LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
990 cghi %r12,__LC_MCK_OLD_PSW
991 je 0f
Martin Schwidefskyc742b312008-12-31 15:11:42 +0100992 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
9930: mvc __LC_RETURN_PSW(16),SP_PSW(%r15)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700994 cghi %r12,__LC_MCK_OLD_PSW
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200995 la %r12,__LC_SAVE_AREA+80
Martin Schwidefsky63779812010-05-17 10:00:03 +0200996 je 1f
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200997 la %r12,__LC_SAVE_AREA+40
9981: mvc 0(40,%r12),SP_R11(%r15)
999 lmg %r0,%r10,SP_R0(%r15)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001000 lg %r15,SP_R15(%r15)
Martin Schwidefsky63779812010-05-17 10:00:03 +020010012: la %r12,__LC_RETURN_PSW
Linus Torvalds1da177e2005-04-16 15:20:36 -07001002 br %r14
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +02001003cleanup_sysc_restore_insn:
Heiko Carstens411788e2007-11-20 11:13:32 +01001004 .quad sysc_done - 4
Martin Schwidefskyc742b312008-12-31 15:11:42 +01001005 .quad sysc_done - 16
Linus Torvalds1da177e2005-04-16 15:20:36 -07001006
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +02001007cleanup_io_tif:
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001008 mvc __LC_RETURN_PSW(8),0(%r12)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +02001009 mvc __LC_RETURN_PSW+8(8),BASED(cleanup_table_io_tif)
Martin Schwidefsky176b1802010-04-09 13:43:00 +02001010 la %r12,__LC_RETURN_PSW
1011 br %r14
1012
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +02001013cleanup_io_restore:
1014 clc 8(8,%r12),BASED(cleanup_io_restore_insn)
Martin Schwidefsky63779812010-05-17 10:00:03 +02001015 je 1f
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +02001016 clc 8(8,%r12),BASED(cleanup_io_restore_insn+8)
Martin Schwidefskyc742b312008-12-31 15:11:42 +01001017 jhe 0f
Martin Schwidefsky63779812010-05-17 10:00:03 +02001018 mvc __LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
Martin Schwidefskyc742b312008-12-31 15:11:42 +010010190: mvc __LC_RETURN_PSW(16),SP_PSW(%r15)
Martin Schwidefsky86f25522010-05-17 10:00:05 +02001020 mvc __LC_SAVE_AREA+80(40),SP_R11(%r15)
1021 lmg %r0,%r10,SP_R0(%r15)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001022 lg %r15,SP_R15(%r15)
Martin Schwidefsky63779812010-05-17 10:00:03 +020010231: la %r12,__LC_RETURN_PSW
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001024 br %r14
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +02001025cleanup_io_restore_insn:
Heiko Carstens411788e2007-11-20 11:13:32 +01001026 .quad io_done - 4
Martin Schwidefskyc742b312008-12-31 15:11:42 +01001027 .quad io_done - 16
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001028
Linus Torvalds1da177e2005-04-16 15:20:36 -07001029/*
1030 * Integer constants
1031 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001032 .align 4
Linus Torvalds1da177e2005-04-16 15:20:36 -07001033.Lcritical_start:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001034 .quad __critical_start
Linus Torvalds1da177e2005-04-16 15:20:36 -07001035.Lcritical_end:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001036 .quad __critical_end
Linus Torvalds1da177e2005-04-16 15:20:36 -07001037
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001038 .section .rodata, "a"
Linus Torvalds1da177e2005-04-16 15:20:36 -07001039#define SYSCALL(esa,esame,emu) .long esame
Heiko Carstens9bf12262009-06-12 10:26:47 +02001040 .globl sys_call_table
Linus Torvalds1da177e2005-04-16 15:20:36 -07001041sys_call_table:
1042#include "syscalls.S"
1043#undef SYSCALL
1044
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -08001045#ifdef CONFIG_COMPAT
Linus Torvalds1da177e2005-04-16 15:20:36 -07001046
1047#define SYSCALL(esa,esame,emu) .long emu
Linus Torvalds1da177e2005-04-16 15:20:36 -07001048sys_call_table_emu:
1049#include "syscalls.S"
1050#undef SYSCALL
1051#endif