2 * arch/s390/kernel/entry.S
3 * S390 low-level entry points.
6 * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
8 * Hartmut Penner (hp@de.ibm.com),
9 * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
10 * Heiko Carstens <heiko.carstens@de.ibm.com>
13 #include <linux/sys.h>
14 #include <linux/linkage.h>
15 #include <linux/config.h>
16 #include <asm/cache.h>
17 #include <asm/lowcore.h>
18 #include <asm/errno.h>
19 #include <asm/ptrace.h>
20 #include <asm/thread_info.h>
21 #include <asm/offsets.h>
22 #include <asm/unistd.h>
26 * Stack layout for the system_call stack entry.
27 * The first few entries are identical to the user_regs_struct.
29 SP_PTREGS = STACK_FRAME_OVERHEAD
30 SP_ARGS = STACK_FRAME_OVERHEAD + __PT_ARGS
31 SP_PSW = STACK_FRAME_OVERHEAD + __PT_PSW
32 SP_R0 = STACK_FRAME_OVERHEAD + __PT_GPRS
33 SP_R1 = STACK_FRAME_OVERHEAD + __PT_GPRS + 8
34 SP_R2 = STACK_FRAME_OVERHEAD + __PT_GPRS + 16
35 SP_R3 = STACK_FRAME_OVERHEAD + __PT_GPRS + 24
36 SP_R4 = STACK_FRAME_OVERHEAD + __PT_GPRS + 32
37 SP_R5 = STACK_FRAME_OVERHEAD + __PT_GPRS + 40
38 SP_R6 = STACK_FRAME_OVERHEAD + __PT_GPRS + 48
39 SP_R7 = STACK_FRAME_OVERHEAD + __PT_GPRS + 56
40 SP_R8 = STACK_FRAME_OVERHEAD + __PT_GPRS + 64
41 SP_R9 = STACK_FRAME_OVERHEAD + __PT_GPRS + 72
42 SP_R10 = STACK_FRAME_OVERHEAD + __PT_GPRS + 80
43 SP_R11 = STACK_FRAME_OVERHEAD + __PT_GPRS + 88
44 SP_R12 = STACK_FRAME_OVERHEAD + __PT_GPRS + 96
45 SP_R13 = STACK_FRAME_OVERHEAD + __PT_GPRS + 104
46 SP_R14 = STACK_FRAME_OVERHEAD + __PT_GPRS + 112
47 SP_R15 = STACK_FRAME_OVERHEAD + __PT_GPRS + 120
48 SP_ORIG_R2 = STACK_FRAME_OVERHEAD + __PT_ORIG_GPR2
49 SP_ILC = STACK_FRAME_OVERHEAD + __PT_ILC
50 SP_TRAP = STACK_FRAME_OVERHEAD + __PT_TRAP
51 SP_SIZE = STACK_FRAME_OVERHEAD + __PT_SIZE
53 STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
54 STACK_SIZE = 1 << STACK_SHIFT
56 _TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_MCCK_PENDING | \
57 _TIF_RESTART_SVC | _TIF_SINGLE_STEP )
58 _TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_MCCK_PENDING)
60 #define BASED(name) name-system_call(%r13)
62 .macro STORE_TIMER lc_offset
63 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
68 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
69 .macro UPDATE_VTIME lc_from,lc_to,lc_sum
78 * Register usage in interrupt handlers:
79 * R9 - pointer to current task structure
80 * R13 - pointer to literal pool
81 * R14 - return register for function calls
82 * R15 - kernel stack pointer
85 .macro SAVE_ALL_BASE savearea
86 stmg %r12,%r15,\savearea
90 .macro SAVE_ALL psworg,savearea,sync
93 tm \psworg+1,0x01 # test problem state bit
94 jz 2f # skip stack setup save
95 lg %r15,__LC_KERNEL_STACK # problem state -> load ksp
97 tm \psworg+1,0x01 # test problem state bit
98 jnz 1f # from user -> load kernel stack
99 clc \psworg+8(8),BASED(.Lcritical_end)
101 clc \psworg+8(8),BASED(.Lcritical_start)
103 brasl %r14,cleanup_critical
104 tm 0(%r12),0x01 # retest problem state after cleanup
106 0: lg %r14,__LC_ASYNC_STACK # are we already on the async. stack ?
108 srag %r14,%r14,STACK_SHIFT
110 1: lg %r15,__LC_ASYNC_STACK # load async stack
112 #ifdef CONFIG_CHECK_STACK
114 2: tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
121 .macro CREATE_STACK_FRAME psworg,savearea
122 aghi %r15,-SP_SIZE # make room for registers & psw
123 mvc SP_PSW(16,%r15),0(%r12) # move user PSW to stack
125 stg %r2,SP_ORIG_R2(%r15) # store original content of gpr 2
126 icm %r12,12,__LC_SVC_ILC
127 stmg %r0,%r11,SP_R0(%r15) # store gprs %r0-%r11 to kernel stack
129 mvc SP_R12(32,%r15),\savearea # move %r12-%r15 to stack
131 stg %r12,__SF_BACKCHAIN(%r15)
134 .macro RESTORE_ALL sync
135 mvc __LC_RETURN_PSW(16),SP_PSW(%r15) # move user PSW to lowcore
137 ni __LC_RETURN_PSW+1,0xfd # clear wait state bit
139 lmg %r0,%r15,SP_R0(%r15) # load gprs 0-15 of user
140 STORE_TIMER __LC_EXIT_TIMER
141 lpswe __LC_RETURN_PSW # back to caller
145 * Scheduler resume function, called by switch_to
146 * gpr2 = (task_struct *) prev
147 * gpr3 = (task_struct *) next
153 tm __THREAD_per+4(%r3),0xe8 # is the new process using per ?
154 jz __switch_to_noper # if not we're fine
155 stctg %c9,%c11,__SF_EMPTY(%r15)# We are using per stuff
156 clc __THREAD_per(24,%r3),__SF_EMPTY(%r15)
157 je __switch_to_noper # we got away without bashing TLB's
158 lctlg %c9,%c11,__THREAD_per(%r3) # Nope we didn't
160 lg %r4,__THREAD_info(%r2) # get thread_info of prev
161 tm __TI_flags+7(%r4),_TIF_MCCK_PENDING # machine check pending?
162 jz __switch_to_no_mcck
163 ni __TI_flags+7(%r4),255-_TIF_MCCK_PENDING # clear flag in prev
164 lg %r4,__THREAD_info(%r3) # get thread_info of next
165 oi __TI_flags+7(%r4),_TIF_MCCK_PENDING # set it in next
167 stmg %r6,%r15,__SF_GPRS(%r15)# store __switch_to registers of prev task
168 stg %r15,__THREAD_ksp(%r2) # store kernel stack to prev->tss.ksp
169 lg %r15,__THREAD_ksp(%r3) # load kernel stack from next->tss.ksp
170 lmg %r6,%r15,__SF_GPRS(%r15)# load __switch_to registers of next task
171 stg %r3,__LC_CURRENT # __LC_CURRENT = current task struct
172 lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4
173 lg %r3,__THREAD_info(%r3) # load thread_info from task struct
174 stg %r3,__LC_THREAD_INFO
176 stg %r3,__LC_KERNEL_STACK # __LC_KERNEL_STACK = new kernel stack
181 * SVC interrupt handler routine. System calls are synchronous events and
182 * are executed with interrupts enabled.
187 STORE_TIMER __LC_SYNC_ENTER_TIMER
189 SAVE_ALL_BASE __LC_SAVE_AREA
190 SAVE_ALL __LC_SVC_OLD_PSW,__LC_SAVE_AREA,1
191 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
192 llgh %r7,__LC_SVC_INT_CODE # get svc number from lowcore
193 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
195 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
197 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
199 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
201 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
204 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
205 slag %r7,%r7,2 # *4 and test for svc 0
207 # svc 0: system call number in %r1
208 cl %r1,BASED(.Lnr_syscalls)
210 lgfr %r7,%r1 # clear high word in r1
211 slag %r7,%r7,2 # svc 0: system call number in %r1
213 mvc SP_ARGS(8,%r15),SP_R7(%r15)
215 larl %r10,sys_call_table
216 #ifdef CONFIG_S390_SUPPORT
217 tm SP_PSW+3(%r15),0x01 # are we running in 31 bit mode ?
219 larl %r10,sys_call_table_emu # use 31 bit emulation system calls
222 tm __TI_flags+7(%r9),(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)
223 lgf %r8,0(%r7,%r10) # load address of system call routine
225 basr %r14,%r8 # call sys_xxxx
226 stg %r2,SP_R2(%r15) # store return value (change R2 on stack)
227 # ATTENTION: check sys_execve_glue before
228 # changing anything here !!
231 tm SP_PSW+1(%r15),0x01 # returning to user ?
233 tm __TI_flags+7(%r9),_TIF_WORK_SVC
234 jnz sysc_work # there is work to do (signals etc.)
239 # recheck if there is more work to do
242 tm __TI_flags+7(%r9),_TIF_WORK_SVC
243 jz sysc_leave # there is no work to do
245 # One of the work bits is on. Find out which one.
248 tm __TI_flags+7(%r9),_TIF_MCCK_PENDING
250 tm __TI_flags+7(%r9),_TIF_NEED_RESCHED
252 tm __TI_flags+7(%r9),_TIF_SIGPENDING
254 tm __TI_flags+7(%r9),_TIF_RESTART_SVC
256 tm __TI_flags+7(%r9),_TIF_SINGLE_STEP
261 # _TIF_NEED_RESCHED is set, call schedule
264 larl %r14,sysc_work_loop
265 jg schedule # return point is sysc_return
268 # _TIF_MCCK_PENDING is set, call handler
271 larl %r14,sysc_work_loop
272 jg s390_handle_mcck # TIF bit will be cleared by handler
275 # _TIF_SIGPENDING is set, call do_signal
278 ni __TI_flags+7(%r9),255-_TIF_SINGLE_STEP # clear TIF_SINGLE_STEP
279 la %r2,SP_PTREGS(%r15) # load pt_regs
280 sgr %r3,%r3 # clear *oldset
281 brasl %r14,do_signal # call do_signal
282 tm __TI_flags+7(%r9),_TIF_RESTART_SVC
284 tm __TI_flags+7(%r9),_TIF_SINGLE_STEP
286 j sysc_leave # out of here, do NOT recheck
289 # _TIF_RESTART_SVC is set, set up registers and restart svc
292 ni __TI_flags+7(%r9),255-_TIF_RESTART_SVC # clear TIF_RESTART_SVC
293 lg %r7,SP_R2(%r15) # load new svc number
295 mvc SP_R2(8,%r15),SP_ORIG_R2(%r15) # restore first argument
296 lmg %r2,%r6,SP_R2(%r15) # load svc arguments
297 j sysc_do_restart # restart svc
300 # _TIF_SINGLE_STEP is set, call do_single_step
303 ni __TI_flags+7(%r9),255-_TIF_SINGLE_STEP # clear TIF_SINGLE_STEP
304 lhi %r0,__LC_PGM_OLD_PSW
305 sth %r0,SP_TRAP(%r15) # set trap indication to pgm check
306 la %r2,SP_PTREGS(%r15) # address of register-save area
307 larl %r14,sysc_return # load adr. of system return
308 jg do_single_step # branch to do_sigtrap
314 # call syscall_trace before and after system call
315 # special linkage: %r12 contains the return address for trace_svc
318 la %r2,SP_PTREGS(%r15) # load pt_regs
322 brasl %r14,syscall_trace
326 lg %r7,SP_R2(%r15) # strace might have changed the
327 sll %r7,2 # system call
330 lmg %r3,%r6,SP_R3(%r15)
331 lg %r2,SP_ORIG_R2(%r15)
332 basr %r14,%r8 # call sys_xxx
333 stg %r2,SP_R2(%r15) # store return value
335 tm __TI_flags+7(%r9),(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)
337 la %r2,SP_PTREGS(%r15) # load pt_regs
339 larl %r14,sysc_return # return point is sysc_return
343 # a new process exits the kernel with ret_from_fork
347 lg %r13,__LC_SVC_NEW_PSW+8
348 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
349 tm SP_PSW+1(%r15),0x01 # forking a kernel thread ?
351 stg %r15,SP_R15(%r15) # store stack pointer for new kthread
352 0: brasl %r14,schedule_tail
353 stosm 24(%r15),0x03 # reenable interrupts
357 # clone, fork, vfork, exec and sigreturn need glue,
358 # because they all expect pt_regs as parameter,
359 # but are called with different parameter.
360 # return-address is set up above
363 la %r2,SP_PTREGS(%r15) # load pt_regs
364 jg sys_clone # branch to sys_clone
366 #ifdef CONFIG_S390_SUPPORT
368 la %r2,SP_PTREGS(%r15) # load pt_regs
369 jg sys32_clone # branch to sys32_clone
373 la %r2,SP_PTREGS(%r15) # load pt_regs
374 jg sys_fork # branch to sys_fork
377 la %r2,SP_PTREGS(%r15) # load pt_regs
378 jg sys_vfork # branch to sys_vfork
381 la %r2,SP_PTREGS(%r15) # load pt_regs
382 lgr %r12,%r14 # save return address
383 brasl %r14,sys_execve # call sys_execve
384 ltgr %r2,%r2 # check if execve failed
385 bnz 0(%r12) # it did fail -> store result in gpr2
386 b 6(%r12) # SKIP STG 2,SP_R2(15) in
387 # system_call/sysc_tracesys
388 #ifdef CONFIG_S390_SUPPORT
390 la %r2,SP_PTREGS(%r15) # load pt_regs
391 lgr %r12,%r14 # save return address
392 brasl %r14,sys32_execve # call sys32_execve
393 ltgr %r2,%r2 # check if execve failed
394 bnz 0(%r12) # it did fail -> store result in gpr2
395 b 6(%r12) # SKIP STG 2,SP_R2(15) in
396 # system_call/sysc_tracesys
400 la %r2,SP_PTREGS(%r15) # load pt_regs as parameter
401 jg sys_sigreturn # branch to sys_sigreturn
403 #ifdef CONFIG_S390_SUPPORT
404 sys32_sigreturn_glue:
405 la %r2,SP_PTREGS(%r15) # load pt_regs as parameter
406 jg sys32_sigreturn # branch to sys32_sigreturn
409 sys_rt_sigreturn_glue:
410 la %r2,SP_PTREGS(%r15) # load pt_regs as parameter
411 jg sys_rt_sigreturn # branch to sys_sigreturn
413 #ifdef CONFIG_S390_SUPPORT
414 sys32_rt_sigreturn_glue:
415 la %r2,SP_PTREGS(%r15) # load pt_regs as parameter
416 jg sys32_rt_sigreturn # branch to sys32_sigreturn
420 # sigsuspend and rt_sigsuspend need pt_regs as an additional
421 # parameter and they have to skip the store of %r2 into the
422 # user register %r2 because the return value was set in
423 # sigsuspend and rt_sigsuspend already and must not be overwritten!
427 lgr %r5,%r4 # move mask back
428 lgr %r4,%r3 # move history1 parameter
429 lgr %r3,%r2 # move history0 parameter
430 la %r2,SP_PTREGS(%r15) # load pt_regs as first parameter
431 la %r14,6(%r14) # skip store of return value
432 jg sys_sigsuspend # branch to sys_sigsuspend
434 #ifdef CONFIG_S390_SUPPORT
435 sys32_sigsuspend_glue:
436 llgfr %r4,%r4 # unsigned long
437 lgr %r5,%r4 # move mask back
439 lgr %r4,%r3 # move history1 parameter
441 lgr %r3,%r2 # move history0 parameter
442 la %r2,SP_PTREGS(%r15) # load pt_regs as first parameter
443 la %r14,6(%r14) # skip store of return value
444 jg sys32_sigsuspend # branch to sys32_sigsuspend
447 sys_rt_sigsuspend_glue:
448 lgr %r4,%r3 # move sigsetsize parameter
449 lgr %r3,%r2 # move unewset parameter
450 la %r2,SP_PTREGS(%r15) # load pt_regs as first parameter
451 la %r14,6(%r14) # skip store of return value
452 jg sys_rt_sigsuspend # branch to sys_rt_sigsuspend
454 #ifdef CONFIG_S390_SUPPORT
455 sys32_rt_sigsuspend_glue:
456 llgfr %r3,%r3 # size_t
457 lgr %r4,%r3 # move sigsetsize parameter
458 llgtr %r2,%r2 # sigset_emu31_t *
459 lgr %r3,%r2 # move unewset parameter
460 la %r2,SP_PTREGS(%r15) # load pt_regs as first parameter
461 la %r14,6(%r14) # skip store of return value
462 jg sys32_rt_sigsuspend # branch to sys32_rt_sigsuspend
465 sys_sigaltstack_glue:
466 la %r4,SP_PTREGS(%r15) # load pt_regs as parameter
467 jg sys_sigaltstack # branch to sys_sigreturn
469 #ifdef CONFIG_S390_SUPPORT
470 sys32_sigaltstack_glue:
471 la %r4,SP_PTREGS(%r15) # load pt_regs as parameter
472 jg sys32_sigaltstack_wrapper # branch to sys_sigreturn
476 * Program check handler routine
479 .globl pgm_check_handler
482 * First we need to check for a special case:
483 * Single stepping an instruction that disables the PER event mask will
484 * cause a PER event AFTER the mask has been set. Example: SVC or LPSW.
485 * For a single stepped SVC the program check handler gets control after
486 * the SVC new PSW has been loaded. But we want to execute the SVC first and
487 * then handle the PER event. Therefore we update the SVC old PSW to point
488 * to the pgm_check_handler and branch to the SVC handler after we checked
489 * if we have to load the kernel stack register.
490 * For every other possible cause for PER event without the PER mask set
491 * we just ignore the PER event (FIXME: is there anything we have to do
494 STORE_TIMER __LC_SYNC_ENTER_TIMER
495 SAVE_ALL_BASE __LC_SAVE_AREA
496 tm __LC_PGM_INT_CODE+1,0x80 # check whether we got a per exception
497 jnz pgm_per # got per exception -> special case
498 SAVE_ALL __LC_PGM_OLD_PSW,__LC_SAVE_AREA,1
499 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA
500 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
501 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
503 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
504 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
505 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
508 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
509 lgf %r3,__LC_PGM_ILC # load program interruption code
514 larl %r1,pgm_check_table
515 lg %r1,0(%r8,%r1) # load address of handler routine
516 la %r2,SP_PTREGS(%r15) # address of register-save area
517 larl %r14,sysc_return
518 br %r1 # branch to interrupt-handler
521 # handle per exception
524 tm __LC_PGM_OLD_PSW,0x40 # test if per event recording is on
525 jnz pgm_per_std # ok, normal per event from user space
526 # ok its one of the special cases, now we need to find out which one
527 clc __LC_PGM_OLD_PSW(16),__LC_SVC_NEW_PSW
529 # no interesting special case, ignore PER event
530 lmg %r12,%r15,__LC_SAVE_AREA
531 lpswe __LC_PGM_OLD_PSW
534 # Normal per exception
537 SAVE_ALL __LC_PGM_OLD_PSW,__LC_SAVE_AREA,1
538 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA
539 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
540 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
542 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
543 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
544 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
547 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
548 lg %r1,__TI_task(%r9)
549 mvc __THREAD_per+__PER_atmid(2,%r1),__LC_PER_ATMID
550 mvc __THREAD_per+__PER_address(8,%r1),__LC_PER_ADDRESS
551 mvc __THREAD_per+__PER_access_id(1,%r1),__LC_PER_ACCESS_ID
552 oi __TI_flags+7(%r9),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP
553 lgf %r3,__LC_PGM_ILC # load program interruption code
555 ngr %r8,%r3 # clear per-event-bit and ilc
560 # it was a single stepped SVC that is causing all the trouble
563 SAVE_ALL __LC_SVC_OLD_PSW,__LC_SAVE_AREA,1
564 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
565 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
566 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
568 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
569 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
570 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
573 llgh %r7,__LC_SVC_INT_CODE # get svc number from lowcore
574 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
575 lg %r1,__TI_task(%r9)
576 mvc __THREAD_per+__PER_atmid(2,%r1),__LC_PER_ATMID
577 mvc __THREAD_per+__PER_address(8,%r1),__LC_PER_ADDRESS
578 mvc __THREAD_per+__PER_access_id(1,%r1),__LC_PER_ACCESS_ID
579 oi __TI_flags+7(%r9),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP
580 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
584 * IO interrupt handler routine
586 .globl io_int_handler
588 STORE_TIMER __LC_ASYNC_ENTER_TIMER
590 SAVE_ALL_BASE __LC_SAVE_AREA+32
591 SAVE_ALL __LC_IO_OLD_PSW,__LC_SAVE_AREA+32,0
592 CREATE_STACK_FRAME __LC_IO_OLD_PSW,__LC_SAVE_AREA+32
593 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
594 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
596 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
597 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
598 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
601 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
602 la %r2,SP_PTREGS(%r15) # address of register-save area
603 brasl %r14,do_IRQ # call standard irq handler
606 tm SP_PSW+1(%r15),0x01 # returning to user ?
607 #ifdef CONFIG_PREEMPT
608 jno io_preempt # no -> check for preemptive scheduling
610 jno io_leave # no-> skip resched & signal
612 tm __TI_flags+7(%r9),_TIF_WORK_INT
613 jnz io_work # there is work to do (signals etc.)
617 #ifdef CONFIG_PREEMPT
619 icm %r0,15,__TI_precount(%r9)
621 # switch to kernel stack
624 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
625 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) # clear back chain
628 tm __TI_flags+7(%r9),_TIF_NEED_RESCHED
631 mvc __TI_precount(4,%r9),0(%r1)
632 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
633 brasl %r14,schedule # call schedule
634 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
635 xc __TI_precount(4,%r9),__TI_precount(%r9)
640 # switch to kernel stack, then check TIF bits
643 lg %r1,__LC_KERNEL_STACK
645 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
646 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) # clear back chain
649 # One of the work bits is on. Find out which one.
650 # Checked are: _TIF_SIGPENDING, _TIF_NEED_RESCHED and _TIF_MCCK_PENDING
653 tm __TI_flags+7(%r9),_TIF_MCCK_PENDING
655 tm __TI_flags+7(%r9),_TIF_NEED_RESCHED
657 tm __TI_flags+7(%r9),_TIF_SIGPENDING
662 # _TIF_MCCK_PENDING is set, call handler
665 larl %r14,io_work_loop
666 jg s390_handle_mcck # TIF bit will be cleared by handler
669 # _TIF_NEED_RESCHED is set, call schedule
672 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
673 brasl %r14,schedule # call scheduler
674 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
675 tm __TI_flags+7(%r9),_TIF_WORK_INT
676 jz io_leave # there is no work to do
680 # _TIF_SIGPENDING is set, call do_signal
683 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
684 la %r2,SP_PTREGS(%r15) # load pt_regs
685 slgr %r3,%r3 # clear *oldset
686 brasl %r14,do_signal # call do_signal
687 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
688 j sysc_leave # out of here, do NOT recheck
691 * External interrupt handler routine
693 .globl ext_int_handler
695 STORE_TIMER __LC_ASYNC_ENTER_TIMER
697 SAVE_ALL_BASE __LC_SAVE_AREA+32
698 SAVE_ALL __LC_EXT_OLD_PSW,__LC_SAVE_AREA+32,0
699 CREATE_STACK_FRAME __LC_EXT_OLD_PSW,__LC_SAVE_AREA+32
700 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
701 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
703 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
704 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
705 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
708 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
709 la %r2,SP_PTREGS(%r15) # address of register-save area
710 llgh %r3,__LC_EXT_INT_CODE # get interruption code
715 * Machine check handler routines
717 .globl mcck_int_handler
719 la %r1,4095 # revalidate r1
720 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # revalidate cpu timer
721 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# revalidate gprs
722 SAVE_ALL_BASE __LC_SAVE_AREA+64
723 la %r12,__LC_MCK_OLD_PSW
724 tm __LC_MCCK_CODE,0x80 # system damage?
725 jo mcck_int_main # yes -> rest of mcck code invalid
726 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
728 spt __LC_LAST_UPDATE_TIMER
729 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
730 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
731 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
732 mvc __LC_LAST_UPDATE_TIMER(8),__LC_EXIT_TIMER
733 0: tm __LC_MCCK_CODE+2,0x08 # mwp of old psw valid?
734 jno mcck_no_vtime # no -> no timer update
735 tm __LC_MCK_OLD_PSW+1,0x01 # interrupting from user ?
737 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
738 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
739 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
743 tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid?
744 jno mcck_int_main # no -> skip cleanup critical
745 tm __LC_MCK_OLD_PSW+1,0x01 # test problem state bit
746 jnz mcck_int_main # from user -> load kernel stack
747 clc __LC_MCK_OLD_PSW+8(8),BASED(.Lcritical_end)
749 clc __LC_MCK_OLD_PSW+8(8),BASED(.Lcritical_start)
751 brasl %r14,cleanup_critical
753 lg %r14,__LC_PANIC_STACK # are we already on the panic stack?
755 srag %r14,%r14,PAGE_SHIFT
757 lg %r15,__LC_PANIC_STACK # load panic stack
758 0: CREATE_STACK_FRAME __LC_MCK_OLD_PSW,__LC_SAVE_AREA+64
759 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
760 la %r2,SP_PTREGS(%r15) # load pt_regs
761 brasl %r14,s390_do_machine_check
762 tm SP_PSW+1(%r15),0x01 # returning to user ?
764 lg %r1,__LC_KERNEL_STACK # switch to kernel stack
766 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
767 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) # clear back chain
769 stosm __SF_EMPTY(%r15),0x04 # turn dat on
770 tm __TI_flags+7(%r9),_TIF_MCCK_PENDING
772 brasl %r14,s390_handle_mcck
778 * Restart interruption handler, kick starter for additional CPUs
780 .globl restart_int_handler
782 lg %r15,__LC_SAVE_AREA+120 # load ksp
783 lghi %r10,__LC_CREGS_SAVE_AREA
784 lctlg %c0,%c15,0(%r10) # get new ctl regs
785 lghi %r10,__LC_AREGS_SAVE_AREA
787 lmg %r6,%r15,__SF_GPRS(%r15) # load registers from clone
788 stosm __SF_EMPTY(%r15),0x04 # now we can turn dat on
792 * If we do not run with SMP enabled, let the new CPU crash ...
794 .globl restart_int_handler
798 lpswe restart_crash-restart_base(%r1)
801 .long 0x000a0000,0x00000000,0x00000000,0x00000000
805 #ifdef CONFIG_CHECK_STACK
807 * The synchronous or the asynchronous stack overflowed. We are dead.
808 * No need to properly save the registers, we are going to panic anyway.
809 * Setup a pt_regs so that show_trace can provide a good call trace.
812 lg %r15,__LC_PANIC_STACK # change to panic stack
814 mvc SP_PSW(16,%r15),0(%r12) # move user PSW to stack
815 stmg %r0,%r11,SP_R0(%r15) # store gprs %r0-%r11 to kernel stack
816 la %r1,__LC_SAVE_AREA
817 chi %r12,__LC_SVC_OLD_PSW
819 chi %r12,__LC_PGM_OLD_PSW
821 la %r1,__LC_SAVE_AREA+16
822 0: mvc SP_R12(32,%r15),0(%r1) # move %r12-%r15 to stack
823 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) # clear back chain
824 la %r2,SP_PTREGS(%r15) # load pt_regs
825 jg kernel_stack_overflow
828 cleanup_table_system_call:
829 .quad system_call, sysc_do_svc
830 cleanup_table_sysc_return:
831 .quad sysc_return, sysc_leave
832 cleanup_table_sysc_leave:
833 .quad sysc_leave, sysc_work_loop
834 cleanup_table_sysc_work_loop:
835 .quad sysc_work_loop, sysc_reschedule
838 clc 8(8,%r12),BASED(cleanup_table_system_call)
840 clc 8(8,%r12),BASED(cleanup_table_system_call+8)
841 jl cleanup_system_call
843 clc 8(8,%r12),BASED(cleanup_table_sysc_return)
845 clc 8(8,%r12),BASED(cleanup_table_sysc_return+8)
846 jl cleanup_sysc_return
848 clc 8(8,%r12),BASED(cleanup_table_sysc_leave)
850 clc 8(8,%r12),BASED(cleanup_table_sysc_leave+8)
851 jl cleanup_sysc_leave
853 clc 8(8,%r12),BASED(cleanup_table_sysc_work_loop)
855 clc 8(8,%r12),BASED(cleanup_table_sysc_work_loop+8)
856 jl cleanup_sysc_return
861 mvc __LC_RETURN_PSW(16),0(%r12)
862 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
863 clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn+8)
865 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
866 0: clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn+16)
869 clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn)
871 mvc __LC_SAVE_AREA(32),__LC_SAVE_AREA+32
872 0: stg %r13,__LC_SAVE_AREA+40
873 SAVE_ALL __LC_SVC_OLD_PSW,__LC_SAVE_AREA,1
874 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
875 stg %r15,__LC_SAVE_AREA+56
876 llgh %r7,__LC_SVC_INT_CODE
877 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
879 clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn+24)
881 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
883 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
885 clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn+32)
887 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
889 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
892 mvc __LC_RETURN_PSW+8(8),BASED(cleanup_table_system_call+8)
893 la %r12,__LC_RETURN_PSW
895 cleanup_system_call_insn:
897 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
905 mvc __LC_RETURN_PSW(8),0(%r12)
906 mvc __LC_RETURN_PSW+8(8),BASED(cleanup_table_sysc_return)
907 la %r12,__LC_RETURN_PSW
911 clc 8(8,%r12),BASED(cleanup_sysc_leave_insn)
913 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
914 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
915 clc 8(8,%r12),BASED(cleanup_sysc_leave_insn+8)
918 mvc __LC_RETURN_PSW(16),SP_PSW(%r15)
919 mvc __LC_SAVE_AREA+32(32),SP_R12(%r15)
920 lmg %r0,%r11,SP_R0(%r15)
922 0: la %r12,__LC_RETURN_PSW
924 cleanup_sysc_leave_insn:
925 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
926 .quad sysc_leave + 16
928 .quad sysc_leave + 12
935 .Lc_pactive: .long PREEMPT_ACTIVE
936 .Lnr_syscalls: .long NR_syscalls
937 .L0x0130: .short 0x130
938 .L0x0140: .short 0x140
939 .L0x0150: .short 0x150
940 .L0x0160: .short 0x160
941 .L0x0170: .short 0x170
943 .quad __critical_start
947 #define SYSCALL(esa,esame,emu) .long esame
948 .globl sys_call_table
950 #include "syscalls.S"
953 #ifdef CONFIG_S390_SUPPORT
955 #define SYSCALL(esa,esame,emu) .long emu
956 .globl sys_call_table_emu
958 #include "syscalls.S"