2 * S390 low-level entry points.
4 * Copyright IBM Corp. 1999, 2012
5 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
6 * Hartmut Penner (hp@de.ibm.com),
7 * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
8 * Heiko Carstens <heiko.carstens@de.ibm.com>
11 #include <linux/init.h>
12 #include <linux/linkage.h>
13 #include <asm/cache.h>
14 #include <asm/errno.h>
15 #include <asm/ptrace.h>
16 #include <asm/thread_info.h>
17 #include <asm/asm-offsets.h>
18 #include <asm/unistd.h>
23 __PT_R1 = __PT_GPRS + 4
24 __PT_R2 = __PT_GPRS + 8
25 __PT_R3 = __PT_GPRS + 12
26 __PT_R4 = __PT_GPRS + 16
27 __PT_R5 = __PT_GPRS + 20
28 __PT_R6 = __PT_GPRS + 24
29 __PT_R7 = __PT_GPRS + 28
30 __PT_R8 = __PT_GPRS + 32
31 __PT_R9 = __PT_GPRS + 36
32 __PT_R10 = __PT_GPRS + 40
33 __PT_R11 = __PT_GPRS + 44
34 __PT_R12 = __PT_GPRS + 48
35 __PT_R13 = __PT_GPRS + 524
36 __PT_R14 = __PT_GPRS + 56
37 __PT_R15 = __PT_GPRS + 60
39 _TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
40 _TIF_MCCK_PENDING | _TIF_PER_TRAP )
41 _TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
43 _TIF_TRACE = (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | \
44 _TIF_SYSCALL_TRACEPOINT)
46 STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
47 STACK_SIZE = 1 << STACK_SHIFT
48 STACK_INIT = STACK_SIZE - STACK_FRAME_OVERHEAD - __PT_SIZE
50 #define BASED(name) name-system_call(%r13)
53 #ifdef CONFIG_TRACE_IRQFLAGS
55 l %r1,BASED(.Lhardirqs_on)
56 basr %r14,%r1 # call trace_hardirqs_on_caller
61 #ifdef CONFIG_TRACE_IRQFLAGS
63 l %r1,BASED(.Lhardirqs_off)
64 basr %r14,%r1 # call trace_hardirqs_off_caller
68 .macro LOCKDEP_SYS_EXIT
70 tm __PT_PSW+1(%r11),0x01 # returning to user ?
72 l %r1,BASED(.Llockdep_sys_exit)
73 basr %r14,%r1 # call lockdep_sys_exit
77 .macro CHECK_STACK stacksize,savearea
78 #ifdef CONFIG_CHECK_STACK
79 tml %r15,\stacksize - CONFIG_STACK_GUARD
85 .macro SWITCH_ASYNC savearea,stack,shift
86 tmh %r8,0x0001 # interrupting from user ?
89 sl %r14,BASED(.Lcritical_start)
90 cl %r14,BASED(.Lcritical_length)
92 la %r11,\savearea # inside critical section, do cleanup
93 bras %r14,cleanup_critical
94 tmh %r8,0x0001 # retest problem state after cleanup
96 0: l %r14,\stack # are we already on the target stack?
100 CHECK_STACK 1<<\shift,\savearea
101 ahi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
103 1: l %r15,\stack # load target stack
104 2: la %r11,STACK_FRAME_OVERHEAD(%r15)
107 .macro ADD64 high,low,timer
114 .macro SUB64 high,low,timer
121 .macro UPDATE_VTIME high,low,enter_timer
122 lm \high,\low,__LC_EXIT_TIMER
123 SUB64 \high,\low,\enter_timer
124 ADD64 \high,\low,__LC_USER_TIMER
125 stm \high,\low,__LC_USER_TIMER
126 lm \high,\low,__LC_LAST_UPDATE_TIMER
127 SUB64 \high,\low,__LC_EXIT_TIMER
128 ADD64 \high,\low,__LC_SYSTEM_TIMER
129 stm \high,\low,__LC_SYSTEM_TIMER
130 mvc __LC_LAST_UPDATE_TIMER(8),\enter_timer
134 st %r8,__LC_RETURN_PSW
135 ni __LC_RETURN_PSW,0xbf
139 .section .kprobes.text, "ax"
142 * Scheduler resume function, called by switch_to
143 * gpr2 = (task_struct *) prev
144 * gpr3 = (task_struct *) next
149 stm %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task
150 st %r15,__THREAD_ksp(%r2) # store kernel stack of prev
151 l %r4,__THREAD_info(%r2) # get thread_info of prev
152 l %r5,__THREAD_info(%r3) # get thread_info of next
154 ahi %r15,STACK_INIT # end of kernel stack of next
155 st %r3,__LC_CURRENT # store task struct of next
156 st %r5,__LC_THREAD_INFO # store thread info of next
157 st %r15,__LC_KERNEL_STACK # store end of kernel stack
158 lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4
159 mvc __LC_CURRENT_PID(4,%r0),__TASK_pid(%r3) # store pid of next
160 l %r15,__THREAD_ksp(%r3) # load kernel stack of next
161 tm __TI_flags+3(%r4),_TIF_MCCK_PENDING # machine check pending?
163 ni __TI_flags+3(%r4),255-_TIF_MCCK_PENDING # clear flag in prev
164 oi __TI_flags+3(%r5),_TIF_MCCK_PENDING # set it in next
165 0: lm %r6,%r15,__SF_GPRS(%r15) # load gprs of next task
170 * SVC interrupt handler routine. System calls are synchronous events and
171 * are executed with interrupts enabled.
175 stpt __LC_SYNC_ENTER_TIMER
177 stm %r8,%r15,__LC_SAVE_AREA_SYNC
178 l %r12,__LC_THREAD_INFO
179 l %r13,__LC_SVC_NEW_PSW+4
181 l %r15,__LC_KERNEL_STACK
182 la %r11,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs
184 UPDATE_VTIME %r8,%r9,__LC_SYNC_ENTER_TIMER
185 stm %r0,%r7,__PT_R0(%r11)
186 mvc __PT_R8(32,%r11),__LC_SAVE_AREA_SYNC
187 mvc __PT_PSW(8,%r11),__LC_SVC_OLD_PSW
188 mvc __PT_INT_CODE(4,%r11),__LC_SVC_ILC
190 oi __TI_flags+3(%r12),_TIF_SYSCALL
191 l %r10,__TI_sysc_table(%r12) # 31 bit system call table
192 lh %r8,__PT_INT_CODE+2(%r11)
193 sla %r8,2 # shift and test for svc0
195 # svc 0: system call number in %r1
196 cl %r1,BASED(.Lnr_syscalls)
198 sth %r1,__PT_INT_CODE+2(%r11)
202 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15)
203 st %r2,__PT_ORIG_GPR2(%r11)
204 st %r7,STACK_FRAME_OVERHEAD(%r15)
205 l %r9,0(%r8,%r10) # get system call addr.
206 tm __TI_flags+2(%r12),_TIF_TRACE >> 8
208 basr %r14,%r9 # call sys_xxxx
209 st %r2,__PT_R2(%r11) # store return value
214 tm __PT_PSW+1(%r11),0x01 # returning to user ?
216 tm __TI_flags+3(%r12),_TIF_WORK_SVC
217 jnz sysc_work # check for work
218 ni __TI_flags+3(%r12),255-_TIF_SYSCALL
220 mvc __LC_RETURN_PSW(8),__PT_PSW(%r11)
222 lm %r0,%r15,__PT_R0(%r11)
227 # One of the work bits is on. Find out which one.
230 tm __TI_flags+3(%r12),_TIF_MCCK_PENDING
232 tm __TI_flags+3(%r12),_TIF_NEED_RESCHED
234 tm __TI_flags+3(%r12),_TIF_PER_TRAP
236 tm __TI_flags+3(%r12),_TIF_SIGPENDING
238 tm __TI_flags+3(%r12),_TIF_NOTIFY_RESUME
239 jo sysc_notify_resume
240 j sysc_return # beware of critical section cleanup
243 # _TIF_NEED_RESCHED is set, call schedule
246 l %r1,BASED(.Lschedule)
247 la %r14,BASED(sysc_return)
248 br %r1 # call schedule
251 # _TIF_MCCK_PENDING is set, call handler
254 l %r1,BASED(.Lhandle_mcck)
255 la %r14,BASED(sysc_return)
256 br %r1 # TIF bit will be cleared by handler
259 # _TIF_SIGPENDING is set, call do_signal
262 lr %r2,%r11 # pass pointer to pt_regs
263 l %r1,BASED(.Ldo_signal)
264 basr %r14,%r1 # call do_signal
265 tm __TI_flags+3(%r12),_TIF_SYSCALL
267 lm %r2,%r7,__PT_R2(%r11) # load svc arguments
268 xr %r8,%r8 # svc 0 returns -ENOSYS
269 clc __PT_INT_CODE+2(2,%r11),BASED(.Lnr_syscalls+2)
270 jnl sysc_nr_ok # invalid svc number -> do svc 0
271 lh %r8,__PT_INT_CODE+2(%r11) # load new svc number
273 j sysc_nr_ok # restart svc
276 # _TIF_NOTIFY_RESUME is set, call do_notify_resume
279 lr %r2,%r11 # pass pointer to pt_regs
280 l %r1,BASED(.Ldo_notify_resume)
281 la %r14,BASED(sysc_return)
282 br %r1 # call do_notify_resume
285 # _TIF_PER_TRAP is set, call do_per_trap
288 ni __TI_flags+3(%r12),255-_TIF_PER_TRAP
289 lr %r2,%r11 # pass pointer to pt_regs
290 l %r1,BASED(.Ldo_per_trap)
291 la %r14,BASED(sysc_return)
292 br %r1 # call do_per_trap
295 # call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
296 # and after the system call
299 l %r1,BASED(.Ltrace_enter)
300 lr %r2,%r11 # pass pointer to pt_regs
303 icm %r0,3,__PT_INT_CODE+2(%r11)
305 basr %r14,%r1 # call do_syscall_trace_enter
306 cl %r2,BASED(.Lnr_syscalls)
312 lm %r3,%r7,__PT_R3(%r11)
313 st %r7,STACK_FRAME_OVERHEAD(%r15)
314 l %r2,__PT_ORIG_GPR2(%r11)
315 basr %r14,%r9 # call sys_xxx
316 st %r2,__PT_R2(%r11) # store return value
318 tm __TI_flags+2(%r12),_TIF_TRACE >> 8
320 l %r1,BASED(.Ltrace_exit)
321 lr %r2,%r11 # pass pointer to pt_regs
322 la %r14,BASED(sysc_return)
323 br %r1 # call do_syscall_trace_exit
326 # a new process exits the kernel with ret_from_fork
329 la %r11,STACK_FRAME_OVERHEAD(%r15)
330 l %r12,__LC_THREAD_INFO
331 l %r13,__LC_SVC_NEW_PSW+4
332 l %r1,BASED(.Lschedule_tail)
333 basr %r14,%r1 # call schedule_tail
335 ssm __LC_SVC_NEW_PSW # reenable interrupts
336 tm __PT_PSW+1(%r11),0x01 # forking a kernel thread ?
338 # it's a kernel thread
339 lm %r9,%r10,__PT_R9(%r11) # load gprs
340 ENTRY(kernel_thread_starter)
346 * Program check handler routine
349 ENTRY(pgm_check_handler)
350 stpt __LC_SYNC_ENTER_TIMER
351 stm %r8,%r15,__LC_SAVE_AREA_SYNC
352 l %r12,__LC_THREAD_INFO
353 l %r13,__LC_SVC_NEW_PSW+4
354 lm %r8,%r9,__LC_PGM_OLD_PSW
355 tmh %r8,0x0001 # test problem state bit
356 jnz 1f # -> fault in user space
357 tmh %r8,0x4000 # PER bit set in old PSW ?
358 jnz 0f # -> enabled, can't be a double fault
359 tm __LC_PGM_ILC+3,0x80 # check for per exception
360 jnz pgm_svcper # -> single stepped svc
361 0: CHECK_STACK STACK_SIZE,__LC_SAVE_AREA_SYNC
362 ahi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
364 1: UPDATE_VTIME %r14,%r15,__LC_SYNC_ENTER_TIMER
365 l %r15,__LC_KERNEL_STACK
366 2: la %r11,STACK_FRAME_OVERHEAD(%r15)
367 stm %r0,%r7,__PT_R0(%r11)
368 mvc __PT_R8(32,%r11),__LC_SAVE_AREA_SYNC
369 stm %r8,%r9,__PT_PSW(%r11)
370 mvc __PT_INT_CODE(4,%r11),__LC_PGM_ILC
371 mvc __PT_INT_PARM_LONG(4,%r11),__LC_TRANS_EXC_CODE
372 tm __LC_PGM_ILC+3,0x80 # check for per exception
374 l %r1,__TI_task(%r12)
375 tmh %r8,0x0001 # kernel per event ?
377 oi __TI_flags+3(%r12),_TIF_PER_TRAP
378 mvc __THREAD_per_address(4,%r1),__LC_PER_ADDRESS
379 mvc __THREAD_per_cause(2,%r1),__LC_PER_CAUSE
380 mvc __THREAD_per_paid(1,%r1),__LC_PER_PAID
382 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15)
383 l %r1,BASED(.Ljump_table)
385 n %r10,__PT_INT_CODE(%r11)
388 l %r1,0(%r10,%r1) # load address of handler routine
389 lr %r2,%r11 # pass pointer to pt_regs
390 basr %r14,%r1 # branch to interrupt-handler
394 # PER event in supervisor state, must be kprobes
398 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15)
399 l %r1,BASED(.Ldo_per_trap)
400 lr %r2,%r11 # pass pointer to pt_regs
401 basr %r14,%r1 # call do_per_trap
405 # single stepped system call
408 oi __TI_flags+3(%r12),_TIF_PER_TRAP
409 mvc __LC_RETURN_PSW(4),__LC_SVC_NEW_PSW
410 mvc __LC_RETURN_PSW+4(4),BASED(.Lsysc_per)
411 lpsw __LC_RETURN_PSW # branch to sysc_per and enable irqs
414 * IO interrupt handler routine
417 ENTRY(io_int_handler)
419 stpt __LC_ASYNC_ENTER_TIMER
420 stm %r8,%r15,__LC_SAVE_AREA_ASYNC
421 l %r12,__LC_THREAD_INFO
422 l %r13,__LC_SVC_NEW_PSW+4
423 lm %r8,%r9,__LC_IO_OLD_PSW
424 tmh %r8,0x0001 # interrupting from user ?
426 UPDATE_VTIME %r14,%r15,__LC_ASYNC_ENTER_TIMER
428 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_STACK,STACK_SHIFT
429 stm %r0,%r7,__PT_R0(%r11)
430 mvc __PT_R8(32,%r11),__LC_SAVE_AREA_ASYNC
431 stm %r8,%r9,__PT_PSW(%r11)
433 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15)
434 l %r1,BASED(.Ldo_IRQ)
435 lr %r2,%r11 # pass pointer to pt_regs
436 basr %r14,%r1 # call do_IRQ
441 tm __TI_flags+3(%r12),_TIF_WORK_INT
442 jnz io_work # there is work to do (signals etc.)
444 mvc __LC_RETURN_PSW(8),__PT_PSW(%r11)
446 lm %r0,%r15,__PT_R0(%r11)
451 # There is work todo, find out in which context we have been interrupted:
452 # 1) if we return to user space we can do all _TIF_WORK_INT work
453 # 2) if we return to kernel code and preemptive scheduling is enabled check
454 # the preemption counter and if it is zero call preempt_schedule_irq
455 # Before any work can be done, a switch to the kernel stack is required.
458 tm __PT_PSW+1(%r11),0x01 # returning to user ?
459 jo io_work_user # yes -> do resched & signal
460 #ifdef CONFIG_PREEMPT
461 # check for preemptive scheduling
462 icm %r0,15,__TI_precount(%r12)
463 jnz io_restore # preemption disabled
464 tm __TI_flags+3(%r12),_TIF_NEED_RESCHED
466 # switch to kernel stack
468 ahi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
469 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
470 xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1)
471 la %r11,STACK_FRAME_OVERHEAD(%r1)
473 # TRACE_IRQS_ON already done at io_return, call
474 # TRACE_IRQS_OFF to keep things symmetrical
476 l %r1,BASED(.Lpreempt_irq)
477 basr %r14,%r1 # call preempt_schedule_irq
484 # Need to do work before returning to userspace, switch to kernel stack
487 l %r1,__LC_KERNEL_STACK
488 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
489 xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1)
490 la %r11,STACK_FRAME_OVERHEAD(%r1)
494 # One of the work bits is on. Find out which one.
495 # Checked are: _TIF_SIGPENDING, _TIF_NOTIFY_RESUME, _TIF_NEED_RESCHED
496 # and _TIF_MCCK_PENDING
499 tm __TI_flags+3(%r12),_TIF_MCCK_PENDING
501 tm __TI_flags+3(%r12),_TIF_NEED_RESCHED
503 tm __TI_flags+3(%r12),_TIF_SIGPENDING
505 tm __TI_flags+3(%r12),_TIF_NOTIFY_RESUME
507 j io_return # beware of critical section cleanup
510 # _TIF_MCCK_PENDING is set, call handler
513 # TRACE_IRQS_ON already done at io_return
514 l %r1,BASED(.Lhandle_mcck)
515 basr %r14,%r1 # TIF bit will be cleared by handler
520 # _TIF_NEED_RESCHED is set, call schedule
523 # TRACE_IRQS_ON already done at io_return
524 l %r1,BASED(.Lschedule)
525 ssm __LC_SVC_NEW_PSW # reenable interrupts
526 basr %r14,%r1 # call scheduler
527 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
532 # _TIF_SIGPENDING is set, call do_signal
535 # TRACE_IRQS_ON already done at io_return
536 l %r1,BASED(.Ldo_signal)
537 ssm __LC_SVC_NEW_PSW # reenable interrupts
538 lr %r2,%r11 # pass pointer to pt_regs
539 basr %r14,%r1 # call do_signal
540 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
545 # _TIF_SIGPENDING is set, call do_signal
548 # TRACE_IRQS_ON already done at io_return
549 l %r1,BASED(.Ldo_notify_resume)
550 ssm __LC_SVC_NEW_PSW # reenable interrupts
551 lr %r2,%r11 # pass pointer to pt_regs
552 basr %r14,%r1 # call do_notify_resume
553 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
558 * External interrupt handler routine
561 ENTRY(ext_int_handler)
563 stpt __LC_ASYNC_ENTER_TIMER
564 stm %r8,%r15,__LC_SAVE_AREA_ASYNC
565 l %r12,__LC_THREAD_INFO
566 l %r13,__LC_SVC_NEW_PSW+4
567 lm %r8,%r9,__LC_EXT_OLD_PSW
568 tmh %r8,0x0001 # interrupting from user ?
570 UPDATE_VTIME %r14,%r15,__LC_ASYNC_ENTER_TIMER
572 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_STACK,STACK_SHIFT
573 stm %r0,%r7,__PT_R0(%r11)
574 mvc __PT_R8(32,%r11),__LC_SAVE_AREA_ASYNC
575 stm %r8,%r9,__PT_PSW(%r11)
577 lr %r2,%r11 # pass pointer to pt_regs
578 l %r3,__LC_EXT_CPU_ADDR # get cpu address + interruption code
579 l %r4,__LC_EXT_PARAMS # get external parameters
580 l %r1,BASED(.Ldo_extint)
581 basr %r14,%r1 # call do_extint
585 * Load idle PSW. The second "half" of this function is in cleanup_idle.
588 st %r3,__SF_EMPTY(%r15)
590 la %r1,psw_idle_lpsw+4-.(%r1)
591 st %r1,__SF_EMPTY+4(%r15)
592 oi __SF_EMPTY+4(%r15),0x80
593 stck __CLOCK_IDLE_ENTER(%r2)
594 stpt __TIMER_IDLE_ENTER(%r2)
596 lpsw __SF_EMPTY(%r15)
603 * Machine check handler routines
606 ENTRY(mcck_int_handler)
608 spt __LC_CPU_TIMER_SAVE_AREA # revalidate cpu timer
609 lm %r0,%r15,__LC_GPREGS_SAVE_AREA # revalidate gprs
610 l %r12,__LC_THREAD_INFO
611 l %r13,__LC_SVC_NEW_PSW+4
612 lm %r8,%r9,__LC_MCK_OLD_PSW
613 tm __LC_MCCK_CODE,0x80 # system damage?
614 jo mcck_panic # yes -> rest of mcck code invalid
615 la %r14,__LC_CPU_TIMER_SAVE_AREA
616 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
617 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
619 la %r14,__LC_SYNC_ENTER_TIMER
620 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
622 la %r14,__LC_ASYNC_ENTER_TIMER
623 0: clc 0(8,%r14),__LC_EXIT_TIMER
625 la %r14,__LC_EXIT_TIMER
626 1: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
628 la %r14,__LC_LAST_UPDATE_TIMER
630 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
631 3: tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid?
632 jno mcck_panic # no -> skip cleanup critical
633 tm %r8,0x0001 # interrupting from user ?
635 UPDATE_VTIME %r14,%r15,__LC_MCCK_ENTER_TIMER
637 SWITCH_ASYNC __LC_GPREGS_SAVE_AREA+32,__LC_PANIC_STACK,PAGE_SHIFT
638 stm %r0,%r7,__PT_R0(%r11)
639 mvc __PT_R8(32,%r11),__LC_GPREGS_SAVE_AREA+32
640 stm %r8,%r9,__PT_PSW(%r11)
641 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15)
642 l %r1,BASED(.Ldo_machine_check)
643 lr %r2,%r11 # pass pointer to pt_regs
644 basr %r14,%r1 # call s390_do_machine_check
645 tm __PT_PSW+1(%r11),0x01 # returning to user ?
647 l %r1,__LC_KERNEL_STACK # switch to kernel stack
648 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
649 xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1)
650 la %r11,STACK_FRAME_OVERHEAD(%r15)
652 ssm __LC_PGM_NEW_PSW # turn dat on, keep irqs off
653 tm __TI_flags+3(%r12),_TIF_MCCK_PENDING
656 l %r1,BASED(.Lhandle_mcck)
657 basr %r14,%r1 # call s390_handle_mcck
660 mvc __LC_RETURN_MCCK_PSW(8),__PT_PSW(%r11) # move return PSW
661 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
663 lm %r0,%r15,__PT_R0(%r11)
665 lpsw __LC_RETURN_MCCK_PSW
666 0: lm %r0,%r15,__PT_R0(%r11)
667 lpsw __LC_RETURN_MCCK_PSW
670 l %r14,__LC_PANIC_STACK
674 l %r15,__LC_PANIC_STACK
676 0: ahi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
680 # PSW restart interrupt handler
682 ENTRY(restart_int_handler)
683 st %r15,__LC_SAVE_AREA_RESTART
684 l %r15,__LC_RESTART_STACK
685 ahi %r15,-__PT_SIZE # create pt_regs on stack
686 xc 0(__PT_SIZE,%r15),0(%r15)
687 stm %r0,%r14,__PT_R0(%r15)
688 mvc __PT_R15(4,%r15),__LC_SAVE_AREA_RESTART
689 mvc __PT_PSW(8,%r15),__LC_RST_OLD_PSW # store restart old psw
690 ahi %r15,-STACK_FRAME_OVERHEAD # create stack frame on stack
691 xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15)
692 l %r1,__LC_RESTART_FN # load fn, parm & source cpu
693 l %r2,__LC_RESTART_DATA
694 l %r3,__LC_RESTART_SOURCE
695 ltr %r3,%r3 # test source cpu address
696 jm 1f # negative -> skip source stop
697 0: sigp %r4,%r3,SIGP_SENSE # sigp sense to source cpu
698 brc 10,0b # wait for status stored
699 1: basr %r14,%r1 # call function
700 stap __SF_EMPTY(%r15) # store cpu address
701 lh %r3,__SF_EMPTY(%r15)
702 2: sigp %r4,%r3,SIGP_STOP # sigp stop to current cpu
706 .section .kprobes.text, "ax"
708 #ifdef CONFIG_CHECK_STACK
710 * The synchronous or the asynchronous stack overflowed. We are dead.
711 * No need to properly save the registers, we are going to panic anyway.
712 * Setup a pt_regs so that show_trace can provide a good call trace.
715 l %r15,__LC_PANIC_STACK # change to panic stack
716 la %r11,STACK_FRAME_OVERHEAD(%r15)
717 stm %r0,%r7,__PT_R0(%r11)
718 stm %r8,%r9,__PT_PSW(%r11)
719 mvc __PT_R8(32,%r11),0(%r14)
721 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15)
722 lr %r2,%r11 # pass pointer to pt_regs
723 br %r1 # branch to kernel_stack_overflow
724 1: .long kernel_stack_overflow
728 .long system_call + 0x80000000
729 .long sysc_do_svc + 0x80000000
730 .long sysc_tif + 0x80000000
731 .long sysc_restore + 0x80000000
732 .long sysc_done + 0x80000000
733 .long io_tif + 0x80000000
734 .long io_restore + 0x80000000
735 .long io_done + 0x80000000
736 .long psw_idle + 0x80000000
737 .long psw_idle_end + 0x80000000
740 cl %r9,BASED(cleanup_table) # system_call
742 cl %r9,BASED(cleanup_table+4) # sysc_do_svc
743 jl cleanup_system_call
744 cl %r9,BASED(cleanup_table+8) # sysc_tif
746 cl %r9,BASED(cleanup_table+12) # sysc_restore
748 cl %r9,BASED(cleanup_table+16) # sysc_done
749 jl cleanup_sysc_restore
750 cl %r9,BASED(cleanup_table+20) # io_tif
752 cl %r9,BASED(cleanup_table+24) # io_restore
754 cl %r9,BASED(cleanup_table+28) # io_done
755 jl cleanup_io_restore
756 cl %r9,BASED(cleanup_table+32) # psw_idle
758 cl %r9,BASED(cleanup_table+36) # psw_idle_end
763 # check if stpt has been executed
764 cl %r9,BASED(cleanup_system_call_insn)
766 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
767 chi %r11,__LC_SAVE_AREA_ASYNC
769 mvc __LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER
770 0: # check if stm has been executed
771 cl %r9,BASED(cleanup_system_call_insn+4)
773 mvc __LC_SAVE_AREA_SYNC(32),0(%r11)
774 0: # set up saved registers r12, and r13
775 st %r12,16(%r11) # r12 thread-info pointer
776 st %r13,20(%r11) # r13 literal-pool pointer
777 # check if the user time calculation has been done
778 cl %r9,BASED(cleanup_system_call_insn+8)
780 l %r10,__LC_EXIT_TIMER
781 l %r15,__LC_EXIT_TIMER+4
782 SUB64 %r10,%r15,__LC_SYNC_ENTER_TIMER
783 ADD64 %r10,%r15,__LC_USER_TIMER
784 st %r10,__LC_USER_TIMER
785 st %r15,__LC_USER_TIMER+4
786 0: # check if the system time calculation has been done
787 cl %r9,BASED(cleanup_system_call_insn+12)
789 l %r10,__LC_LAST_UPDATE_TIMER
790 l %r15,__LC_LAST_UPDATE_TIMER+4
791 SUB64 %r10,%r15,__LC_EXIT_TIMER
792 ADD64 %r10,%r15,__LC_SYSTEM_TIMER
793 st %r10,__LC_SYSTEM_TIMER
794 st %r15,__LC_SYSTEM_TIMER+4
795 0: # update accounting time stamp
796 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
797 # set up saved register 11
798 l %r15,__LC_KERNEL_STACK
799 la %r9,STACK_FRAME_OVERHEAD(%r15)
800 st %r9,12(%r11) # r11 pt_regs pointer
802 mvc __PT_R8(32,%r9),__LC_SAVE_AREA_SYNC
803 stm %r0,%r7,__PT_R0(%r9)
804 mvc __PT_PSW(8,%r9),__LC_SVC_OLD_PSW
805 mvc __PT_INT_CODE(4,%r9),__LC_SVC_ILC
806 # setup saved register 15
807 st %r15,28(%r11) # r15 stack pointer
808 # set new psw address and exit
809 l %r9,BASED(cleanup_table+4) # sysc_do_svc + 0x80000000
811 cleanup_system_call_insn:
812 .long system_call + 0x80000000
813 .long sysc_stm + 0x80000000
814 .long sysc_vtime + 0x80000000 + 36
815 .long sysc_vtime + 0x80000000 + 76
818 l %r9,BASED(cleanup_table+8) # sysc_tif + 0x80000000
821 cleanup_sysc_restore:
822 cl %r9,BASED(cleanup_sysc_restore_insn)
824 l %r9,12(%r11) # get saved pointer to pt_regs
825 mvc __LC_RETURN_PSW(8),__PT_PSW(%r9)
826 mvc 0(32,%r11),__PT_R8(%r9)
827 lm %r0,%r7,__PT_R0(%r9)
828 0: lm %r8,%r9,__LC_RETURN_PSW
830 cleanup_sysc_restore_insn:
831 .long sysc_done - 4 + 0x80000000
834 l %r9,BASED(cleanup_table+20) # io_tif + 0x80000000
838 cl %r9,BASED(cleanup_io_restore_insn)
840 l %r9,12(%r11) # get saved r11 pointer to pt_regs
841 mvc __LC_RETURN_PSW(8),__PT_PSW(%r9)
842 mvc 0(32,%r11),__PT_R8(%r9)
843 lm %r0,%r7,__PT_R0(%r9)
844 0: lm %r8,%r9,__LC_RETURN_PSW
846 cleanup_io_restore_insn:
847 .long io_done - 4 + 0x80000000
850 # copy interrupt clock & cpu timer
851 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_INT_CLOCK
852 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_ASYNC_ENTER_TIMER
853 chi %r11,__LC_SAVE_AREA_ASYNC
855 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_MCCK_CLOCK
856 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_MCCK_ENTER_TIMER
857 0: # check if stck has been executed
858 cl %r9,BASED(cleanup_idle_insn)
860 mvc __CLOCK_IDLE_ENTER(8,%r2),__CLOCK_IDLE_EXIT(%r2)
861 mvc __TIMER_IDLE_ENTER(8,%r2),__TIMER_IDLE_EXIT(%r3)
862 1: # account system time going idle
863 lm %r9,%r10,__LC_STEAL_TIMER
864 ADD64 %r9,%r10,__CLOCK_IDLE_ENTER(%r2)
865 SUB64 %r9,%r10,__LC_LAST_UPDATE_CLOCK
866 stm %r9,%r10,__LC_STEAL_TIMER
867 mvc __LC_LAST_UPDATE_CLOCK(8),__CLOCK_IDLE_EXIT(%r2)
868 lm %r9,%r10,__LC_SYSTEM_TIMER
869 ADD64 %r9,%r10,__LC_LAST_UPDATE_TIMER
870 SUB64 %r9,%r10,__TIMER_IDLE_ENTER(%r2)
871 stm %r9,%r10,__LC_SYSTEM_TIMER
872 mvc __LC_LAST_UPDATE_TIMER(8),__TIMER_IDLE_EXIT(%r2)
874 n %r8,BASED(cleanup_idle_wait) # clear wait state bit
875 l %r9,24(%r11) # return from psw_idle
878 .long psw_idle_lpsw + 0x80000000
889 .quad 0x7fffffffffffffff
894 .Ldo_machine_check: .long s390_do_machine_check
895 .Lhandle_mcck: .long s390_handle_mcck
896 .Ldo_IRQ: .long do_IRQ
897 .Ldo_extint: .long do_extint
898 .Ldo_signal: .long do_signal
899 .Ldo_notify_resume: .long do_notify_resume
900 .Ldo_per_trap: .long do_per_trap
901 .Ljump_table: .long pgm_check_table
902 .Lschedule: .long schedule
903 #ifdef CONFIG_PREEMPT
904 .Lpreempt_irq: .long preempt_schedule_irq
906 .Ltrace_enter: .long do_syscall_trace_enter
907 .Ltrace_exit: .long do_syscall_trace_exit
908 .Lschedule_tail: .long schedule_tail
909 .Lsysc_per: .long sysc_per + 0x80000000
910 #ifdef CONFIG_TRACE_IRQFLAGS
911 .Lhardirqs_on: .long trace_hardirqs_on_caller
912 .Lhardirqs_off: .long trace_hardirqs_off_caller
914 #ifdef CONFIG_LOCKDEP
915 .Llockdep_sys_exit: .long lockdep_sys_exit
917 .Lcritical_start: .long __critical_start + 0x80000000
918 .Lcritical_length: .long __critical_end - __critical_start
920 .section .rodata, "a"
921 #define SYSCALL(esa,esame,emu) .long esa
922 .globl sys_call_table
924 #include "syscalls.S"