blob: 84a105838e03d2765723a3b995d00133e434ea11 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Heiko Carstens54dfe5d2006-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 *
Heiko Carstens54dfe5d2006-02-01 03:06:38 -08005 * Copyright (C) IBM Corp. 1999,2006
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
12#include <linux/sys.h>
13#include <linux/linkage.h>
Heiko Carstens2bc89b52008-02-05 16:50:40 +010014#include <linux/init.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <asm/cache.h>
16#include <asm/lowcore.h>
17#include <asm/errno.h>
18#include <asm/ptrace.h>
19#include <asm/thread_info.h>
Sam Ravnborg0013a852005-09-09 20:57:26 +020020#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <asm/unistd.h>
22#include <asm/page.h>
23
24/*
25 * Stack layout for the system_call stack entry.
26 * The first few entries are identical to the user_regs_struct.
27 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +020028SP_PTREGS = STACK_FRAME_OVERHEAD
29SP_ARGS = STACK_FRAME_OVERHEAD + __PT_ARGS
30SP_PSW = STACK_FRAME_OVERHEAD + __PT_PSW
31SP_R0 = STACK_FRAME_OVERHEAD + __PT_GPRS
32SP_R1 = STACK_FRAME_OVERHEAD + __PT_GPRS + 8
33SP_R2 = STACK_FRAME_OVERHEAD + __PT_GPRS + 16
34SP_R3 = STACK_FRAME_OVERHEAD + __PT_GPRS + 24
35SP_R4 = STACK_FRAME_OVERHEAD + __PT_GPRS + 32
36SP_R5 = STACK_FRAME_OVERHEAD + __PT_GPRS + 40
37SP_R6 = STACK_FRAME_OVERHEAD + __PT_GPRS + 48
38SP_R7 = STACK_FRAME_OVERHEAD + __PT_GPRS + 56
39SP_R8 = STACK_FRAME_OVERHEAD + __PT_GPRS + 64
40SP_R9 = STACK_FRAME_OVERHEAD + __PT_GPRS + 72
41SP_R10 = STACK_FRAME_OVERHEAD + __PT_GPRS + 80
42SP_R11 = STACK_FRAME_OVERHEAD + __PT_GPRS + 88
43SP_R12 = STACK_FRAME_OVERHEAD + __PT_GPRS + 96
44SP_R13 = STACK_FRAME_OVERHEAD + __PT_GPRS + 104
45SP_R14 = STACK_FRAME_OVERHEAD + __PT_GPRS + 112
46SP_R15 = STACK_FRAME_OVERHEAD + __PT_GPRS + 120
47SP_ORIG_R2 = STACK_FRAME_OVERHEAD + __PT_ORIG_GPR2
48SP_ILC = STACK_FRAME_OVERHEAD + __PT_ILC
Martin Schwidefsky59da2132008-11-27 11:05:55 +010049SP_SVCNR = STACK_FRAME_OVERHEAD + __PT_SVCNR
Heiko Carstens25d83cb2006-09-28 16:56:37 +020050SP_SIZE = STACK_FRAME_OVERHEAD + __PT_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
53STACK_SIZE = 1 << STACK_SHIFT
54
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +020055_TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
Heiko Carstens54dfe5d2006-02-01 03:06:38 -080056 _TIF_MCCK_PENDING | _TIF_RESTART_SVC | _TIF_SINGLE_STEP )
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +020057_TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
Heiko Carstens54dfe5d2006-02-01 03:06:38 -080058 _TIF_MCCK_PENDING)
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60#define BASED(name) name-system_call(%r13)
61
Heiko Carstens1f194a42006-07-03 00:24:46 -070062#ifdef CONFIG_TRACE_IRQFLAGS
63 .macro TRACE_IRQS_ON
Heiko Carstens50bec4c2008-11-14 18:18:05 +010064 basr %r2,%r0
65 brasl %r14,trace_hardirqs_on_caller
Heiko Carstens1f194a42006-07-03 00:24:46 -070066 .endm
67
68 .macro TRACE_IRQS_OFF
Heiko Carstens50bec4c2008-11-14 18:18:05 +010069 basr %r2,%r0
70 brasl %r14,trace_hardirqs_off_caller
Heiko Carstens1f194a42006-07-03 00:24:46 -070071 .endm
Heiko Carstens523b44c2007-10-11 22:11:12 +020072
Heiko Carstens411788e2007-11-20 11:13:32 +010073 .macro TRACE_IRQS_CHECK
Heiko Carstens50bec4c2008-11-14 18:18:05 +010074 basr %r2,%r0
Heiko Carstens411788e2007-11-20 11:13:32 +010075 tm SP_PSW(%r15),0x03 # irqs enabled?
76 jz 0f
Heiko Carstens50bec4c2008-11-14 18:18:05 +010077 brasl %r14,trace_hardirqs_on_caller
Heiko Carstens411788e2007-11-20 11:13:32 +010078 j 1f
Heiko Carstens50bec4c2008-11-14 18:18:05 +0100790: brasl %r14,trace_hardirqs_off_caller
Heiko Carstens411788e2007-11-20 11:13:32 +0100801:
Heiko Carstens523b44c2007-10-11 22:11:12 +020081 .endm
Heiko Carstens1f194a42006-07-03 00:24:46 -070082#else
83#define TRACE_IRQS_ON
84#define TRACE_IRQS_OFF
Heiko Carstens411788e2007-11-20 11:13:32 +010085#define TRACE_IRQS_CHECK
86#endif
87
88#ifdef CONFIG_LOCKDEP
89 .macro LOCKDEP_SYS_EXIT
90 tm SP_PSW+1(%r15),0x01 # returning to user ?
91 jz 0f
92 brasl %r14,lockdep_sys_exit
930:
94 .endm
95#else
Heiko Carstens523b44c2007-10-11 22:11:12 +020096#define LOCKDEP_SYS_EXIT
Heiko Carstens1f194a42006-07-03 00:24:46 -070097#endif
98
Heiko Carstens25d83cb2006-09-28 16:56:37 +020099 .macro UPDATE_VTIME lc_from,lc_to,lc_sum
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 lg %r10,\lc_from
101 slg %r10,\lc_to
102 alg %r10,\lc_sum
103 stg %r10,\lc_sum
104 .endm
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105
106/*
107 * Register usage in interrupt handlers:
108 * R9 - pointer to current task structure
109 * R13 - pointer to literal pool
110 * R14 - return register for function calls
111 * R15 - kernel stack pointer
112 */
113
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200114 .macro SAVE_ALL_BASE savearea
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 stmg %r12,%r15,\savearea
116 larl %r13,system_call
117 .endm
118
Martin Schwidefsky987ad702007-07-10 11:24:18 +0200119 .macro SAVE_ALL_SVC psworg,savearea
120 la %r12,\psworg
121 lg %r15,__LC_KERNEL_STACK # problem state -> load ksp
122 .endm
123
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200124 .macro SAVE_ALL_SYNC psworg,savearea
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 la %r12,\psworg
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 tm \psworg+1,0x01 # test problem state bit
127 jz 2f # skip stack setup save
128 lg %r15,__LC_KERNEL_STACK # problem state -> load ksp
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200129#ifdef CONFIG_CHECK_STACK
130 j 3f
1312: tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
132 jz stack_overflow
1333:
134#endif
1352:
136 .endm
137
138 .macro SAVE_ALL_ASYNC psworg,savearea
139 la %r12,\psworg
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 tm \psworg+1,0x01 # test problem state bit
141 jnz 1f # from user -> load kernel stack
142 clc \psworg+8(8),BASED(.Lcritical_end)
143 jhe 0f
144 clc \psworg+8(8),BASED(.Lcritical_start)
145 jl 0f
146 brasl %r14,cleanup_critical
Peter Oberparleiter6add9f72005-09-16 19:27:42 -0700147 tm 1(%r12),0x01 # retest problem state after cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 jnz 1f
1490: lg %r14,__LC_ASYNC_STACK # are we already on the async. stack ?
150 slgr %r14,%r15
151 srag %r14,%r14,STACK_SHIFT
152 jz 2f
1531: lg %r15,__LC_ASYNC_STACK # load async stack
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154#ifdef CONFIG_CHECK_STACK
155 j 3f
1562: tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
157 jz stack_overflow
1583:
159#endif
Heiko Carstens77fa2242005-06-25 14:55:30 -07001602:
161 .endm
162
163 .macro CREATE_STACK_FRAME psworg,savearea
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200164 aghi %r15,-SP_SIZE # make room for registers & psw
165 mvc SP_PSW(16,%r15),0(%r12) # move user PSW to stack
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 stg %r2,SP_ORIG_R2(%r15) # store original content of gpr 2
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100167 icm %r12,3,__LC_SVC_ILC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 stmg %r0,%r11,SP_R0(%r15) # store gprs %r0-%r11 to kernel stack
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100169 st %r12,SP_SVCNR(%r15)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 mvc SP_R12(32,%r15),\savearea # move %r12-%r15 to stack
171 la %r12,0
172 stg %r12,__SF_BACKCHAIN(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200173 .endm
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700175 .macro RESTORE_ALL psworg,sync
176 mvc \psworg(16),SP_PSW(%r15) # move user PSW to lowcore
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 .if !\sync
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700178 ni \psworg+1,0xfd # clear wait state bit
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 .endif
Martin Schwidefskyc742b312008-12-31 15:11:42 +0100180 lg %r14,__LC_VDSO_PER_CPU
181 lmg %r0,%r13,SP_R0(%r15) # load gprs 0-13 of user
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100182 stpt __LC_EXIT_TIMER
Martin Schwidefskyc742b312008-12-31 15:11:42 +0100183 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
184 lmg %r14,%r15,SP_R14(%r15) # load grps 14-15 of user
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700185 lpswe \psworg # back to caller
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 .endm
187
188/*
189 * Scheduler resume function, called by switch_to
190 * gpr2 = (task_struct *) prev
191 * gpr3 = (task_struct *) next
192 * Returns:
193 * gpr2 = prev
194 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200195 .globl __switch_to
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196__switch_to:
197 tm __THREAD_per+4(%r3),0xe8 # is the new process using per ?
198 jz __switch_to_noper # if not we're fine
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200199 stctg %c9,%c11,__SF_EMPTY(%r15)# We are using per stuff
200 clc __THREAD_per(24,%r3),__SF_EMPTY(%r15)
201 je __switch_to_noper # we got away without bashing TLB's
202 lctlg %c9,%c11,__THREAD_per(%r3) # Nope we didn't
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203__switch_to_noper:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200204 lg %r4,__THREAD_info(%r2) # get thread_info of prev
Heiko Carstens77fa2242005-06-25 14:55:30 -0700205 tm __TI_flags+7(%r4),_TIF_MCCK_PENDING # machine check pending?
206 jz __switch_to_no_mcck
207 ni __TI_flags+7(%r4),255-_TIF_MCCK_PENDING # clear flag in prev
208 lg %r4,__THREAD_info(%r3) # get thread_info of next
209 oi __TI_flags+7(%r4),_TIF_MCCK_PENDING # set it in next
210__switch_to_no_mcck:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200211 stmg %r6,%r15,__SF_GPRS(%r15)# store __switch_to registers of prev task
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 stg %r15,__THREAD_ksp(%r2) # store kernel stack to prev->tss.ksp
213 lg %r15,__THREAD_ksp(%r3) # load kernel stack from next->tss.ksp
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200214 lmg %r6,%r15,__SF_GPRS(%r15)# load __switch_to registers of next task
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 stg %r3,__LC_CURRENT # __LC_CURRENT = current task struct
216 lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200217 lg %r3,__THREAD_info(%r3) # load thread_info from task struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 stg %r3,__LC_THREAD_INFO
219 aghi %r3,STACK_SIZE
220 stg %r3,__LC_KERNEL_STACK # __LC_KERNEL_STACK = new kernel stack
221 br %r14
222
223__critical_start:
224/*
225 * SVC interrupt handler routine. System calls are synchronous events and
226 * are executed with interrupts enabled.
227 */
228
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200229 .globl system_call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230system_call:
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100231 stpt __LC_SYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232sysc_saveall:
233 SAVE_ALL_BASE __LC_SAVE_AREA
Martin Schwidefsky987ad702007-07-10 11:24:18 +0200234 SAVE_ALL_SVC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200235 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
236 llgh %r7,__LC_SVC_INT_CODE # get svc number from lowcore
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237sysc_vtime:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
239sysc_stime:
240 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
241sysc_update:
242 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243sysc_do_svc:
244 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100245 ltgr %r7,%r7 # test for svc 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 jnz sysc_nr_ok
247 # svc 0: system call number in %r1
248 cl %r1,BASED(.Lnr_syscalls)
249 jnl sysc_nr_ok
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200250 lgfr %r7,%r1 # clear high word in r1
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251sysc_nr_ok:
252 mvc SP_ARGS(8,%r15),SP_R7(%r15)
253sysc_do_restart:
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100254 sth %r7,SP_SVCNR(%r15)
255 sllg %r7,%r7,2 # svc number * 4
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200256 larl %r10,sys_call_table
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800257#ifdef CONFIG_COMPAT
Heiko Carstensc5630772005-09-03 15:58:04 -0700258 tm __TI_flags+5(%r9),(_TIF_31BIT>>16) # running in 31 bit mode ?
259 jno sysc_noemu
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200260 larl %r10,sys_call_table_emu # use 31 bit emulation system calls
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261sysc_noemu:
262#endif
263 tm __TI_flags+7(%r9),(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200264 lgf %r8,0(%r7,%r10) # load address of system call routine
265 jnz sysc_tracesys
266 basr %r14,%r8 # call sys_xxxx
267 stg %r2,SP_R2(%r15) # store return value (change R2 on stack)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268
269sysc_return:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270 tm __TI_flags+7(%r9),_TIF_WORK_SVC
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200271 jnz sysc_work # there is work to do (signals etc.)
Heiko Carstens411788e2007-11-20 11:13:32 +0100272sysc_restore:
273#ifdef CONFIG_TRACE_IRQFLAGS
274 larl %r1,sysc_restore_trace_psw
275 lpswe 0(%r1)
276sysc_restore_trace:
277 TRACE_IRQS_CHECK
Heiko Carstens523b44c2007-10-11 22:11:12 +0200278 LOCKDEP_SYS_EXIT
Heiko Carstens411788e2007-11-20 11:13:32 +0100279#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280sysc_leave:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200281 RESTORE_ALL __LC_RETURN_PSW,1
Heiko Carstens411788e2007-11-20 11:13:32 +0100282sysc_done:
283
284#ifdef CONFIG_TRACE_IRQFLAGS
285 .align 8
286 .globl sysc_restore_trace_psw
287sysc_restore_trace_psw:
288 .quad 0, sysc_restore_trace
289#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290
291#
292# recheck if there is more work to do
293#
294sysc_work_loop:
295 tm __TI_flags+7(%r9),_TIF_WORK_SVC
Heiko Carstens411788e2007-11-20 11:13:32 +0100296 jz sysc_restore # there is no work to do
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297#
298# One of the work bits is on. Find out which one.
299#
300sysc_work:
Martin Schwidefsky26889052008-05-07 09:22:52 +0200301 tm SP_PSW+1(%r15),0x01 # returning to user ?
302 jno sysc_restore
Heiko Carstens77fa2242005-06-25 14:55:30 -0700303 tm __TI_flags+7(%r9),_TIF_MCCK_PENDING
304 jo sysc_mcck_pending
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 tm __TI_flags+7(%r9),_TIF_NEED_RESCHED
306 jo sysc_reschedule
Roland McGrath02a029b2008-04-30 00:53:08 -0700307 tm __TI_flags+7(%r9),_TIF_SIGPENDING
Heiko Carstens54dfe5d2006-02-01 03:06:38 -0800308 jnz sysc_sigpending
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200309 tm __TI_flags+7(%r9),_TIF_NOTIFY_RESUME
310 jnz sysc_notify_resume
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 tm __TI_flags+7(%r9),_TIF_RESTART_SVC
312 jo sysc_restart
313 tm __TI_flags+7(%r9),_TIF_SINGLE_STEP
314 jo sysc_singlestep
Heiko Carstens411788e2007-11-20 11:13:32 +0100315 j sysc_restore
316sysc_work_done:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317
318#
319# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200320#
321sysc_reschedule:
322 larl %r14,sysc_work_loop
323 jg schedule # return point is sysc_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324
325#
Heiko Carstens77fa2242005-06-25 14:55:30 -0700326# _TIF_MCCK_PENDING is set, call handler
327#
328sysc_mcck_pending:
329 larl %r14,sysc_work_loop
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200330 jg s390_handle_mcck # TIF bit will be cleared by handler
Heiko Carstens77fa2242005-06-25 14:55:30 -0700331
332#
Roland McGrath02a029b2008-04-30 00:53:08 -0700333# _TIF_SIGPENDING is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334#
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200335sysc_sigpending:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336 ni __TI_flags+7(%r9),255-_TIF_SINGLE_STEP # clear TIF_SINGLE_STEP
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200337 la %r2,SP_PTREGS(%r15) # load pt_regs
338 brasl %r14,do_signal # call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 tm __TI_flags+7(%r9),_TIF_RESTART_SVC
340 jo sysc_restart
341 tm __TI_flags+7(%r9),_TIF_SINGLE_STEP
342 jo sysc_singlestep
Heiko Carstense1c3ad92005-11-07 00:59:02 -0800343 j sysc_work_loop
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344
345#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200346# _TIF_NOTIFY_RESUME is set, call do_notify_resume
347#
348sysc_notify_resume:
349 la %r2,SP_PTREGS(%r15) # load pt_regs
350 larl %r14,sysc_work_loop
351 jg do_notify_resume # call do_notify_resume
352
353#
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354# _TIF_RESTART_SVC is set, set up registers and restart svc
355#
356sysc_restart:
357 ni __TI_flags+7(%r9),255-_TIF_RESTART_SVC # clear TIF_RESTART_SVC
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200358 lg %r7,SP_R2(%r15) # load new svc number
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 mvc SP_R2(8,%r15),SP_ORIG_R2(%r15) # restore first argument
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200360 lmg %r2,%r6,SP_R2(%r15) # load svc arguments
361 j sysc_do_restart # restart svc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362
363#
364# _TIF_SINGLE_STEP is set, call do_single_step
365#
366sysc_singlestep:
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100367 ni __TI_flags+7(%r9),255-_TIF_SINGLE_STEP # clear TIF_SINGLE_STEP
368 xc SP_SVCNR(2,%r15),SP_SVCNR(%r15) # clear svc number
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 la %r2,SP_PTREGS(%r15) # address of register-save area
370 larl %r14,sysc_return # load adr. of system return
371 jg do_single_step # branch to do_sigtrap
372
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200374# call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
375# and after the system call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376#
377sysc_tracesys:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200378 la %r2,SP_PTREGS(%r15) # load pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 la %r3,0
380 srl %r7,2
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200381 stg %r7,SP_R2(%r15)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200382 brasl %r14,do_syscall_trace_enter
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383 lghi %r0,NR_syscalls
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200384 clgr %r0,%r2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 jnh sysc_tracenogo
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100386 sllg %r7,%r2,2 # svc number *4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 lgf %r8,0(%r7,%r10)
388sysc_tracego:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200389 lmg %r3,%r6,SP_R3(%r15)
390 lg %r2,SP_ORIG_R2(%r15)
391 basr %r14,%r8 # call sys_xxx
392 stg %r2,SP_R2(%r15) # store return value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393sysc_tracenogo:
394 tm __TI_flags+7(%r9),(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200395 jz sysc_return
396 la %r2,SP_PTREGS(%r15) # load pt_regs
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200397 larl %r14,sysc_return # return point is sysc_return
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200398 jg do_syscall_trace_exit
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399
400#
401# a new process exits the kernel with ret_from_fork
402#
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200403 .globl ret_from_fork
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404ret_from_fork:
405 lg %r13,__LC_SVC_NEW_PSW+8
406 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
407 tm SP_PSW+1(%r15),0x01 # forking a kernel thread ?
408 jo 0f
409 stg %r15,SP_R15(%r15) # store stack pointer for new kthread
Heiko Carstens25d83cb2006-09-28 16:56:37 +02004100: brasl %r14,schedule_tail
Heiko Carstens1f194a42006-07-03 00:24:46 -0700411 TRACE_IRQS_ON
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200412 stosm 24(%r15),0x03 # reenable interrupts
Al Viro8f2961c2008-12-25 13:37:58 +0100413 j sysc_tracenogo
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414
415#
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200416# kernel_execve function needs to deal with pt_regs that is not
417# at the usual place
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418#
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200419 .globl kernel_execve
420kernel_execve:
421 stmg %r12,%r15,96(%r15)
422 lgr %r14,%r15
423 aghi %r15,-SP_SIZE
424 stg %r14,__SF_BACKCHAIN(%r15)
425 la %r12,SP_PTREGS(%r15)
426 xc 0(__PT_SIZE,%r12),0(%r12)
427 lgr %r5,%r12
428 brasl %r14,do_execve
429 ltgfr %r2,%r2
430 je 0f
431 aghi %r15,SP_SIZE
432 lmg %r12,%r15,96(%r15)
433 br %r14
434 # execve succeeded.
4350: stnsm __SF_EMPTY(%r15),0xfc # disable interrupts
436 lg %r15,__LC_KERNEL_STACK # load ksp
437 aghi %r15,-SP_SIZE # make room for registers & psw
438 lg %r13,__LC_SVC_NEW_PSW+8
439 lg %r9,__LC_THREAD_INFO
440 mvc SP_PTREGS(__PT_SIZE,%r15),0(%r12) # copy pt_regs
441 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
442 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
443 brasl %r14,execve_tail
444 j sysc_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445
446/*
447 * Program check handler routine
448 */
449
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200450 .globl pgm_check_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451pgm_check_handler:
452/*
453 * First we need to check for a special case:
454 * Single stepping an instruction that disables the PER event mask will
455 * cause a PER event AFTER the mask has been set. Example: SVC or LPSW.
456 * For a single stepped SVC the program check handler gets control after
457 * the SVC new PSW has been loaded. But we want to execute the SVC first and
458 * then handle the PER event. Therefore we update the SVC old PSW to point
459 * to the pgm_check_handler and branch to the SVC handler after we checked
460 * if we have to load the kernel stack register.
461 * For every other possible cause for PER event without the PER mask set
462 * we just ignore the PER event (FIXME: is there anything we have to do
463 * for LPSW?).
464 */
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100465 stpt __LC_SYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 SAVE_ALL_BASE __LC_SAVE_AREA
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200467 tm __LC_PGM_INT_CODE+1,0x80 # check whether we got a per exception
468 jnz pgm_per # got per exception -> special case
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200469 SAVE_ALL_SYNC __LC_PGM_OLD_PSW,__LC_SAVE_AREA
Heiko Carstens77fa2242005-06-25 14:55:30 -0700470 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
472 jz pgm_no_vtime
473 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
474 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
475 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
476pgm_no_vtime:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
Christian Borntraeger9e74a6b82008-04-17 07:46:30 +0200478 mvc SP_ARGS(8,%r15),__LC_LAST_BREAK
Heiko Carstens411788e2007-11-20 11:13:32 +0100479 TRACE_IRQS_OFF
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200480 lgf %r3,__LC_PGM_ILC # load program interruption code
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481 lghi %r8,0x7f
482 ngr %r8,%r3
483pgm_do_call:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200484 sll %r8,3
485 larl %r1,pgm_check_table
486 lg %r1,0(%r8,%r1) # load address of handler routine
487 la %r2,SP_PTREGS(%r15) # address of register-save area
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 larl %r14,sysc_return
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200489 br %r1 # branch to interrupt-handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490
491#
492# handle per exception
493#
494pgm_per:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200495 tm __LC_PGM_OLD_PSW,0x40 # test if per event recording is on
496 jnz pgm_per_std # ok, normal per event from user space
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497# ok its one of the special cases, now we need to find out which one
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200498 clc __LC_PGM_OLD_PSW(16),__LC_SVC_NEW_PSW
499 je pgm_svcper
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500# no interesting special case, ignore PER event
501 lmg %r12,%r15,__LC_SAVE_AREA
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200502 lpswe __LC_PGM_OLD_PSW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503
504#
505# Normal per exception
506#
507pgm_per_std:
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200508 SAVE_ALL_SYNC __LC_PGM_OLD_PSW,__LC_SAVE_AREA
Heiko Carstens77fa2242005-06-25 14:55:30 -0700509 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
511 jz pgm_no_vtime2
512 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
513 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
514 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
515pgm_no_vtime2:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
Heiko Carstens411788e2007-11-20 11:13:32 +0100517 TRACE_IRQS_OFF
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 lg %r1,__TI_task(%r9)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200519 tm SP_PSW+1(%r15),0x01 # kernel per event ?
520 jz kernel_per
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 mvc __THREAD_per+__PER_atmid(2,%r1),__LC_PER_ATMID
522 mvc __THREAD_per+__PER_address(8,%r1),__LC_PER_ADDRESS
523 mvc __THREAD_per+__PER_access_id(1,%r1),__LC_PER_ACCESS_ID
524 oi __TI_flags+7(%r9),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200525 lgf %r3,__LC_PGM_ILC # load program interruption code
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 lghi %r8,0x7f
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200527 ngr %r8,%r3 # clear per-event-bit and ilc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 je sysc_return
529 j pgm_do_call
530
531#
532# it was a single stepped SVC that is causing all the trouble
533#
534pgm_svcper:
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200535 SAVE_ALL_SYNC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Heiko Carstens77fa2242005-06-25 14:55:30 -0700536 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
538 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
539 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200540 llgh %r7,__LC_SVC_INT_CODE # get svc number from lowcore
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
542 lg %r1,__TI_task(%r9)
543 mvc __THREAD_per+__PER_atmid(2,%r1),__LC_PER_ATMID
544 mvc __THREAD_per+__PER_address(8,%r1),__LC_PER_ADDRESS
545 mvc __THREAD_per+__PER_access_id(1,%r1),__LC_PER_ACCESS_ID
546 oi __TI_flags+7(%r9),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP
Heiko Carstens1f194a42006-07-03 00:24:46 -0700547 TRACE_IRQS_ON
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
549 j sysc_do_svc
550
Michael Grundy4ba069b2006-09-20 15:58:39 +0200551#
552# per was called from kernel, must be kprobes
553#
554kernel_per:
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100555 xc SP_SVCNR(2,%r15),SP_SVCNR(%r15) # clear svc number
Michael Grundy4ba069b2006-09-20 15:58:39 +0200556 la %r2,SP_PTREGS(%r15) # address of register-save area
Heiko Carstens411788e2007-11-20 11:13:32 +0100557 larl %r14,sysc_restore # load adr. of system ret, no work
Michael Grundy4ba069b2006-09-20 15:58:39 +0200558 jg do_single_step # branch to do_single_step
559
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560/*
561 * IO interrupt handler routine
562 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200563 .globl io_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564io_int_handler:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 stck __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100566 stpt __LC_ASYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 SAVE_ALL_BASE __LC_SAVE_AREA+32
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200568 SAVE_ALL_ASYNC __LC_IO_OLD_PSW,__LC_SAVE_AREA+32
Heiko Carstens77fa2242005-06-25 14:55:30 -0700569 CREATE_STACK_FRAME __LC_IO_OLD_PSW,__LC_SAVE_AREA+32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
571 jz io_no_vtime
572 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
573 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
574 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
575io_no_vtime:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
Heiko Carstens1f194a42006-07-03 00:24:46 -0700577 TRACE_IRQS_OFF
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200578 la %r2,SP_PTREGS(%r15) # address of register-save area
579 brasl %r14,do_IRQ # call standard irq handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580io_return:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 tm __TI_flags+7(%r9),_TIF_WORK_INT
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200582 jnz io_work # there is work to do (signals etc.)
Heiko Carstens411788e2007-11-20 11:13:32 +0100583io_restore:
584#ifdef CONFIG_TRACE_IRQFLAGS
585 larl %r1,io_restore_trace_psw
586 lpswe 0(%r1)
587io_restore_trace:
588 TRACE_IRQS_CHECK
Heiko Carstens523b44c2007-10-11 22:11:12 +0200589 LOCKDEP_SYS_EXIT
Heiko Carstens411788e2007-11-20 11:13:32 +0100590#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591io_leave:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200592 RESTORE_ALL __LC_RETURN_PSW,0
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700593io_done:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594
Heiko Carstens411788e2007-11-20 11:13:32 +0100595#ifdef CONFIG_TRACE_IRQFLAGS
596 .align 8
597 .globl io_restore_trace_psw
598io_restore_trace_psw:
599 .quad 0, io_restore_trace
600#endif
601
Martin Schwidefsky26889052008-05-07 09:22:52 +0200602#
Christian Borntraeger0eaeafa2008-05-07 09:22:53 +0200603# There is work todo, we need to check if we return to userspace, then
604# check, if we are in SIE, if yes leave it
Martin Schwidefsky26889052008-05-07 09:22:52 +0200605#
606io_work:
607 tm SP_PSW+1(%r15),0x01 # returning to user ?
608#ifndef CONFIG_PREEMPT
Christian Borntraeger0eaeafa2008-05-07 09:22:53 +0200609#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
610 jnz io_work_user # yes -> no need to check for SIE
611 la %r1, BASED(sie_opcode) # we return to kernel here
612 lg %r2, SP_PSW+8(%r15)
613 clc 0(2,%r1), 0(%r2) # is current instruction = SIE?
614 jne io_restore # no-> return to kernel
615 lg %r1, SP_PSW+8(%r15) # yes-> add 4 bytes to leave SIE
616 aghi %r1, 4
617 stg %r1, SP_PSW+8(%r15)
618 j io_restore # return to kernel
619#else
Martin Schwidefsky26889052008-05-07 09:22:52 +0200620 jno io_restore # no-> skip resched & signal
Christian Borntraeger0eaeafa2008-05-07 09:22:53 +0200621#endif
Martin Schwidefsky26889052008-05-07 09:22:52 +0200622#else
623 jnz io_work_user # yes -> do resched & signal
Christian Borntraeger0eaeafa2008-05-07 09:22:53 +0200624#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
625 la %r1, BASED(sie_opcode)
626 lg %r2, SP_PSW+8(%r15)
627 clc 0(2,%r1), 0(%r2) # is current instruction = SIE?
628 jne 0f # no -> leave PSW alone
629 lg %r1, SP_PSW+8(%r15) # yes-> add 4 bytes to leave SIE
630 aghi %r1, 4
631 stg %r1, SP_PSW+8(%r15)
6320:
633#endif
Martin Schwidefsky26889052008-05-07 09:22:52 +0200634 # check for preemptive scheduling
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200635 icm %r0,15,__TI_precount(%r9)
Martin Schwidefsky26889052008-05-07 09:22:52 +0200636 jnz io_restore # preemption is disabled
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 # switch to kernel stack
638 lg %r1,SP_R15(%r15)
639 aghi %r1,-SP_SIZE
640 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200641 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) # clear back chain
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642 lgr %r15,%r1
643io_resume_loop:
644 tm __TI_flags+7(%r9),_TIF_NEED_RESCHED
Heiko Carstens411788e2007-11-20 11:13:32 +0100645 jno io_restore
Heiko Carstensb8e7a542007-11-20 11:13:35 +0100646 larl %r14,io_resume_loop
647 jg preempt_schedule_irq
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648#endif
649
Martin Schwidefsky26889052008-05-07 09:22:52 +0200650io_work_user:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651 lg %r1,__LC_KERNEL_STACK
652 aghi %r1,-SP_SIZE
653 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200654 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) # clear back chain
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 lgr %r15,%r1
656#
657# One of the work bits is on. Find out which one.
Heiko Carstens54dfe5d2006-02-01 03:06:38 -0800658# Checked are: _TIF_SIGPENDING, _TIF_RESTORE_SIGPENDING, _TIF_NEED_RESCHED
659# and _TIF_MCCK_PENDING
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660#
661io_work_loop:
Heiko Carstens77fa2242005-06-25 14:55:30 -0700662 tm __TI_flags+7(%r9),_TIF_MCCK_PENDING
663 jo io_mcck_pending
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 tm __TI_flags+7(%r9),_TIF_NEED_RESCHED
665 jo io_reschedule
Roland McGrath02a029b2008-04-30 00:53:08 -0700666 tm __TI_flags+7(%r9),_TIF_SIGPENDING
Heiko Carstens54dfe5d2006-02-01 03:06:38 -0800667 jnz io_sigpending
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200668 tm __TI_flags+7(%r9),_TIF_NOTIFY_RESUME
669 jnz io_notify_resume
Heiko Carstens411788e2007-11-20 11:13:32 +0100670 j io_restore
671io_work_done:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672
Christian Borntraeger0eaeafa2008-05-07 09:22:53 +0200673#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
674sie_opcode:
675 .long 0xb2140000
676#endif
677
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678#
Heiko Carstens77fa2242005-06-25 14:55:30 -0700679# _TIF_MCCK_PENDING is set, call handler
680#
681io_mcck_pending:
Heiko Carstensb771aea2007-07-27 12:29:18 +0200682 brasl %r14,s390_handle_mcck # TIF bit will be cleared by handler
Heiko Carstensb771aea2007-07-27 12:29:18 +0200683 j io_work_loop
Heiko Carstens77fa2242005-06-25 14:55:30 -0700684
685#
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200687#
688io_reschedule:
Heiko Carstens411788e2007-11-20 11:13:32 +0100689 TRACE_IRQS_ON
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200690 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
691 brasl %r14,schedule # call scheduler
692 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100693 TRACE_IRQS_OFF
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694 tm __TI_flags+7(%r9),_TIF_WORK_INT
Heiko Carstens411788e2007-11-20 11:13:32 +0100695 jz io_restore # there is no work to do
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696 j io_work_loop
697
698#
Roland McGrath02a029b2008-04-30 00:53:08 -0700699# _TIF_SIGPENDING or is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700#
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200701io_sigpending:
Heiko Carstens411788e2007-11-20 11:13:32 +0100702 TRACE_IRQS_ON
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200703 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
704 la %r2,SP_PTREGS(%r15) # load pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700705 brasl %r14,do_signal # call do_signal
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200706 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100707 TRACE_IRQS_OFF
Heiko Carstense1c3ad92005-11-07 00:59:02 -0800708 j io_work_loop
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200710#
711# _TIF_NOTIFY_RESUME or is set, call do_notify_resume
712#
713io_notify_resume:
714 TRACE_IRQS_ON
715 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
716 la %r2,SP_PTREGS(%r15) # load pt_regs
717 brasl %r14,do_notify_resume # call do_notify_resume
718 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
719 TRACE_IRQS_OFF
720 j io_work_loop
721
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722/*
723 * External interrupt handler routine
724 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200725 .globl ext_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726ext_int_handler:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 stck __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100728 stpt __LC_ASYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729 SAVE_ALL_BASE __LC_SAVE_AREA+32
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200730 SAVE_ALL_ASYNC __LC_EXT_OLD_PSW,__LC_SAVE_AREA+32
Heiko Carstens77fa2242005-06-25 14:55:30 -0700731 CREATE_STACK_FRAME __LC_EXT_OLD_PSW,__LC_SAVE_AREA+32
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
733 jz ext_no_vtime
734 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
735 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
736 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
737ext_no_vtime:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
Heiko Carstens1f194a42006-07-03 00:24:46 -0700739 TRACE_IRQS_OFF
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200740 la %r2,SP_PTREGS(%r15) # address of register-save area
741 llgh %r3,__LC_EXT_INT_CODE # get interruption code
742 brasl %r14,do_extint
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743 j io_return
744
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700745__critical_end:
746
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747/*
748 * Machine check handler routines
749 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200750 .globl mcck_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751mcck_int_handler:
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100752 stck __LC_INT_CLOCK
Heiko Carstens77fa2242005-06-25 14:55:30 -0700753 la %r1,4095 # revalidate r1
754 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # revalidate cpu timer
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200755 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# revalidate gprs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 SAVE_ALL_BASE __LC_SAVE_AREA+64
Heiko Carstens77fa2242005-06-25 14:55:30 -0700757 la %r12,__LC_MCK_OLD_PSW
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200758 tm __LC_MCCK_CODE,0x80 # system damage?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700759 jo mcck_int_main # yes -> rest of mcck code invalid
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200760 la %r14,4095
761 mvc __LC_SAVE_AREA+104(8),__LC_ASYNC_ENTER_TIMER
762 mvc __LC_ASYNC_ENTER_TIMER(8),__LC_CPU_TIMER_SAVE_AREA-4095(%r14)
763 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
764 jo 1f
765 la %r14,__LC_SYNC_ENTER_TIMER
766 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
767 jl 0f
768 la %r14,__LC_ASYNC_ENTER_TIMER
7690: clc 0(8,%r14),__LC_EXIT_TIMER
770 jl 0f
771 la %r14,__LC_EXIT_TIMER
7720: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
773 jl 0f
774 la %r14,__LC_LAST_UPDATE_TIMER
7750: spt 0(%r14)
776 mvc __LC_ASYNC_ENTER_TIMER(8),0(%r14)
Martin Schwidefskyc185b782008-12-25 13:39:25 +01007771: tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700778 jno mcck_int_main # no -> skip cleanup critical
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200779 tm __LC_MCK_OLD_PSW+1,0x01 # test problem state bit
Heiko Carstens77fa2242005-06-25 14:55:30 -0700780 jnz mcck_int_main # from user -> load kernel stack
781 clc __LC_MCK_OLD_PSW+8(8),BASED(.Lcritical_end)
782 jhe mcck_int_main
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200783 clc __LC_MCK_OLD_PSW+8(8),BASED(.Lcritical_start)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700784 jl mcck_int_main
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200785 brasl %r14,cleanup_critical
Heiko Carstens77fa2242005-06-25 14:55:30 -0700786mcck_int_main:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200787 lg %r14,__LC_PANIC_STACK # are we already on the panic stack?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700788 slgr %r14,%r15
789 srag %r14,%r14,PAGE_SHIFT
790 jz 0f
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200791 lg %r15,__LC_PANIC_STACK # load panic stack
Heiko Carstens77fa2242005-06-25 14:55:30 -07007920: CREATE_STACK_FRAME __LC_MCK_OLD_PSW,__LC_SAVE_AREA+64
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700793 tm __LC_MCCK_CODE+2,0x08 # mwp of old psw valid?
794 jno mcck_no_vtime # no -> no timer update
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200795 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700796 jz mcck_no_vtime
797 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
798 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
799 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
800mcck_no_vtime:
Heiko Carstens77fa2242005-06-25 14:55:30 -0700801 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
802 la %r2,SP_PTREGS(%r15) # load pt_regs
803 brasl %r14,s390_do_machine_check
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200804 tm SP_PSW+1(%r15),0x01 # returning to user ?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700805 jno mcck_return
806 lg %r1,__LC_KERNEL_STACK # switch to kernel stack
807 aghi %r1,-SP_SIZE
808 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
809 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) # clear back chain
810 lgr %r15,%r1
811 stosm __SF_EMPTY(%r15),0x04 # turn dat on
812 tm __TI_flags+7(%r9),_TIF_MCCK_PENDING
813 jno mcck_return
Heiko Carstens1f194a42006-07-03 00:24:46 -0700814 TRACE_IRQS_OFF
Heiko Carstens77fa2242005-06-25 14:55:30 -0700815 brasl %r14,s390_handle_mcck
Heiko Carstens1f194a42006-07-03 00:24:46 -0700816 TRACE_IRQS_ON
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817mcck_return:
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200818 mvc __LC_RETURN_MCCK_PSW(16),SP_PSW(%r15) # move return PSW
819 ni __LC_RETURN_MCCK_PSW+1,0xfd # clear wait state bit
820 lmg %r0,%r15,SP_R0(%r15) # load gprs 0-15
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200821 mvc __LC_ASYNC_ENTER_TIMER(8),__LC_SAVE_AREA+104
822 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
823 jno 0f
824 stpt __LC_EXIT_TIMER
Martin Schwidefskyc185b782008-12-25 13:39:25 +01008250: lpswe __LC_RETURN_MCCK_PSW # back to caller
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827/*
828 * Restart interruption handler, kick starter for additional CPUs
829 */
Heiko Carstens84b36a82007-06-19 13:10:03 +0200830#ifdef CONFIG_SMP
Heiko Carstens2bc89b52008-02-05 16:50:40 +0100831 __CPUINIT
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200832 .globl restart_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700833restart_int_handler:
Martin Schwidefsky5b409ed2009-04-14 15:36:27 +0200834 basr %r1,0
835restart_base:
836 spt restart_vtime-restart_base(%r1)
837 stck __LC_LAST_UPDATE_CLOCK
838 mvc __LC_LAST_UPDATE_TIMER(8),restart_vtime-restart_base(%r1)
839 mvc __LC_EXIT_TIMER(8),restart_vtime-restart_base(%r1)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200840 lg %r15,__LC_SAVE_AREA+120 # load ksp
841 lghi %r10,__LC_CREGS_SAVE_AREA
842 lctlg %c0,%c15,0(%r10) # get new ctl regs
843 lghi %r10,__LC_AREGS_SAVE_AREA
844 lam %a0,%a15,0(%r10)
845 lmg %r6,%r15,__SF_GPRS(%r15) # load registers from clone
Martin Schwidefsky5b409ed2009-04-14 15:36:27 +0200846 lg %r1,__LC_THREAD_INFO
847 mvc __LC_USER_TIMER(8),__TI_user_timer(%r1)
848 mvc __LC_SYSTEM_TIMER(8),__TI_system_timer(%r1)
849 xc __LC_STEAL_TIMER(8),__LC_STEAL_TIMER
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200850 stosm __SF_EMPTY(%r15),0x04 # now we can turn dat on
851 jg start_secondary
Martin Schwidefsky5b409ed2009-04-14 15:36:27 +0200852 .align 8
853restart_vtime:
854 .long 0x7fffffff,0xffffffff
Heiko Carstens84b36a82007-06-19 13:10:03 +0200855 .previous
Linus Torvalds1da177e2005-04-16 15:20:36 -0700856#else
857/*
858 * If we do not run with SMP enabled, let the new CPU crash ...
859 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200860 .globl restart_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700861restart_int_handler:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200862 basr %r1,0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700863restart_base:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200864 lpswe restart_crash-restart_base(%r1)
865 .align 8
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866restart_crash:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200867 .long 0x000a0000,0x00000000,0x00000000,0x00000000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700868restart_go:
869#endif
870
871#ifdef CONFIG_CHECK_STACK
872/*
873 * The synchronous or the asynchronous stack overflowed. We are dead.
874 * No need to properly save the registers, we are going to panic anyway.
875 * Setup a pt_regs so that show_trace can provide a good call trace.
876 */
877stack_overflow:
878 lg %r15,__LC_PANIC_STACK # change to panic stack
Heiko Carstens9514e232006-09-20 15:59:22 +0200879 aghi %r15,-SP_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700880 mvc SP_PSW(16,%r15),0(%r12) # move user PSW to stack
881 stmg %r0,%r11,SP_R0(%r15) # store gprs %r0-%r11 to kernel stack
882 la %r1,__LC_SAVE_AREA
883 chi %r12,__LC_SVC_OLD_PSW
884 je 0f
885 chi %r12,__LC_PGM_OLD_PSW
886 je 0f
Heiko Carstens9514e232006-09-20 15:59:22 +0200887 la %r1,__LC_SAVE_AREA+32
Heiko Carstens25d83cb2006-09-28 16:56:37 +02008880: mvc SP_R12(32,%r15),0(%r1) # move %r12-%r15 to stack
Christian Borntraeger9e74a6b82008-04-17 07:46:30 +0200889 mvc SP_ARGS(8,%r15),__LC_LAST_BREAK
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200890 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) # clear back chain
891 la %r2,SP_PTREGS(%r15) # load pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700892 jg kernel_stack_overflow
893#endif
894
895cleanup_table_system_call:
896 .quad system_call, sysc_do_svc
897cleanup_table_sysc_return:
898 .quad sysc_return, sysc_leave
899cleanup_table_sysc_leave:
Heiko Carstens411788e2007-11-20 11:13:32 +0100900 .quad sysc_leave, sysc_done
Linus Torvalds1da177e2005-04-16 15:20:36 -0700901cleanup_table_sysc_work_loop:
Heiko Carstens411788e2007-11-20 11:13:32 +0100902 .quad sysc_work_loop, sysc_work_done
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200903cleanup_table_io_return:
904 .quad io_return, io_leave
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700905cleanup_table_io_leave:
906 .quad io_leave, io_done
907cleanup_table_io_work_loop:
Heiko Carstens411788e2007-11-20 11:13:32 +0100908 .quad io_work_loop, io_work_done
Linus Torvalds1da177e2005-04-16 15:20:36 -0700909
910cleanup_critical:
911 clc 8(8,%r12),BASED(cleanup_table_system_call)
912 jl 0f
913 clc 8(8,%r12),BASED(cleanup_table_system_call+8)
914 jl cleanup_system_call
9150:
916 clc 8(8,%r12),BASED(cleanup_table_sysc_return)
917 jl 0f
918 clc 8(8,%r12),BASED(cleanup_table_sysc_return+8)
919 jl cleanup_sysc_return
9200:
921 clc 8(8,%r12),BASED(cleanup_table_sysc_leave)
922 jl 0f
923 clc 8(8,%r12),BASED(cleanup_table_sysc_leave+8)
924 jl cleanup_sysc_leave
9250:
926 clc 8(8,%r12),BASED(cleanup_table_sysc_work_loop)
927 jl 0f
928 clc 8(8,%r12),BASED(cleanup_table_sysc_work_loop+8)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700929 jl cleanup_sysc_return
Linus Torvalds1da177e2005-04-16 15:20:36 -07009300:
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200931 clc 8(8,%r12),BASED(cleanup_table_io_return)
932 jl 0f
933 clc 8(8,%r12),BASED(cleanup_table_io_return+8)
934 jl cleanup_io_return
9350:
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700936 clc 8(8,%r12),BASED(cleanup_table_io_leave)
937 jl 0f
938 clc 8(8,%r12),BASED(cleanup_table_io_leave+8)
939 jl cleanup_io_leave
9400:
941 clc 8(8,%r12),BASED(cleanup_table_io_work_loop)
942 jl 0f
943 clc 8(8,%r12),BASED(cleanup_table_io_work_loop+8)
944 jl cleanup_io_return
9450:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700946 br %r14
947
948cleanup_system_call:
949 mvc __LC_RETURN_PSW(16),0(%r12)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700950 cghi %r12,__LC_MCK_OLD_PSW
951 je 0f
952 la %r12,__LC_SAVE_AREA+32
953 j 1f
9540: la %r12,__LC_SAVE_AREA+64
9551:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700956 clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn+8)
957 jh 0f
958 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
9590: clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn+16)
960 jhe cleanup_vtime
Linus Torvalds1da177e2005-04-16 15:20:36 -0700961 clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn)
962 jh 0f
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700963 mvc __LC_SAVE_AREA(32),0(%r12)
9640: stg %r13,8(%r12)
965 stg %r12,__LC_SAVE_AREA+96 # argh
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200966 SAVE_ALL_SYNC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Heiko Carstens77fa2242005-06-25 14:55:30 -0700967 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700968 lg %r12,__LC_SAVE_AREA+96 # argh
969 stg %r15,24(%r12)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700970 llgh %r7,__LC_SVC_INT_CODE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700971cleanup_vtime:
972 clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn+24)
973 jhe cleanup_stime
Linus Torvalds1da177e2005-04-16 15:20:36 -0700974 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
975cleanup_stime:
976 clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn+32)
977 jh cleanup_update
978 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
979cleanup_update:
980 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700981 mvc __LC_RETURN_PSW+8(8),BASED(cleanup_table_system_call+8)
982 la %r12,__LC_RETURN_PSW
983 br %r14
984cleanup_system_call_insn:
985 .quad sysc_saveall
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200986 .quad system_call
987 .quad sysc_vtime
988 .quad sysc_stime
989 .quad sysc_update
Linus Torvalds1da177e2005-04-16 15:20:36 -0700990
991cleanup_sysc_return:
992 mvc __LC_RETURN_PSW(8),0(%r12)
993 mvc __LC_RETURN_PSW+8(8),BASED(cleanup_table_sysc_return)
994 la %r12,__LC_RETURN_PSW
995 br %r14
996
997cleanup_sysc_leave:
998 clc 8(8,%r12),BASED(cleanup_sysc_leave_insn)
Martin Schwidefskyc742b312008-12-31 15:11:42 +0100999 je 3f
Linus Torvalds1da177e2005-04-16 15:20:36 -07001000 clc 8(8,%r12),BASED(cleanup_sysc_leave_insn+8)
Martin Schwidefskyc742b312008-12-31 15:11:42 +01001001 jhe 0f
1002 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
10030: mvc __LC_RETURN_PSW(16),SP_PSW(%r15)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001004 cghi %r12,__LC_MCK_OLD_PSW
Martin Schwidefskyc742b312008-12-31 15:11:42 +01001005 jne 1f
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001006 mvc __LC_SAVE_AREA+64(32),SP_R12(%r15)
Martin Schwidefskyc742b312008-12-31 15:11:42 +01001007 j 2f
10081: mvc __LC_SAVE_AREA+32(32),SP_R12(%r15)
10092: lmg %r0,%r11,SP_R0(%r15)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001010 lg %r15,SP_R15(%r15)
Martin Schwidefskyc742b312008-12-31 15:11:42 +010010113: la %r12,__LC_RETURN_PSW
Linus Torvalds1da177e2005-04-16 15:20:36 -07001012 br %r14
1013cleanup_sysc_leave_insn:
Heiko Carstens411788e2007-11-20 11:13:32 +01001014 .quad sysc_done - 4
Martin Schwidefskyc742b312008-12-31 15:11:42 +01001015 .quad sysc_done - 16
Linus Torvalds1da177e2005-04-16 15:20:36 -07001016
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001017cleanup_io_return:
1018 mvc __LC_RETURN_PSW(8),0(%r12)
1019 mvc __LC_RETURN_PSW+8(8),BASED(cleanup_table_io_work_loop)
1020 la %r12,__LC_RETURN_PSW
1021 br %r14
1022
1023cleanup_io_leave:
1024 clc 8(8,%r12),BASED(cleanup_io_leave_insn)
Martin Schwidefskyc742b312008-12-31 15:11:42 +01001025 je 3f
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001026 clc 8(8,%r12),BASED(cleanup_io_leave_insn+8)
Martin Schwidefskyc742b312008-12-31 15:11:42 +01001027 jhe 0f
1028 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
10290: mvc __LC_RETURN_PSW(16),SP_PSW(%r15)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001030 cghi %r12,__LC_MCK_OLD_PSW
Martin Schwidefskyc742b312008-12-31 15:11:42 +01001031 jne 1f
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001032 mvc __LC_SAVE_AREA+64(32),SP_R12(%r15)
Martin Schwidefskyc742b312008-12-31 15:11:42 +01001033 j 2f
10341: mvc __LC_SAVE_AREA+32(32),SP_R12(%r15)
10352: lmg %r0,%r11,SP_R0(%r15)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001036 lg %r15,SP_R15(%r15)
Martin Schwidefskyc742b312008-12-31 15:11:42 +010010373: la %r12,__LC_RETURN_PSW
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001038 br %r14
1039cleanup_io_leave_insn:
Heiko Carstens411788e2007-11-20 11:13:32 +01001040 .quad io_done - 4
Martin Schwidefskyc742b312008-12-31 15:11:42 +01001041 .quad io_done - 16
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001042
Linus Torvalds1da177e2005-04-16 15:20:36 -07001043/*
1044 * Integer constants
1045 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001046 .align 4
Linus Torvalds1da177e2005-04-16 15:20:36 -07001047.Lconst:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001048.Lnr_syscalls: .long NR_syscalls
1049.L0x0130: .short 0x130
1050.L0x0140: .short 0x140
1051.L0x0150: .short 0x150
1052.L0x0160: .short 0x160
1053.L0x0170: .short 0x170
Linus Torvalds1da177e2005-04-16 15:20:36 -07001054.Lcritical_start:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001055 .quad __critical_start
Linus Torvalds1da177e2005-04-16 15:20:36 -07001056.Lcritical_end:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001057 .quad __critical_end
Linus Torvalds1da177e2005-04-16 15:20:36 -07001058
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001059 .section .rodata, "a"
Linus Torvalds1da177e2005-04-16 15:20:36 -07001060#define SYSCALL(esa,esame,emu) .long esame
Linus Torvalds1da177e2005-04-16 15:20:36 -07001061sys_call_table:
1062#include "syscalls.S"
1063#undef SYSCALL
1064
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -08001065#ifdef CONFIG_COMPAT
Linus Torvalds1da177e2005-04-16 15:20:36 -07001066
1067#define SYSCALL(esa,esame,emu) .long emu
Linus Torvalds1da177e2005-04-16 15:20:36 -07001068sys_call_table_emu:
1069#include "syscalls.S"
1070#undef SYSCALL
1071#endif