2 * arch/s390/kernel/entry.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 + 4
33 SP_R2 = STACK_FRAME_OVERHEAD + __PT_GPRS + 8
34 SP_R3 = STACK_FRAME_OVERHEAD + __PT_GPRS + 12
35 SP_R4 = STACK_FRAME_OVERHEAD + __PT_GPRS + 16
36 SP_R5 = STACK_FRAME_OVERHEAD + __PT_GPRS + 20
37 SP_R6 = STACK_FRAME_OVERHEAD + __PT_GPRS + 24
38 SP_R7 = STACK_FRAME_OVERHEAD + __PT_GPRS + 28
39 SP_R8 = STACK_FRAME_OVERHEAD + __PT_GPRS + 32
40 SP_R9 = STACK_FRAME_OVERHEAD + __PT_GPRS + 36
41 SP_R10 = STACK_FRAME_OVERHEAD + __PT_GPRS + 40
42 SP_R11 = STACK_FRAME_OVERHEAD + __PT_GPRS + 44
43 SP_R12 = STACK_FRAME_OVERHEAD + __PT_GPRS + 48
44 SP_R13 = STACK_FRAME_OVERHEAD + __PT_GPRS + 52
45 SP_R14 = STACK_FRAME_OVERHEAD + __PT_GPRS + 56
46 SP_R15 = STACK_FRAME_OVERHEAD + __PT_GPRS + 60
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 _TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | _TIF_NEED_RESCHED | \
53 _TIF_MCCK_PENDING | _TIF_RESTART_SVC | _TIF_SINGLE_STEP )
54 _TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | _TIF_NEED_RESCHED | \
57 STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
58 STACK_SIZE = 1 << STACK_SHIFT
60 #define BASED(name) name-system_call(%r13)
63 * Register usage in interrupt handlers:
64 * R9 - pointer to current task structure
65 * R13 - pointer to literal pool
66 * R14 - return register for function calls
67 * R15 - kernel stack pointer
70 .macro STORE_TIMER lc_offset
71 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
76 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
77 .macro UPDATE_VTIME lc_from,lc_to,lc_sum
87 1: stm %r10,%r11,\lc_sum
91 .macro SAVE_ALL_BASE savearea
92 stm %r12,%r15,\savearea
93 l %r13,__LC_SVC_NEW_PSW+4 # load &system_call to %r13
96 .macro SAVE_ALL psworg,savearea,sync
99 tm \psworg+1,0x01 # test problem state bit
100 bz BASED(2f) # skip stack setup save
101 l %r15,__LC_KERNEL_STACK # problem state -> load ksp
103 tm \psworg+1,0x01 # test problem state bit
104 bnz BASED(1f) # from user -> load async stack
105 clc \psworg+4(4),BASED(.Lcritical_end)
107 clc \psworg+4(4),BASED(.Lcritical_start)
109 l %r14,BASED(.Lcleanup_critical)
111 tm 1(%r12),0x01 # retest problem state after cleanup
113 0: l %r14,__LC_ASYNC_STACK # are we already on the async stack ?
117 1: l %r15,__LC_ASYNC_STACK
119 #ifdef CONFIG_CHECK_STACK
121 2: tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
122 bz BASED(stack_overflow)
128 .macro CREATE_STACK_FRAME psworg,savearea
129 s %r15,BASED(.Lc_spsize) # make room for registers & psw
130 mvc SP_PSW(8,%r15),0(%r12) # move user PSW to stack
132 st %r2,SP_ORIG_R2(%r15) # store original content of gpr 2
133 icm %r12,12,__LC_SVC_ILC
134 stm %r0,%r11,SP_R0(%r15) # store gprs %r0-%r11 to kernel stack
136 mvc SP_R12(16,%r15),\savearea # move %r12-%r15 to stack
138 st %r12,__SF_BACKCHAIN(%r15) # clear back chain
141 .macro RESTORE_ALL psworg,sync
142 mvc \psworg(8),SP_PSW(%r15) # move user PSW to lowcore
144 ni \psworg+1,0xfd # clear wait state bit
146 lm %r0,%r15,SP_R0(%r15) # load gprs 0-15 of user
147 STORE_TIMER __LC_EXIT_TIMER
148 lpsw \psworg # back to caller
152 * Scheduler resume function, called by switch_to
153 * gpr2 = (task_struct *) prev
154 * gpr3 = (task_struct *) next
162 tm __THREAD_per(%r3),0xe8 # new process is using per ?
163 bz __switch_to_noper-__switch_to_base(%r1) # if not we're fine
164 stctl %c9,%c11,__SF_EMPTY(%r15) # We are using per stuff
165 clc __THREAD_per(12,%r3),__SF_EMPTY(%r15)
166 be __switch_to_noper-__switch_to_base(%r1) # we got away w/o bashing TLB's
167 lctl %c9,%c11,__THREAD_per(%r3) # Nope we didn't
169 l %r4,__THREAD_info(%r2) # get thread_info of prev
170 tm __TI_flags+3(%r4),_TIF_MCCK_PENDING # machine check pending?
171 bz __switch_to_no_mcck-__switch_to_base(%r1)
172 ni __TI_flags+3(%r4),255-_TIF_MCCK_PENDING # clear flag in prev
173 l %r4,__THREAD_info(%r3) # get thread_info of next
174 oi __TI_flags+3(%r4),_TIF_MCCK_PENDING # set it in next
176 stm %r6,%r15,__SF_GPRS(%r15)# store __switch_to registers of prev task
177 st %r15,__THREAD_ksp(%r2) # store kernel stack to prev->tss.ksp
178 l %r15,__THREAD_ksp(%r3) # load kernel stack from next->tss.ksp
179 lm %r6,%r15,__SF_GPRS(%r15)# load __switch_to registers of next task
180 st %r3,__LC_CURRENT # __LC_CURRENT = current task struct
181 lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4
182 l %r3,__THREAD_info(%r3) # load thread_info from task struct
183 st %r3,__LC_THREAD_INFO
185 st %r3,__LC_KERNEL_STACK # __LC_KERNEL_STACK = new kernel stack
190 * SVC interrupt handler routine. System calls are synchronous events and
191 * are executed with interrupts enabled.
196 STORE_TIMER __LC_SYNC_ENTER_TIMER
198 SAVE_ALL_BASE __LC_SAVE_AREA
199 SAVE_ALL __LC_SVC_OLD_PSW,__LC_SAVE_AREA,1
200 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
201 lh %r7,0x8a # get svc number from lowcore
202 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
204 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
205 bz BASED(sysc_do_svc)
206 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
208 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
210 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
213 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
214 sla %r7,2 # *4 and test for svc 0
215 bnz BASED(sysc_nr_ok) # svc number > 0
216 # svc 0: system call number in %r1
217 cl %r1,BASED(.Lnr_syscalls)
218 bnl BASED(sysc_nr_ok)
219 lr %r7,%r1 # copy svc number to %r7
222 mvc SP_ARGS(4,%r15),SP_R7(%r15)
224 tm __TI_flags+3(%r9),(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)
225 l %r8,sys_call_table-system_call(%r7,%r13) # get system call addr.
226 bnz BASED(sysc_tracesys)
227 basr %r14,%r8 # call sys_xxxx
228 st %r2,SP_R2(%r15) # store return value (change R2 on stack)
229 # ATTENTION: check sys_execve_glue before
230 # changing anything here !!
233 tm SP_PSW+1(%r15),0x01 # returning to user ?
234 bno BASED(sysc_leave)
235 tm __TI_flags+3(%r9),_TIF_WORK_SVC
236 bnz BASED(sysc_work) # there is work to do (signals etc.)
238 RESTORE_ALL __LC_RETURN_PSW,1
241 # recheck if there is more work to do
244 tm __TI_flags+3(%r9),_TIF_WORK_SVC
245 bz BASED(sysc_leave) # there is no work to do
247 # One of the work bits is on. Find out which one.
250 tm __TI_flags+3(%r9),_TIF_MCCK_PENDING
251 bo BASED(sysc_mcck_pending)
252 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED
253 bo BASED(sysc_reschedule)
254 tm __TI_flags+3(%r9),(_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)
255 bnz BASED(sysc_sigpending)
256 tm __TI_flags+3(%r9),_TIF_RESTART_SVC
257 bo BASED(sysc_restart)
258 tm __TI_flags+3(%r9),_TIF_SINGLE_STEP
259 bo BASED(sysc_singlestep)
263 # _TIF_NEED_RESCHED is set, call schedule
266 l %r1,BASED(.Lschedule)
267 la %r14,BASED(sysc_work_loop)
268 br %r1 # call scheduler
271 # _TIF_MCCK_PENDING is set, call handler
274 l %r1,BASED(.Ls390_handle_mcck)
275 la %r14,BASED(sysc_work_loop)
276 br %r1 # TIF bit will be cleared by handler
279 # _TIF_SIGPENDING or _TIF_RESTORE_SIGMASK is set, call do_signal
282 ni __TI_flags+3(%r9),255-_TIF_SINGLE_STEP # clear TIF_SINGLE_STEP
283 la %r2,SP_PTREGS(%r15) # load pt_regs
284 l %r1,BASED(.Ldo_signal)
285 basr %r14,%r1 # call do_signal
286 tm __TI_flags+3(%r9),_TIF_RESTART_SVC
287 bo BASED(sysc_restart)
288 tm __TI_flags+3(%r9),_TIF_SINGLE_STEP
289 bo BASED(sysc_singlestep)
290 b BASED(sysc_work_loop)
293 # _TIF_RESTART_SVC is set, set up registers and restart svc
296 ni __TI_flags+3(%r9),255-_TIF_RESTART_SVC # clear TIF_RESTART_SVC
297 l %r7,SP_R2(%r15) # load new svc number
299 mvc SP_R2(4,%r15),SP_ORIG_R2(%r15) # restore first argument
300 lm %r2,%r6,SP_R2(%r15) # load svc arguments
301 b BASED(sysc_do_restart) # restart svc
304 # _TIF_SINGLE_STEP is set, call do_single_step
307 ni __TI_flags+3(%r9),255-_TIF_SINGLE_STEP # clear TIF_SINGLE_STEP
308 mvi SP_TRAP+1(%r15),0x28 # set trap indication to pgm check
309 la %r2,SP_PTREGS(%r15) # address of register-save area
310 l %r1,BASED(.Lhandle_per) # load adr. of per handler
311 la %r14,BASED(sysc_return) # load adr. of system return
312 br %r1 # branch to do_single_step
315 # call trace before and after sys_call
319 la %r2,SP_PTREGS(%r15) # load pt_regs
324 clc SP_R2(4,%r15),BASED(.Lnr_syscalls)
325 bnl BASED(sysc_tracenogo)
326 l %r7,SP_R2(%r15) # strace might have changed the
327 sll %r7,2 # system call
328 l %r8,sys_call_table-system_call(%r7,%r13)
330 lm %r3,%r6,SP_R3(%r15)
331 l %r2,SP_ORIG_R2(%r15)
332 basr %r14,%r8 # call sys_xxx
333 st %r2,SP_R2(%r15) # store return value
335 tm __TI_flags+3(%r9),(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)
336 bz BASED(sysc_return)
338 la %r2,SP_PTREGS(%r15) # load pt_regs
340 la %r14,BASED(sysc_return)
344 # a new process exits the kernel with ret_from_fork
348 l %r13,__LC_SVC_NEW_PSW+4
349 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
350 tm SP_PSW+1(%r15),0x01 # forking a kernel thread ?
352 st %r15,SP_R15(%r15) # store stack pointer for new kthread
353 0: l %r1,BASED(.Lschedtail)
355 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
359 # clone, fork, vfork, exec and sigreturn need glue,
360 # because they all expect pt_regs as parameter,
361 # but are called with different parameter.
362 # return-address is set up above
365 la %r2,SP_PTREGS(%r15) # load pt_regs
367 br %r1 # branch to sys_clone
370 la %r2,SP_PTREGS(%r15) # load pt_regs
372 br %r1 # branch to sys_fork
375 la %r2,SP_PTREGS(%r15) # load pt_regs
377 br %r1 # branch to sys_vfork
380 la %r2,SP_PTREGS(%r15) # load pt_regs
381 l %r1,BASED(.Lexecve)
382 lr %r12,%r14 # save return address
383 basr %r14,%r1 # call sys_execve
384 ltr %r2,%r2 # check if execve failed
385 bnz 0(%r12) # it did fail -> store result in gpr2
386 b 4(%r12) # SKIP ST 2,SP_R2(15) after BASR 14,8
387 # in system_call/sysc_tracesys
390 la %r2,SP_PTREGS(%r15) # load pt_regs as parameter
391 l %r1,BASED(.Lsigreturn)
392 br %r1 # branch to sys_sigreturn
394 sys_rt_sigreturn_glue:
395 la %r2,SP_PTREGS(%r15) # load pt_regs as parameter
396 l %r1,BASED(.Lrt_sigreturn)
397 br %r1 # branch to sys_sigreturn
399 sys_sigaltstack_glue:
400 la %r4,SP_PTREGS(%r15) # load pt_regs as parameter
401 l %r1,BASED(.Lsigaltstack)
402 br %r1 # branch to sys_sigreturn
406 * Program check handler routine
409 .globl pgm_check_handler
412 * First we need to check for a special case:
413 * Single stepping an instruction that disables the PER event mask will
414 * cause a PER event AFTER the mask has been set. Example: SVC or LPSW.
415 * For a single stepped SVC the program check handler gets control after
416 * the SVC new PSW has been loaded. But we want to execute the SVC first and
417 * then handle the PER event. Therefore we update the SVC old PSW to point
418 * to the pgm_check_handler and branch to the SVC handler after we checked
419 * if we have to load the kernel stack register.
420 * For every other possible cause for PER event without the PER mask set
421 * we just ignore the PER event (FIXME: is there anything we have to do
424 STORE_TIMER __LC_SYNC_ENTER_TIMER
425 SAVE_ALL_BASE __LC_SAVE_AREA
426 tm __LC_PGM_INT_CODE+1,0x80 # check whether we got a per exception
427 bnz BASED(pgm_per) # got per exception -> special case
428 SAVE_ALL __LC_PGM_OLD_PSW,__LC_SAVE_AREA,1
429 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA
430 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
431 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
432 bz BASED(pgm_no_vtime)
433 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
434 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
435 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
438 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
439 l %r3,__LC_PGM_ILC # load program interruption code
443 l %r7,BASED(.Ljump_table)
445 l %r7,0(%r8,%r7) # load address of handler routine
446 la %r2,SP_PTREGS(%r15) # address of register-save area
447 la %r14,BASED(sysc_return)
448 br %r7 # branch to interrupt-handler
451 # handle per exception
454 tm __LC_PGM_OLD_PSW,0x40 # test if per event recording is on
455 bnz BASED(pgm_per_std) # ok, normal per event from user space
456 # ok its one of the special cases, now we need to find out which one
457 clc __LC_PGM_OLD_PSW(8),__LC_SVC_NEW_PSW
459 # no interesting special case, ignore PER event
460 lm %r12,%r15,__LC_SAVE_AREA
464 # Normal per exception
467 SAVE_ALL __LC_PGM_OLD_PSW,__LC_SAVE_AREA,1
468 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA
469 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
470 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
471 bz BASED(pgm_no_vtime2)
472 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
473 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
474 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
477 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
479 mvc __THREAD_per+__PER_atmid(2,%r1),__LC_PER_ATMID
480 mvc __THREAD_per+__PER_address(4,%r1),__LC_PER_ADDRESS
481 mvc __THREAD_per+__PER_access_id(1,%r1),__LC_PER_ACCESS_ID
482 oi __TI_flags+3(%r9),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP
483 l %r3,__LC_PGM_ILC # load program interruption code
485 nr %r8,%r3 # clear per-event-bit and ilc
486 be BASED(sysc_return) # only per or per+check ?
490 # it was a single stepped SVC that is causing all the trouble
493 SAVE_ALL __LC_SVC_OLD_PSW,__LC_SAVE_AREA,1
494 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
495 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
496 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
497 bz BASED(pgm_no_vtime3)
498 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
499 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
500 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
503 lh %r7,0x8a # get svc number from lowcore
504 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
506 mvc __THREAD_per+__PER_atmid(2,%r1),__LC_PER_ATMID
507 mvc __THREAD_per+__PER_address(4,%r1),__LC_PER_ADDRESS
508 mvc __THREAD_per+__PER_access_id(1,%r1),__LC_PER_ACCESS_ID
509 oi __TI_flags+3(%r9),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP
510 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
514 * IO interrupt handler routine
517 .globl io_int_handler
519 STORE_TIMER __LC_ASYNC_ENTER_TIMER
521 SAVE_ALL_BASE __LC_SAVE_AREA+16
522 SAVE_ALL __LC_IO_OLD_PSW,__LC_SAVE_AREA+16,0
523 CREATE_STACK_FRAME __LC_IO_OLD_PSW,__LC_SAVE_AREA+16
524 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
525 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
526 bz BASED(io_no_vtime)
527 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
528 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
529 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
532 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
533 l %r1,BASED(.Ldo_IRQ) # load address of do_IRQ
534 la %r2,SP_PTREGS(%r15) # address of register-save area
535 basr %r14,%r1 # branch to standard irq handler
538 tm SP_PSW+1(%r15),0x01 # returning to user ?
539 #ifdef CONFIG_PREEMPT
540 bno BASED(io_preempt) # no -> check for preemptive scheduling
542 bno BASED(io_leave) # no-> skip resched & signal
544 tm __TI_flags+3(%r9),_TIF_WORK_INT
545 bnz BASED(io_work) # there is work to do (signals etc.)
547 RESTORE_ALL __LC_RETURN_PSW,0
550 #ifdef CONFIG_PREEMPT
552 icm %r0,15,__TI_precount(%r9)
555 s %r1,BASED(.Lc_spsize)
556 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
557 xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1) # clear back chain
560 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED
562 mvc __TI_precount(4,%r9),BASED(.Lc_pactive)
563 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
564 l %r1,BASED(.Lschedule)
565 basr %r14,%r1 # call schedule
566 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
567 xc __TI_precount(4,%r9),__TI_precount(%r9)
568 b BASED(io_resume_loop)
572 # switch to kernel stack, then check the TIF bits
575 l %r1,__LC_KERNEL_STACK
576 s %r1,BASED(.Lc_spsize)
577 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
578 xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1) # clear back chain
581 # One of the work bits is on. Find out which one.
582 # Checked are: _TIF_SIGPENDING, _TIF_RESTORE_SIGMASK, _TIF_NEED_RESCHED
583 # and _TIF_MCCK_PENDING
586 tm __TI_flags+3(%r9),_TIF_MCCK_PENDING
587 bo BASED(io_mcck_pending)
588 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED
589 bo BASED(io_reschedule)
590 tm __TI_flags+3(%r9),(_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)
591 bnz BASED(io_sigpending)
595 # _TIF_MCCK_PENDING is set, call handler
598 l %r1,BASED(.Ls390_handle_mcck)
599 la %r14,BASED(io_work_loop)
600 br %r1 # TIF bit will be cleared by handler
603 # _TIF_NEED_RESCHED is set, call schedule
606 l %r1,BASED(.Lschedule)
607 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
608 basr %r14,%r1 # call scheduler
609 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
610 tm __TI_flags+3(%r9),_TIF_WORK_INT
611 bz BASED(io_leave) # there is no work to do
612 b BASED(io_work_loop)
615 # _TIF_SIGPENDING or _TIF_RESTORE_SIGMASK is set, call do_signal
618 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
619 la %r2,SP_PTREGS(%r15) # load pt_regs
620 l %r1,BASED(.Ldo_signal)
621 basr %r14,%r1 # call do_signal
622 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
623 b BASED(io_work_loop)
626 * External interrupt handler routine
629 .globl ext_int_handler
631 STORE_TIMER __LC_ASYNC_ENTER_TIMER
633 SAVE_ALL_BASE __LC_SAVE_AREA+16
634 SAVE_ALL __LC_EXT_OLD_PSW,__LC_SAVE_AREA+16,0
635 CREATE_STACK_FRAME __LC_EXT_OLD_PSW,__LC_SAVE_AREA+16
636 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
637 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
638 bz BASED(ext_no_vtime)
639 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
640 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
641 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
644 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
645 la %r2,SP_PTREGS(%r15) # address of register-save area
646 lh %r3,__LC_EXT_INT_CODE # get interruption code
647 l %r1,BASED(.Ldo_extint)
654 * Machine check handler routines
657 .globl mcck_int_handler
659 spt __LC_CPU_TIMER_SAVE_AREA # revalidate cpu timer
660 mvc __LC_ASYNC_ENTER_TIMER(8),__LC_CPU_TIMER_SAVE_AREA
661 lm %r0,%r15,__LC_GPREGS_SAVE_AREA # revalidate gprs
662 SAVE_ALL_BASE __LC_SAVE_AREA+32
663 la %r12,__LC_MCK_OLD_PSW
664 tm __LC_MCCK_CODE,0x80 # system damage?
665 bo BASED(mcck_int_main) # yes -> rest of mcck code invalid
666 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
668 spt __LC_LAST_UPDATE_TIMER # revalidate cpu timer
669 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
670 mvc __LC_ASYNC_ENTER_TIMER(8),__LC_LAST_UPDATE_TIMER
671 mvc __LC_SYNC_ENTER_TIMER(8),__LC_LAST_UPDATE_TIMER
672 mvc __LC_EXIT_TIMER(8),__LC_LAST_UPDATE_TIMER
674 0: tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid?
675 bno BASED(mcck_int_main) # no -> skip cleanup critical
676 tm __LC_MCK_OLD_PSW+1,0x01 # test problem state bit
677 bnz BASED(mcck_int_main) # from user -> load async stack
678 clc __LC_MCK_OLD_PSW+4(4),BASED(.Lcritical_end)
679 bhe BASED(mcck_int_main)
680 clc __LC_MCK_OLD_PSW+4(4),BASED(.Lcritical_start)
681 bl BASED(mcck_int_main)
682 l %r14,BASED(.Lcleanup_critical)
685 l %r14,__LC_PANIC_STACK # are we already on the panic stack?
689 l %r15,__LC_PANIC_STACK # load panic stack
690 0: CREATE_STACK_FRAME __LC_MCK_OLD_PSW,__LC_SAVE_AREA+32
691 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
692 tm __LC_MCCK_CODE+2,0x08 # mwp of old psw valid?
693 bno BASED(mcck_no_vtime) # no -> skip cleanup critical
694 tm __LC_MCK_OLD_PSW+1,0x01 # interrupting from user ?
695 bz BASED(mcck_no_vtime)
696 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
697 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
698 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
701 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
702 la %r2,SP_PTREGS(%r15) # load pt_regs
703 l %r1,BASED(.Ls390_mcck)
704 basr %r14,%r1 # call machine check handler
705 tm SP_PSW+1(%r15),0x01 # returning to user ?
706 bno BASED(mcck_return)
707 l %r1,__LC_KERNEL_STACK # switch to kernel stack
708 s %r1,BASED(.Lc_spsize)
709 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
710 xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1) # clear back chain
712 stosm __SF_EMPTY(%r15),0x04 # turn dat on
713 tm __TI_flags+3(%r9),_TIF_MCCK_PENDING
714 bno BASED(mcck_return)
715 l %r1,BASED(.Ls390_handle_mcck)
716 basr %r14,%r1 # call machine check handler
718 RESTORE_ALL __LC_RETURN_MCCK_PSW,0
722 * Restart interruption handler, kick starter for additional CPUs
724 .globl restart_int_handler
726 l %r15,__LC_SAVE_AREA+60 # load ksp
727 lctl %c0,%c15,__LC_CREGS_SAVE_AREA # get new ctl regs
728 lam %a0,%a15,__LC_AREGS_SAVE_AREA
729 lm %r6,%r15,__SF_GPRS(%r15) # load registers from clone
730 stosm __SF_EMPTY(%r15),0x04 # now we can turn dat on
732 l %r14,restart_addr-.(%r14)
733 br %r14 # branch to start_secondary
735 .long start_secondary
738 * If we do not run with SMP enabled, let the new CPU crash ...
740 .globl restart_int_handler
744 lpsw restart_crash-restart_base(%r1)
747 .long 0x000a0000,0x00000000
751 #ifdef CONFIG_CHECK_STACK
753 * The synchronous or the asynchronous stack overflowed. We are dead.
754 * No need to properly save the registers, we are going to panic anyway.
755 * Setup a pt_regs so that show_trace can provide a good call trace.
758 l %r15,__LC_PANIC_STACK # change to panic stack
759 sl %r15,BASED(.Lc_spsize)
760 mvc SP_PSW(8,%r15),0(%r12) # move user PSW to stack
761 stm %r0,%r11,SP_R0(%r15) # store gprs %r0-%r11 to kernel stack
762 la %r1,__LC_SAVE_AREA
763 ch %r12,BASED(.L0x020) # old psw addr == __LC_SVC_OLD_PSW ?
765 ch %r12,BASED(.L0x028) # old psw addr == __LC_PGM_OLD_PSW ?
767 la %r1,__LC_SAVE_AREA+16
768 0: mvc SP_R12(16,%r15),0(%r1) # move %r12-%r15 to stack
769 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15) # clear back chain
770 l %r1,BASED(1f) # branch to kernel_stack_overflow
771 la %r2,SP_PTREGS(%r15) # load pt_regs
773 1: .long kernel_stack_overflow
776 cleanup_table_system_call:
777 .long system_call + 0x80000000, sysc_do_svc + 0x80000000
778 cleanup_table_sysc_return:
779 .long sysc_return + 0x80000000, sysc_leave + 0x80000000
780 cleanup_table_sysc_leave:
781 .long sysc_leave + 0x80000000, sysc_work_loop + 0x80000000
782 cleanup_table_sysc_work_loop:
783 .long sysc_work_loop + 0x80000000, sysc_reschedule + 0x80000000
784 cleanup_table_io_leave:
785 .long io_leave + 0x80000000, io_done + 0x80000000
786 cleanup_table_io_work_loop:
787 .long io_work_loop + 0x80000000, io_mcck_pending + 0x80000000
790 clc 4(4,%r12),BASED(cleanup_table_system_call)
792 clc 4(4,%r12),BASED(cleanup_table_system_call+4)
793 bl BASED(cleanup_system_call)
795 clc 4(4,%r12),BASED(cleanup_table_sysc_return)
797 clc 4(4,%r12),BASED(cleanup_table_sysc_return+4)
798 bl BASED(cleanup_sysc_return)
800 clc 4(4,%r12),BASED(cleanup_table_sysc_leave)
802 clc 4(4,%r12),BASED(cleanup_table_sysc_leave+4)
803 bl BASED(cleanup_sysc_leave)
805 clc 4(4,%r12),BASED(cleanup_table_sysc_work_loop)
807 clc 4(4,%r12),BASED(cleanup_table_sysc_work_loop+4)
808 bl BASED(cleanup_sysc_return)
810 clc 4(4,%r12),BASED(cleanup_table_io_leave)
812 clc 4(4,%r12),BASED(cleanup_table_io_leave+4)
813 bl BASED(cleanup_io_leave)
815 clc 4(4,%r12),BASED(cleanup_table_io_work_loop)
817 clc 4(4,%r12),BASED(cleanup_table_io_work_loop+4)
818 bl BASED(cleanup_io_return)
823 mvc __LC_RETURN_PSW(8),0(%r12)
824 c %r12,BASED(.Lmck_old_psw)
826 la %r12,__LC_SAVE_AREA+16
828 0: la %r12,__LC_SAVE_AREA+32
830 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
831 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+4)
833 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
834 0: clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+8)
835 bhe BASED(cleanup_vtime)
837 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn)
839 mvc __LC_SAVE_AREA(16),0(%r12)
841 st %r12,__LC_SAVE_AREA+48 # argh
842 SAVE_ALL __LC_SVC_OLD_PSW,__LC_SAVE_AREA,1
843 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
844 l %r12,__LC_SAVE_AREA+48 # argh
847 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
849 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+12)
850 bhe BASED(cleanup_stime)
851 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
852 bz BASED(cleanup_novtime)
853 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
855 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+16)
856 bh BASED(cleanup_update)
857 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
859 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
862 mvc __LC_RETURN_PSW+4(4),BASED(cleanup_table_system_call+4)
863 la %r12,__LC_RETURN_PSW
865 cleanup_system_call_insn:
866 .long sysc_saveall + 0x80000000
867 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
868 .long system_call + 0x80000000
869 .long sysc_vtime + 0x80000000
870 .long sysc_stime + 0x80000000
871 .long sysc_update + 0x80000000
875 mvc __LC_RETURN_PSW(4),0(%r12)
876 mvc __LC_RETURN_PSW+4(4),BASED(cleanup_table_sysc_return)
877 la %r12,__LC_RETURN_PSW
881 clc 4(4,%r12),BASED(cleanup_sysc_leave_insn)
883 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
884 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
885 clc 4(4,%r12),BASED(cleanup_sysc_leave_insn+4)
888 mvc __LC_RETURN_PSW(8),SP_PSW(%r15)
889 c %r12,BASED(.Lmck_old_psw)
891 mvc __LC_SAVE_AREA+32(16),SP_R12(%r15)
893 0: mvc __LC_SAVE_AREA+16(16),SP_R12(%r15)
894 1: lm %r0,%r11,SP_R0(%r15)
896 2: la %r12,__LC_RETURN_PSW
898 cleanup_sysc_leave_insn:
899 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
900 .long sysc_leave + 14 + 0x80000000
902 .long sysc_leave + 10 + 0x80000000
905 mvc __LC_RETURN_PSW(4),0(%r12)
906 mvc __LC_RETURN_PSW+4(4),BASED(cleanup_table_io_work_loop)
907 la %r12,__LC_RETURN_PSW
911 clc 4(4,%r12),BASED(cleanup_io_leave_insn)
913 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
914 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
915 clc 4(4,%r12),BASED(cleanup_io_leave_insn+4)
918 mvc __LC_RETURN_PSW(8),SP_PSW(%r15)
919 c %r12,BASED(.Lmck_old_psw)
921 mvc __LC_SAVE_AREA+32(16),SP_R12(%r15)
923 0: mvc __LC_SAVE_AREA+16(16),SP_R12(%r15)
924 1: lm %r0,%r11,SP_R0(%r15)
926 2: la %r12,__LC_RETURN_PSW
928 cleanup_io_leave_insn:
929 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
930 .long io_leave + 18 + 0x80000000
932 .long io_leave + 14 + 0x80000000
938 .Lc_spsize: .long SP_SIZE
939 .Lc_overhead: .long STACK_FRAME_OVERHEAD
940 .Lc_pactive: .long PREEMPT_ACTIVE
941 .Lnr_syscalls: .long NR_syscalls
942 .L0x018: .short 0x018
943 .L0x020: .short 0x020
944 .L0x028: .short 0x028
945 .L0x030: .short 0x030
946 .L0x038: .short 0x038
952 .Ls390_mcck: .long s390_do_machine_check
954 .long s390_handle_mcck
955 .Lmck_old_psw: .long __LC_MCK_OLD_PSW
956 .Ldo_IRQ: .long do_IRQ
957 .Ldo_extint: .long do_extint
958 .Ldo_signal: .long do_signal
959 .Lhandle_per: .long do_single_step
960 .Ljump_table: .long pgm_check_table
961 .Lschedule: .long schedule
962 .Lclone: .long sys_clone
963 .Lexecve: .long sys_execve
964 .Lfork: .long sys_fork
965 .Lrt_sigreturn:.long sys_rt_sigreturn
967 .long sys_rt_sigsuspend
968 .Lsigreturn: .long sys_sigreturn
969 .Lsigsuspend: .long sys_sigsuspend
970 .Lsigaltstack: .long sys_sigaltstack
971 .Ltrace: .long syscall_trace
972 .Lvfork: .long sys_vfork
973 .Lschedtail: .long schedule_tail
976 .long __critical_start + 0x80000000
978 .long __critical_end + 0x80000000
980 .long cleanup_critical
982 #define SYSCALL(esa,esame,emu) .long esa
983 .globl sys_call_table
985 #include "syscalls.S"