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/processor.h>
14 #include <asm/cache.h>
15 #include <asm/errno.h>
16 #include <asm/ptrace.h>
17 #include <asm/thread_info.h>
18 #include <asm/asm-offsets.h>
19 #include <asm/unistd.h>
24 __PT_R1 = __PT_GPRS + 8
25 __PT_R2 = __PT_GPRS + 16
26 __PT_R3 = __PT_GPRS + 24
27 __PT_R4 = __PT_GPRS + 32
28 __PT_R5 = __PT_GPRS + 40
29 __PT_R6 = __PT_GPRS + 48
30 __PT_R7 = __PT_GPRS + 56
31 __PT_R8 = __PT_GPRS + 64
32 __PT_R9 = __PT_GPRS + 72
33 __PT_R10 = __PT_GPRS + 80
34 __PT_R11 = __PT_GPRS + 88
35 __PT_R12 = __PT_GPRS + 96
36 __PT_R13 = __PT_GPRS + 104
37 __PT_R14 = __PT_GPRS + 112
38 __PT_R15 = __PT_GPRS + 120
40 STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
41 STACK_SIZE = 1 << STACK_SHIFT
43 _TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
44 _TIF_MCCK_PENDING | _TIF_PER_TRAP )
45 _TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
47 _TIF_TRACE = (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | \
48 _TIF_SYSCALL_TRACEPOINT)
49 _TIF_EXIT_SIE = (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_MCCK_PENDING)
51 #define BASED(name) name-system_call(%r13)
54 #ifdef CONFIG_TRACE_IRQFLAGS
56 brasl %r14,trace_hardirqs_on_caller
61 #ifdef CONFIG_TRACE_IRQFLAGS
63 brasl %r14,trace_hardirqs_off_caller
67 .macro LOCKDEP_SYS_EXIT
69 tm __PT_PSW+1(%r11),0x01 # returning to user ?
71 brasl %r14,lockdep_sys_exit
76 #if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
77 tm __LC_MACHINE_FLAGS+6,0x20 # MACHINE_FLAG_SPP
79 .insn s,0xb2800000,\newpp
83 .macro HANDLE_SIE_INTERCEPT scratch,pgmcheck
84 #if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
85 tmhh %r8,0x0001 # interrupting from user ?
88 slg \scratch,BASED(.Lsie_loop)
89 clg \scratch,BASED(.Lsie_length)
91 # Some program interrupts are suppressing (e.g. protection).
92 # We must also check the instruction after SIE in that case.
93 # do_protection_exception will rewind to rewind_pad
98 lg %r9,BASED(.Lsie_loop)
99 SPP BASED(.Lhost_id) # set host id
103 .macro CHECK_STACK stacksize,savearea
104 #ifdef CONFIG_CHECK_STACK
105 tml %r15,\stacksize - CONFIG_STACK_GUARD
111 .macro SWITCH_ASYNC savearea,stack,shift
112 tmhh %r8,0x0001 # interrupting from user ?
115 slg %r14,BASED(.Lcritical_start)
116 clg %r14,BASED(.Lcritical_length)
118 lghi %r11,\savearea # inside critical section, do cleanup
119 brasl %r14,cleanup_critical
120 tmhh %r8,0x0001 # retest problem state after cleanup
122 0: lg %r14,\stack # are we already on the target stack?
124 srag %r14,%r14,\shift
126 CHECK_STACK 1<<\shift,\savearea
128 1: lg %r15,\stack # load target stack
129 2: aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
130 la %r11,STACK_FRAME_OVERHEAD(%r15)
133 .macro UPDATE_VTIME scratch,enter_timer
134 lg \scratch,__LC_EXIT_TIMER
135 slg \scratch,\enter_timer
136 alg \scratch,__LC_USER_TIMER
137 stg \scratch,__LC_USER_TIMER
138 lg \scratch,__LC_LAST_UPDATE_TIMER
139 slg \scratch,__LC_EXIT_TIMER
140 alg \scratch,__LC_SYSTEM_TIMER
141 stg \scratch,__LC_SYSTEM_TIMER
142 mvc __LC_LAST_UPDATE_TIMER(8),\enter_timer
145 .macro LAST_BREAK scratch
146 srag \scratch,%r10,23
148 stg %r10,__TI_last_break(%r12)
152 stg %r8,__LC_RETURN_PSW
153 ni __LC_RETURN_PSW,0xbf
158 #ifdef CONFIG_HAVE_MARCH_Z9_109_FEATURES
159 .insn s,0xb27c0000,\savearea # store clock fast
161 .insn s,0xb2050000,\savearea # store clock
165 .section .kprobes.text, "ax"
168 * Scheduler resume function, called by switch_to
169 * gpr2 = (task_struct *) prev
170 * gpr3 = (task_struct *) next
175 stmg %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task
176 stg %r15,__THREAD_ksp(%r2) # store kernel stack of prev
177 lg %r4,__THREAD_info(%r2) # get thread_info of prev
178 lg %r5,__THREAD_info(%r3) # get thread_info of next
180 aghi %r15,STACK_SIZE # end of kernel stack of next
181 stg %r3,__LC_CURRENT # store task struct of next
182 stg %r5,__LC_THREAD_INFO # store thread info of next
183 stg %r15,__LC_KERNEL_STACK # store end of kernel stack
184 lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4
185 mvc __LC_CURRENT_PID+4(4,%r0),__TASK_pid(%r3) # store pid of next
186 lg %r15,__THREAD_ksp(%r3) # load kernel stack of next
187 tm __TI_flags+7(%r4),_TIF_MCCK_PENDING # machine check pending?
189 ni __TI_flags+7(%r4),255-_TIF_MCCK_PENDING # clear flag in prev
190 oi __TI_flags+7(%r5),_TIF_MCCK_PENDING # set it in next
191 0: lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task
196 * SVC interrupt handler routine. System calls are synchronous events and
197 * are executed with interrupts enabled.
201 stpt __LC_SYNC_ENTER_TIMER
203 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
204 lg %r10,__LC_LAST_BREAK
205 lg %r12,__LC_THREAD_INFO
206 larl %r13,system_call
208 lg %r15,__LC_KERNEL_STACK
209 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
210 la %r11,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs
212 UPDATE_VTIME %r13,__LC_SYNC_ENTER_TIMER
214 stmg %r0,%r7,__PT_R0(%r11)
215 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
216 mvc __PT_PSW(16,%r11),__LC_SVC_OLD_PSW
217 mvc __PT_INT_CODE(4,%r11),__LC_SVC_ILC
219 oi __TI_flags+7(%r12),_TIF_SYSCALL
220 llgh %r8,__PT_INT_CODE+2(%r11)
221 slag %r8,%r8,2 # shift and test for svc 0
223 # svc 0: system call number in %r1
224 llgfr %r1,%r1 # clear high word in r1
227 sth %r1,__PT_INT_CODE+2(%r11)
230 larl %r10,sys_call_table # 64 bit system call table
232 tm __TI_flags+5(%r12),(_TIF_31BIT>>16)
234 larl %r10,sys_call_table_emu # 31 bit system call table
237 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
238 stg %r2,__PT_ORIG_GPR2(%r11)
239 stg %r7,STACK_FRAME_OVERHEAD(%r15)
240 lgf %r9,0(%r8,%r10) # get system call add.
241 tm __TI_flags+6(%r12),_TIF_TRACE >> 8
243 basr %r14,%r9 # call sys_xxxx
244 stg %r2,__PT_R2(%r11) # store return value
249 tm __PT_PSW+1(%r11),0x01 # returning to user ?
251 tm __TI_flags+7(%r12),_TIF_WORK_SVC
252 jnz sysc_work # check for work
253 ni __TI_flags+7(%r12),255-_TIF_SYSCALL
255 lg %r14,__LC_VDSO_PER_CPU
256 lmg %r0,%r10,__PT_R0(%r11)
257 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
259 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
260 lmg %r11,%r15,__PT_R11(%r11)
261 lpswe __LC_RETURN_PSW
265 # One of the work bits is on. Find out which one.
268 tm __TI_flags+7(%r12),_TIF_MCCK_PENDING
270 tm __TI_flags+7(%r12),_TIF_NEED_RESCHED
272 tm __TI_flags+7(%r12),_TIF_PER_TRAP
274 tm __TI_flags+7(%r12),_TIF_SIGPENDING
276 tm __TI_flags+7(%r12),_TIF_NOTIFY_RESUME
277 jo sysc_notify_resume
278 j sysc_return # beware of critical section cleanup
281 # _TIF_NEED_RESCHED is set, call schedule
284 larl %r14,sysc_return
288 # _TIF_MCCK_PENDING is set, call handler
291 larl %r14,sysc_return
292 jg s390_handle_mcck # TIF bit will be cleared by handler
295 # _TIF_SIGPENDING is set, call do_signal
298 lgr %r2,%r11 # pass pointer to pt_regs
300 tm __TI_flags+7(%r12),_TIF_SYSCALL
302 lmg %r2,%r7,__PT_R2(%r11) # load svc arguments
303 lghi %r8,0 # svc 0 returns -ENOSYS
304 llgh %r1,__PT_INT_CODE+2(%r11) # load new svc number
306 jnl sysc_nr_ok # invalid svc number -> do svc 0
308 j sysc_nr_ok # restart svc
311 # _TIF_NOTIFY_RESUME is set, call do_notify_resume
314 lgr %r2,%r11 # pass pointer to pt_regs
315 larl %r14,sysc_return
319 # _TIF_PER_TRAP is set, call do_per_trap
322 ni __TI_flags+7(%r12),255-_TIF_PER_TRAP
323 lgr %r2,%r11 # pass pointer to pt_regs
324 larl %r14,sysc_return
328 # call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
329 # and after the system call
332 lgr %r2,%r11 # pass pointer to pt_regs
334 llgh %r0,__PT_INT_CODE+2(%r11)
335 stg %r0,__PT_R2(%r11)
336 brasl %r14,do_syscall_trace_enter
343 lmg %r3,%r7,__PT_R3(%r11)
344 stg %r7,STACK_FRAME_OVERHEAD(%r15)
345 lg %r2,__PT_ORIG_GPR2(%r11)
346 basr %r14,%r9 # call sys_xxx
347 stg %r2,__PT_R2(%r11) # store return value
349 tm __TI_flags+6(%r12),_TIF_TRACE >> 8
351 lgr %r2,%r11 # pass pointer to pt_regs
352 larl %r14,sysc_return
353 jg do_syscall_trace_exit
356 # a new process exits the kernel with ret_from_fork
359 la %r11,STACK_FRAME_OVERHEAD(%r15)
360 lg %r12,__LC_THREAD_INFO
361 brasl %r14,schedule_tail
363 ssm __LC_SVC_NEW_PSW # reenable interrupts
364 tm __PT_PSW+1(%r11),0x01 # forking a kernel thread ?
366 # it's a kernel thread
367 lmg %r9,%r10,__PT_R9(%r11) # load gprs
368 ENTRY(kernel_thread_starter)
374 * Program check handler routine
377 ENTRY(pgm_check_handler)
378 stpt __LC_SYNC_ENTER_TIMER
379 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
380 lg %r10,__LC_LAST_BREAK
381 lg %r12,__LC_THREAD_INFO
382 larl %r13,system_call
383 lmg %r8,%r9,__LC_PGM_OLD_PSW
384 HANDLE_SIE_INTERCEPT %r14,1
385 tmhh %r8,0x0001 # test problem state bit
386 jnz 1f # -> fault in user space
387 tmhh %r8,0x4000 # PER bit set in old PSW ?
388 jnz 0f # -> enabled, can't be a double fault
389 tm __LC_PGM_ILC+3,0x80 # check for per exception
390 jnz pgm_svcper # -> single stepped svc
391 0: CHECK_STACK STACK_SIZE,__LC_SAVE_AREA_SYNC
393 1: UPDATE_VTIME %r14,__LC_SYNC_ENTER_TIMER
395 lg %r15,__LC_KERNEL_STACK
396 lg %r14,__TI_task(%r12)
397 lghi %r13,__LC_PGM_TDB
398 tm __LC_PGM_ILC+2,0x02 # check for transaction abort
400 mvc __THREAD_trap_tdb(256,%r14),0(%r13)
401 2: aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
402 la %r11,STACK_FRAME_OVERHEAD(%r15)
403 stmg %r0,%r7,__PT_R0(%r11)
404 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
405 stmg %r8,%r9,__PT_PSW(%r11)
406 mvc __PT_INT_CODE(4,%r11),__LC_PGM_ILC
407 mvc __PT_INT_PARM_LONG(8,%r11),__LC_TRANS_EXC_CODE
408 stg %r10,__PT_ARGS(%r11)
409 tm __LC_PGM_ILC+3,0x80 # check for per exception
411 tmhh %r8,0x0001 # kernel per event ?
413 oi __TI_flags+7(%r12),_TIF_PER_TRAP
414 mvc __THREAD_per_address(8,%r14),__LC_PER_ADDRESS
415 mvc __THREAD_per_cause(2,%r14),__LC_PER_CAUSE
416 mvc __THREAD_per_paid(1,%r14),__LC_PER_PAID
418 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
419 larl %r1,pgm_check_table
420 llgh %r10,__PT_INT_CODE+2(%r11)
424 lgf %r1,0(%r10,%r1) # load address of handler routine
425 lgr %r2,%r11 # pass pointer to pt_regs
426 basr %r14,%r1 # branch to interrupt-handler
430 # PER event in supervisor state, must be kprobes
434 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
435 lgr %r2,%r11 # pass pointer to pt_regs
436 brasl %r14,do_per_trap
440 # single stepped system call
443 oi __TI_flags+7(%r12),_TIF_PER_TRAP
444 mvc __LC_RETURN_PSW(8),__LC_SVC_NEW_PSW
446 stg %r14,__LC_RETURN_PSW+8
447 lpswe __LC_RETURN_PSW # branch to sysc_per and enable irqs
450 * IO interrupt handler routine
452 ENTRY(io_int_handler)
454 stpt __LC_ASYNC_ENTER_TIMER
455 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
456 lg %r10,__LC_LAST_BREAK
457 lg %r12,__LC_THREAD_INFO
458 larl %r13,system_call
459 lmg %r8,%r9,__LC_IO_OLD_PSW
460 HANDLE_SIE_INTERCEPT %r14,0
461 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_STACK,STACK_SHIFT
462 tmhh %r8,0x0001 # interrupting from user?
464 UPDATE_VTIME %r14,__LC_ASYNC_ENTER_TIMER
467 stmg %r0,%r7,__PT_R0(%r11)
468 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
469 stmg %r8,%r9,__PT_PSW(%r11)
471 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
472 lgr %r2,%r11 # pass pointer to pt_regs
478 tm __TI_flags+7(%r12),_TIF_WORK_INT
479 jnz io_work # there is work to do (signals etc.)
481 lg %r14,__LC_VDSO_PER_CPU
482 lmg %r0,%r10,__PT_R0(%r11)
483 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
485 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
486 lmg %r11,%r15,__PT_R11(%r11)
487 lpswe __LC_RETURN_PSW
491 # There is work todo, find out in which context we have been interrupted:
492 # 1) if we return to user space we can do all _TIF_WORK_INT work
493 # 2) if we return to kernel code and kvm is enabled check if we need to
494 # modify the psw to leave SIE
495 # 3) if we return to kernel code and preemptive scheduling is enabled check
496 # the preemption counter and if it is zero call preempt_schedule_irq
497 # Before any work can be done, a switch to the kernel stack is required.
500 tm __PT_PSW+1(%r11),0x01 # returning to user ?
501 jo io_work_user # yes -> do resched & signal
502 #ifdef CONFIG_PREEMPT
503 # check for preemptive scheduling
504 icm %r0,15,__TI_precount(%r12)
505 jnz io_restore # preemption is disabled
506 tm __TI_flags+7(%r12),_TIF_NEED_RESCHED
508 # switch to kernel stack
509 lg %r1,__PT_R15(%r11)
510 aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
511 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
512 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
513 la %r11,STACK_FRAME_OVERHEAD(%r1)
515 # TRACE_IRQS_ON already done at io_return, call
516 # TRACE_IRQS_OFF to keep things symmetrical
518 brasl %r14,preempt_schedule_irq
525 # Need to do work before returning to userspace, switch to kernel stack
528 lg %r1,__LC_KERNEL_STACK
529 aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
530 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
531 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
532 la %r11,STACK_FRAME_OVERHEAD(%r1)
536 # One of the work bits is on. Find out which one.
537 # Checked are: _TIF_SIGPENDING, _TIF_NOTIFY_RESUME, _TIF_NEED_RESCHED
538 # and _TIF_MCCK_PENDING
541 tm __TI_flags+7(%r12),_TIF_MCCK_PENDING
543 tm __TI_flags+7(%r12),_TIF_NEED_RESCHED
545 tm __TI_flags+7(%r12),_TIF_SIGPENDING
547 tm __TI_flags+7(%r12),_TIF_NOTIFY_RESUME
549 j io_return # beware of critical section cleanup
552 # _TIF_MCCK_PENDING is set, call handler
555 # TRACE_IRQS_ON already done at io_return
556 brasl %r14,s390_handle_mcck # TIF bit will be cleared by handler
561 # _TIF_NEED_RESCHED is set, call schedule
564 # TRACE_IRQS_ON already done at io_return
565 ssm __LC_SVC_NEW_PSW # reenable interrupts
566 brasl %r14,schedule # call scheduler
567 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
572 # _TIF_SIGPENDING or is set, call do_signal
575 # TRACE_IRQS_ON already done at io_return
576 ssm __LC_SVC_NEW_PSW # reenable interrupts
577 lgr %r2,%r11 # pass pointer to pt_regs
579 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
584 # _TIF_NOTIFY_RESUME or is set, call do_notify_resume
587 # TRACE_IRQS_ON already done at io_return
588 ssm __LC_SVC_NEW_PSW # reenable interrupts
589 lgr %r2,%r11 # pass pointer to pt_regs
590 brasl %r14,do_notify_resume
591 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
596 * External interrupt handler routine
598 ENTRY(ext_int_handler)
600 stpt __LC_ASYNC_ENTER_TIMER
601 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
602 lg %r10,__LC_LAST_BREAK
603 lg %r12,__LC_THREAD_INFO
604 larl %r13,system_call
605 lmg %r8,%r9,__LC_EXT_OLD_PSW
606 HANDLE_SIE_INTERCEPT %r14,0
607 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_STACK,STACK_SHIFT
608 tmhh %r8,0x0001 # interrupting from user ?
610 UPDATE_VTIME %r14,__LC_ASYNC_ENTER_TIMER
613 stmg %r0,%r7,__PT_R0(%r11)
614 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
615 stmg %r8,%r9,__PT_PSW(%r11)
617 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
619 lgr %r2,%r11 # pass pointer to pt_regs
620 llgf %r3,__LC_EXT_CPU_ADDR # get cpu address + interruption code
621 llgf %r4,__LC_EXT_PARAMS # get external parameter
622 lg %r5,__LC_EXT_PARAMS2-4096(%r1) # get 64 bit external parameter
627 * Load idle PSW. The second "half" of this function is in cleanup_idle.
630 stg %r3,__SF_EMPTY(%r15)
631 larl %r1,psw_idle_lpsw+4
632 stg %r1,__SF_EMPTY+8(%r15)
633 STCK __CLOCK_IDLE_ENTER(%r2)
634 stpt __TIMER_IDLE_ENTER(%r2)
636 lpswe __SF_EMPTY(%r15)
643 * Machine check handler routines
645 ENTRY(mcck_int_handler)
647 la %r1,4095 # revalidate r1
648 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # revalidate cpu timer
649 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# revalidate gprs
650 lg %r10,__LC_LAST_BREAK
651 lg %r12,__LC_THREAD_INFO
652 larl %r13,system_call
653 lmg %r8,%r9,__LC_MCK_OLD_PSW
654 HANDLE_SIE_INTERCEPT %r14,0
655 tm __LC_MCCK_CODE,0x80 # system damage?
656 jo mcck_panic # yes -> rest of mcck code invalid
657 lghi %r14,__LC_CPU_TIMER_SAVE_AREA
658 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
659 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
661 la %r14,__LC_SYNC_ENTER_TIMER
662 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
664 la %r14,__LC_ASYNC_ENTER_TIMER
665 0: clc 0(8,%r14),__LC_EXIT_TIMER
667 la %r14,__LC_EXIT_TIMER
668 1: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
670 la %r14,__LC_LAST_UPDATE_TIMER
672 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
673 3: tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid?
674 jno mcck_panic # no -> skip cleanup critical
675 SWITCH_ASYNC __LC_GPREGS_SAVE_AREA+64,__LC_PANIC_STACK,PAGE_SHIFT
676 tm %r8,0x0001 # interrupting from user ?
678 UPDATE_VTIME %r14,__LC_MCCK_ENTER_TIMER
681 lghi %r14,__LC_GPREGS_SAVE_AREA
682 mvc __PT_R0(128,%r11),0(%r14)
683 stmg %r8,%r9,__PT_PSW(%r11)
684 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
685 lgr %r2,%r11 # pass pointer to pt_regs
686 brasl %r14,s390_do_machine_check
687 tm __PT_PSW+1(%r11),0x01 # returning to user ?
689 lg %r1,__LC_KERNEL_STACK # switch to kernel stack
690 aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
691 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
692 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
693 la %r11,STACK_FRAME_OVERHEAD(%r1)
695 ssm __LC_PGM_NEW_PSW # turn dat on, keep irqs off
696 tm __TI_flags+7(%r12),_TIF_MCCK_PENDING
699 brasl %r14,s390_handle_mcck
702 lg %r14,__LC_VDSO_PER_CPU
703 lmg %r0,%r10,__PT_R0(%r11)
704 mvc __LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW
705 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
708 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
709 0: lmg %r11,%r15,__PT_R11(%r11)
710 lpswe __LC_RETURN_MCCK_PSW
713 lg %r14,__LC_PANIC_STACK
715 srag %r14,%r14,PAGE_SHIFT
717 lg %r15,__LC_PANIC_STACK
718 0: aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
722 # PSW restart interrupt handler
724 ENTRY(restart_int_handler)
725 stg %r15,__LC_SAVE_AREA_RESTART
726 lg %r15,__LC_RESTART_STACK
727 aghi %r15,-__PT_SIZE # create pt_regs on stack
728 xc 0(__PT_SIZE,%r15),0(%r15)
729 stmg %r0,%r14,__PT_R0(%r15)
730 mvc __PT_R15(8,%r15),__LC_SAVE_AREA_RESTART
731 mvc __PT_PSW(16,%r15),__LC_RST_OLD_PSW # store restart old psw
732 aghi %r15,-STACK_FRAME_OVERHEAD # create stack frame on stack
733 xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15)
734 lg %r1,__LC_RESTART_FN # load fn, parm & source cpu
735 lg %r2,__LC_RESTART_DATA
736 lg %r3,__LC_RESTART_SOURCE
737 ltgr %r3,%r3 # test source cpu address
738 jm 1f # negative -> skip source stop
739 0: sigp %r4,%r3,SIGP_SENSE # sigp sense to source cpu
740 brc 10,0b # wait for status stored
741 1: basr %r14,%r1 # call function
742 stap __SF_EMPTY(%r15) # store cpu address
743 llgh %r3,__SF_EMPTY(%r15)
744 2: sigp %r4,%r3,SIGP_STOP # sigp stop to current cpu
748 .section .kprobes.text, "ax"
750 #ifdef CONFIG_CHECK_STACK
752 * The synchronous or the asynchronous stack overflowed. We are dead.
753 * No need to properly save the registers, we are going to panic anyway.
754 * Setup a pt_regs so that show_trace can provide a good call trace.
757 lg %r11,__LC_PANIC_STACK # change to panic stack
758 aghi %r11,-__PT_SIZE # create pt_regs
759 stmg %r0,%r7,__PT_R0(%r11)
760 stmg %r8,%r9,__PT_PSW(%r11)
761 mvc __PT_R8(64,%r11),0(%r14)
762 stg %r10,__PT_ORIG_GPR2(%r11) # store last break to orig_gpr2
764 aghi %r15,-STACK_FRAME_OVERHEAD
765 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
766 lgr %r2,%r11 # pass pointer to pt_regs
767 jg kernel_stack_overflow
784 clg %r9,BASED(cleanup_table) # system_call
786 clg %r9,BASED(cleanup_table+8) # sysc_do_svc
787 jl cleanup_system_call
788 clg %r9,BASED(cleanup_table+16) # sysc_tif
790 clg %r9,BASED(cleanup_table+24) # sysc_restore
792 clg %r9,BASED(cleanup_table+32) # sysc_done
793 jl cleanup_sysc_restore
794 clg %r9,BASED(cleanup_table+40) # io_tif
796 clg %r9,BASED(cleanup_table+48) # io_restore
798 clg %r9,BASED(cleanup_table+56) # io_done
799 jl cleanup_io_restore
800 clg %r9,BASED(cleanup_table+64) # psw_idle
802 clg %r9,BASED(cleanup_table+72) # psw_idle_end
808 # check if stpt has been executed
809 clg %r9,BASED(cleanup_system_call_insn)
811 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
812 cghi %r11,__LC_SAVE_AREA_ASYNC
814 mvc __LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER
815 0: # check if stmg has been executed
816 clg %r9,BASED(cleanup_system_call_insn+8)
818 mvc __LC_SAVE_AREA_SYNC(64),0(%r11)
819 0: # check if base register setup + TIF bit load has been done
820 clg %r9,BASED(cleanup_system_call_insn+16)
822 # set up saved registers r10 and r12
823 stg %r10,16(%r11) # r10 last break
824 stg %r12,32(%r11) # r12 thread-info pointer
825 0: # check if the user time update has been done
826 clg %r9,BASED(cleanup_system_call_insn+24)
828 lg %r15,__LC_EXIT_TIMER
829 slg %r15,__LC_SYNC_ENTER_TIMER
830 alg %r15,__LC_USER_TIMER
831 stg %r15,__LC_USER_TIMER
832 0: # check if the system time update has been done
833 clg %r9,BASED(cleanup_system_call_insn+32)
835 lg %r15,__LC_LAST_UPDATE_TIMER
836 slg %r15,__LC_EXIT_TIMER
837 alg %r15,__LC_SYSTEM_TIMER
838 stg %r15,__LC_SYSTEM_TIMER
839 0: # update accounting time stamp
840 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
845 mvc __TI_last_break(8,%r12),16(%r11)
846 0: # set up saved register r11
847 lg %r15,__LC_KERNEL_STACK
849 stg %r15,24(%r11) # r11 pt_regs pointer
851 mvc __PT_R8(64,%r15),__LC_SAVE_AREA_SYNC
852 stmg %r0,%r7,__PT_R0(%r15)
853 mvc __PT_PSW(16,%r15),__LC_SVC_OLD_PSW
854 mvc __PT_INT_CODE(4,%r15),__LC_SVC_ILC
855 # setup saved register r15
856 aghi %r15,-STACK_FRAME_OVERHEAD
857 stg %r15,56(%r11) # r15 stack pointer
858 # set new psw address and exit
861 cleanup_system_call_insn:
872 cleanup_sysc_restore:
873 clg %r9,BASED(cleanup_sysc_restore_insn)
875 lg %r9,24(%r11) # get saved pointer to pt_regs
876 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
877 mvc 0(64,%r11),__PT_R8(%r9)
878 lmg %r0,%r7,__PT_R0(%r9)
879 0: lmg %r8,%r9,__LC_RETURN_PSW
881 cleanup_sysc_restore_insn:
889 clg %r9,BASED(cleanup_io_restore_insn)
891 lg %r9,24(%r11) # get saved r11 pointer to pt_regs
892 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
893 mvc 0(64,%r11),__PT_R8(%r9)
894 lmg %r0,%r7,__PT_R0(%r9)
895 0: lmg %r8,%r9,__LC_RETURN_PSW
897 cleanup_io_restore_insn:
901 # copy interrupt clock & cpu timer
902 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_INT_CLOCK
903 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_ASYNC_ENTER_TIMER
904 cghi %r11,__LC_SAVE_AREA_ASYNC
906 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_MCCK_CLOCK
907 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_MCCK_ENTER_TIMER
908 0: # check if stck & stpt have been executed
909 clg %r9,BASED(cleanup_idle_insn)
911 mvc __CLOCK_IDLE_ENTER(8,%r2),__CLOCK_IDLE_EXIT(%r2)
912 mvc __TIMER_IDLE_ENTER(8,%r2),__TIMER_IDLE_EXIT(%r2)
913 1: # account system time going idle
914 lg %r9,__LC_STEAL_TIMER
915 alg %r9,__CLOCK_IDLE_ENTER(%r2)
916 slg %r9,__LC_LAST_UPDATE_CLOCK
917 stg %r9,__LC_STEAL_TIMER
918 mvc __LC_LAST_UPDATE_CLOCK(8),__CLOCK_IDLE_EXIT(%r2)
919 lg %r9,__LC_SYSTEM_TIMER
920 alg %r9,__LC_LAST_UPDATE_TIMER
921 slg %r9,__TIMER_IDLE_ENTER(%r2)
922 stg %r9,__LC_SYSTEM_TIMER
923 mvc __LC_LAST_UPDATE_TIMER(8),__TIMER_IDLE_EXIT(%r2)
925 nihh %r8,0xfffd # clear wait state bit
926 lg %r9,48(%r11) # return from psw_idle
936 .quad __critical_start
938 .quad __critical_end - __critical_start
941 #if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
943 * sie64a calling convention:
944 * %r2 pointer to sie control block
945 * %r3 guest register save area
948 stmg %r6,%r14,__SF_GPRS(%r15) # save kernel registers
949 stg %r2,__SF_EMPTY(%r15) # save control block pointer
950 stg %r3,__SF_EMPTY+8(%r15) # save guest register save area
951 xc __SF_EMPTY+16(8,%r15),__SF_EMPTY+16(%r15) # host id == 0
952 lmg %r0,%r13,0(%r3) # load guest gprs 0-13
953 # some program checks are suppressing. C code (e.g. do_protection_exception)
954 # will rewind the PSW by the ILC, which is 4 bytes in case of SIE. Other
955 # instructions in the sie_loop should not cause program interrupts. So
956 # lets use a nop (47 00 00 00) as a landing pad.
957 # See also HANDLE_SIE_INTERCEPT
961 lg %r14,__LC_THREAD_INFO # pointer thread_info struct
962 tm __TI_flags+7(%r14),_TIF_EXIT_SIE
964 lg %r14,__LC_GMAP # get gmap pointer
967 lctlg %c1,%c1,__GMAP_ASCE(%r14) # load primary asce
969 lg %r14,__SF_EMPTY(%r15) # get control block pointer
970 SPP __SF_EMPTY(%r15) # set guest id
973 SPP __SF_EMPTY+16(%r15) # set host id
974 lg %r14,__LC_THREAD_INFO # pointer thread_info struct
976 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
977 lg %r14,__SF_EMPTY+8(%r15) # load guest register save area
978 stmg %r0,%r13,0(%r14) # save guest gprs 0-13
979 lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers
983 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
984 lg %r14,__LC_THREAD_INFO # pointer thread_info struct
985 lg %r14,__SF_EMPTY+8(%r15) # load guest register save area
986 stmg %r0,%r13,0(%r14) # save guest gprs 0-13
987 lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers
995 .quad sie_done - sie_loop
999 EX_TABLE(rewind_pad,sie_fault)
1000 EX_TABLE(sie_loop,sie_fault)
1003 .section .rodata, "a"
1004 #define SYSCALL(esa,esame,emu) .long esame
1005 .globl sys_call_table
1007 #include "syscalls.S"
1010 #ifdef CONFIG_COMPAT
1012 #define SYSCALL(esa,esame,emu) .long emu
1014 #include "syscalls.S"