blob: 1a434a7004ee4f5432d37e8019c03d31e8265d26 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * arch/s390/kernel/entry.S
3 * 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),
7 * 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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <asm/cache.h>
15#include <asm/lowcore.h>
16#include <asm/errno.h>
17#include <asm/ptrace.h>
18#include <asm/thread_info.h>
Sam Ravnborg0013a852005-09-09 20:57:26 +020019#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <asm/unistd.h>
21#include <asm/page.h>
22
23/*
24 * Stack layout for the system_call stack entry.
25 * The first few entries are identical to the user_regs_struct.
26 */
27SP_PTREGS = STACK_FRAME_OVERHEAD
28SP_ARGS = STACK_FRAME_OVERHEAD + __PT_ARGS
29SP_PSW = STACK_FRAME_OVERHEAD + __PT_PSW
30SP_R0 = STACK_FRAME_OVERHEAD + __PT_GPRS
31SP_R1 = STACK_FRAME_OVERHEAD + __PT_GPRS + 4
32SP_R2 = STACK_FRAME_OVERHEAD + __PT_GPRS + 8
33SP_R3 = STACK_FRAME_OVERHEAD + __PT_GPRS + 12
34SP_R4 = STACK_FRAME_OVERHEAD + __PT_GPRS + 16
35SP_R5 = STACK_FRAME_OVERHEAD + __PT_GPRS + 20
36SP_R6 = STACK_FRAME_OVERHEAD + __PT_GPRS + 24
37SP_R7 = STACK_FRAME_OVERHEAD + __PT_GPRS + 28
38SP_R8 = STACK_FRAME_OVERHEAD + __PT_GPRS + 32
39SP_R9 = STACK_FRAME_OVERHEAD + __PT_GPRS + 36
40SP_R10 = STACK_FRAME_OVERHEAD + __PT_GPRS + 40
41SP_R11 = STACK_FRAME_OVERHEAD + __PT_GPRS + 44
42SP_R12 = STACK_FRAME_OVERHEAD + __PT_GPRS + 48
43SP_R13 = STACK_FRAME_OVERHEAD + __PT_GPRS + 52
44SP_R14 = STACK_FRAME_OVERHEAD + __PT_GPRS + 56
45SP_R15 = STACK_FRAME_OVERHEAD + __PT_GPRS + 60
46SP_ORIG_R2 = STACK_FRAME_OVERHEAD + __PT_ORIG_GPR2
47SP_ILC = STACK_FRAME_OVERHEAD + __PT_ILC
48SP_TRAP = STACK_FRAME_OVERHEAD + __PT_TRAP
49SP_SIZE = STACK_FRAME_OVERHEAD + __PT_SIZE
50
Heiko Carstens54dfe5d2006-02-01 03:06:38 -080051_TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | _TIF_NEED_RESCHED | \
52 _TIF_MCCK_PENDING | _TIF_RESTART_SVC | _TIF_SINGLE_STEP )
53_TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | _TIF_NEED_RESCHED | \
54 _TIF_MCCK_PENDING)
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
56STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
57STACK_SIZE = 1 << STACK_SHIFT
58
59#define BASED(name) name-system_call(%r13)
60
61/*
62 * Register usage in interrupt handlers:
63 * R9 - pointer to current task structure
64 * R13 - pointer to literal pool
65 * R14 - return register for function calls
66 * R15 - kernel stack pointer
67 */
68
69 .macro STORE_TIMER lc_offset
70#ifdef CONFIG_VIRT_CPU_ACCOUNTING
71 stpt \lc_offset
72#endif
73 .endm
74
75#ifdef CONFIG_VIRT_CPU_ACCOUNTING
76 .macro UPDATE_VTIME lc_from,lc_to,lc_sum
77 lm %r10,%r11,\lc_from
78 sl %r10,\lc_to
79 sl %r11,\lc_to+4
80 bc 3,BASED(0f)
81 sl %r10,BASED(.Lc_1)
820: al %r10,\lc_sum
83 al %r11,\lc_sum+4
84 bc 12,BASED(1f)
85 al %r10,BASED(.Lc_1)
861: stm %r10,%r11,\lc_sum
87 .endm
88#endif
89
90 .macro SAVE_ALL_BASE savearea
91 stm %r12,%r15,\savearea
92 l %r13,__LC_SVC_NEW_PSW+4 # load &system_call to %r13
93 .endm
94
Martin Schwidefsky63b12242006-06-29 14:58:05 +020095 .macro SAVE_ALL_SYNC psworg,savearea
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 la %r12,\psworg
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 tm \psworg+1,0x01 # test problem state bit
98 bz BASED(2f) # skip stack setup save
99 l %r15,__LC_KERNEL_STACK # problem state -> load ksp
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200100#ifdef CONFIG_CHECK_STACK
101 b BASED(3f)
1022: tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
103 bz BASED(stack_overflow)
1043:
105#endif
1062:
107 .endm
108
109 .macro SAVE_ALL_ASYNC psworg,savearea
110 la %r12,\psworg
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 tm \psworg+1,0x01 # test problem state bit
112 bnz BASED(1f) # from user -> load async stack
113 clc \psworg+4(4),BASED(.Lcritical_end)
114 bhe BASED(0f)
115 clc \psworg+4(4),BASED(.Lcritical_start)
116 bl BASED(0f)
117 l %r14,BASED(.Lcleanup_critical)
118 basr %r14,%r14
Peter Oberparleiter6add9f72005-09-16 19:27:42 -0700119 tm 1(%r12),0x01 # retest problem state after cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 bnz BASED(1f)
1210: l %r14,__LC_ASYNC_STACK # are we already on the async stack ?
122 slr %r14,%r15
123 sra %r14,STACK_SHIFT
124 be BASED(2f)
1251: l %r15,__LC_ASYNC_STACK
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126#ifdef CONFIG_CHECK_STACK
127 b BASED(3f)
1282: tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
129 bz BASED(stack_overflow)
1303:
131#endif
Heiko Carstens77fa2242005-06-25 14:55:30 -07001322:
133 .endm
134
135 .macro CREATE_STACK_FRAME psworg,savearea
136 s %r15,BASED(.Lc_spsize) # make room for registers & psw
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 mvc SP_PSW(8,%r15),0(%r12) # move user PSW to stack
138 la %r12,\psworg
139 st %r2,SP_ORIG_R2(%r15) # store original content of gpr 2
140 icm %r12,12,__LC_SVC_ILC
141 stm %r0,%r11,SP_R0(%r15) # store gprs %r0-%r11 to kernel stack
142 st %r12,SP_ILC(%r15)
143 mvc SP_R12(16,%r15),\savearea # move %r12-%r15 to stack
144 la %r12,0
145 st %r12,__SF_BACKCHAIN(%r15) # clear back chain
146 .endm
147
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700148 .macro RESTORE_ALL psworg,sync
149 mvc \psworg(8),SP_PSW(%r15) # move user PSW to lowcore
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 .if !\sync
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700151 ni \psworg+1,0xfd # clear wait state bit
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 .endif
153 lm %r0,%r15,SP_R0(%r15) # load gprs 0-15 of user
154 STORE_TIMER __LC_EXIT_TIMER
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700155 lpsw \psworg # back to caller
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 .endm
157
158/*
159 * Scheduler resume function, called by switch_to
160 * gpr2 = (task_struct *) prev
161 * gpr3 = (task_struct *) next
162 * Returns:
163 * gpr2 = prev
164 */
165 .globl __switch_to
166__switch_to:
167 basr %r1,0
168__switch_to_base:
169 tm __THREAD_per(%r3),0xe8 # new process is using per ?
170 bz __switch_to_noper-__switch_to_base(%r1) # if not we're fine
171 stctl %c9,%c11,__SF_EMPTY(%r15) # We are using per stuff
172 clc __THREAD_per(12,%r3),__SF_EMPTY(%r15)
173 be __switch_to_noper-__switch_to_base(%r1) # we got away w/o bashing TLB's
174 lctl %c9,%c11,__THREAD_per(%r3) # Nope we didn't
175__switch_to_noper:
Heiko Carstens77fa2242005-06-25 14:55:30 -0700176 l %r4,__THREAD_info(%r2) # get thread_info of prev
177 tm __TI_flags+3(%r4),_TIF_MCCK_PENDING # machine check pending?
178 bz __switch_to_no_mcck-__switch_to_base(%r1)
179 ni __TI_flags+3(%r4),255-_TIF_MCCK_PENDING # clear flag in prev
180 l %r4,__THREAD_info(%r3) # get thread_info of next
181 oi __TI_flags+3(%r4),_TIF_MCCK_PENDING # set it in next
182__switch_to_no_mcck:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 stm %r6,%r15,__SF_GPRS(%r15)# store __switch_to registers of prev task
184 st %r15,__THREAD_ksp(%r2) # store kernel stack to prev->tss.ksp
185 l %r15,__THREAD_ksp(%r3) # load kernel stack from next->tss.ksp
186 lm %r6,%r15,__SF_GPRS(%r15)# load __switch_to registers of next task
187 st %r3,__LC_CURRENT # __LC_CURRENT = current task struct
188 lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4
189 l %r3,__THREAD_info(%r3) # load thread_info from task struct
190 st %r3,__LC_THREAD_INFO
191 ahi %r3,STACK_SIZE
192 st %r3,__LC_KERNEL_STACK # __LC_KERNEL_STACK = new kernel stack
193 br %r14
194
195__critical_start:
196/*
197 * SVC interrupt handler routine. System calls are synchronous events and
198 * are executed with interrupts enabled.
199 */
200
201 .globl system_call
202system_call:
203 STORE_TIMER __LC_SYNC_ENTER_TIMER
204sysc_saveall:
205 SAVE_ALL_BASE __LC_SAVE_AREA
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200206 SAVE_ALL_SYNC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Heiko Carstens77fa2242005-06-25 14:55:30 -0700207 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208 lh %r7,0x8a # get svc number from lowcore
209#ifdef CONFIG_VIRT_CPU_ACCOUNTING
210sysc_vtime:
211 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
212 bz BASED(sysc_do_svc)
213 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
214sysc_stime:
215 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
216sysc_update:
217 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
218#endif
219sysc_do_svc:
220 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
221 sla %r7,2 # *4 and test for svc 0
222 bnz BASED(sysc_nr_ok) # svc number > 0
223 # svc 0: system call number in %r1
224 cl %r1,BASED(.Lnr_syscalls)
225 bnl BASED(sysc_nr_ok)
226 lr %r7,%r1 # copy svc number to %r7
227 sla %r7,2 # *4
228sysc_nr_ok:
229 mvc SP_ARGS(4,%r15),SP_R7(%r15)
230sysc_do_restart:
231 tm __TI_flags+3(%r9),(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)
232 l %r8,sys_call_table-system_call(%r7,%r13) # get system call addr.
233 bnz BASED(sysc_tracesys)
234 basr %r14,%r8 # call sys_xxxx
235 st %r2,SP_R2(%r15) # store return value (change R2 on stack)
236 # ATTENTION: check sys_execve_glue before
237 # changing anything here !!
238
239sysc_return:
240 tm SP_PSW+1(%r15),0x01 # returning to user ?
241 bno BASED(sysc_leave)
242 tm __TI_flags+3(%r9),_TIF_WORK_SVC
243 bnz BASED(sysc_work) # there is work to do (signals etc.)
244sysc_leave:
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700245 RESTORE_ALL __LC_RETURN_PSW,1
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
247#
248# recheck if there is more work to do
249#
250sysc_work_loop:
251 tm __TI_flags+3(%r9),_TIF_WORK_SVC
252 bz BASED(sysc_leave) # there is no work to do
253#
254# One of the work bits is on. Find out which one.
255#
256sysc_work:
Heiko Carstens77fa2242005-06-25 14:55:30 -0700257 tm __TI_flags+3(%r9),_TIF_MCCK_PENDING
258 bo BASED(sysc_mcck_pending)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED
260 bo BASED(sysc_reschedule)
Heiko Carstens54dfe5d2006-02-01 03:06:38 -0800261 tm __TI_flags+3(%r9),(_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)
262 bnz BASED(sysc_sigpending)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 tm __TI_flags+3(%r9),_TIF_RESTART_SVC
264 bo BASED(sysc_restart)
265 tm __TI_flags+3(%r9),_TIF_SINGLE_STEP
266 bo BASED(sysc_singlestep)
267 b BASED(sysc_leave)
268
269#
270# _TIF_NEED_RESCHED is set, call schedule
271#
272sysc_reschedule:
273 l %r1,BASED(.Lschedule)
274 la %r14,BASED(sysc_work_loop)
275 br %r1 # call scheduler
276
277#
Heiko Carstens77fa2242005-06-25 14:55:30 -0700278# _TIF_MCCK_PENDING is set, call handler
279#
280sysc_mcck_pending:
281 l %r1,BASED(.Ls390_handle_mcck)
282 la %r14,BASED(sysc_work_loop)
283 br %r1 # TIF bit will be cleared by handler
284
285#
Heiko Carstens54dfe5d2006-02-01 03:06:38 -0800286# _TIF_SIGPENDING or _TIF_RESTORE_SIGMASK is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287#
288sysc_sigpending:
289 ni __TI_flags+3(%r9),255-_TIF_SINGLE_STEP # clear TIF_SINGLE_STEP
290 la %r2,SP_PTREGS(%r15) # load pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 l %r1,BASED(.Ldo_signal)
292 basr %r14,%r1 # call do_signal
293 tm __TI_flags+3(%r9),_TIF_RESTART_SVC
294 bo BASED(sysc_restart)
295 tm __TI_flags+3(%r9),_TIF_SINGLE_STEP
296 bo BASED(sysc_singlestep)
Heiko Carstense1c3ad92005-11-07 00:59:02 -0800297 b BASED(sysc_work_loop)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298
299#
300# _TIF_RESTART_SVC is set, set up registers and restart svc
301#
302sysc_restart:
303 ni __TI_flags+3(%r9),255-_TIF_RESTART_SVC # clear TIF_RESTART_SVC
304 l %r7,SP_R2(%r15) # load new svc number
305 sla %r7,2
306 mvc SP_R2(4,%r15),SP_ORIG_R2(%r15) # restore first argument
307 lm %r2,%r6,SP_R2(%r15) # load svc arguments
308 b BASED(sysc_do_restart) # restart svc
309
310#
311# _TIF_SINGLE_STEP is set, call do_single_step
312#
313sysc_singlestep:
314 ni __TI_flags+3(%r9),255-_TIF_SINGLE_STEP # clear TIF_SINGLE_STEP
315 mvi SP_TRAP+1(%r15),0x28 # set trap indication to pgm check
316 la %r2,SP_PTREGS(%r15) # address of register-save area
317 l %r1,BASED(.Lhandle_per) # load adr. of per handler
318 la %r14,BASED(sysc_return) # load adr. of system return
319 br %r1 # branch to do_single_step
320
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321#
322# call trace before and after sys_call
323#
324sysc_tracesys:
325 l %r1,BASED(.Ltrace)
326 la %r2,SP_PTREGS(%r15) # load pt_regs
327 la %r3,0
328 srl %r7,2
329 st %r7,SP_R2(%r15)
330 basr %r14,%r1
331 clc SP_R2(4,%r15),BASED(.Lnr_syscalls)
332 bnl BASED(sysc_tracenogo)
333 l %r7,SP_R2(%r15) # strace might have changed the
334 sll %r7,2 # system call
335 l %r8,sys_call_table-system_call(%r7,%r13)
336sysc_tracego:
337 lm %r3,%r6,SP_R3(%r15)
338 l %r2,SP_ORIG_R2(%r15)
339 basr %r14,%r8 # call sys_xxx
340 st %r2,SP_R2(%r15) # store return value
341sysc_tracenogo:
342 tm __TI_flags+3(%r9),(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)
343 bz BASED(sysc_return)
344 l %r1,BASED(.Ltrace)
345 la %r2,SP_PTREGS(%r15) # load pt_regs
346 la %r3,1
347 la %r14,BASED(sysc_return)
348 br %r1
349
350#
351# a new process exits the kernel with ret_from_fork
352#
353 .globl ret_from_fork
354ret_from_fork:
355 l %r13,__LC_SVC_NEW_PSW+4
356 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
357 tm SP_PSW+1(%r15),0x01 # forking a kernel thread ?
358 bo BASED(0f)
359 st %r15,SP_R15(%r15) # store stack pointer for new kthread
3600: l %r1,BASED(.Lschedtail)
361 basr %r14,%r1
362 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
363 b BASED(sysc_return)
364
365#
366# clone, fork, vfork, exec and sigreturn need glue,
367# because they all expect pt_regs as parameter,
368# but are called with different parameter.
369# return-address is set up above
370#
371sys_clone_glue:
372 la %r2,SP_PTREGS(%r15) # load pt_regs
373 l %r1,BASED(.Lclone)
374 br %r1 # branch to sys_clone
375
376sys_fork_glue:
377 la %r2,SP_PTREGS(%r15) # load pt_regs
378 l %r1,BASED(.Lfork)
379 br %r1 # branch to sys_fork
380
381sys_vfork_glue:
382 la %r2,SP_PTREGS(%r15) # load pt_regs
383 l %r1,BASED(.Lvfork)
384 br %r1 # branch to sys_vfork
385
386sys_execve_glue:
387 la %r2,SP_PTREGS(%r15) # load pt_regs
388 l %r1,BASED(.Lexecve)
389 lr %r12,%r14 # save return address
390 basr %r14,%r1 # call sys_execve
391 ltr %r2,%r2 # check if execve failed
392 bnz 0(%r12) # it did fail -> store result in gpr2
393 b 4(%r12) # SKIP ST 2,SP_R2(15) after BASR 14,8
394 # in system_call/sysc_tracesys
395
396sys_sigreturn_glue:
397 la %r2,SP_PTREGS(%r15) # load pt_regs as parameter
398 l %r1,BASED(.Lsigreturn)
399 br %r1 # branch to sys_sigreturn
400
401sys_rt_sigreturn_glue:
402 la %r2,SP_PTREGS(%r15) # load pt_regs as parameter
403 l %r1,BASED(.Lrt_sigreturn)
404 br %r1 # branch to sys_sigreturn
405
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406sys_sigaltstack_glue:
407 la %r4,SP_PTREGS(%r15) # load pt_regs as parameter
408 l %r1,BASED(.Lsigaltstack)
409 br %r1 # branch to sys_sigreturn
410
411
412/*
413 * Program check handler routine
414 */
415
416 .globl pgm_check_handler
417pgm_check_handler:
418/*
419 * First we need to check for a special case:
420 * Single stepping an instruction that disables the PER event mask will
421 * cause a PER event AFTER the mask has been set. Example: SVC or LPSW.
422 * For a single stepped SVC the program check handler gets control after
423 * the SVC new PSW has been loaded. But we want to execute the SVC first and
424 * then handle the PER event. Therefore we update the SVC old PSW to point
425 * to the pgm_check_handler and branch to the SVC handler after we checked
426 * if we have to load the kernel stack register.
427 * For every other possible cause for PER event without the PER mask set
428 * we just ignore the PER event (FIXME: is there anything we have to do
429 * for LPSW?).
430 */
431 STORE_TIMER __LC_SYNC_ENTER_TIMER
432 SAVE_ALL_BASE __LC_SAVE_AREA
433 tm __LC_PGM_INT_CODE+1,0x80 # check whether we got a per exception
434 bnz BASED(pgm_per) # got per exception -> special case
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200435 SAVE_ALL_SYNC __LC_PGM_OLD_PSW,__LC_SAVE_AREA
Heiko Carstens77fa2242005-06-25 14:55:30 -0700436 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437#ifdef CONFIG_VIRT_CPU_ACCOUNTING
438 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
439 bz BASED(pgm_no_vtime)
440 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
441 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
442 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
443pgm_no_vtime:
444#endif
445 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
446 l %r3,__LC_PGM_ILC # load program interruption code
447 la %r8,0x7f
448 nr %r8,%r3
449pgm_do_call:
450 l %r7,BASED(.Ljump_table)
451 sll %r8,2
452 l %r7,0(%r8,%r7) # load address of handler routine
453 la %r2,SP_PTREGS(%r15) # address of register-save area
454 la %r14,BASED(sysc_return)
455 br %r7 # branch to interrupt-handler
456
457#
458# handle per exception
459#
460pgm_per:
461 tm __LC_PGM_OLD_PSW,0x40 # test if per event recording is on
462 bnz BASED(pgm_per_std) # ok, normal per event from user space
463# ok its one of the special cases, now we need to find out which one
464 clc __LC_PGM_OLD_PSW(8),__LC_SVC_NEW_PSW
465 be BASED(pgm_svcper)
466# no interesting special case, ignore PER event
467 lm %r12,%r15,__LC_SAVE_AREA
468 lpsw 0x28
469
470#
471# Normal per exception
472#
473pgm_per_std:
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200474 SAVE_ALL_SYNC __LC_PGM_OLD_PSW,__LC_SAVE_AREA
Heiko Carstens77fa2242005-06-25 14:55:30 -0700475 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476#ifdef CONFIG_VIRT_CPU_ACCOUNTING
477 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
478 bz BASED(pgm_no_vtime2)
479 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
480 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
481 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
482pgm_no_vtime2:
483#endif
484 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
485 l %r1,__TI_task(%r9)
486 mvc __THREAD_per+__PER_atmid(2,%r1),__LC_PER_ATMID
487 mvc __THREAD_per+__PER_address(4,%r1),__LC_PER_ADDRESS
488 mvc __THREAD_per+__PER_access_id(1,%r1),__LC_PER_ACCESS_ID
489 oi __TI_flags+3(%r9),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP
490 l %r3,__LC_PGM_ILC # load program interruption code
491 la %r8,0x7f
492 nr %r8,%r3 # clear per-event-bit and ilc
493 be BASED(sysc_return) # only per or per+check ?
494 b BASED(pgm_do_call)
495
496#
497# it was a single stepped SVC that is causing all the trouble
498#
499pgm_svcper:
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200500 SAVE_ALL_SYNC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Heiko Carstens77fa2242005-06-25 14:55:30 -0700501 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502#ifdef CONFIG_VIRT_CPU_ACCOUNTING
503 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
504 bz BASED(pgm_no_vtime3)
505 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
506 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
507 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
508pgm_no_vtime3:
509#endif
510 lh %r7,0x8a # get svc number from lowcore
511 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
512 l %r1,__TI_task(%r9)
513 mvc __THREAD_per+__PER_atmid(2,%r1),__LC_PER_ATMID
514 mvc __THREAD_per+__PER_address(4,%r1),__LC_PER_ADDRESS
515 mvc __THREAD_per+__PER_access_id(1,%r1),__LC_PER_ACCESS_ID
516 oi __TI_flags+3(%r9),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP
517 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
518 b BASED(sysc_do_svc)
519
520/*
521 * IO interrupt handler routine
522 */
523
524 .globl io_int_handler
525io_int_handler:
526 STORE_TIMER __LC_ASYNC_ENTER_TIMER
527 stck __LC_INT_CLOCK
528 SAVE_ALL_BASE __LC_SAVE_AREA+16
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200529 SAVE_ALL_ASYNC __LC_IO_OLD_PSW,__LC_SAVE_AREA+16
Heiko Carstens77fa2242005-06-25 14:55:30 -0700530 CREATE_STACK_FRAME __LC_IO_OLD_PSW,__LC_SAVE_AREA+16
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531#ifdef CONFIG_VIRT_CPU_ACCOUNTING
532 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
533 bz BASED(io_no_vtime)
534 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
535 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
536 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
537io_no_vtime:
538#endif
539 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
540 l %r1,BASED(.Ldo_IRQ) # load address of do_IRQ
541 la %r2,SP_PTREGS(%r15) # address of register-save area
542 basr %r14,%r1 # branch to standard irq handler
543
544io_return:
545 tm SP_PSW+1(%r15),0x01 # returning to user ?
546#ifdef CONFIG_PREEMPT
547 bno BASED(io_preempt) # no -> check for preemptive scheduling
548#else
549 bno BASED(io_leave) # no-> skip resched & signal
550#endif
551 tm __TI_flags+3(%r9),_TIF_WORK_INT
552 bnz BASED(io_work) # there is work to do (signals etc.)
553io_leave:
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700554 RESTORE_ALL __LC_RETURN_PSW,0
555io_done:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556
557#ifdef CONFIG_PREEMPT
558io_preempt:
559 icm %r0,15,__TI_precount(%r9)
560 bnz BASED(io_leave)
561 l %r1,SP_R15(%r15)
562 s %r1,BASED(.Lc_spsize)
563 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
564 xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1) # clear back chain
565 lr %r15,%r1
566io_resume_loop:
567 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED
568 bno BASED(io_leave)
569 mvc __TI_precount(4,%r9),BASED(.Lc_pactive)
570 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
571 l %r1,BASED(.Lschedule)
572 basr %r14,%r1 # call schedule
573 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
574 xc __TI_precount(4,%r9),__TI_precount(%r9)
575 b BASED(io_resume_loop)
576#endif
577
578#
579# switch to kernel stack, then check the TIF bits
580#
581io_work:
582 l %r1,__LC_KERNEL_STACK
583 s %r1,BASED(.Lc_spsize)
584 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
585 xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1) # clear back chain
586 lr %r15,%r1
587#
588# One of the work bits is on. Find out which one.
Heiko Carstens54dfe5d2006-02-01 03:06:38 -0800589# Checked are: _TIF_SIGPENDING, _TIF_RESTORE_SIGMASK, _TIF_NEED_RESCHED
590# and _TIF_MCCK_PENDING
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591#
592io_work_loop:
Heiko Carstens77fa2242005-06-25 14:55:30 -0700593 tm __TI_flags+3(%r9),_TIF_MCCK_PENDING
594 bo BASED(io_mcck_pending)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED
596 bo BASED(io_reschedule)
Heiko Carstens54dfe5d2006-02-01 03:06:38 -0800597 tm __TI_flags+3(%r9),(_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)
598 bnz BASED(io_sigpending)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 b BASED(io_leave)
600
601#
Heiko Carstens77fa2242005-06-25 14:55:30 -0700602# _TIF_MCCK_PENDING is set, call handler
603#
604io_mcck_pending:
605 l %r1,BASED(.Ls390_handle_mcck)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700606 la %r14,BASED(io_work_loop)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700607 br %r1 # TIF bit will be cleared by handler
608
609#
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610# _TIF_NEED_RESCHED is set, call schedule
611#
612io_reschedule:
613 l %r1,BASED(.Lschedule)
614 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
615 basr %r14,%r1 # call scheduler
616 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
617 tm __TI_flags+3(%r9),_TIF_WORK_INT
618 bz BASED(io_leave) # there is no work to do
619 b BASED(io_work_loop)
620
621#
Heiko Carstens54dfe5d2006-02-01 03:06:38 -0800622# _TIF_SIGPENDING or _TIF_RESTORE_SIGMASK is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623#
624io_sigpending:
625 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
626 la %r2,SP_PTREGS(%r15) # load pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627 l %r1,BASED(.Ldo_signal)
628 basr %r14,%r1 # call do_signal
629 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
Heiko Carstense1c3ad92005-11-07 00:59:02 -0800630 b BASED(io_work_loop)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631
632/*
633 * External interrupt handler routine
634 */
635
636 .globl ext_int_handler
637ext_int_handler:
638 STORE_TIMER __LC_ASYNC_ENTER_TIMER
639 stck __LC_INT_CLOCK
640 SAVE_ALL_BASE __LC_SAVE_AREA+16
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200641 SAVE_ALL_ASYNC __LC_EXT_OLD_PSW,__LC_SAVE_AREA+16
Heiko Carstens77fa2242005-06-25 14:55:30 -0700642 CREATE_STACK_FRAME __LC_EXT_OLD_PSW,__LC_SAVE_AREA+16
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643#ifdef CONFIG_VIRT_CPU_ACCOUNTING
644 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
645 bz BASED(ext_no_vtime)
646 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
647 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
648 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
649ext_no_vtime:
650#endif
651 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
652 la %r2,SP_PTREGS(%r15) # address of register-save area
653 lh %r3,__LC_EXT_INT_CODE # get interruption code
654 l %r1,BASED(.Ldo_extint)
655 basr %r14,%r1
656 b BASED(io_return)
657
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700658__critical_end:
659
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660/*
661 * Machine check handler routines
662 */
663
664 .globl mcck_int_handler
665mcck_int_handler:
Heiko Carstens77fa2242005-06-25 14:55:30 -0700666 spt __LC_CPU_TIMER_SAVE_AREA # revalidate cpu timer
667 lm %r0,%r15,__LC_GPREGS_SAVE_AREA # revalidate gprs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668 SAVE_ALL_BASE __LC_SAVE_AREA+32
Heiko Carstens77fa2242005-06-25 14:55:30 -0700669 la %r12,__LC_MCK_OLD_PSW
670 tm __LC_MCCK_CODE,0x80 # system damage?
671 bo BASED(mcck_int_main) # yes -> rest of mcck code invalid
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672#ifdef CONFIG_VIRT_CPU_ACCOUNTING
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200673 mvc __LC_SAVE_AREA+52(8),__LC_ASYNC_ENTER_TIMER
674 mvc __LC_ASYNC_ENTER_TIMER(8),__LC_CPU_TIMER_SAVE_AREA
675 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
676 bo BASED(1f)
677 la %r14,__LC_SYNC_ENTER_TIMER
678 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
679 bl BASED(0f)
680 la %r14,__LC_ASYNC_ENTER_TIMER
6810: clc 0(8,%r14),__LC_EXIT_TIMER
682 bl BASED(0f)
683 la %r14,__LC_EXIT_TIMER
6840: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
685 bl BASED(0f)
686 la %r14,__LC_LAST_UPDATE_TIMER
6870: spt 0(%r14)
688 mvc __LC_ASYNC_ENTER_TIMER(8),0(%r14)
6891:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690#endif
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200691 tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700692 bno BASED(mcck_int_main) # no -> skip cleanup critical
693 tm __LC_MCK_OLD_PSW+1,0x01 # test problem state bit
694 bnz BASED(mcck_int_main) # from user -> load async stack
695 clc __LC_MCK_OLD_PSW+4(4),BASED(.Lcritical_end)
696 bhe BASED(mcck_int_main)
697 clc __LC_MCK_OLD_PSW+4(4),BASED(.Lcritical_start)
698 bl BASED(mcck_int_main)
699 l %r14,BASED(.Lcleanup_critical)
700 basr %r14,%r14
701mcck_int_main:
702 l %r14,__LC_PANIC_STACK # are we already on the panic stack?
703 slr %r14,%r15
704 sra %r14,PAGE_SHIFT
705 be BASED(0f)
706 l %r15,__LC_PANIC_STACK # load panic stack
7070: CREATE_STACK_FRAME __LC_MCK_OLD_PSW,__LC_SAVE_AREA+32
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700708#ifdef CONFIG_VIRT_CPU_ACCOUNTING
709 tm __LC_MCCK_CODE+2,0x08 # mwp of old psw valid?
710 bno BASED(mcck_no_vtime) # no -> skip cleanup critical
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200711 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700712 bz BASED(mcck_no_vtime)
713 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
714 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
715 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
716mcck_no_vtime:
717#endif
Heiko Carstens77fa2242005-06-25 14:55:30 -0700718 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
719 la %r2,SP_PTREGS(%r15) # load pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 l %r1,BASED(.Ls390_mcck)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700721 basr %r14,%r1 # call machine check handler
722 tm SP_PSW+1(%r15),0x01 # returning to user ?
723 bno BASED(mcck_return)
724 l %r1,__LC_KERNEL_STACK # switch to kernel stack
725 s %r1,BASED(.Lc_spsize)
726 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
727 xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1) # clear back chain
728 lr %r15,%r1
729 stosm __SF_EMPTY(%r15),0x04 # turn dat on
730 tm __TI_flags+3(%r9),_TIF_MCCK_PENDING
731 bno BASED(mcck_return)
732 l %r1,BASED(.Ls390_handle_mcck)
733 basr %r14,%r1 # call machine check handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734mcck_return:
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200735 mvc __LC_RETURN_MCCK_PSW(8),SP_PSW(%r15) # move return PSW
736 ni __LC_RETURN_MCCK_PSW+1,0xfd # clear wait state bit
737#ifdef CONFIG_VIRT_CPU_ACCOUNTING
738 mvc __LC_ASYNC_ENTER_TIMER(8),__LC_SAVE_AREA+52
739 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
740 bno BASED(0f)
741 lm %r0,%r15,SP_R0(%r15) # load gprs 0-15
742 stpt __LC_EXIT_TIMER
743 lpsw __LC_RETURN_MCCK_PSW # back to caller
7440:
745#endif
746 lm %r0,%r15,SP_R0(%r15) # load gprs 0-15
747 lpsw __LC_RETURN_MCCK_PSW # back to caller
748
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700749 RESTORE_ALL __LC_RETURN_MCCK_PSW,0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750
751#ifdef CONFIG_SMP
752/*
753 * Restart interruption handler, kick starter for additional CPUs
754 */
755 .globl restart_int_handler
756restart_int_handler:
757 l %r15,__LC_SAVE_AREA+60 # load ksp
758 lctl %c0,%c15,__LC_CREGS_SAVE_AREA # get new ctl regs
759 lam %a0,%a15,__LC_AREGS_SAVE_AREA
760 lm %r6,%r15,__SF_GPRS(%r15) # load registers from clone
761 stosm __SF_EMPTY(%r15),0x04 # now we can turn dat on
762 basr %r14,0
763 l %r14,restart_addr-.(%r14)
764 br %r14 # branch to start_secondary
765restart_addr:
766 .long start_secondary
767#else
768/*
769 * If we do not run with SMP enabled, let the new CPU crash ...
770 */
771 .globl restart_int_handler
772restart_int_handler:
773 basr %r1,0
774restart_base:
775 lpsw restart_crash-restart_base(%r1)
776 .align 8
777restart_crash:
778 .long 0x000a0000,0x00000000
779restart_go:
780#endif
781
782#ifdef CONFIG_CHECK_STACK
783/*
784 * The synchronous or the asynchronous stack overflowed. We are dead.
785 * No need to properly save the registers, we are going to panic anyway.
786 * Setup a pt_regs so that show_trace can provide a good call trace.
787 */
788stack_overflow:
789 l %r15,__LC_PANIC_STACK # change to panic stack
790 sl %r15,BASED(.Lc_spsize)
791 mvc SP_PSW(8,%r15),0(%r12) # move user PSW to stack
792 stm %r0,%r11,SP_R0(%r15) # store gprs %r0-%r11 to kernel stack
793 la %r1,__LC_SAVE_AREA
794 ch %r12,BASED(.L0x020) # old psw addr == __LC_SVC_OLD_PSW ?
795 be BASED(0f)
796 ch %r12,BASED(.L0x028) # old psw addr == __LC_PGM_OLD_PSW ?
797 be BASED(0f)
798 la %r1,__LC_SAVE_AREA+16
7990: mvc SP_R12(16,%r15),0(%r1) # move %r12-%r15 to stack
800 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15) # clear back chain
801 l %r1,BASED(1f) # branch to kernel_stack_overflow
802 la %r2,SP_PTREGS(%r15) # load pt_regs
803 br %r1
8041: .long kernel_stack_overflow
805#endif
806
807cleanup_table_system_call:
808 .long system_call + 0x80000000, sysc_do_svc + 0x80000000
809cleanup_table_sysc_return:
810 .long sysc_return + 0x80000000, sysc_leave + 0x80000000
811cleanup_table_sysc_leave:
812 .long sysc_leave + 0x80000000, sysc_work_loop + 0x80000000
813cleanup_table_sysc_work_loop:
814 .long sysc_work_loop + 0x80000000, sysc_reschedule + 0x80000000
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200815cleanup_table_io_return:
816 .long io_return + 0x80000000, io_leave + 0x80000000
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700817cleanup_table_io_leave:
818 .long io_leave + 0x80000000, io_done + 0x80000000
819cleanup_table_io_work_loop:
820 .long io_work_loop + 0x80000000, io_mcck_pending + 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821
822cleanup_critical:
823 clc 4(4,%r12),BASED(cleanup_table_system_call)
824 bl BASED(0f)
825 clc 4(4,%r12),BASED(cleanup_table_system_call+4)
826 bl BASED(cleanup_system_call)
8270:
828 clc 4(4,%r12),BASED(cleanup_table_sysc_return)
829 bl BASED(0f)
830 clc 4(4,%r12),BASED(cleanup_table_sysc_return+4)
831 bl BASED(cleanup_sysc_return)
8320:
833 clc 4(4,%r12),BASED(cleanup_table_sysc_leave)
834 bl BASED(0f)
835 clc 4(4,%r12),BASED(cleanup_table_sysc_leave+4)
836 bl BASED(cleanup_sysc_leave)
8370:
838 clc 4(4,%r12),BASED(cleanup_table_sysc_work_loop)
839 bl BASED(0f)
840 clc 4(4,%r12),BASED(cleanup_table_sysc_work_loop+4)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700841 bl BASED(cleanup_sysc_return)
Linus Torvalds1da177e2005-04-16 15:20:36 -07008420:
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200843 clc 4(4,%r12),BASED(cleanup_table_io_return)
844 bl BASED(0f)
845 clc 4(4,%r12),BASED(cleanup_table_io_return+4)
846 bl BASED(cleanup_io_return)
8470:
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700848 clc 4(4,%r12),BASED(cleanup_table_io_leave)
849 bl BASED(0f)
850 clc 4(4,%r12),BASED(cleanup_table_io_leave+4)
851 bl BASED(cleanup_io_leave)
8520:
853 clc 4(4,%r12),BASED(cleanup_table_io_work_loop)
854 bl BASED(0f)
855 clc 4(4,%r12),BASED(cleanup_table_io_work_loop+4)
856 bl BASED(cleanup_io_return)
8570:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700858 br %r14
859
860cleanup_system_call:
861 mvc __LC_RETURN_PSW(8),0(%r12)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700862 c %r12,BASED(.Lmck_old_psw)
863 be BASED(0f)
864 la %r12,__LC_SAVE_AREA+16
865 b BASED(1f)
8660: la %r12,__LC_SAVE_AREA+32
8671:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700868#ifdef CONFIG_VIRT_CPU_ACCOUNTING
869 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+4)
870 bh BASED(0f)
871 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
8720: clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+8)
873 bhe BASED(cleanup_vtime)
874#endif
875 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn)
876 bh BASED(0f)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700877 mvc __LC_SAVE_AREA(16),0(%r12)
8780: st %r13,4(%r12)
879 st %r12,__LC_SAVE_AREA+48 # argh
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200880 SAVE_ALL_SYNC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Heiko Carstens77fa2242005-06-25 14:55:30 -0700881 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700882 l %r12,__LC_SAVE_AREA+48 # argh
883 st %r15,12(%r12)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884 lh %r7,0x8a
885#ifdef CONFIG_VIRT_CPU_ACCOUNTING
886cleanup_vtime:
887 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+12)
888 bhe BASED(cleanup_stime)
889 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
890 bz BASED(cleanup_novtime)
891 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
892cleanup_stime:
893 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+16)
894 bh BASED(cleanup_update)
895 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
896cleanup_update:
897 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
898cleanup_novtime:
899#endif
900 mvc __LC_RETURN_PSW+4(4),BASED(cleanup_table_system_call+4)
901 la %r12,__LC_RETURN_PSW
902 br %r14
903cleanup_system_call_insn:
904 .long sysc_saveall + 0x80000000
905#ifdef CONFIG_VIRT_CPU_ACCOUNTING
906 .long system_call + 0x80000000
907 .long sysc_vtime + 0x80000000
908 .long sysc_stime + 0x80000000
909 .long sysc_update + 0x80000000
910#endif
911
912cleanup_sysc_return:
913 mvc __LC_RETURN_PSW(4),0(%r12)
914 mvc __LC_RETURN_PSW+4(4),BASED(cleanup_table_sysc_return)
915 la %r12,__LC_RETURN_PSW
916 br %r14
917
918cleanup_sysc_leave:
919 clc 4(4,%r12),BASED(cleanup_sysc_leave_insn)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700920 be BASED(2f)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700921#ifdef CONFIG_VIRT_CPU_ACCOUNTING
922 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
923 clc 4(4,%r12),BASED(cleanup_sysc_leave_insn+4)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700924 be BASED(2f)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700925#endif
926 mvc __LC_RETURN_PSW(8),SP_PSW(%r15)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700927 c %r12,BASED(.Lmck_old_psw)
928 bne BASED(0f)
929 mvc __LC_SAVE_AREA+32(16),SP_R12(%r15)
930 b BASED(1f)
9310: mvc __LC_SAVE_AREA+16(16),SP_R12(%r15)
9321: lm %r0,%r11,SP_R0(%r15)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700933 l %r15,SP_R15(%r15)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07009342: la %r12,__LC_RETURN_PSW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700935 br %r14
936cleanup_sysc_leave_insn:
937#ifdef CONFIG_VIRT_CPU_ACCOUNTING
938 .long sysc_leave + 14 + 0x80000000
939#endif
940 .long sysc_leave + 10 + 0x80000000
941
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700942cleanup_io_return:
943 mvc __LC_RETURN_PSW(4),0(%r12)
944 mvc __LC_RETURN_PSW+4(4),BASED(cleanup_table_io_work_loop)
945 la %r12,__LC_RETURN_PSW
946 br %r14
947
948cleanup_io_leave:
949 clc 4(4,%r12),BASED(cleanup_io_leave_insn)
950 be BASED(2f)
951#ifdef CONFIG_VIRT_CPU_ACCOUNTING
952 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
953 clc 4(4,%r12),BASED(cleanup_io_leave_insn+4)
954 be BASED(2f)
955#endif
956 mvc __LC_RETURN_PSW(8),SP_PSW(%r15)
957 c %r12,BASED(.Lmck_old_psw)
958 bne BASED(0f)
959 mvc __LC_SAVE_AREA+32(16),SP_R12(%r15)
960 b BASED(1f)
9610: mvc __LC_SAVE_AREA+16(16),SP_R12(%r15)
9621: lm %r0,%r11,SP_R0(%r15)
963 l %r15,SP_R15(%r15)
9642: la %r12,__LC_RETURN_PSW
965 br %r14
966cleanup_io_leave_insn:
967#ifdef CONFIG_VIRT_CPU_ACCOUNTING
968 .long io_leave + 18 + 0x80000000
969#endif
970 .long io_leave + 14 + 0x80000000
971
Linus Torvalds1da177e2005-04-16 15:20:36 -0700972/*
973 * Integer constants
974 */
975 .align 4
976.Lc_spsize: .long SP_SIZE
977.Lc_overhead: .long STACK_FRAME_OVERHEAD
978.Lc_pactive: .long PREEMPT_ACTIVE
979.Lnr_syscalls: .long NR_syscalls
980.L0x018: .short 0x018
981.L0x020: .short 0x020
982.L0x028: .short 0x028
983.L0x030: .short 0x030
984.L0x038: .short 0x038
985.Lc_1: .long 1
986
987/*
988 * Symbol constants
989 */
990.Ls390_mcck: .long s390_do_machine_check
Heiko Carstens77fa2242005-06-25 14:55:30 -0700991.Ls390_handle_mcck:
992 .long s390_handle_mcck
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700993.Lmck_old_psw: .long __LC_MCK_OLD_PSW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700994.Ldo_IRQ: .long do_IRQ
995.Ldo_extint: .long do_extint
996.Ldo_signal: .long do_signal
997.Lhandle_per: .long do_single_step
998.Ljump_table: .long pgm_check_table
999.Lschedule: .long schedule
1000.Lclone: .long sys_clone
1001.Lexecve: .long sys_execve
1002.Lfork: .long sys_fork
1003.Lrt_sigreturn:.long sys_rt_sigreturn
1004.Lrt_sigsuspend:
1005 .long sys_rt_sigsuspend
1006.Lsigreturn: .long sys_sigreturn
1007.Lsigsuspend: .long sys_sigsuspend
1008.Lsigaltstack: .long sys_sigaltstack
1009.Ltrace: .long syscall_trace
1010.Lvfork: .long sys_vfork
1011.Lschedtail: .long schedule_tail
1012
1013.Lcritical_start:
1014 .long __critical_start + 0x80000000
1015.Lcritical_end:
1016 .long __critical_end + 0x80000000
1017.Lcleanup_critical:
1018 .long cleanup_critical
1019
1020#define SYSCALL(esa,esame,emu) .long esa
Linus Torvalds1da177e2005-04-16 15:20:36 -07001021sys_call_table:
1022#include "syscalls.S"
1023#undef SYSCALL
1024