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
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 lg %r9,BASED(.Lsie_loop)
92 SPP BASED(.Lhost_id) # set host id
96 .macro CHECK_STACK stacksize,savearea
97 #ifdef CONFIG_CHECK_STACK
98 tml %r15,\stacksize - CONFIG_STACK_GUARD
104 .macro SWITCH_ASYNC savearea,stack,shift
105 tmhh %r8,0x0001 # interrupting from user ?
108 slg %r14,BASED(.Lcritical_start)
109 clg %r14,BASED(.Lcritical_length)
111 lghi %r11,\savearea # inside critical section, do cleanup
112 brasl %r14,cleanup_critical
113 tmhh %r8,0x0001 # retest problem state after cleanup
115 0: lg %r14,\stack # are we already on the target stack?
117 srag %r14,%r14,\shift
119 CHECK_STACK 1<<\shift,\savearea
121 1: lg %r15,\stack # load target stack
122 2: aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
123 la %r11,STACK_FRAME_OVERHEAD(%r15)
126 .macro UPDATE_VTIME scratch,enter_timer
127 lg \scratch,__LC_EXIT_TIMER
128 slg \scratch,\enter_timer
129 alg \scratch,__LC_USER_TIMER
130 stg \scratch,__LC_USER_TIMER
131 lg \scratch,__LC_LAST_UPDATE_TIMER
132 slg \scratch,__LC_EXIT_TIMER
133 alg \scratch,__LC_SYSTEM_TIMER
134 stg \scratch,__LC_SYSTEM_TIMER
135 mvc __LC_LAST_UPDATE_TIMER(8),\enter_timer
138 .macro LAST_BREAK scratch
139 srag \scratch,%r10,23
141 stg %r10,__TI_last_break(%r12)
145 stg %r8,__LC_RETURN_PSW
146 ni __LC_RETURN_PSW,0xbf
151 #ifdef CONFIG_HAVE_MARCH_Z9_109_FEATURES
152 .insn s,0xb27c0000,\savearea # store clock fast
154 .insn s,0xb2050000,\savearea # store clock
158 .section .kprobes.text, "ax"
161 * Scheduler resume function, called by switch_to
162 * gpr2 = (task_struct *) prev
163 * gpr3 = (task_struct *) next
168 stmg %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task
169 stg %r15,__THREAD_ksp(%r2) # store kernel stack of prev
170 lg %r4,__THREAD_info(%r2) # get thread_info of prev
171 lg %r5,__THREAD_info(%r3) # get thread_info of next
173 aghi %r15,STACK_SIZE # end of kernel stack of next
174 stg %r3,__LC_CURRENT # store task struct of next
175 stg %r5,__LC_THREAD_INFO # store thread info of next
176 stg %r15,__LC_KERNEL_STACK # store end of kernel stack
177 lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4
178 mvc __LC_CURRENT_PID+4(4,%r0),__TASK_pid(%r3) # store pid of next
179 lg %r15,__THREAD_ksp(%r3) # load kernel stack of next
180 tm __TI_flags+7(%r4),_TIF_MCCK_PENDING # machine check pending?
182 ni __TI_flags+7(%r4),255-_TIF_MCCK_PENDING # clear flag in prev
183 oi __TI_flags+7(%r5),_TIF_MCCK_PENDING # set it in next
184 0: lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task
189 * SVC interrupt handler routine. System calls are synchronous events and
190 * are executed with interrupts enabled.
194 stpt __LC_SYNC_ENTER_TIMER
196 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
197 lg %r10,__LC_LAST_BREAK
198 lg %r12,__LC_THREAD_INFO
199 larl %r13,system_call
201 lg %r15,__LC_KERNEL_STACK
202 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
203 la %r11,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs
205 UPDATE_VTIME %r13,__LC_SYNC_ENTER_TIMER
207 stmg %r0,%r7,__PT_R0(%r11)
208 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
209 mvc __PT_PSW(16,%r11),__LC_SVC_OLD_PSW
210 mvc __PT_INT_CODE(4,%r11),__LC_SVC_ILC
212 oi __TI_flags+7(%r12),_TIF_SYSCALL
213 llgh %r8,__PT_INT_CODE+2(%r11)
214 slag %r8,%r8,2 # shift and test for svc 0
216 # svc 0: system call number in %r1
217 llgfr %r1,%r1 # clear high word in r1
220 sth %r1,__PT_INT_CODE+2(%r11)
223 larl %r10,sys_call_table # 64 bit system call table
225 tm __TI_flags+5(%r12),(_TIF_31BIT>>16)
227 larl %r10,sys_call_table_emu # 31 bit system call table
230 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
231 stg %r2,__PT_ORIG_GPR2(%r11)
232 stg %r7,STACK_FRAME_OVERHEAD(%r15)
233 lgf %r9,0(%r8,%r10) # get system call add.
234 tm __TI_flags+6(%r12),_TIF_TRACE >> 8
236 basr %r14,%r9 # call sys_xxxx
237 stg %r2,__PT_R2(%r11) # store return value
242 tm __PT_PSW+1(%r11),0x01 # returning to user ?
244 tm __TI_flags+7(%r12),_TIF_WORK_SVC
245 jnz sysc_work # check for work
246 ni __TI_flags+7(%r12),255-_TIF_SYSCALL
248 lg %r14,__LC_VDSO_PER_CPU
249 lmg %r0,%r10,__PT_R0(%r11)
250 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
252 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
253 lmg %r11,%r15,__PT_R11(%r11)
254 lpswe __LC_RETURN_PSW
258 # One of the work bits is on. Find out which one.
261 tm __TI_flags+7(%r12),_TIF_MCCK_PENDING
263 tm __TI_flags+7(%r12),_TIF_NEED_RESCHED
265 tm __TI_flags+7(%r12),_TIF_SIGPENDING
267 tm __TI_flags+7(%r12),_TIF_NOTIFY_RESUME
268 jo sysc_notify_resume
269 tm __TI_flags+7(%r12),_TIF_PER_TRAP
271 j sysc_return # beware of critical section cleanup
274 # _TIF_NEED_RESCHED is set, call schedule
277 larl %r14,sysc_return
281 # _TIF_MCCK_PENDING is set, call handler
284 larl %r14,sysc_return
285 jg s390_handle_mcck # TIF bit will be cleared by handler
288 # _TIF_SIGPENDING is set, call do_signal
291 ni __TI_flags+7(%r12),255-_TIF_PER_TRAP # clear TIF_PER_TRAP
292 lgr %r2,%r11 # pass pointer to pt_regs
294 tm __TI_flags+7(%r12),_TIF_SYSCALL
296 lmg %r2,%r7,__PT_R2(%r11) # load svc arguments
297 lghi %r8,0 # svc 0 returns -ENOSYS
298 llgh %r1,__PT_INT_CODE+2(%r11) # load new svc number
300 jnl sysc_nr_ok # invalid svc number -> do svc 0
302 j sysc_nr_ok # restart svc
305 # _TIF_NOTIFY_RESUME is set, call do_notify_resume
308 lgr %r2,%r11 # pass pointer to pt_regs
309 larl %r14,sysc_return
313 # _TIF_PER_TRAP is set, call do_per_trap
316 ni __TI_flags+7(%r12),255-(_TIF_SYSCALL | _TIF_PER_TRAP)
317 lgr %r2,%r11 # pass pointer to pt_regs
318 larl %r14,sysc_return
322 # call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
323 # and after the system call
326 lgr %r2,%r11 # pass pointer to pt_regs
328 llgh %r0,__PT_INT_CODE+2(%r11)
329 stg %r0,__PT_R2(%r11)
330 brasl %r14,do_syscall_trace_enter
337 lmg %r3,%r7,__PT_R3(%r11)
338 stg %r7,STACK_FRAME_OVERHEAD(%r15)
339 lg %r2,__PT_ORIG_GPR2(%r11)
340 basr %r14,%r9 # call sys_xxx
341 stg %r2,__PT_R2(%r11) # store return value
343 tm __TI_flags+6(%r12),_TIF_TRACE >> 8
345 lgr %r2,%r11 # pass pointer to pt_regs
346 larl %r14,sysc_return
347 jg do_syscall_trace_exit
350 # a new process exits the kernel with ret_from_fork
353 la %r11,STACK_FRAME_OVERHEAD(%r15)
354 lg %r12,__LC_THREAD_INFO
355 tm __PT_PSW+1(%r11),0x01 # forking a kernel thread ?
357 brasl %r14,schedule_tail
359 ssm __LC_SVC_NEW_PSW # reenable interrupts
361 1: # it's a kernel thread
362 stg %r15,__PT_R15(%r11) # store stack pointer for new kthread
363 brasl %r14,schedule_tail
365 ssm __LC_SVC_NEW_PSW # reenable interrupts
366 lmg %r9,%r11,__PT_R9(%r11) # load gprs
367 ENTRY(kernel_thread_starter)
373 ENTRY(ret_from_kernel_execve)
374 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
377 aghi %r15,-STACK_FRAME_OVERHEAD
378 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
379 lg %r12,__LC_THREAD_INFO
380 ssm __LC_SVC_NEW_PSW # reenable interrupts
384 * Program check handler routine
387 ENTRY(pgm_check_handler)
388 stpt __LC_SYNC_ENTER_TIMER
389 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
390 lg %r10,__LC_LAST_BREAK
391 lg %r12,__LC_THREAD_INFO
392 larl %r13,system_call
393 lmg %r8,%r9,__LC_PGM_OLD_PSW
394 HANDLE_SIE_INTERCEPT %r14
395 tmhh %r8,0x0001 # test problem state bit
396 jnz 1f # -> fault in user space
397 tmhh %r8,0x4000 # PER bit set in old PSW ?
398 jnz 0f # -> enabled, can't be a double fault
399 tm __LC_PGM_ILC+3,0x80 # check for per exception
400 jnz pgm_svcper # -> single stepped svc
401 0: CHECK_STACK STACK_SIZE,__LC_SAVE_AREA_SYNC
403 1: UPDATE_VTIME %r14,__LC_SYNC_ENTER_TIMER
405 lg %r15,__LC_KERNEL_STACK
406 lg %r14,__TI_task(%r12)
407 lghi %r13,__LC_PGM_TDB
408 tm __LC_PGM_ILC+2,0x02 # check for transaction abort
410 mvc __THREAD_trap_tdb(256,%r14),0(%r13)
411 2: aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
412 la %r11,STACK_FRAME_OVERHEAD(%r15)
413 stmg %r0,%r7,__PT_R0(%r11)
414 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
415 stmg %r8,%r9,__PT_PSW(%r11)
416 mvc __PT_INT_CODE(4,%r11),__LC_PGM_ILC
417 mvc __PT_INT_PARM_LONG(8,%r11),__LC_TRANS_EXC_CODE
418 stg %r10,__PT_ARGS(%r11)
419 tm __LC_PGM_ILC+3,0x80 # check for per exception
421 tmhh %r8,0x0001 # kernel per event ?
423 oi __TI_flags+7(%r12),_TIF_PER_TRAP
424 mvc __THREAD_per_address(8,%r14),__LC_PER_ADDRESS
425 mvc __THREAD_per_cause(2,%r14),__LC_PER_CAUSE
426 mvc __THREAD_per_paid(1,%r14),__LC_PER_PAID
428 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
429 larl %r1,pgm_check_table
430 llgh %r10,__PT_INT_CODE+2(%r11)
434 lg %r1,0(%r10,%r1) # load address of handler routine
435 lgr %r2,%r11 # pass pointer to pt_regs
436 basr %r14,%r1 # branch to interrupt-handler
440 # PER event in supervisor state, must be kprobes
444 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
445 lgr %r2,%r11 # pass pointer to pt_regs
446 brasl %r14,do_per_trap
450 # single stepped system call
453 oi __TI_flags+7(%r12),_TIF_PER_TRAP
454 mvc __LC_RETURN_PSW(8),__LC_SVC_NEW_PSW
456 stg %r14,__LC_RETURN_PSW+8
457 lpswe __LC_RETURN_PSW # branch to sysc_per and enable irqs
460 * IO interrupt handler routine
462 ENTRY(io_int_handler)
464 stpt __LC_ASYNC_ENTER_TIMER
465 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
466 lg %r10,__LC_LAST_BREAK
467 lg %r12,__LC_THREAD_INFO
468 larl %r13,system_call
469 lmg %r8,%r9,__LC_IO_OLD_PSW
470 HANDLE_SIE_INTERCEPT %r14
471 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_STACK,STACK_SHIFT
472 tmhh %r8,0x0001 # interrupting from user?
474 UPDATE_VTIME %r14,__LC_ASYNC_ENTER_TIMER
477 stmg %r0,%r7,__PT_R0(%r11)
478 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
479 stmg %r8,%r9,__PT_PSW(%r11)
481 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
482 lgr %r2,%r11 # pass pointer to pt_regs
488 tm __TI_flags+7(%r12),_TIF_WORK_INT
489 jnz io_work # there is work to do (signals etc.)
491 lg %r14,__LC_VDSO_PER_CPU
492 lmg %r0,%r10,__PT_R0(%r11)
493 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
495 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
496 lmg %r11,%r15,__PT_R11(%r11)
497 lpswe __LC_RETURN_PSW
501 # There is work todo, find out in which context we have been interrupted:
502 # 1) if we return to user space we can do all _TIF_WORK_INT work
503 # 2) if we return to kernel code and kvm is enabled check if we need to
504 # modify the psw to leave SIE
505 # 3) if we return to kernel code and preemptive scheduling is enabled check
506 # the preemption counter and if it is zero call preempt_schedule_irq
507 # Before any work can be done, a switch to the kernel stack is required.
510 tm __PT_PSW+1(%r11),0x01 # returning to user ?
511 jo io_work_user # yes -> do resched & signal
512 #ifdef CONFIG_PREEMPT
513 # check for preemptive scheduling
514 icm %r0,15,__TI_precount(%r12)
515 jnz io_restore # preemption is disabled
516 tm __TI_flags+7(%r12),_TIF_NEED_RESCHED
518 # switch to kernel stack
519 lg %r1,__PT_R15(%r11)
520 aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
521 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
522 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
523 la %r11,STACK_FRAME_OVERHEAD(%r1)
525 # TRACE_IRQS_ON already done at io_return, call
526 # TRACE_IRQS_OFF to keep things symmetrical
528 brasl %r14,preempt_schedule_irq
535 # Need to do work before returning to userspace, switch to kernel stack
538 lg %r1,__LC_KERNEL_STACK
539 aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
540 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
541 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
542 la %r11,STACK_FRAME_OVERHEAD(%r1)
546 # One of the work bits is on. Find out which one.
547 # Checked are: _TIF_SIGPENDING, _TIF_NOTIFY_RESUME, _TIF_NEED_RESCHED
548 # and _TIF_MCCK_PENDING
551 tm __TI_flags+7(%r12),_TIF_MCCK_PENDING
553 tm __TI_flags+7(%r12),_TIF_NEED_RESCHED
555 tm __TI_flags+7(%r12),_TIF_SIGPENDING
557 tm __TI_flags+7(%r12),_TIF_NOTIFY_RESUME
559 j io_return # beware of critical section cleanup
562 # _TIF_MCCK_PENDING is set, call handler
565 # TRACE_IRQS_ON already done at io_return
566 brasl %r14,s390_handle_mcck # TIF bit will be cleared by handler
571 # _TIF_NEED_RESCHED is set, call schedule
574 # TRACE_IRQS_ON already done at io_return
575 ssm __LC_SVC_NEW_PSW # reenable interrupts
576 brasl %r14,schedule # call scheduler
577 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
582 # _TIF_SIGPENDING or is set, call do_signal
585 # TRACE_IRQS_ON already done at io_return
586 ssm __LC_SVC_NEW_PSW # reenable interrupts
587 lgr %r2,%r11 # pass pointer to pt_regs
589 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
594 # _TIF_NOTIFY_RESUME or is set, call do_notify_resume
597 # TRACE_IRQS_ON already done at io_return
598 ssm __LC_SVC_NEW_PSW # reenable interrupts
599 lgr %r2,%r11 # pass pointer to pt_regs
600 brasl %r14,do_notify_resume
601 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
606 * External interrupt handler routine
608 ENTRY(ext_int_handler)
610 stpt __LC_ASYNC_ENTER_TIMER
611 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
612 lg %r10,__LC_LAST_BREAK
613 lg %r12,__LC_THREAD_INFO
614 larl %r13,system_call
615 lmg %r8,%r9,__LC_EXT_OLD_PSW
616 HANDLE_SIE_INTERCEPT %r14
617 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_STACK,STACK_SHIFT
618 tmhh %r8,0x0001 # interrupting from user ?
620 UPDATE_VTIME %r14,__LC_ASYNC_ENTER_TIMER
623 stmg %r0,%r7,__PT_R0(%r11)
624 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
625 stmg %r8,%r9,__PT_PSW(%r11)
627 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
629 lgr %r2,%r11 # pass pointer to pt_regs
630 llgf %r3,__LC_EXT_CPU_ADDR # get cpu address + interruption code
631 llgf %r4,__LC_EXT_PARAMS # get external parameter
632 lg %r5,__LC_EXT_PARAMS2-4096(%r1) # get 64 bit external parameter
637 * Load idle PSW. The second "half" of this function is in cleanup_idle.
640 stg %r3,__SF_EMPTY(%r15)
641 larl %r1,psw_idle_lpsw+4
642 stg %r1,__SF_EMPTY+8(%r15)
643 STCK __CLOCK_IDLE_ENTER(%r2)
644 stpt __TIMER_IDLE_ENTER(%r2)
646 lpswe __SF_EMPTY(%r15)
653 * Machine check handler routines
655 ENTRY(mcck_int_handler)
657 la %r1,4095 # revalidate r1
658 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # revalidate cpu timer
659 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# revalidate gprs
660 lg %r10,__LC_LAST_BREAK
661 lg %r12,__LC_THREAD_INFO
662 larl %r13,system_call
663 lmg %r8,%r9,__LC_MCK_OLD_PSW
664 HANDLE_SIE_INTERCEPT %r14
665 tm __LC_MCCK_CODE,0x80 # system damage?
666 jo mcck_panic # yes -> rest of mcck code invalid
667 lghi %r14,__LC_CPU_TIMER_SAVE_AREA
668 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
669 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
671 la %r14,__LC_SYNC_ENTER_TIMER
672 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
674 la %r14,__LC_ASYNC_ENTER_TIMER
675 0: clc 0(8,%r14),__LC_EXIT_TIMER
677 la %r14,__LC_EXIT_TIMER
678 1: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
680 la %r14,__LC_LAST_UPDATE_TIMER
682 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
683 3: tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid?
684 jno mcck_panic # no -> skip cleanup critical
685 SWITCH_ASYNC __LC_GPREGS_SAVE_AREA+64,__LC_PANIC_STACK,PAGE_SHIFT
686 tm %r8,0x0001 # interrupting from user ?
688 UPDATE_VTIME %r14,__LC_MCCK_ENTER_TIMER
691 lghi %r14,__LC_GPREGS_SAVE_AREA
692 mvc __PT_R0(128,%r11),0(%r14)
693 stmg %r8,%r9,__PT_PSW(%r11)
694 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
695 lgr %r2,%r11 # pass pointer to pt_regs
696 brasl %r14,s390_do_machine_check
697 tm __PT_PSW+1(%r11),0x01 # returning to user ?
699 lg %r1,__LC_KERNEL_STACK # switch to kernel stack
700 aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
701 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
702 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
703 la %r11,STACK_FRAME_OVERHEAD(%r1)
705 ssm __LC_PGM_NEW_PSW # turn dat on, keep irqs off
706 tm __TI_flags+7(%r12),_TIF_MCCK_PENDING
709 brasl %r14,s390_handle_mcck
712 lg %r14,__LC_VDSO_PER_CPU
713 lmg %r0,%r10,__PT_R0(%r11)
714 mvc __LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW
715 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
718 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
719 0: lmg %r11,%r15,__PT_R11(%r11)
720 lpswe __LC_RETURN_MCCK_PSW
723 lg %r14,__LC_PANIC_STACK
725 srag %r14,%r14,PAGE_SHIFT
727 lg %r15,__LC_PANIC_STACK
728 0: aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
732 # PSW restart interrupt handler
734 ENTRY(restart_int_handler)
735 stg %r15,__LC_SAVE_AREA_RESTART
736 lg %r15,__LC_RESTART_STACK
737 aghi %r15,-__PT_SIZE # create pt_regs on stack
738 xc 0(__PT_SIZE,%r15),0(%r15)
739 stmg %r0,%r14,__PT_R0(%r15)
740 mvc __PT_R15(8,%r15),__LC_SAVE_AREA_RESTART
741 mvc __PT_PSW(16,%r15),__LC_RST_OLD_PSW # store restart old psw
742 aghi %r15,-STACK_FRAME_OVERHEAD # create stack frame on stack
743 xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15)
744 lg %r1,__LC_RESTART_FN # load fn, parm & source cpu
745 lg %r2,__LC_RESTART_DATA
746 lg %r3,__LC_RESTART_SOURCE
747 ltgr %r3,%r3 # test source cpu address
748 jm 1f # negative -> skip source stop
749 0: sigp %r4,%r3,SIGP_SENSE # sigp sense to source cpu
750 brc 10,0b # wait for status stored
751 1: basr %r14,%r1 # call function
752 stap __SF_EMPTY(%r15) # store cpu address
753 llgh %r3,__SF_EMPTY(%r15)
754 2: sigp %r4,%r3,SIGP_STOP # sigp stop to current cpu
758 .section .kprobes.text, "ax"
760 #ifdef CONFIG_CHECK_STACK
762 * The synchronous or the asynchronous stack overflowed. We are dead.
763 * No need to properly save the registers, we are going to panic anyway.
764 * Setup a pt_regs so that show_trace can provide a good call trace.
767 lg %r11,__LC_PANIC_STACK # change to panic stack
768 aghi %r11,-__PT_SIZE # create pt_regs
769 stmg %r0,%r7,__PT_R0(%r11)
770 stmg %r8,%r9,__PT_PSW(%r11)
771 mvc __PT_R8(64,%r11),0(%r14)
772 stg %r10,__PT_ORIG_GPR2(%r11) # store last break to orig_gpr2
774 aghi %r15,-STACK_FRAME_OVERHEAD
775 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
776 lgr %r2,%r11 # pass pointer to pt_regs
777 jg kernel_stack_overflow
794 clg %r9,BASED(cleanup_table) # system_call
796 clg %r9,BASED(cleanup_table+8) # sysc_do_svc
797 jl cleanup_system_call
798 clg %r9,BASED(cleanup_table+16) # sysc_tif
800 clg %r9,BASED(cleanup_table+24) # sysc_restore
802 clg %r9,BASED(cleanup_table+32) # sysc_done
803 jl cleanup_sysc_restore
804 clg %r9,BASED(cleanup_table+40) # io_tif
806 clg %r9,BASED(cleanup_table+48) # io_restore
808 clg %r9,BASED(cleanup_table+56) # io_done
809 jl cleanup_io_restore
810 clg %r9,BASED(cleanup_table+64) # psw_idle
812 clg %r9,BASED(cleanup_table+72) # psw_idle_end
818 # check if stpt has been executed
819 clg %r9,BASED(cleanup_system_call_insn)
821 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
822 cghi %r11,__LC_SAVE_AREA_ASYNC
824 mvc __LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER
825 0: # check if stmg has been executed
826 clg %r9,BASED(cleanup_system_call_insn+8)
828 mvc __LC_SAVE_AREA_SYNC(64),0(%r11)
829 0: # check if base register setup + TIF bit load has been done
830 clg %r9,BASED(cleanup_system_call_insn+16)
832 # set up saved registers r10 and r12
833 stg %r10,16(%r11) # r10 last break
834 stg %r12,32(%r11) # r12 thread-info pointer
835 0: # check if the user time update has been done
836 clg %r9,BASED(cleanup_system_call_insn+24)
838 lg %r15,__LC_EXIT_TIMER
839 slg %r15,__LC_SYNC_ENTER_TIMER
840 alg %r15,__LC_USER_TIMER
841 stg %r15,__LC_USER_TIMER
842 0: # check if the system time update has been done
843 clg %r9,BASED(cleanup_system_call_insn+32)
845 lg %r15,__LC_LAST_UPDATE_TIMER
846 slg %r15,__LC_EXIT_TIMER
847 alg %r15,__LC_SYSTEM_TIMER
848 stg %r15,__LC_SYSTEM_TIMER
849 0: # update accounting time stamp
850 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
855 mvc __TI_last_break(8,%r12),16(%r11)
856 0: # set up saved register r11
857 lg %r15,__LC_KERNEL_STACK
859 stg %r15,24(%r11) # r11 pt_regs pointer
861 mvc __PT_R8(64,%r15),__LC_SAVE_AREA_SYNC
862 stmg %r0,%r7,__PT_R0(%r15)
863 mvc __PT_PSW(16,%r15),__LC_SVC_OLD_PSW
864 mvc __PT_INT_CODE(4,%r15),__LC_SVC_ILC
865 # setup saved register r15
866 aghi %r15,-STACK_FRAME_OVERHEAD
867 stg %r15,56(%r11) # r15 stack pointer
868 # set new psw address and exit
871 cleanup_system_call_insn:
882 cleanup_sysc_restore:
883 clg %r9,BASED(cleanup_sysc_restore_insn)
885 lg %r9,24(%r11) # get saved pointer to pt_regs
886 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
887 mvc 0(64,%r11),__PT_R8(%r9)
888 lmg %r0,%r7,__PT_R0(%r9)
889 0: lmg %r8,%r9,__LC_RETURN_PSW
891 cleanup_sysc_restore_insn:
899 clg %r9,BASED(cleanup_io_restore_insn)
901 lg %r9,24(%r11) # get saved r11 pointer to pt_regs
902 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
903 mvc 0(64,%r11),__PT_R8(%r9)
904 lmg %r0,%r7,__PT_R0(%r9)
905 0: lmg %r8,%r9,__LC_RETURN_PSW
907 cleanup_io_restore_insn:
911 # copy interrupt clock & cpu timer
912 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_INT_CLOCK
913 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_ASYNC_ENTER_TIMER
914 cghi %r11,__LC_SAVE_AREA_ASYNC
916 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_MCCK_CLOCK
917 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_MCCK_ENTER_TIMER
918 0: # check if stck & stpt have been executed
919 clg %r9,BASED(cleanup_idle_insn)
921 mvc __CLOCK_IDLE_ENTER(8,%r2),__CLOCK_IDLE_EXIT(%r2)
922 mvc __TIMER_IDLE_ENTER(8,%r2),__TIMER_IDLE_EXIT(%r2)
923 1: # account system time going idle
924 lg %r9,__LC_STEAL_TIMER
925 alg %r9,__CLOCK_IDLE_ENTER(%r2)
926 slg %r9,__LC_LAST_UPDATE_CLOCK
927 stg %r9,__LC_STEAL_TIMER
928 mvc __LC_LAST_UPDATE_CLOCK(8),__CLOCK_IDLE_EXIT(%r2)
929 lg %r9,__LC_SYSTEM_TIMER
930 alg %r9,__LC_LAST_UPDATE_TIMER
931 slg %r9,__TIMER_IDLE_ENTER(%r2)
932 stg %r9,__LC_SYSTEM_TIMER
933 mvc __LC_LAST_UPDATE_TIMER(8),__TIMER_IDLE_EXIT(%r2)
935 nihh %r8,0xfffd # clear wait state bit
936 lg %r9,48(%r11) # return from psw_idle
946 .quad __critical_start
948 .quad __critical_end - __critical_start
951 #if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
953 * sie64a calling convention:
954 * %r2 pointer to sie control block
955 * %r3 guest register save area
958 stmg %r6,%r14,__SF_GPRS(%r15) # save kernel registers
959 stg %r2,__SF_EMPTY(%r15) # save control block pointer
960 stg %r3,__SF_EMPTY+8(%r15) # save guest register save area
961 xc __SF_EMPTY+16(8,%r15),__SF_EMPTY+16(%r15) # host id == 0
962 lmg %r0,%r13,0(%r3) # load guest gprs 0-13
964 lg %r14,__LC_THREAD_INFO # pointer thread_info struct
965 tm __TI_flags+7(%r14),_TIF_EXIT_SIE
967 lg %r14,__LC_GMAP # get gmap pointer
970 lctlg %c1,%c1,__GMAP_ASCE(%r14) # load primary asce
972 lg %r14,__SF_EMPTY(%r15) # get control block pointer
973 SPP __SF_EMPTY(%r15) # set guest id
976 SPP __SF_EMPTY+16(%r15) # set host id
977 lg %r14,__LC_THREAD_INFO # pointer thread_info struct
979 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
980 lg %r14,__SF_EMPTY+8(%r15) # load guest register save area
981 stmg %r0,%r13,0(%r14) # save guest gprs 0-13
982 lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers
986 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
987 lg %r14,__LC_THREAD_INFO # pointer thread_info struct
988 lg %r14,__SF_EMPTY+8(%r15) # load guest register save area
989 stmg %r0,%r13,0(%r14) # save guest gprs 0-13
990 lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers
998 .quad sie_done - sie_loop
1002 EX_TABLE(sie_loop,sie_fault)
1005 .section .rodata, "a"
1006 #define SYSCALL(esa,esame,emu) .long esame
1007 .globl sys_call_table
1009 #include "syscalls.S"
1012 #ifdef CONFIG_COMPAT
1014 #define SYSCALL(esa,esame,emu) .long emu
1016 #include "syscalls.S"