2 * arch/s390/kernel/entry64.S
3 * S390 low-level entry points.
5 * Copyright (C) IBM Corp. 1999,2006
6 * 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),
9 * Heiko Carstens <heiko.carstens@de.ibm.com>
12 #include <linux/sys.h>
13 #include <linux/linkage.h>
14 #include <linux/config.h>
15 #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>
20 #include <asm/asm-offsets.h>
21 #include <asm/unistd.h>
25 * Stack layout for the system_call stack entry.
26 * The first few entries are identical to the user_regs_struct.
28 SP_PTREGS = STACK_FRAME_OVERHEAD
29 SP_ARGS = STACK_FRAME_OVERHEAD + __PT_ARGS
30 SP_PSW = STACK_FRAME_OVERHEAD + __PT_PSW
31 SP_R0 = STACK_FRAME_OVERHEAD + __PT_GPRS
32 SP_R1 = STACK_FRAME_OVERHEAD + __PT_GPRS + 8
33 SP_R2 = STACK_FRAME_OVERHEAD + __PT_GPRS + 16
34 SP_R3 = STACK_FRAME_OVERHEAD + __PT_GPRS + 24
35 SP_R4 = STACK_FRAME_OVERHEAD + __PT_GPRS + 32
36 SP_R5 = STACK_FRAME_OVERHEAD + __PT_GPRS + 40
37 SP_R6 = STACK_FRAME_OVERHEAD + __PT_GPRS + 48
38 SP_R7 = STACK_FRAME_OVERHEAD + __PT_GPRS + 56
39 SP_R8 = STACK_FRAME_OVERHEAD + __PT_GPRS + 64
40 SP_R9 = STACK_FRAME_OVERHEAD + __PT_GPRS + 72
41 SP_R10 = STACK_FRAME_OVERHEAD + __PT_GPRS + 80
42 SP_R11 = STACK_FRAME_OVERHEAD + __PT_GPRS + 88
43 SP_R12 = STACK_FRAME_OVERHEAD + __PT_GPRS + 96
44 SP_R13 = STACK_FRAME_OVERHEAD + __PT_GPRS + 104
45 SP_R14 = STACK_FRAME_OVERHEAD + __PT_GPRS + 112
46 SP_R15 = STACK_FRAME_OVERHEAD + __PT_GPRS + 120
47 SP_ORIG_R2 = STACK_FRAME_OVERHEAD + __PT_ORIG_GPR2
48 SP_ILC = STACK_FRAME_OVERHEAD + __PT_ILC
49 SP_TRAP = STACK_FRAME_OVERHEAD + __PT_TRAP
50 SP_SIZE = STACK_FRAME_OVERHEAD + __PT_SIZE
52 STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
53 STACK_SIZE = 1 << STACK_SHIFT
55 _TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | _TIF_NEED_RESCHED | \
56 _TIF_MCCK_PENDING | _TIF_RESTART_SVC | _TIF_SINGLE_STEP )
57 _TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | _TIF_NEED_RESCHED | \
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 1(%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 psworg,sync
135 mvc \psworg(16),SP_PSW(%r15) # move user PSW to lowcore
137 ni \psworg+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 \psworg # 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
217 tm __TI_flags+5(%r9),(_TIF_31BIT>>16) # 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.)
236 RESTORE_ALL __LC_RETURN_PSW,1
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 | _TIF_RESTORE_SIGMASK)
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 or _TIF_RESTORE_SIGMASK 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 brasl %r14,do_signal # call do_signal
281 tm __TI_flags+7(%r9),_TIF_RESTART_SVC
283 tm __TI_flags+7(%r9),_TIF_SINGLE_STEP
288 # _TIF_RESTART_SVC is set, set up registers and restart svc
291 ni __TI_flags+7(%r9),255-_TIF_RESTART_SVC # clear TIF_RESTART_SVC
292 lg %r7,SP_R2(%r15) # load new svc number
294 mvc SP_R2(8,%r15),SP_ORIG_R2(%r15) # restore first argument
295 lmg %r2,%r6,SP_R2(%r15) # load svc arguments
296 j sysc_do_restart # restart svc
299 # _TIF_SINGLE_STEP is set, call do_single_step
302 ni __TI_flags+7(%r9),255-_TIF_SINGLE_STEP # clear TIF_SINGLE_STEP
303 lhi %r0,__LC_PGM_OLD_PSW
304 sth %r0,SP_TRAP(%r15) # set trap indication to pgm check
305 la %r2,SP_PTREGS(%r15) # address of register-save area
306 larl %r14,sysc_return # load adr. of system return
307 jg do_single_step # branch to do_sigtrap
311 # call syscall_trace before and after system call
312 # special linkage: %r12 contains the return address for trace_svc
315 la %r2,SP_PTREGS(%r15) # load pt_regs
319 brasl %r14,syscall_trace
323 lg %r7,SP_R2(%r15) # strace might have changed the
324 sll %r7,2 # system call
327 lmg %r3,%r6,SP_R3(%r15)
328 lg %r2,SP_ORIG_R2(%r15)
329 basr %r14,%r8 # call sys_xxx
330 stg %r2,SP_R2(%r15) # store return value
332 tm __TI_flags+7(%r9),(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)
334 la %r2,SP_PTREGS(%r15) # load pt_regs
336 larl %r14,sysc_return # return point is sysc_return
340 # a new process exits the kernel with ret_from_fork
344 lg %r13,__LC_SVC_NEW_PSW+8
345 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
346 tm SP_PSW+1(%r15),0x01 # forking a kernel thread ?
348 stg %r15,SP_R15(%r15) # store stack pointer for new kthread
349 0: brasl %r14,schedule_tail
350 stosm 24(%r15),0x03 # reenable interrupts
354 # clone, fork, vfork, exec and sigreturn need glue,
355 # because they all expect pt_regs as parameter,
356 # but are called with different parameter.
357 # return-address is set up above
360 la %r2,SP_PTREGS(%r15) # load pt_regs
361 jg sys_clone # branch to sys_clone
365 la %r2,SP_PTREGS(%r15) # load pt_regs
366 jg sys32_clone # branch to sys32_clone
370 la %r2,SP_PTREGS(%r15) # load pt_regs
371 jg sys_fork # branch to sys_fork
374 la %r2,SP_PTREGS(%r15) # load pt_regs
375 jg sys_vfork # branch to sys_vfork
378 la %r2,SP_PTREGS(%r15) # load pt_regs
379 lgr %r12,%r14 # save return address
380 brasl %r14,sys_execve # call sys_execve
381 ltgr %r2,%r2 # check if execve failed
382 bnz 0(%r12) # it did fail -> store result in gpr2
383 b 6(%r12) # SKIP STG 2,SP_R2(15) in
384 # system_call/sysc_tracesys
387 la %r2,SP_PTREGS(%r15) # load pt_regs
388 lgr %r12,%r14 # save return address
389 brasl %r14,sys32_execve # call sys32_execve
390 ltgr %r2,%r2 # check if execve failed
391 bnz 0(%r12) # it did fail -> store result in gpr2
392 b 6(%r12) # SKIP STG 2,SP_R2(15) in
393 # system_call/sysc_tracesys
397 la %r2,SP_PTREGS(%r15) # load pt_regs as parameter
398 jg sys_sigreturn # branch to sys_sigreturn
401 sys32_sigreturn_glue:
402 la %r2,SP_PTREGS(%r15) # load pt_regs as parameter
403 jg sys32_sigreturn # branch to sys32_sigreturn
406 sys_rt_sigreturn_glue:
407 la %r2,SP_PTREGS(%r15) # load pt_regs as parameter
408 jg sys_rt_sigreturn # branch to sys_sigreturn
411 sys32_rt_sigreturn_glue:
412 la %r2,SP_PTREGS(%r15) # load pt_regs as parameter
413 jg sys32_rt_sigreturn # branch to sys32_sigreturn
416 sys_sigaltstack_glue:
417 la %r4,SP_PTREGS(%r15) # load pt_regs as parameter
418 jg sys_sigaltstack # branch to sys_sigreturn
421 sys32_sigaltstack_glue:
422 la %r4,SP_PTREGS(%r15) # load pt_regs as parameter
423 jg sys32_sigaltstack_wrapper # branch to sys_sigreturn
427 * Program check handler routine
430 .globl pgm_check_handler
433 * First we need to check for a special case:
434 * Single stepping an instruction that disables the PER event mask will
435 * cause a PER event AFTER the mask has been set. Example: SVC or LPSW.
436 * For a single stepped SVC the program check handler gets control after
437 * the SVC new PSW has been loaded. But we want to execute the SVC first and
438 * then handle the PER event. Therefore we update the SVC old PSW to point
439 * to the pgm_check_handler and branch to the SVC handler after we checked
440 * if we have to load the kernel stack register.
441 * For every other possible cause for PER event without the PER mask set
442 * we just ignore the PER event (FIXME: is there anything we have to do
445 STORE_TIMER __LC_SYNC_ENTER_TIMER
446 SAVE_ALL_BASE __LC_SAVE_AREA
447 tm __LC_PGM_INT_CODE+1,0x80 # check whether we got a per exception
448 jnz pgm_per # got per exception -> special case
449 SAVE_ALL __LC_PGM_OLD_PSW,__LC_SAVE_AREA,1
450 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA
451 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
452 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
454 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
455 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
456 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
459 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
460 lgf %r3,__LC_PGM_ILC # load program interruption code
465 larl %r1,pgm_check_table
466 lg %r1,0(%r8,%r1) # load address of handler routine
467 la %r2,SP_PTREGS(%r15) # address of register-save area
468 larl %r14,sysc_return
469 br %r1 # branch to interrupt-handler
472 # handle per exception
475 tm __LC_PGM_OLD_PSW,0x40 # test if per event recording is on
476 jnz pgm_per_std # ok, normal per event from user space
477 # ok its one of the special cases, now we need to find out which one
478 clc __LC_PGM_OLD_PSW(16),__LC_SVC_NEW_PSW
480 # no interesting special case, ignore PER event
481 lmg %r12,%r15,__LC_SAVE_AREA
482 lpswe __LC_PGM_OLD_PSW
485 # Normal per exception
488 SAVE_ALL __LC_PGM_OLD_PSW,__LC_SAVE_AREA,1
489 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA
490 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
491 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
493 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
494 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
495 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
498 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
499 lg %r1,__TI_task(%r9)
500 mvc __THREAD_per+__PER_atmid(2,%r1),__LC_PER_ATMID
501 mvc __THREAD_per+__PER_address(8,%r1),__LC_PER_ADDRESS
502 mvc __THREAD_per+__PER_access_id(1,%r1),__LC_PER_ACCESS_ID
503 oi __TI_flags+7(%r9),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP
504 lgf %r3,__LC_PGM_ILC # load program interruption code
506 ngr %r8,%r3 # clear per-event-bit and ilc
511 # it was a single stepped SVC that is causing all the trouble
514 SAVE_ALL __LC_SVC_OLD_PSW,__LC_SAVE_AREA,1
515 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
516 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
517 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
519 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
520 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
521 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
524 llgh %r7,__LC_SVC_INT_CODE # get svc number from lowcore
525 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
526 lg %r1,__TI_task(%r9)
527 mvc __THREAD_per+__PER_atmid(2,%r1),__LC_PER_ATMID
528 mvc __THREAD_per+__PER_address(8,%r1),__LC_PER_ADDRESS
529 mvc __THREAD_per+__PER_access_id(1,%r1),__LC_PER_ACCESS_ID
530 oi __TI_flags+7(%r9),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP
531 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
535 * IO interrupt handler routine
537 .globl io_int_handler
539 STORE_TIMER __LC_ASYNC_ENTER_TIMER
541 SAVE_ALL_BASE __LC_SAVE_AREA+32
542 SAVE_ALL __LC_IO_OLD_PSW,__LC_SAVE_AREA+32,0
543 CREATE_STACK_FRAME __LC_IO_OLD_PSW,__LC_SAVE_AREA+32
544 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
545 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
547 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
548 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
549 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
552 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
553 la %r2,SP_PTREGS(%r15) # address of register-save area
554 brasl %r14,do_IRQ # call standard irq handler
557 tm SP_PSW+1(%r15),0x01 # returning to user ?
558 #ifdef CONFIG_PREEMPT
559 jno io_preempt # no -> check for preemptive scheduling
561 jno io_leave # no-> skip resched & signal
563 tm __TI_flags+7(%r9),_TIF_WORK_INT
564 jnz io_work # there is work to do (signals etc.)
566 RESTORE_ALL __LC_RETURN_PSW,0
569 #ifdef CONFIG_PREEMPT
571 icm %r0,15,__TI_precount(%r9)
573 # switch to kernel stack
576 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
577 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) # clear back chain
580 tm __TI_flags+7(%r9),_TIF_NEED_RESCHED
583 mvc __TI_precount(4,%r9),0(%r1)
584 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
585 brasl %r14,schedule # call schedule
586 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
587 xc __TI_precount(4,%r9),__TI_precount(%r9)
592 # switch to kernel stack, then check TIF bits
595 lg %r1,__LC_KERNEL_STACK
597 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
598 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) # clear back chain
601 # One of the work bits is on. Find out which one.
602 # Checked are: _TIF_SIGPENDING, _TIF_RESTORE_SIGPENDING, _TIF_NEED_RESCHED
603 # and _TIF_MCCK_PENDING
606 tm __TI_flags+7(%r9),_TIF_MCCK_PENDING
608 tm __TI_flags+7(%r9),_TIF_NEED_RESCHED
610 tm __TI_flags+7(%r9),(_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)
615 # _TIF_MCCK_PENDING is set, call handler
618 larl %r14,io_work_loop
619 jg s390_handle_mcck # TIF bit will be cleared by handler
622 # _TIF_NEED_RESCHED is set, call schedule
625 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
626 brasl %r14,schedule # call scheduler
627 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
628 tm __TI_flags+7(%r9),_TIF_WORK_INT
629 jz io_leave # there is no work to do
633 # _TIF_SIGPENDING or _TIF_RESTORE_SIGMASK is set, call do_signal
636 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
637 la %r2,SP_PTREGS(%r15) # load pt_regs
638 brasl %r14,do_signal # call do_signal
639 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
643 * External interrupt handler routine
645 .globl ext_int_handler
647 STORE_TIMER __LC_ASYNC_ENTER_TIMER
649 SAVE_ALL_BASE __LC_SAVE_AREA+32
650 SAVE_ALL __LC_EXT_OLD_PSW,__LC_SAVE_AREA+32,0
651 CREATE_STACK_FRAME __LC_EXT_OLD_PSW,__LC_SAVE_AREA+32
652 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
653 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
655 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
656 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
657 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
660 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
661 la %r2,SP_PTREGS(%r15) # address of register-save area
662 llgh %r3,__LC_EXT_INT_CODE # get interruption code
669 * Machine check handler routines
671 .globl mcck_int_handler
673 la %r1,4095 # revalidate r1
674 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # revalidate cpu timer
675 mvc __LC_ASYNC_ENTER_TIMER(8),__LC_CPU_TIMER_SAVE_AREA-4095(%r1)
676 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# revalidate gprs
677 SAVE_ALL_BASE __LC_SAVE_AREA+64
678 la %r12,__LC_MCK_OLD_PSW
679 tm __LC_MCCK_CODE,0x80 # system damage?
680 jo mcck_int_main # yes -> rest of mcck code invalid
681 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
683 spt __LC_LAST_UPDATE_TIMER
684 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
685 mvc __LC_ASYNC_ENTER_TIMER(8),__LC_LAST_UPDATE_TIMER
686 mvc __LC_SYNC_ENTER_TIMER(8),__LC_LAST_UPDATE_TIMER
687 mvc __LC_EXIT_TIMER(8),__LC_LAST_UPDATE_TIMER
689 0: tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid?
690 jno mcck_int_main # no -> skip cleanup critical
691 tm __LC_MCK_OLD_PSW+1,0x01 # test problem state bit
692 jnz mcck_int_main # from user -> load kernel stack
693 clc __LC_MCK_OLD_PSW+8(8),BASED(.Lcritical_end)
695 clc __LC_MCK_OLD_PSW+8(8),BASED(.Lcritical_start)
697 brasl %r14,cleanup_critical
699 lg %r14,__LC_PANIC_STACK # are we already on the panic stack?
701 srag %r14,%r14,PAGE_SHIFT
703 lg %r15,__LC_PANIC_STACK # load panic stack
704 0: CREATE_STACK_FRAME __LC_MCK_OLD_PSW,__LC_SAVE_AREA+64
705 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
706 tm __LC_MCCK_CODE+2,0x08 # mwp of old psw valid?
707 jno mcck_no_vtime # no -> no timer update
708 tm __LC_MCK_OLD_PSW+1,0x01 # interrupting from user ?
710 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
711 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
712 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
715 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
716 la %r2,SP_PTREGS(%r15) # load pt_regs
717 brasl %r14,s390_do_machine_check
718 tm SP_PSW+1(%r15),0x01 # returning to user ?
720 lg %r1,__LC_KERNEL_STACK # switch to kernel stack
722 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
723 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) # clear back chain
725 stosm __SF_EMPTY(%r15),0x04 # turn dat on
726 tm __TI_flags+7(%r9),_TIF_MCCK_PENDING
728 brasl %r14,s390_handle_mcck
730 RESTORE_ALL __LC_RETURN_MCCK_PSW,0
734 * Restart interruption handler, kick starter for additional CPUs
736 .globl restart_int_handler
738 lg %r15,__LC_SAVE_AREA+120 # load ksp
739 lghi %r10,__LC_CREGS_SAVE_AREA
740 lctlg %c0,%c15,0(%r10) # get new ctl regs
741 lghi %r10,__LC_AREGS_SAVE_AREA
743 lmg %r6,%r15,__SF_GPRS(%r15) # load registers from clone
744 stosm __SF_EMPTY(%r15),0x04 # now we can turn dat on
748 * If we do not run with SMP enabled, let the new CPU crash ...
750 .globl restart_int_handler
754 lpswe restart_crash-restart_base(%r1)
757 .long 0x000a0000,0x00000000,0x00000000,0x00000000
761 #ifdef CONFIG_CHECK_STACK
763 * The synchronous or the asynchronous stack overflowed. We are dead.
764 * No need to properly save the registers, we are going to panic anyway.
765 * Setup a pt_regs so that show_trace can provide a good call trace.
768 lg %r15,__LC_PANIC_STACK # change to panic stack
770 mvc SP_PSW(16,%r15),0(%r12) # move user PSW to stack
771 stmg %r0,%r11,SP_R0(%r15) # store gprs %r0-%r11 to kernel stack
772 la %r1,__LC_SAVE_AREA
773 chi %r12,__LC_SVC_OLD_PSW
775 chi %r12,__LC_PGM_OLD_PSW
777 la %r1,__LC_SAVE_AREA+16
778 0: mvc SP_R12(32,%r15),0(%r1) # move %r12-%r15 to stack
779 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) # clear back chain
780 la %r2,SP_PTREGS(%r15) # load pt_regs
781 jg kernel_stack_overflow
784 cleanup_table_system_call:
785 .quad system_call, sysc_do_svc
786 cleanup_table_sysc_return:
787 .quad sysc_return, sysc_leave
788 cleanup_table_sysc_leave:
789 .quad sysc_leave, sysc_work_loop
790 cleanup_table_sysc_work_loop:
791 .quad sysc_work_loop, sysc_reschedule
792 cleanup_table_io_leave:
793 .quad io_leave, io_done
794 cleanup_table_io_work_loop:
795 .quad io_work_loop, io_mcck_pending
798 clc 8(8,%r12),BASED(cleanup_table_system_call)
800 clc 8(8,%r12),BASED(cleanup_table_system_call+8)
801 jl cleanup_system_call
803 clc 8(8,%r12),BASED(cleanup_table_sysc_return)
805 clc 8(8,%r12),BASED(cleanup_table_sysc_return+8)
806 jl cleanup_sysc_return
808 clc 8(8,%r12),BASED(cleanup_table_sysc_leave)
810 clc 8(8,%r12),BASED(cleanup_table_sysc_leave+8)
811 jl cleanup_sysc_leave
813 clc 8(8,%r12),BASED(cleanup_table_sysc_work_loop)
815 clc 8(8,%r12),BASED(cleanup_table_sysc_work_loop+8)
816 jl cleanup_sysc_return
818 clc 8(8,%r12),BASED(cleanup_table_io_leave)
820 clc 8(8,%r12),BASED(cleanup_table_io_leave+8)
823 clc 8(8,%r12),BASED(cleanup_table_io_work_loop)
825 clc 8(8,%r12),BASED(cleanup_table_io_work_loop+8)
831 mvc __LC_RETURN_PSW(16),0(%r12)
832 cghi %r12,__LC_MCK_OLD_PSW
834 la %r12,__LC_SAVE_AREA+32
836 0: la %r12,__LC_SAVE_AREA+64
838 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
839 clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn+8)
841 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
842 0: clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn+16)
845 clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn)
847 mvc __LC_SAVE_AREA(32),0(%r12)
849 stg %r12,__LC_SAVE_AREA+96 # argh
850 SAVE_ALL __LC_SVC_OLD_PSW,__LC_SAVE_AREA,1
851 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
852 lg %r12,__LC_SAVE_AREA+96 # argh
854 llgh %r7,__LC_SVC_INT_CODE
855 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
857 clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn+24)
859 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
861 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
863 clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn+32)
865 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
867 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
870 mvc __LC_RETURN_PSW+8(8),BASED(cleanup_table_system_call+8)
871 la %r12,__LC_RETURN_PSW
873 cleanup_system_call_insn:
875 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
883 mvc __LC_RETURN_PSW(8),0(%r12)
884 mvc __LC_RETURN_PSW+8(8),BASED(cleanup_table_sysc_return)
885 la %r12,__LC_RETURN_PSW
889 clc 8(8,%r12),BASED(cleanup_sysc_leave_insn)
891 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
892 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
893 clc 8(8,%r12),BASED(cleanup_sysc_leave_insn+8)
896 mvc __LC_RETURN_PSW(16),SP_PSW(%r15)
897 cghi %r12,__LC_MCK_OLD_PSW
899 mvc __LC_SAVE_AREA+64(32),SP_R12(%r15)
901 0: mvc __LC_SAVE_AREA+32(32),SP_R12(%r15)
902 1: lmg %r0,%r11,SP_R0(%r15)
904 2: la %r12,__LC_RETURN_PSW
906 cleanup_sysc_leave_insn:
907 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
908 .quad sysc_leave + 16
910 .quad sysc_leave + 12
913 mvc __LC_RETURN_PSW(8),0(%r12)
914 mvc __LC_RETURN_PSW+8(8),BASED(cleanup_table_io_work_loop)
915 la %r12,__LC_RETURN_PSW
919 clc 8(8,%r12),BASED(cleanup_io_leave_insn)
921 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
922 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
923 clc 8(8,%r12),BASED(cleanup_io_leave_insn+8)
926 mvc __LC_RETURN_PSW(16),SP_PSW(%r15)
927 cghi %r12,__LC_MCK_OLD_PSW
929 mvc __LC_SAVE_AREA+64(32),SP_R12(%r15)
931 0: mvc __LC_SAVE_AREA+32(32),SP_R12(%r15)
932 1: lmg %r0,%r11,SP_R0(%r15)
934 2: la %r12,__LC_RETURN_PSW
936 cleanup_io_leave_insn:
937 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
947 .Lc_pactive: .long PREEMPT_ACTIVE
948 .Lnr_syscalls: .long NR_syscalls
949 .L0x0130: .short 0x130
950 .L0x0140: .short 0x140
951 .L0x0150: .short 0x150
952 .L0x0160: .short 0x160
953 .L0x0170: .short 0x170
955 .quad __critical_start
959 #define SYSCALL(esa,esame,emu) .long esame
960 .globl sys_call_table
962 #include "syscalls.S"
967 #define SYSCALL(esa,esame,emu) .long emu
968 .globl sys_call_table_emu
970 #include "syscalls.S"