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 <asm/cache.h>
15 #include <asm/lowcore.h>
16 #include <asm/errno.h>
17 #include <asm/ptrace.h>
18 #include <asm/thread_info.h>
19 #include <asm/asm-offsets.h>
20 #include <asm/unistd.h>
24 * Stack layout for the system_call stack entry.
25 * The first few entries are identical to the user_regs_struct.
27 SP_PTREGS = STACK_FRAME_OVERHEAD
28 SP_ARGS = STACK_FRAME_OVERHEAD + __PT_ARGS
29 SP_PSW = STACK_FRAME_OVERHEAD + __PT_PSW
30 SP_R0 = STACK_FRAME_OVERHEAD + __PT_GPRS
31 SP_R1 = STACK_FRAME_OVERHEAD + __PT_GPRS + 8
32 SP_R2 = STACK_FRAME_OVERHEAD + __PT_GPRS + 16
33 SP_R3 = STACK_FRAME_OVERHEAD + __PT_GPRS + 24
34 SP_R4 = STACK_FRAME_OVERHEAD + __PT_GPRS + 32
35 SP_R5 = STACK_FRAME_OVERHEAD + __PT_GPRS + 40
36 SP_R6 = STACK_FRAME_OVERHEAD + __PT_GPRS + 48
37 SP_R7 = STACK_FRAME_OVERHEAD + __PT_GPRS + 56
38 SP_R8 = STACK_FRAME_OVERHEAD + __PT_GPRS + 64
39 SP_R9 = STACK_FRAME_OVERHEAD + __PT_GPRS + 72
40 SP_R10 = STACK_FRAME_OVERHEAD + __PT_GPRS + 80
41 SP_R11 = STACK_FRAME_OVERHEAD + __PT_GPRS + 88
42 SP_R12 = STACK_FRAME_OVERHEAD + __PT_GPRS + 96
43 SP_R13 = STACK_FRAME_OVERHEAD + __PT_GPRS + 104
44 SP_R14 = STACK_FRAME_OVERHEAD + __PT_GPRS + 112
45 SP_R15 = STACK_FRAME_OVERHEAD + __PT_GPRS + 120
46 SP_ORIG_R2 = STACK_FRAME_OVERHEAD + __PT_ORIG_GPR2
47 SP_ILC = STACK_FRAME_OVERHEAD + __PT_ILC
48 SP_TRAP = STACK_FRAME_OVERHEAD + __PT_TRAP
49 SP_SIZE = STACK_FRAME_OVERHEAD + __PT_SIZE
51 STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
52 STACK_SIZE = 1 << STACK_SHIFT
54 _TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | _TIF_NEED_RESCHED | \
55 _TIF_MCCK_PENDING | _TIF_RESTART_SVC | _TIF_SINGLE_STEP )
56 _TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | _TIF_NEED_RESCHED | \
59 #define BASED(name) name-system_call(%r13)
61 #ifdef CONFIG_TRACE_IRQFLAGS
63 brasl %r14,trace_hardirqs_on
67 brasl %r14,trace_hardirqs_off
70 .macro LOCKDEP_SYS_EXIT
71 brasl %r14,lockdep_sys_exit
75 #define TRACE_IRQS_OFF
76 #define LOCKDEP_SYS_EXIT
79 .macro STORE_TIMER lc_offset
80 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
85 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
86 .macro UPDATE_VTIME lc_from,lc_to,lc_sum
95 * Register usage in interrupt handlers:
96 * R9 - pointer to current task structure
97 * R13 - pointer to literal pool
98 * R14 - return register for function calls
99 * R15 - kernel stack pointer
102 .macro SAVE_ALL_BASE savearea
103 stmg %r12,%r15,\savearea
104 larl %r13,system_call
107 .macro SAVE_ALL_SVC psworg,savearea
109 lg %r15,__LC_KERNEL_STACK # problem state -> load ksp
112 .macro SAVE_ALL_SYNC psworg,savearea
114 tm \psworg+1,0x01 # test problem state bit
115 jz 2f # skip stack setup save
116 lg %r15,__LC_KERNEL_STACK # problem state -> load ksp
117 #ifdef CONFIG_CHECK_STACK
119 2: tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
126 .macro SAVE_ALL_ASYNC psworg,savearea
128 tm \psworg+1,0x01 # test problem state bit
129 jnz 1f # from user -> load kernel stack
130 clc \psworg+8(8),BASED(.Lcritical_end)
132 clc \psworg+8(8),BASED(.Lcritical_start)
134 brasl %r14,cleanup_critical
135 tm 1(%r12),0x01 # retest problem state after cleanup
137 0: lg %r14,__LC_ASYNC_STACK # are we already on the async. stack ?
139 srag %r14,%r14,STACK_SHIFT
141 1: lg %r15,__LC_ASYNC_STACK # load async stack
142 #ifdef CONFIG_CHECK_STACK
144 2: tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
151 .macro CREATE_STACK_FRAME psworg,savearea
152 aghi %r15,-SP_SIZE # make room for registers & psw
153 mvc SP_PSW(16,%r15),0(%r12) # move user PSW to stack
155 stg %r2,SP_ORIG_R2(%r15) # store original content of gpr 2
156 icm %r12,12,__LC_SVC_ILC
157 stmg %r0,%r11,SP_R0(%r15) # store gprs %r0-%r11 to kernel stack
159 mvc SP_R12(32,%r15),\savearea # move %r12-%r15 to stack
161 stg %r12,__SF_BACKCHAIN(%r15)
164 .macro RESTORE_ALL psworg,sync
165 mvc \psworg(16),SP_PSW(%r15) # move user PSW to lowcore
167 ni \psworg+1,0xfd # clear wait state bit
169 lmg %r0,%r15,SP_R0(%r15) # load gprs 0-15 of user
170 STORE_TIMER __LC_EXIT_TIMER
171 lpswe \psworg # back to caller
175 * Scheduler resume function, called by switch_to
176 * gpr2 = (task_struct *) prev
177 * gpr3 = (task_struct *) next
183 tm __THREAD_per+4(%r3),0xe8 # is the new process using per ?
184 jz __switch_to_noper # if not we're fine
185 stctg %c9,%c11,__SF_EMPTY(%r15)# We are using per stuff
186 clc __THREAD_per(24,%r3),__SF_EMPTY(%r15)
187 je __switch_to_noper # we got away without bashing TLB's
188 lctlg %c9,%c11,__THREAD_per(%r3) # Nope we didn't
190 lg %r4,__THREAD_info(%r2) # get thread_info of prev
191 tm __TI_flags+7(%r4),_TIF_MCCK_PENDING # machine check pending?
192 jz __switch_to_no_mcck
193 ni __TI_flags+7(%r4),255-_TIF_MCCK_PENDING # clear flag in prev
194 lg %r4,__THREAD_info(%r3) # get thread_info of next
195 oi __TI_flags+7(%r4),_TIF_MCCK_PENDING # set it in next
197 stmg %r6,%r15,__SF_GPRS(%r15)# store __switch_to registers of prev task
198 stg %r15,__THREAD_ksp(%r2) # store kernel stack to prev->tss.ksp
199 lg %r15,__THREAD_ksp(%r3) # load kernel stack from next->tss.ksp
200 lmg %r6,%r15,__SF_GPRS(%r15)# load __switch_to registers of next task
201 stg %r3,__LC_CURRENT # __LC_CURRENT = current task struct
202 lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4
203 lg %r3,__THREAD_info(%r3) # load thread_info from task struct
204 stg %r3,__LC_THREAD_INFO
206 stg %r3,__LC_KERNEL_STACK # __LC_KERNEL_STACK = new kernel stack
211 * SVC interrupt handler routine. System calls are synchronous events and
212 * are executed with interrupts enabled.
217 STORE_TIMER __LC_SYNC_ENTER_TIMER
219 SAVE_ALL_BASE __LC_SAVE_AREA
220 SAVE_ALL_SVC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
221 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
222 llgh %r7,__LC_SVC_INT_CODE # get svc number from lowcore
223 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
225 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
227 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
229 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
231 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
234 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
235 slag %r7,%r7,2 # *4 and test for svc 0
237 # svc 0: system call number in %r1
238 cl %r1,BASED(.Lnr_syscalls)
240 lgfr %r7,%r1 # clear high word in r1
241 slag %r7,%r7,2 # svc 0: system call number in %r1
243 mvc SP_ARGS(8,%r15),SP_R7(%r15)
245 larl %r10,sys_call_table
247 tm __TI_flags+5(%r9),(_TIF_31BIT>>16) # running in 31 bit mode ?
249 larl %r10,sys_call_table_emu # use 31 bit emulation system calls
252 tm __TI_flags+7(%r9),(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)
253 lgf %r8,0(%r7,%r10) # load address of system call routine
255 basr %r14,%r8 # call sys_xxxx
256 stg %r2,SP_R2(%r15) # store return value (change R2 on stack)
259 tm SP_PSW+1(%r15),0x01 # returning to user ?
261 tm __TI_flags+7(%r9),_TIF_WORK_SVC
262 jnz sysc_work # there is work to do (signals etc.)
265 RESTORE_ALL __LC_RETURN_PSW,1
268 # recheck if there is more work to do
271 tm __TI_flags+7(%r9),_TIF_WORK_SVC
272 jz sysc_leave # there is no work to do
274 # One of the work bits is on. Find out which one.
277 tm __TI_flags+7(%r9),_TIF_MCCK_PENDING
279 tm __TI_flags+7(%r9),_TIF_NEED_RESCHED
281 tm __TI_flags+7(%r9),(_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)
283 tm __TI_flags+7(%r9),_TIF_RESTART_SVC
285 tm __TI_flags+7(%r9),_TIF_SINGLE_STEP
291 # _TIF_NEED_RESCHED is set, call schedule
294 larl %r14,sysc_work_loop
295 jg schedule # return point is sysc_return
298 # _TIF_MCCK_PENDING is set, call handler
301 larl %r14,sysc_work_loop
302 jg s390_handle_mcck # TIF bit will be cleared by handler
305 # _TIF_SIGPENDING or _TIF_RESTORE_SIGMASK is set, call do_signal
308 ni __TI_flags+7(%r9),255-_TIF_SINGLE_STEP # clear TIF_SINGLE_STEP
309 la %r2,SP_PTREGS(%r15) # load pt_regs
310 brasl %r14,do_signal # call do_signal
311 tm __TI_flags+7(%r9),_TIF_RESTART_SVC
313 tm __TI_flags+7(%r9),_TIF_SINGLE_STEP
318 # _TIF_RESTART_SVC is set, set up registers and restart svc
321 ni __TI_flags+7(%r9),255-_TIF_RESTART_SVC # clear TIF_RESTART_SVC
322 lg %r7,SP_R2(%r15) # load new svc number
324 mvc SP_R2(8,%r15),SP_ORIG_R2(%r15) # restore first argument
325 lmg %r2,%r6,SP_R2(%r15) # load svc arguments
326 j sysc_do_restart # restart svc
329 # _TIF_SINGLE_STEP is set, call do_single_step
332 ni __TI_flags+7(%r9),255-_TIF_SINGLE_STEP # clear TIF_SINGLE_STEP
333 lhi %r0,__LC_PGM_OLD_PSW
334 sth %r0,SP_TRAP(%r15) # set trap indication to pgm check
335 la %r2,SP_PTREGS(%r15) # address of register-save area
336 larl %r14,sysc_return # load adr. of system return
337 jg do_single_step # branch to do_sigtrap
340 # call syscall_trace before and after system call
341 # special linkage: %r12 contains the return address for trace_svc
344 la %r2,SP_PTREGS(%r15) # load pt_regs
348 brasl %r14,syscall_trace
352 lg %r7,SP_R2(%r15) # strace might have changed the
353 sll %r7,2 # system call
356 lmg %r3,%r6,SP_R3(%r15)
357 lg %r2,SP_ORIG_R2(%r15)
358 basr %r14,%r8 # call sys_xxx
359 stg %r2,SP_R2(%r15) # store return value
361 tm __TI_flags+7(%r9),(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)
363 la %r2,SP_PTREGS(%r15) # load pt_regs
365 larl %r14,sysc_return # return point is sysc_return
369 # a new process exits the kernel with ret_from_fork
373 lg %r13,__LC_SVC_NEW_PSW+8
374 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
375 tm SP_PSW+1(%r15),0x01 # forking a kernel thread ?
377 stg %r15,SP_R15(%r15) # store stack pointer for new kthread
378 0: brasl %r14,schedule_tail
380 stosm 24(%r15),0x03 # reenable interrupts
384 # kernel_execve function needs to deal with pt_regs that is not
389 stmg %r12,%r15,96(%r15)
392 stg %r14,__SF_BACKCHAIN(%r15)
393 la %r12,SP_PTREGS(%r15)
394 xc 0(__PT_SIZE,%r12),0(%r12)
400 lmg %r12,%r15,96(%r15)
403 0: stnsm __SF_EMPTY(%r15),0xfc # disable interrupts
404 lg %r15,__LC_KERNEL_STACK # load ksp
405 aghi %r15,-SP_SIZE # make room for registers & psw
406 lg %r13,__LC_SVC_NEW_PSW+8
407 lg %r9,__LC_THREAD_INFO
408 mvc SP_PTREGS(__PT_SIZE,%r15),0(%r12) # copy pt_regs
409 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
410 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
411 brasl %r14,execve_tail
415 * Program check handler routine
418 .globl pgm_check_handler
421 * First we need to check for a special case:
422 * Single stepping an instruction that disables the PER event mask will
423 * cause a PER event AFTER the mask has been set. Example: SVC or LPSW.
424 * For a single stepped SVC the program check handler gets control after
425 * the SVC new PSW has been loaded. But we want to execute the SVC first and
426 * then handle the PER event. Therefore we update the SVC old PSW to point
427 * to the pgm_check_handler and branch to the SVC handler after we checked
428 * if we have to load the kernel stack register.
429 * For every other possible cause for PER event without the PER mask set
430 * we just ignore the PER event (FIXME: is there anything we have to do
433 STORE_TIMER __LC_SYNC_ENTER_TIMER
434 SAVE_ALL_BASE __LC_SAVE_AREA
435 tm __LC_PGM_INT_CODE+1,0x80 # check whether we got a per exception
436 jnz pgm_per # got per exception -> special case
437 SAVE_ALL_SYNC __LC_PGM_OLD_PSW,__LC_SAVE_AREA
438 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA
439 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
440 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
442 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
443 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
444 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
447 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
448 lgf %r3,__LC_PGM_ILC # load program interruption code
453 larl %r1,pgm_check_table
454 lg %r1,0(%r8,%r1) # load address of handler routine
455 la %r2,SP_PTREGS(%r15) # address of register-save area
456 larl %r14,sysc_return
457 br %r1 # branch to interrupt-handler
460 # handle per exception
463 tm __LC_PGM_OLD_PSW,0x40 # test if per event recording is on
464 jnz pgm_per_std # ok, normal per event from user space
465 # ok its one of the special cases, now we need to find out which one
466 clc __LC_PGM_OLD_PSW(16),__LC_SVC_NEW_PSW
468 # no interesting special case, ignore PER event
469 lmg %r12,%r15,__LC_SAVE_AREA
470 lpswe __LC_PGM_OLD_PSW
473 # Normal per exception
476 SAVE_ALL_SYNC __LC_PGM_OLD_PSW,__LC_SAVE_AREA
477 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA
478 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
479 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
481 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
482 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
483 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
486 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
487 lg %r1,__TI_task(%r9)
488 tm SP_PSW+1(%r15),0x01 # kernel per event ?
490 mvc __THREAD_per+__PER_atmid(2,%r1),__LC_PER_ATMID
491 mvc __THREAD_per+__PER_address(8,%r1),__LC_PER_ADDRESS
492 mvc __THREAD_per+__PER_access_id(1,%r1),__LC_PER_ACCESS_ID
493 oi __TI_flags+7(%r9),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP
494 lgf %r3,__LC_PGM_ILC # load program interruption code
496 ngr %r8,%r3 # clear per-event-bit and ilc
501 # it was a single stepped SVC that is causing all the trouble
504 SAVE_ALL_SYNC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
505 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
506 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
507 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
509 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
510 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
511 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
514 llgh %r7,__LC_SVC_INT_CODE # get svc number from lowcore
515 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
516 lg %r1,__TI_task(%r9)
517 mvc __THREAD_per+__PER_atmid(2,%r1),__LC_PER_ATMID
518 mvc __THREAD_per+__PER_address(8,%r1),__LC_PER_ADDRESS
519 mvc __THREAD_per+__PER_access_id(1,%r1),__LC_PER_ACCESS_ID
520 oi __TI_flags+7(%r9),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP
522 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
526 # per was called from kernel, must be kprobes
529 lhi %r0,__LC_PGM_OLD_PSW
530 sth %r0,SP_TRAP(%r15) # set trap indication to pgm check
531 la %r2,SP_PTREGS(%r15) # address of register-save area
532 larl %r14,sysc_leave # load adr. of system ret, no work
533 jg do_single_step # branch to do_single_step
536 * IO interrupt handler routine
538 .globl io_int_handler
540 STORE_TIMER __LC_ASYNC_ENTER_TIMER
542 SAVE_ALL_BASE __LC_SAVE_AREA+32
543 SAVE_ALL_ASYNC __LC_IO_OLD_PSW,__LC_SAVE_AREA+32
544 CREATE_STACK_FRAME __LC_IO_OLD_PSW,__LC_SAVE_AREA+32
545 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
546 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
548 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
549 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
550 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
553 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
555 la %r2,SP_PTREGS(%r15) # address of register-save area
556 brasl %r14,do_IRQ # call standard irq handler
560 tm SP_PSW+1(%r15),0x01 # returning to user ?
561 #ifdef CONFIG_PREEMPT
562 jno io_preempt # no -> check for preemptive scheduling
564 jno io_leave # no-> skip resched & signal
566 tm __TI_flags+7(%r9),_TIF_WORK_INT
567 jnz io_work # there is work to do (signals etc.)
570 RESTORE_ALL __LC_RETURN_PSW,0
573 #ifdef CONFIG_PREEMPT
575 icm %r0,15,__TI_precount(%r9)
577 # switch to kernel stack
580 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
581 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) # clear back chain
584 tm __TI_flags+7(%r9),_TIF_NEED_RESCHED
587 mvc __TI_precount(4,%r9),0(%r1)
588 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
589 brasl %r14,schedule # call schedule
590 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
591 xc __TI_precount(4,%r9),__TI_precount(%r9)
596 # switch to kernel stack, then check TIF bits
599 lg %r1,__LC_KERNEL_STACK
601 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
602 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) # clear back chain
605 # One of the work bits is on. Find out which one.
606 # Checked are: _TIF_SIGPENDING, _TIF_RESTORE_SIGPENDING, _TIF_NEED_RESCHED
607 # and _TIF_MCCK_PENDING
610 tm __TI_flags+7(%r9),_TIF_MCCK_PENDING
612 tm __TI_flags+7(%r9),_TIF_NEED_RESCHED
614 tm __TI_flags+7(%r9),(_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)
620 # _TIF_MCCK_PENDING is set, call handler
624 brasl %r14,s390_handle_mcck # TIF bit will be cleared by handler
629 # _TIF_NEED_RESCHED is set, call schedule
632 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
633 brasl %r14,schedule # call scheduler
634 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
635 tm __TI_flags+7(%r9),_TIF_WORK_INT
636 jz io_leave # there is no work to do
640 # _TIF_SIGPENDING or _TIF_RESTORE_SIGMASK is set, call do_signal
643 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
644 la %r2,SP_PTREGS(%r15) # load pt_regs
645 brasl %r14,do_signal # call do_signal
646 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
650 * External interrupt handler routine
652 .globl ext_int_handler
654 STORE_TIMER __LC_ASYNC_ENTER_TIMER
656 SAVE_ALL_BASE __LC_SAVE_AREA+32
657 SAVE_ALL_ASYNC __LC_EXT_OLD_PSW,__LC_SAVE_AREA+32
658 CREATE_STACK_FRAME __LC_EXT_OLD_PSW,__LC_SAVE_AREA+32
659 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
660 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
662 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
663 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
664 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
667 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
669 la %r2,SP_PTREGS(%r15) # address of register-save area
670 llgh %r3,__LC_EXT_INT_CODE # get interruption code
678 * Machine check handler routines
680 .globl mcck_int_handler
682 la %r1,4095 # revalidate r1
683 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # revalidate cpu timer
684 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# revalidate gprs
685 SAVE_ALL_BASE __LC_SAVE_AREA+64
686 la %r12,__LC_MCK_OLD_PSW
687 tm __LC_MCCK_CODE,0x80 # system damage?
688 jo mcck_int_main # yes -> rest of mcck code invalid
689 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
691 mvc __LC_SAVE_AREA+104(8),__LC_ASYNC_ENTER_TIMER
692 mvc __LC_ASYNC_ENTER_TIMER(8),__LC_CPU_TIMER_SAVE_AREA-4095(%r14)
693 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
695 la %r14,__LC_SYNC_ENTER_TIMER
696 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
698 la %r14,__LC_ASYNC_ENTER_TIMER
699 0: clc 0(8,%r14),__LC_EXIT_TIMER
701 la %r14,__LC_EXIT_TIMER
702 0: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
704 la %r14,__LC_LAST_UPDATE_TIMER
706 mvc __LC_ASYNC_ENTER_TIMER(8),0(%r14)
709 tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid?
710 jno mcck_int_main # no -> skip cleanup critical
711 tm __LC_MCK_OLD_PSW+1,0x01 # test problem state bit
712 jnz mcck_int_main # from user -> load kernel stack
713 clc __LC_MCK_OLD_PSW+8(8),BASED(.Lcritical_end)
715 clc __LC_MCK_OLD_PSW+8(8),BASED(.Lcritical_start)
717 brasl %r14,cleanup_critical
719 lg %r14,__LC_PANIC_STACK # are we already on the panic stack?
721 srag %r14,%r14,PAGE_SHIFT
723 lg %r15,__LC_PANIC_STACK # load panic stack
724 0: CREATE_STACK_FRAME __LC_MCK_OLD_PSW,__LC_SAVE_AREA+64
725 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
726 tm __LC_MCCK_CODE+2,0x08 # mwp of old psw valid?
727 jno mcck_no_vtime # no -> no timer update
728 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
730 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
731 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
732 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
735 lg %r9,__LC_THREAD_INFO # load pointer to thread_info struct
736 la %r2,SP_PTREGS(%r15) # load pt_regs
737 brasl %r14,s390_do_machine_check
738 tm SP_PSW+1(%r15),0x01 # returning to user ?
740 lg %r1,__LC_KERNEL_STACK # switch to kernel stack
742 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
743 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) # clear back chain
745 stosm __SF_EMPTY(%r15),0x04 # turn dat on
746 tm __TI_flags+7(%r9),_TIF_MCCK_PENDING
749 brasl %r14,s390_handle_mcck
752 mvc __LC_RETURN_MCCK_PSW(16),SP_PSW(%r15) # move return PSW
753 ni __LC_RETURN_MCCK_PSW+1,0xfd # clear wait state bit
754 lmg %r0,%r15,SP_R0(%r15) # load gprs 0-15
755 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
756 mvc __LC_ASYNC_ENTER_TIMER(8),__LC_SAVE_AREA+104
757 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
762 lpswe __LC_RETURN_MCCK_PSW # back to caller
765 * Restart interruption handler, kick starter for additional CPUs
768 #ifndef CONFIG_HOTPLUG_CPU
769 .section .init.text,"ax"
771 .globl restart_int_handler
773 lg %r15,__LC_SAVE_AREA+120 # load ksp
774 lghi %r10,__LC_CREGS_SAVE_AREA
775 lctlg %c0,%c15,0(%r10) # get new ctl regs
776 lghi %r10,__LC_AREGS_SAVE_AREA
778 lmg %r6,%r15,__SF_GPRS(%r15) # load registers from clone
779 stosm __SF_EMPTY(%r15),0x04 # now we can turn dat on
781 #ifndef CONFIG_HOTPLUG_CPU
786 * If we do not run with SMP enabled, let the new CPU crash ...
788 .globl restart_int_handler
792 lpswe restart_crash-restart_base(%r1)
795 .long 0x000a0000,0x00000000,0x00000000,0x00000000
799 #ifdef CONFIG_CHECK_STACK
801 * The synchronous or the asynchronous stack overflowed. We are dead.
802 * No need to properly save the registers, we are going to panic anyway.
803 * Setup a pt_regs so that show_trace can provide a good call trace.
806 lg %r15,__LC_PANIC_STACK # change to panic stack
808 mvc SP_PSW(16,%r15),0(%r12) # move user PSW to stack
809 stmg %r0,%r11,SP_R0(%r15) # store gprs %r0-%r11 to kernel stack
810 la %r1,__LC_SAVE_AREA
811 chi %r12,__LC_SVC_OLD_PSW
813 chi %r12,__LC_PGM_OLD_PSW
815 la %r1,__LC_SAVE_AREA+32
816 0: mvc SP_R12(32,%r15),0(%r1) # move %r12-%r15 to stack
817 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) # clear back chain
818 la %r2,SP_PTREGS(%r15) # load pt_regs
819 jg kernel_stack_overflow
822 cleanup_table_system_call:
823 .quad system_call, sysc_do_svc
824 cleanup_table_sysc_return:
825 .quad sysc_return, sysc_leave
826 cleanup_table_sysc_leave:
827 .quad sysc_leave, sysc_work_loop
828 cleanup_table_sysc_work_loop:
829 .quad sysc_work_loop, sysc_reschedule
830 cleanup_table_io_return:
831 .quad io_return, io_leave
832 cleanup_table_io_leave:
833 .quad io_leave, io_done
834 cleanup_table_io_work_loop:
835 .quad io_work_loop, io_mcck_pending
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
858 clc 8(8,%r12),BASED(cleanup_table_io_return)
860 clc 8(8,%r12),BASED(cleanup_table_io_return+8)
863 clc 8(8,%r12),BASED(cleanup_table_io_leave)
865 clc 8(8,%r12),BASED(cleanup_table_io_leave+8)
868 clc 8(8,%r12),BASED(cleanup_table_io_work_loop)
870 clc 8(8,%r12),BASED(cleanup_table_io_work_loop+8)
876 mvc __LC_RETURN_PSW(16),0(%r12)
877 cghi %r12,__LC_MCK_OLD_PSW
879 la %r12,__LC_SAVE_AREA+32
881 0: la %r12,__LC_SAVE_AREA+64
883 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
884 clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn+8)
886 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
887 0: clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn+16)
890 clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn)
892 mvc __LC_SAVE_AREA(32),0(%r12)
894 stg %r12,__LC_SAVE_AREA+96 # argh
895 SAVE_ALL_SYNC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
896 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
897 lg %r12,__LC_SAVE_AREA+96 # argh
899 llgh %r7,__LC_SVC_INT_CODE
900 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
902 clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn+24)
904 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
906 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
908 clc __LC_RETURN_PSW+8(8),BASED(cleanup_system_call_insn+32)
910 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
912 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
915 mvc __LC_RETURN_PSW+8(8),BASED(cleanup_table_system_call+8)
916 la %r12,__LC_RETURN_PSW
918 cleanup_system_call_insn:
920 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
928 mvc __LC_RETURN_PSW(8),0(%r12)
929 mvc __LC_RETURN_PSW+8(8),BASED(cleanup_table_sysc_return)
930 la %r12,__LC_RETURN_PSW
934 clc 8(8,%r12),BASED(cleanup_sysc_leave_insn)
936 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
937 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
938 clc 8(8,%r12),BASED(cleanup_sysc_leave_insn+8)
941 mvc __LC_RETURN_PSW(16),SP_PSW(%r15)
942 cghi %r12,__LC_MCK_OLD_PSW
944 mvc __LC_SAVE_AREA+64(32),SP_R12(%r15)
946 0: mvc __LC_SAVE_AREA+32(32),SP_R12(%r15)
947 1: lmg %r0,%r11,SP_R0(%r15)
949 2: la %r12,__LC_RETURN_PSW
951 cleanup_sysc_leave_insn:
952 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
953 .quad sysc_leave + 16
955 .quad sysc_leave + 12
958 mvc __LC_RETURN_PSW(8),0(%r12)
959 mvc __LC_RETURN_PSW+8(8),BASED(cleanup_table_io_work_loop)
960 la %r12,__LC_RETURN_PSW
964 clc 8(8,%r12),BASED(cleanup_io_leave_insn)
966 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
967 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
968 clc 8(8,%r12),BASED(cleanup_io_leave_insn+8)
971 mvc __LC_RETURN_PSW(16),SP_PSW(%r15)
972 cghi %r12,__LC_MCK_OLD_PSW
974 mvc __LC_SAVE_AREA+64(32),SP_R12(%r15)
976 0: mvc __LC_SAVE_AREA+32(32),SP_R12(%r15)
977 1: lmg %r0,%r11,SP_R0(%r15)
979 2: la %r12,__LC_RETURN_PSW
981 cleanup_io_leave_insn:
982 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
992 .Lc_pactive: .long PREEMPT_ACTIVE
993 .Lnr_syscalls: .long NR_syscalls
994 .L0x0130: .short 0x130
995 .L0x0140: .short 0x140
996 .L0x0150: .short 0x150
997 .L0x0160: .short 0x160
998 .L0x0170: .short 0x170
1000 .quad __critical_start
1002 .quad __critical_end
1004 .section .rodata, "a"
1005 #define SYSCALL(esa,esame,emu) .long esame
1007 #include "syscalls.S"
1010 #ifdef CONFIG_COMPAT
1012 #define SYSCALL(esa,esame,emu) .long emu
1014 #include "syscalls.S"