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
49 #define BASED(name) name-system_call(%r13)
52 #ifdef CONFIG_TRACE_IRQFLAGS
54 l %r1,BASED(.Lhardirqs_on)
55 basr %r14,%r1 # call trace_hardirqs_on_caller
60 #ifdef CONFIG_TRACE_IRQFLAGS
62 l %r1,BASED(.Lhardirqs_off)
63 basr %r14,%r1 # call trace_hardirqs_off_caller
67 .macro LOCKDEP_SYS_EXIT
69 tm __PT_PSW+1(%r11),0x01 # returning to user ?
71 l %r1,BASED(.Llockdep_sys_exit)
72 basr %r14,%r1 # call lockdep_sys_exit
76 .macro CHECK_STACK stacksize,savearea
77 #ifdef CONFIG_CHECK_STACK
78 tml %r15,\stacksize - CONFIG_STACK_GUARD
84 .macro SWITCH_ASYNC savearea,stack,shift
85 tmh %r8,0x0001 # interrupting from user ?
88 sl %r14,BASED(.Lcritical_start)
89 cl %r14,BASED(.Lcritical_length)
91 la %r11,\savearea # inside critical section, do cleanup
92 bras %r14,cleanup_critical
93 tmh %r8,0x0001 # retest problem state after cleanup
95 0: l %r14,\stack # are we already on the target stack?
99 CHECK_STACK 1<<\shift,\savearea
101 1: l %r15,\stack # load target stack
102 2: ahi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
103 la %r11,STACK_FRAME_OVERHEAD(%r15)
106 .macro ADD64 high,low,timer
113 .macro SUB64 high,low,timer
120 .macro UPDATE_VTIME high,low,enter_timer
121 lm \high,\low,__LC_EXIT_TIMER
122 SUB64 \high,\low,\enter_timer
123 ADD64 \high,\low,__LC_USER_TIMER
124 stm \high,\low,__LC_USER_TIMER
125 lm \high,\low,__LC_LAST_UPDATE_TIMER
126 SUB64 \high,\low,__LC_EXIT_TIMER
127 ADD64 \high,\low,__LC_SYSTEM_TIMER
128 stm \high,\low,__LC_SYSTEM_TIMER
129 mvc __LC_LAST_UPDATE_TIMER(8),\enter_timer
133 st %r8,__LC_RETURN_PSW
134 ni __LC_RETURN_PSW,0xbf
138 .section .kprobes.text, "ax"
141 * Scheduler resume function, called by switch_to
142 * gpr2 = (task_struct *) prev
143 * gpr3 = (task_struct *) next
148 stm %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task
149 st %r15,__THREAD_ksp(%r2) # store kernel stack of prev
150 l %r4,__THREAD_info(%r2) # get thread_info of prev
151 l %r5,__THREAD_info(%r3) # get thread_info of next
153 ahi %r15,STACK_SIZE # end of kernel stack of next
154 st %r3,__LC_CURRENT # store task struct of next
155 st %r5,__LC_THREAD_INFO # store thread info of next
156 st %r15,__LC_KERNEL_STACK # store end of kernel stack
157 lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4
158 mvc __LC_CURRENT_PID(4,%r0),__TASK_pid(%r3) # store pid of next
159 l %r15,__THREAD_ksp(%r3) # load kernel stack of next
160 tm __TI_flags+3(%r4),_TIF_MCCK_PENDING # machine check pending?
162 ni __TI_flags+3(%r4),255-_TIF_MCCK_PENDING # clear flag in prev
163 oi __TI_flags+3(%r5),_TIF_MCCK_PENDING # set it in next
164 0: lm %r6,%r15,__SF_GPRS(%r15) # load gprs of next task
169 * SVC interrupt handler routine. System calls are synchronous events and
170 * are executed with interrupts enabled.
174 stpt __LC_SYNC_ENTER_TIMER
176 stm %r8,%r15,__LC_SAVE_AREA_SYNC
177 l %r12,__LC_THREAD_INFO
178 l %r13,__LC_SVC_NEW_PSW+4
180 l %r15,__LC_KERNEL_STACK
181 ahi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
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 lh %r8,__PT_INT_CODE+2(%r11)
192 sla %r8,2 # shift and test for svc0
194 # svc 0: system call number in %r1
195 cl %r1,BASED(.Lnr_syscalls)
197 sth %r1,__PT_INT_CODE+2(%r11)
201 l %r10,BASED(.Lsys_call_table) # 31 bit system call table
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
363 1: UPDATE_VTIME %r14,%r15,__LC_SYNC_ENTER_TIMER
364 l %r15,__LC_KERNEL_STACK
365 2: ahi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
366 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 ahi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
489 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
490 xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1)
491 la %r11,STACK_FRAME_OVERHEAD(%r1)
495 # One of the work bits is on. Find out which one.
496 # Checked are: _TIF_SIGPENDING, _TIF_NOTIFY_RESUME, _TIF_NEED_RESCHED
497 # and _TIF_MCCK_PENDING
500 tm __TI_flags+3(%r12),_TIF_MCCK_PENDING
502 tm __TI_flags+3(%r12),_TIF_NEED_RESCHED
504 tm __TI_flags+3(%r12),_TIF_SIGPENDING
506 tm __TI_flags+3(%r12),_TIF_NOTIFY_RESUME
508 j io_return # beware of critical section cleanup
511 # _TIF_MCCK_PENDING is set, call handler
514 # TRACE_IRQS_ON already done at io_return
515 l %r1,BASED(.Lhandle_mcck)
516 basr %r14,%r1 # TIF bit will be cleared by handler
521 # _TIF_NEED_RESCHED is set, call schedule
524 # TRACE_IRQS_ON already done at io_return
525 l %r1,BASED(.Lschedule)
526 ssm __LC_SVC_NEW_PSW # reenable interrupts
527 basr %r14,%r1 # call scheduler
528 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
533 # _TIF_SIGPENDING is set, call do_signal
536 # TRACE_IRQS_ON already done at io_return
537 l %r1,BASED(.Ldo_signal)
538 ssm __LC_SVC_NEW_PSW # reenable interrupts
539 lr %r2,%r11 # pass pointer to pt_regs
540 basr %r14,%r1 # call do_signal
541 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
546 # _TIF_SIGPENDING is set, call do_signal
549 # TRACE_IRQS_ON already done at io_return
550 l %r1,BASED(.Ldo_notify_resume)
551 ssm __LC_SVC_NEW_PSW # reenable interrupts
552 lr %r2,%r11 # pass pointer to pt_regs
553 basr %r14,%r1 # call do_notify_resume
554 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
559 * External interrupt handler routine
562 ENTRY(ext_int_handler)
564 stpt __LC_ASYNC_ENTER_TIMER
565 stm %r8,%r15,__LC_SAVE_AREA_ASYNC
566 l %r12,__LC_THREAD_INFO
567 l %r13,__LC_SVC_NEW_PSW+4
568 lm %r8,%r9,__LC_EXT_OLD_PSW
569 tmh %r8,0x0001 # interrupting from user ?
571 UPDATE_VTIME %r14,%r15,__LC_ASYNC_ENTER_TIMER
573 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_STACK,STACK_SHIFT
574 stm %r0,%r7,__PT_R0(%r11)
575 mvc __PT_R8(32,%r11),__LC_SAVE_AREA_ASYNC
576 stm %r8,%r9,__PT_PSW(%r11)
578 lr %r2,%r11 # pass pointer to pt_regs
579 l %r3,__LC_EXT_CPU_ADDR # get cpu address + interruption code
580 l %r4,__LC_EXT_PARAMS # get external parameters
581 l %r1,BASED(.Ldo_extint)
582 basr %r14,%r1 # call do_extint
586 * Load idle PSW. The second "half" of this function is in cleanup_idle.
589 st %r3,__SF_EMPTY(%r15)
591 la %r1,psw_idle_lpsw+4-.(%r1)
592 st %r1,__SF_EMPTY+4(%r15)
593 oi __SF_EMPTY+4(%r15),0x80
594 stck __CLOCK_IDLE_ENTER(%r2)
595 stpt __TIMER_IDLE_ENTER(%r2)
597 lpsw __SF_EMPTY(%r15)
604 * Machine check handler routines
607 ENTRY(mcck_int_handler)
609 spt __LC_CPU_TIMER_SAVE_AREA # revalidate cpu timer
610 lm %r0,%r15,__LC_GPREGS_SAVE_AREA # revalidate gprs
611 l %r12,__LC_THREAD_INFO
612 l %r13,__LC_SVC_NEW_PSW+4
613 lm %r8,%r9,__LC_MCK_OLD_PSW
614 tm __LC_MCCK_CODE,0x80 # system damage?
615 jo mcck_panic # yes -> rest of mcck code invalid
616 la %r14,__LC_CPU_TIMER_SAVE_AREA
617 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
618 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
620 la %r14,__LC_SYNC_ENTER_TIMER
621 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
623 la %r14,__LC_ASYNC_ENTER_TIMER
624 0: clc 0(8,%r14),__LC_EXIT_TIMER
626 la %r14,__LC_EXIT_TIMER
627 1: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
629 la %r14,__LC_LAST_UPDATE_TIMER
631 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
632 3: tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid?
633 jno mcck_panic # no -> skip cleanup critical
634 tm %r8,0x0001 # interrupting from user ?
636 UPDATE_VTIME %r14,%r15,__LC_MCCK_ENTER_TIMER
638 SWITCH_ASYNC __LC_GPREGS_SAVE_AREA+32,__LC_PANIC_STACK,PAGE_SHIFT
639 stm %r0,%r7,__PT_R0(%r11)
640 mvc __PT_R8(32,%r11),__LC_GPREGS_SAVE_AREA+32
641 stm %r8,%r9,__PT_PSW(%r11)
642 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15)
643 l %r1,BASED(.Ldo_machine_check)
644 lr %r2,%r11 # pass pointer to pt_regs
645 basr %r14,%r1 # call s390_do_machine_check
646 tm __PT_PSW+1(%r11),0x01 # returning to user ?
648 l %r1,__LC_KERNEL_STACK # switch to kernel stack
649 ahi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
650 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
651 xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1)
652 la %r11,STACK_FRAME_OVERHEAD(%r15)
654 ssm __LC_PGM_NEW_PSW # turn dat on, keep irqs off
655 tm __TI_flags+3(%r12),_TIF_MCCK_PENDING
658 l %r1,BASED(.Lhandle_mcck)
659 basr %r14,%r1 # call s390_handle_mcck
662 mvc __LC_RETURN_MCCK_PSW(8),__PT_PSW(%r11) # move return PSW
663 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
665 lm %r0,%r15,__PT_R0(%r11)
667 lpsw __LC_RETURN_MCCK_PSW
668 0: lm %r0,%r15,__PT_R0(%r11)
669 lpsw __LC_RETURN_MCCK_PSW
672 l %r14,__LC_PANIC_STACK
676 l %r15,__LC_PANIC_STACK
677 0: ahi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
681 # PSW restart interrupt handler
683 ENTRY(restart_int_handler)
684 st %r15,__LC_SAVE_AREA_RESTART
685 l %r15,__LC_RESTART_STACK
686 ahi %r15,-__PT_SIZE # create pt_regs on stack
687 xc 0(__PT_SIZE,%r15),0(%r15)
688 stm %r0,%r14,__PT_R0(%r15)
689 mvc __PT_R15(4,%r15),__LC_SAVE_AREA_RESTART
690 mvc __PT_PSW(8,%r15),__LC_RST_OLD_PSW # store restart old psw
691 ahi %r15,-STACK_FRAME_OVERHEAD # create stack frame on stack
692 xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15)
693 l %r1,__LC_RESTART_FN # load fn, parm & source cpu
694 l %r2,__LC_RESTART_DATA
695 l %r3,__LC_RESTART_SOURCE
696 ltr %r3,%r3 # test source cpu address
697 jm 1f # negative -> skip source stop
698 0: sigp %r4,%r3,SIGP_SENSE # sigp sense to source cpu
699 brc 10,0b # wait for status stored
700 1: basr %r14,%r1 # call function
701 stap __SF_EMPTY(%r15) # store cpu address
702 lh %r3,__SF_EMPTY(%r15)
703 2: sigp %r4,%r3,SIGP_STOP # sigp stop to current cpu
707 .section .kprobes.text, "ax"
709 #ifdef CONFIG_CHECK_STACK
711 * The synchronous or the asynchronous stack overflowed. We are dead.
712 * No need to properly save the registers, we are going to panic anyway.
713 * Setup a pt_regs so that show_trace can provide a good call trace.
716 l %r15,__LC_PANIC_STACK # change to panic stack
717 ahi %r15,-__PT_SIZE # create pt_regs
718 stm %r0,%r7,__PT_R0(%r15)
719 stm %r8,%r9,__PT_PSW(%r15)
720 mvc __PT_R8(32,%r11),0(%r14)
722 ahi %r15,-STACK_FRAME_OVERHEAD
724 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15)
725 lr %r2,%r11 # pass pointer to pt_regs
726 br %r1 # branch to kernel_stack_overflow
727 1: .long kernel_stack_overflow
731 .long system_call + 0x80000000
732 .long sysc_do_svc + 0x80000000
733 .long sysc_tif + 0x80000000
734 .long sysc_restore + 0x80000000
735 .long sysc_done + 0x80000000
736 .long io_tif + 0x80000000
737 .long io_restore + 0x80000000
738 .long io_done + 0x80000000
739 .long psw_idle + 0x80000000
740 .long psw_idle_end + 0x80000000
743 cl %r9,BASED(cleanup_table) # system_call
745 cl %r9,BASED(cleanup_table+4) # sysc_do_svc
746 jl cleanup_system_call
747 cl %r9,BASED(cleanup_table+8) # sysc_tif
749 cl %r9,BASED(cleanup_table+12) # sysc_restore
751 cl %r9,BASED(cleanup_table+16) # sysc_done
752 jl cleanup_sysc_restore
753 cl %r9,BASED(cleanup_table+20) # io_tif
755 cl %r9,BASED(cleanup_table+24) # io_restore
757 cl %r9,BASED(cleanup_table+28) # io_done
758 jl cleanup_io_restore
759 cl %r9,BASED(cleanup_table+32) # psw_idle
761 cl %r9,BASED(cleanup_table+36) # psw_idle_end
766 # check if stpt has been executed
767 cl %r9,BASED(cleanup_system_call_insn)
769 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
770 chi %r11,__LC_SAVE_AREA_ASYNC
772 mvc __LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER
773 0: # check if stm has been executed
774 cl %r9,BASED(cleanup_system_call_insn+4)
776 mvc __LC_SAVE_AREA_SYNC(32),0(%r11)
777 0: # set up saved registers r12, and r13
778 st %r12,16(%r11) # r12 thread-info pointer
779 st %r13,20(%r11) # r13 literal-pool pointer
780 # check if the user time calculation has been done
781 cl %r9,BASED(cleanup_system_call_insn+8)
783 l %r10,__LC_EXIT_TIMER
784 l %r15,__LC_EXIT_TIMER+4
785 SUB64 %r10,%r15,__LC_SYNC_ENTER_TIMER
786 ADD64 %r10,%r15,__LC_USER_TIMER
787 st %r10,__LC_USER_TIMER
788 st %r15,__LC_USER_TIMER+4
789 0: # check if the system time calculation has been done
790 cl %r9,BASED(cleanup_system_call_insn+12)
792 l %r10,__LC_LAST_UPDATE_TIMER
793 l %r15,__LC_LAST_UPDATE_TIMER+4
794 SUB64 %r10,%r15,__LC_EXIT_TIMER
795 ADD64 %r10,%r15,__LC_SYSTEM_TIMER
796 st %r10,__LC_SYSTEM_TIMER
797 st %r15,__LC_SYSTEM_TIMER+4
798 0: # update accounting time stamp
799 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
800 # set up saved register 11
801 l %r15,__LC_KERNEL_STACK
803 st %r15,12(%r11) # r11 pt_regs pointer
805 mvc __PT_R8(32,%r15),__LC_SAVE_AREA_SYNC
806 stm %r0,%r7,__PT_R0(%r15)
807 mvc __PT_PSW(8,%r15),__LC_SVC_OLD_PSW
808 mvc __PT_INT_CODE(4,%r15),__LC_SVC_ILC
809 # setup saved register 15
810 ahi %r15,-STACK_FRAME_OVERHEAD
811 st %r15,28(%r11) # r15 stack pointer
812 # set new psw address and exit
813 l %r9,BASED(cleanup_table+4) # sysc_do_svc + 0x80000000
815 cleanup_system_call_insn:
816 .long system_call + 0x80000000
817 .long sysc_stm + 0x80000000
818 .long sysc_vtime + 0x80000000 + 36
819 .long sysc_vtime + 0x80000000 + 76
822 l %r9,BASED(cleanup_table+8) # sysc_tif + 0x80000000
825 cleanup_sysc_restore:
826 cl %r9,BASED(cleanup_sysc_restore_insn)
828 l %r9,12(%r11) # get saved pointer to pt_regs
829 mvc __LC_RETURN_PSW(8),__PT_PSW(%r9)
830 mvc 0(32,%r11),__PT_R8(%r9)
831 lm %r0,%r7,__PT_R0(%r9)
832 0: lm %r8,%r9,__LC_RETURN_PSW
834 cleanup_sysc_restore_insn:
835 .long sysc_done - 4 + 0x80000000
838 l %r9,BASED(cleanup_table+20) # io_tif + 0x80000000
842 cl %r9,BASED(cleanup_io_restore_insn)
844 l %r9,12(%r11) # get saved r11 pointer to pt_regs
845 mvc __LC_RETURN_PSW(8),__PT_PSW(%r9)
846 mvc 0(32,%r11),__PT_R8(%r9)
847 lm %r0,%r7,__PT_R0(%r9)
848 0: lm %r8,%r9,__LC_RETURN_PSW
850 cleanup_io_restore_insn:
851 .long io_done - 4 + 0x80000000
854 # copy interrupt clock & cpu timer
855 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_INT_CLOCK
856 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_ASYNC_ENTER_TIMER
857 chi %r11,__LC_SAVE_AREA_ASYNC
859 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_MCCK_CLOCK
860 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_MCCK_ENTER_TIMER
861 0: # check if stck has been executed
862 cl %r9,BASED(cleanup_idle_insn)
864 mvc __CLOCK_IDLE_ENTER(8,%r2),__CLOCK_IDLE_EXIT(%r2)
865 mvc __TIMER_IDLE_ENTER(8,%r2),__TIMER_IDLE_EXIT(%r3)
866 1: # account system time going idle
867 lm %r9,%r10,__LC_STEAL_TIMER
868 ADD64 %r9,%r10,__CLOCK_IDLE_ENTER(%r2)
869 SUB64 %r9,%r10,__LC_LAST_UPDATE_CLOCK
870 stm %r9,%r10,__LC_STEAL_TIMER
871 mvc __LC_LAST_UPDATE_CLOCK(8),__CLOCK_IDLE_EXIT(%r2)
872 lm %r9,%r10,__LC_SYSTEM_TIMER
873 ADD64 %r9,%r10,__LC_LAST_UPDATE_TIMER
874 SUB64 %r9,%r10,__TIMER_IDLE_ENTER(%r2)
875 stm %r9,%r10,__LC_SYSTEM_TIMER
876 mvc __LC_LAST_UPDATE_TIMER(8),__TIMER_IDLE_EXIT(%r2)
878 n %r8,BASED(cleanup_idle_wait) # clear wait state bit
879 l %r9,24(%r11) # return from psw_idle
882 .long psw_idle_lpsw + 0x80000000
893 .quad 0x7fffffffffffffff
898 .Ldo_machine_check: .long s390_do_machine_check
899 .Lhandle_mcck: .long s390_handle_mcck
900 .Ldo_IRQ: .long do_IRQ
901 .Ldo_extint: .long do_extint
902 .Ldo_signal: .long do_signal
903 .Ldo_notify_resume: .long do_notify_resume
904 .Ldo_per_trap: .long do_per_trap
905 .Ljump_table: .long pgm_check_table
906 .Lschedule: .long schedule
907 #ifdef CONFIG_PREEMPT
908 .Lpreempt_irq: .long preempt_schedule_irq
910 .Ltrace_enter: .long do_syscall_trace_enter
911 .Ltrace_exit: .long do_syscall_trace_exit
912 .Lschedule_tail: .long schedule_tail
913 .Lsys_call_table: .long sys_call_table
914 .Lsysc_per: .long sysc_per + 0x80000000
915 #ifdef CONFIG_TRACE_IRQFLAGS
916 .Lhardirqs_on: .long trace_hardirqs_on_caller
917 .Lhardirqs_off: .long trace_hardirqs_off_caller
919 #ifdef CONFIG_LOCKDEP
920 .Llockdep_sys_exit: .long lockdep_sys_exit
922 .Lcritical_start: .long __critical_start + 0x80000000
923 .Lcritical_length: .long __critical_end - __critical_start
925 .section .rodata, "a"
926 #define SYSCALL(esa,esame,emu) .long esa
927 .globl sys_call_table
929 #include "syscalls.S"