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
42 STACK_INIT = STACK_SIZE - STACK_FRAME_OVERHEAD - __PT_SIZE
44 _TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
45 _TIF_MCCK_PENDING | _TIF_PER_TRAP )
46 _TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
48 _TIF_TRACE = (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | \
49 _TIF_SYSCALL_TRACEPOINT)
50 _TIF_EXIT_SIE = (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_MCCK_PENDING)
52 #define BASED(name) name-system_call(%r13)
55 #ifdef CONFIG_TRACE_IRQFLAGS
57 brasl %r14,trace_hardirqs_on_caller
62 #ifdef CONFIG_TRACE_IRQFLAGS
64 brasl %r14,trace_hardirqs_off_caller
68 .macro LOCKDEP_SYS_EXIT
70 tm __PT_PSW+1(%r11),0x01 # returning to user ?
72 brasl %r14,lockdep_sys_exit
77 #if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
78 tm __LC_MACHINE_FLAGS+6,0x20 # MACHINE_FLAG_LPP
80 .insn s,0xb2800000,\newpp
84 .macro HANDLE_SIE_INTERCEPT scratch,pgmcheck
85 #if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
86 tmhh %r8,0x0001 # interrupting from user ?
89 slg \scratch,BASED(.Lsie_loop)
90 clg \scratch,BASED(.Lsie_length)
92 # Some program interrupts are suppressing (e.g. protection).
93 # We must also check the instruction after SIE in that case.
94 # do_protection_exception will rewind to rewind_pad
99 lg %r9,BASED(.Lsie_loop)
100 LPP BASED(.Lhost_id) # set host id
104 .macro CHECK_STACK stacksize,savearea
105 #ifdef CONFIG_CHECK_STACK
106 tml %r15,\stacksize - CONFIG_STACK_GUARD
112 .macro SWITCH_ASYNC savearea,stack,shift
113 tmhh %r8,0x0001 # interrupting from user ?
116 slg %r14,BASED(.Lcritical_start)
117 clg %r14,BASED(.Lcritical_length)
119 lghi %r11,\savearea # inside critical section, do cleanup
120 brasl %r14,cleanup_critical
121 tmhh %r8,0x0001 # retest problem state after cleanup
123 0: lg %r14,\stack # are we already on the target stack?
125 srag %r14,%r14,\shift
127 CHECK_STACK 1<<\shift,\savearea
128 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
130 1: lg %r15,\stack # load target stack
131 2: la %r11,STACK_FRAME_OVERHEAD(%r15)
134 .macro UPDATE_VTIME scratch,enter_timer
135 lg \scratch,__LC_EXIT_TIMER
136 slg \scratch,\enter_timer
137 alg \scratch,__LC_USER_TIMER
138 stg \scratch,__LC_USER_TIMER
139 lg \scratch,__LC_LAST_UPDATE_TIMER
140 slg \scratch,__LC_EXIT_TIMER
141 alg \scratch,__LC_SYSTEM_TIMER
142 stg \scratch,__LC_SYSTEM_TIMER
143 mvc __LC_LAST_UPDATE_TIMER(8),\enter_timer
146 .macro LAST_BREAK scratch
147 srag \scratch,%r10,23
149 stg %r10,__TI_last_break(%r12)
153 stg %r8,__LC_RETURN_PSW
154 ni __LC_RETURN_PSW,0xbf
159 #ifdef CONFIG_HAVE_MARCH_Z9_109_FEATURES
160 .insn s,0xb27c0000,\savearea # store clock fast
162 .insn s,0xb2050000,\savearea # store clock
166 .section .kprobes.text, "ax"
169 * Scheduler resume function, called by switch_to
170 * gpr2 = (task_struct *) prev
171 * gpr3 = (task_struct *) next
176 stmg %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task
177 stg %r15,__THREAD_ksp(%r2) # store kernel stack of prev
178 lg %r4,__THREAD_info(%r2) # get thread_info of prev
179 lg %r5,__THREAD_info(%r3) # get thread_info of next
181 aghi %r15,STACK_INIT # end of kernel stack of next
182 stg %r3,__LC_CURRENT # store task struct of next
183 stg %r5,__LC_THREAD_INFO # store thread info of next
184 stg %r15,__LC_KERNEL_STACK # store end of kernel stack
185 lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4
186 mvc __LC_CURRENT_PID+4(4,%r0),__TASK_pid(%r3) # store pid of next
187 lg %r15,__THREAD_ksp(%r3) # load kernel stack of next
188 tm __TI_flags+7(%r4),_TIF_MCCK_PENDING # machine check pending?
190 ni __TI_flags+7(%r4),255-_TIF_MCCK_PENDING # clear flag in prev
191 oi __TI_flags+7(%r5),_TIF_MCCK_PENDING # set it in next
192 0: lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task
197 * SVC interrupt handler routine. System calls are synchronous events and
198 * are executed with interrupts enabled.
202 stpt __LC_SYNC_ENTER_TIMER
204 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
205 lg %r10,__LC_LAST_BREAK
206 lg %r12,__LC_THREAD_INFO
208 lg %r15,__LC_KERNEL_STACK
209 la %r11,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs
211 UPDATE_VTIME %r13,__LC_SYNC_ENTER_TIMER
213 stmg %r0,%r7,__PT_R0(%r11)
214 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
215 mvc __PT_PSW(16,%r11),__LC_SVC_OLD_PSW
216 mvc __PT_INT_CODE(4,%r11),__LC_SVC_ILC
218 oi __TI_flags+7(%r12),_TIF_SYSCALL
219 lg %r10,__TI_sysc_table(%r12) # address of system call table
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 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_PER_TRAP
267 tm __TI_flags+7(%r12),_TIF_SIGPENDING
269 tm __TI_flags+7(%r12),_TIF_NOTIFY_RESUME
270 jo sysc_notify_resume
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 lgr %r2,%r11 # pass pointer to pt_regs
293 tm __TI_flags+7(%r12),_TIF_SYSCALL
295 lmg %r2,%r7,__PT_R2(%r11) # load svc arguments
296 lghi %r8,0 # svc 0 returns -ENOSYS
297 llgh %r1,__PT_INT_CODE+2(%r11) # load new svc number
299 jnl sysc_nr_ok # invalid svc number -> do svc 0
301 j sysc_nr_ok # restart svc
304 # _TIF_NOTIFY_RESUME is set, call do_notify_resume
307 lgr %r2,%r11 # pass pointer to pt_regs
308 larl %r14,sysc_return
312 # _TIF_PER_TRAP is set, call do_per_trap
315 ni __TI_flags+7(%r12),255-_TIF_PER_TRAP
316 lgr %r2,%r11 # pass pointer to pt_regs
317 larl %r14,sysc_return
321 # call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
322 # and after the system call
325 lgr %r2,%r11 # pass pointer to pt_regs
327 llgh %r0,__PT_INT_CODE+2(%r11)
328 stg %r0,__PT_R2(%r11)
329 brasl %r14,do_syscall_trace_enter
336 lmg %r3,%r7,__PT_R3(%r11)
337 stg %r7,STACK_FRAME_OVERHEAD(%r15)
338 lg %r2,__PT_ORIG_GPR2(%r11)
339 basr %r14,%r9 # call sys_xxx
340 stg %r2,__PT_R2(%r11) # store return value
342 tm __TI_flags+6(%r12),_TIF_TRACE >> 8
344 lgr %r2,%r11 # pass pointer to pt_regs
345 larl %r14,sysc_return
346 jg do_syscall_trace_exit
349 # a new process exits the kernel with ret_from_fork
352 la %r11,STACK_FRAME_OVERHEAD(%r15)
353 lg %r12,__LC_THREAD_INFO
354 brasl %r14,schedule_tail
356 ssm __LC_SVC_NEW_PSW # reenable interrupts
357 tm __PT_PSW+1(%r11),0x01 # forking a kernel thread ?
359 # it's a kernel thread
360 lmg %r9,%r10,__PT_R9(%r11) # load gprs
361 ENTRY(kernel_thread_starter)
367 * Program check handler routine
370 ENTRY(pgm_check_handler)
371 stpt __LC_SYNC_ENTER_TIMER
372 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
373 lg %r10,__LC_LAST_BREAK
374 lg %r12,__LC_THREAD_INFO
375 larl %r13,system_call
376 lmg %r8,%r9,__LC_PGM_OLD_PSW
377 HANDLE_SIE_INTERCEPT %r14,1
378 tmhh %r8,0x0001 # test problem state bit
379 jnz 1f # -> fault in user space
380 tmhh %r8,0x4000 # PER bit set in old PSW ?
381 jnz 0f # -> enabled, can't be a double fault
382 tm __LC_PGM_ILC+3,0x80 # check for per exception
383 jnz pgm_svcper # -> single stepped svc
384 0: CHECK_STACK STACK_SIZE,__LC_SAVE_AREA_SYNC
385 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
387 1: UPDATE_VTIME %r14,__LC_SYNC_ENTER_TIMER
389 lg %r15,__LC_KERNEL_STACK
390 lg %r14,__TI_task(%r12)
391 lghi %r13,__LC_PGM_TDB
392 tm __LC_PGM_ILC+2,0x02 # check for transaction abort
394 mvc __THREAD_trap_tdb(256,%r14),0(%r13)
395 2: la %r11,STACK_FRAME_OVERHEAD(%r15)
396 stmg %r0,%r7,__PT_R0(%r11)
397 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
398 stmg %r8,%r9,__PT_PSW(%r11)
399 mvc __PT_INT_CODE(4,%r11),__LC_PGM_ILC
400 mvc __PT_INT_PARM_LONG(8,%r11),__LC_TRANS_EXC_CODE
401 stg %r10,__PT_ARGS(%r11)
402 tm __LC_PGM_ILC+3,0x80 # check for per exception
404 tmhh %r8,0x0001 # kernel per event ?
406 oi __TI_flags+7(%r12),_TIF_PER_TRAP
407 mvc __THREAD_per_address(8,%r14),__LC_PER_ADDRESS
408 mvc __THREAD_per_cause(2,%r14),__LC_PER_CAUSE
409 mvc __THREAD_per_paid(1,%r14),__LC_PER_PAID
411 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
412 larl %r1,pgm_check_table
413 llgh %r10,__PT_INT_CODE+2(%r11)
417 lgf %r1,0(%r10,%r1) # load address of handler routine
418 lgr %r2,%r11 # pass pointer to pt_regs
419 basr %r14,%r1 # branch to interrupt-handler
423 # PER event in supervisor state, must be kprobes
427 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
428 lgr %r2,%r11 # pass pointer to pt_regs
429 brasl %r14,do_per_trap
433 # single stepped system call
436 oi __TI_flags+7(%r12),_TIF_PER_TRAP
437 mvc __LC_RETURN_PSW(8),__LC_SVC_NEW_PSW
439 stg %r14,__LC_RETURN_PSW+8
440 lpswe __LC_RETURN_PSW # branch to sysc_per and enable irqs
443 * IO interrupt handler routine
445 ENTRY(io_int_handler)
447 stpt __LC_ASYNC_ENTER_TIMER
448 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
449 lg %r10,__LC_LAST_BREAK
450 lg %r12,__LC_THREAD_INFO
451 larl %r13,system_call
452 lmg %r8,%r9,__LC_IO_OLD_PSW
453 HANDLE_SIE_INTERCEPT %r14,0
454 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_STACK,STACK_SHIFT
455 tmhh %r8,0x0001 # interrupting from user?
457 UPDATE_VTIME %r14,__LC_ASYNC_ENTER_TIMER
460 stmg %r0,%r7,__PT_R0(%r11)
461 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
462 stmg %r8,%r9,__PT_PSW(%r11)
464 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
465 lgr %r2,%r11 # pass pointer to pt_regs
471 tm __TI_flags+7(%r12),_TIF_WORK_INT
472 jnz io_work # there is work to do (signals etc.)
474 lg %r14,__LC_VDSO_PER_CPU
475 lmg %r0,%r10,__PT_R0(%r11)
476 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
478 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
479 lmg %r11,%r15,__PT_R11(%r11)
480 lpswe __LC_RETURN_PSW
484 # There is work todo, find out in which context we have been interrupted:
485 # 1) if we return to user space we can do all _TIF_WORK_INT work
486 # 2) if we return to kernel code and kvm is enabled check if we need to
487 # modify the psw to leave SIE
488 # 3) if we return to kernel code and preemptive scheduling is enabled check
489 # the preemption counter and if it is zero call preempt_schedule_irq
490 # Before any work can be done, a switch to the kernel stack is required.
493 tm __PT_PSW+1(%r11),0x01 # returning to user ?
494 jo io_work_user # yes -> do resched & signal
495 #ifdef CONFIG_PREEMPT
496 # check for preemptive scheduling
497 icm %r0,15,__TI_precount(%r12)
498 jnz io_restore # preemption is disabled
499 tm __TI_flags+7(%r12),_TIF_NEED_RESCHED
501 # switch to kernel stack
502 lg %r1,__PT_R15(%r11)
503 aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
504 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
505 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
506 la %r11,STACK_FRAME_OVERHEAD(%r1)
508 # TRACE_IRQS_ON already done at io_return, call
509 # TRACE_IRQS_OFF to keep things symmetrical
511 brasl %r14,preempt_schedule_irq
518 # Need to do work before returning to userspace, switch to kernel stack
521 lg %r1,__LC_KERNEL_STACK
522 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
523 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
524 la %r11,STACK_FRAME_OVERHEAD(%r1)
528 # One of the work bits is on. Find out which one.
529 # Checked are: _TIF_SIGPENDING, _TIF_NOTIFY_RESUME, _TIF_NEED_RESCHED
530 # and _TIF_MCCK_PENDING
533 tm __TI_flags+7(%r12),_TIF_MCCK_PENDING
535 tm __TI_flags+7(%r12),_TIF_NEED_RESCHED
537 tm __TI_flags+7(%r12),_TIF_SIGPENDING
539 tm __TI_flags+7(%r12),_TIF_NOTIFY_RESUME
541 j io_return # beware of critical section cleanup
544 # _TIF_MCCK_PENDING is set, call handler
547 # TRACE_IRQS_ON already done at io_return
548 brasl %r14,s390_handle_mcck # TIF bit will be cleared by handler
553 # _TIF_NEED_RESCHED is set, call schedule
556 # TRACE_IRQS_ON already done at io_return
557 ssm __LC_SVC_NEW_PSW # reenable interrupts
558 brasl %r14,schedule # call scheduler
559 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
564 # _TIF_SIGPENDING or is set, call do_signal
567 # TRACE_IRQS_ON already done at io_return
568 ssm __LC_SVC_NEW_PSW # reenable interrupts
569 lgr %r2,%r11 # pass pointer to pt_regs
571 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
576 # _TIF_NOTIFY_RESUME or is set, call do_notify_resume
579 # TRACE_IRQS_ON already done at io_return
580 ssm __LC_SVC_NEW_PSW # reenable interrupts
581 lgr %r2,%r11 # pass pointer to pt_regs
582 brasl %r14,do_notify_resume
583 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
588 * External interrupt handler routine
590 ENTRY(ext_int_handler)
592 stpt __LC_ASYNC_ENTER_TIMER
593 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
594 lg %r10,__LC_LAST_BREAK
595 lg %r12,__LC_THREAD_INFO
596 larl %r13,system_call
597 lmg %r8,%r9,__LC_EXT_OLD_PSW
598 HANDLE_SIE_INTERCEPT %r14,0
599 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_STACK,STACK_SHIFT
600 tmhh %r8,0x0001 # interrupting from user ?
602 UPDATE_VTIME %r14,__LC_ASYNC_ENTER_TIMER
605 stmg %r0,%r7,__PT_R0(%r11)
606 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
607 stmg %r8,%r9,__PT_PSW(%r11)
609 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
611 lgr %r2,%r11 # pass pointer to pt_regs
612 llgf %r3,__LC_EXT_CPU_ADDR # get cpu address + interruption code
613 llgf %r4,__LC_EXT_PARAMS # get external parameter
614 lg %r5,__LC_EXT_PARAMS2-4096(%r1) # get 64 bit external parameter
619 * Load idle PSW. The second "half" of this function is in cleanup_idle.
622 stg %r3,__SF_EMPTY(%r15)
623 larl %r1,psw_idle_lpsw+4
624 stg %r1,__SF_EMPTY+8(%r15)
625 STCK __CLOCK_IDLE_ENTER(%r2)
626 stpt __TIMER_IDLE_ENTER(%r2)
628 lpswe __SF_EMPTY(%r15)
635 * Machine check handler routines
637 ENTRY(mcck_int_handler)
639 la %r1,4095 # revalidate r1
640 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # revalidate cpu timer
641 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# revalidate gprs
642 lg %r10,__LC_LAST_BREAK
643 lg %r12,__LC_THREAD_INFO
644 larl %r13,system_call
645 lmg %r8,%r9,__LC_MCK_OLD_PSW
646 HANDLE_SIE_INTERCEPT %r14,0
647 tm __LC_MCCK_CODE,0x80 # system damage?
648 jo mcck_panic # yes -> rest of mcck code invalid
649 lghi %r14,__LC_CPU_TIMER_SAVE_AREA
650 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
651 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
653 la %r14,__LC_SYNC_ENTER_TIMER
654 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
656 la %r14,__LC_ASYNC_ENTER_TIMER
657 0: clc 0(8,%r14),__LC_EXIT_TIMER
659 la %r14,__LC_EXIT_TIMER
660 1: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
662 la %r14,__LC_LAST_UPDATE_TIMER
664 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
665 3: tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid?
666 jno mcck_panic # no -> skip cleanup critical
667 SWITCH_ASYNC __LC_GPREGS_SAVE_AREA+64,__LC_PANIC_STACK,PAGE_SHIFT
668 tm %r8,0x0001 # interrupting from user ?
670 UPDATE_VTIME %r14,__LC_MCCK_ENTER_TIMER
673 lghi %r14,__LC_GPREGS_SAVE_AREA+64
674 stmg %r0,%r7,__PT_R0(%r11)
675 mvc __PT_R8(64,%r11),0(%r14)
676 stmg %r8,%r9,__PT_PSW(%r11)
677 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
678 lgr %r2,%r11 # pass pointer to pt_regs
679 brasl %r14,s390_do_machine_check
680 tm __PT_PSW+1(%r11),0x01 # returning to user ?
682 lg %r1,__LC_KERNEL_STACK # switch to kernel stack
683 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
684 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
685 la %r11,STACK_FRAME_OVERHEAD(%r1)
687 ssm __LC_PGM_NEW_PSW # turn dat on, keep irqs off
688 tm __TI_flags+7(%r12),_TIF_MCCK_PENDING
691 brasl %r14,s390_handle_mcck
694 lg %r14,__LC_VDSO_PER_CPU
695 lmg %r0,%r10,__PT_R0(%r11)
696 mvc __LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW
697 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
700 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
701 0: lmg %r11,%r15,__PT_R11(%r11)
702 lpswe __LC_RETURN_MCCK_PSW
705 lg %r14,__LC_PANIC_STACK
707 srag %r14,%r14,PAGE_SHIFT
709 lg %r15,__LC_PANIC_STACK
710 0: aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
714 # PSW restart interrupt handler
716 ENTRY(restart_int_handler)
717 stg %r15,__LC_SAVE_AREA_RESTART
718 lg %r15,__LC_RESTART_STACK
719 aghi %r15,-__PT_SIZE # create pt_regs on stack
720 xc 0(__PT_SIZE,%r15),0(%r15)
721 stmg %r0,%r14,__PT_R0(%r15)
722 mvc __PT_R15(8,%r15),__LC_SAVE_AREA_RESTART
723 mvc __PT_PSW(16,%r15),__LC_RST_OLD_PSW # store restart old psw
724 aghi %r15,-STACK_FRAME_OVERHEAD # create stack frame on stack
725 xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15)
726 lg %r1,__LC_RESTART_FN # load fn, parm & source cpu
727 lg %r2,__LC_RESTART_DATA
728 lg %r3,__LC_RESTART_SOURCE
729 ltgr %r3,%r3 # test source cpu address
730 jm 1f # negative -> skip source stop
731 0: sigp %r4,%r3,SIGP_SENSE # sigp sense to source cpu
732 brc 10,0b # wait for status stored
733 1: basr %r14,%r1 # call function
734 stap __SF_EMPTY(%r15) # store cpu address
735 llgh %r3,__SF_EMPTY(%r15)
736 2: sigp %r4,%r3,SIGP_STOP # sigp stop to current cpu
740 .section .kprobes.text, "ax"
742 #ifdef CONFIG_CHECK_STACK
744 * The synchronous or the asynchronous stack overflowed. We are dead.
745 * No need to properly save the registers, we are going to panic anyway.
746 * Setup a pt_regs so that show_trace can provide a good call trace.
749 lg %r15,__LC_PANIC_STACK # change to panic stack
750 la %r11,STACK_FRAME_OVERHEAD(%r15)
751 stmg %r0,%r7,__PT_R0(%r11)
752 stmg %r8,%r9,__PT_PSW(%r11)
753 mvc __PT_R8(64,%r11),0(%r14)
754 stg %r10,__PT_ORIG_GPR2(%r11) # store last break to orig_gpr2
755 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
756 lgr %r2,%r11 # pass pointer to pt_regs
757 jg kernel_stack_overflow
774 clg %r9,BASED(cleanup_table) # system_call
776 clg %r9,BASED(cleanup_table+8) # sysc_do_svc
777 jl cleanup_system_call
778 clg %r9,BASED(cleanup_table+16) # sysc_tif
780 clg %r9,BASED(cleanup_table+24) # sysc_restore
782 clg %r9,BASED(cleanup_table+32) # sysc_done
783 jl cleanup_sysc_restore
784 clg %r9,BASED(cleanup_table+40) # io_tif
786 clg %r9,BASED(cleanup_table+48) # io_restore
788 clg %r9,BASED(cleanup_table+56) # io_done
789 jl cleanup_io_restore
790 clg %r9,BASED(cleanup_table+64) # psw_idle
792 clg %r9,BASED(cleanup_table+72) # psw_idle_end
798 # check if stpt has been executed
799 clg %r9,BASED(cleanup_system_call_insn)
801 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
802 cghi %r11,__LC_SAVE_AREA_ASYNC
804 mvc __LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER
805 0: # check if stmg has been executed
806 clg %r9,BASED(cleanup_system_call_insn+8)
808 mvc __LC_SAVE_AREA_SYNC(64),0(%r11)
809 0: # check if base register setup + TIF bit load has been done
810 clg %r9,BASED(cleanup_system_call_insn+16)
812 # set up saved registers r10 and r12
813 stg %r10,16(%r11) # r10 last break
814 stg %r12,32(%r11) # r12 thread-info pointer
815 0: # check if the user time update has been done
816 clg %r9,BASED(cleanup_system_call_insn+24)
818 lg %r15,__LC_EXIT_TIMER
819 slg %r15,__LC_SYNC_ENTER_TIMER
820 alg %r15,__LC_USER_TIMER
821 stg %r15,__LC_USER_TIMER
822 0: # check if the system time update has been done
823 clg %r9,BASED(cleanup_system_call_insn+32)
825 lg %r15,__LC_LAST_UPDATE_TIMER
826 slg %r15,__LC_EXIT_TIMER
827 alg %r15,__LC_SYSTEM_TIMER
828 stg %r15,__LC_SYSTEM_TIMER
829 0: # update accounting time stamp
830 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
835 mvc __TI_last_break(8,%r12),16(%r11)
836 0: # set up saved register r11
837 lg %r15,__LC_KERNEL_STACK
838 la %r9,STACK_FRAME_OVERHEAD(%r15)
839 stg %r9,24(%r11) # r11 pt_regs pointer
841 mvc __PT_R8(64,%r9),__LC_SAVE_AREA_SYNC
842 stmg %r0,%r7,__PT_R0(%r9)
843 mvc __PT_PSW(16,%r9),__LC_SVC_OLD_PSW
844 mvc __PT_INT_CODE(4,%r9),__LC_SVC_ILC
845 # setup saved register r15
846 stg %r15,56(%r11) # r15 stack pointer
847 # set new psw address and exit
850 cleanup_system_call_insn:
861 cleanup_sysc_restore:
862 clg %r9,BASED(cleanup_sysc_restore_insn)
864 lg %r9,24(%r11) # get saved pointer to pt_regs
865 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
866 mvc 0(64,%r11),__PT_R8(%r9)
867 lmg %r0,%r7,__PT_R0(%r9)
868 0: lmg %r8,%r9,__LC_RETURN_PSW
870 cleanup_sysc_restore_insn:
878 clg %r9,BASED(cleanup_io_restore_insn)
880 lg %r9,24(%r11) # get saved r11 pointer to pt_regs
881 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
882 mvc 0(64,%r11),__PT_R8(%r9)
883 lmg %r0,%r7,__PT_R0(%r9)
884 0: lmg %r8,%r9,__LC_RETURN_PSW
886 cleanup_io_restore_insn:
890 # copy interrupt clock & cpu timer
891 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_INT_CLOCK
892 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_ASYNC_ENTER_TIMER
893 cghi %r11,__LC_SAVE_AREA_ASYNC
895 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_MCCK_CLOCK
896 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_MCCK_ENTER_TIMER
897 0: # check if stck & stpt have been executed
898 clg %r9,BASED(cleanup_idle_insn)
900 mvc __CLOCK_IDLE_ENTER(8,%r2),__CLOCK_IDLE_EXIT(%r2)
901 mvc __TIMER_IDLE_ENTER(8,%r2),__TIMER_IDLE_EXIT(%r2)
902 1: # account system time going idle
903 lg %r9,__LC_STEAL_TIMER
904 alg %r9,__CLOCK_IDLE_ENTER(%r2)
905 slg %r9,__LC_LAST_UPDATE_CLOCK
906 stg %r9,__LC_STEAL_TIMER
907 mvc __LC_LAST_UPDATE_CLOCK(8),__CLOCK_IDLE_EXIT(%r2)
908 lg %r9,__LC_SYSTEM_TIMER
909 alg %r9,__LC_LAST_UPDATE_TIMER
910 slg %r9,__TIMER_IDLE_ENTER(%r2)
911 stg %r9,__LC_SYSTEM_TIMER
912 mvc __LC_LAST_UPDATE_TIMER(8),__TIMER_IDLE_EXIT(%r2)
914 nihh %r8,0xfffd # clear wait state bit
915 lg %r9,48(%r11) # return from psw_idle
925 .quad __critical_start
927 .quad __critical_end - __critical_start
930 #if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
932 * sie64a calling convention:
933 * %r2 pointer to sie control block
934 * %r3 guest register save area
937 stmg %r6,%r14,__SF_GPRS(%r15) # save kernel registers
938 stg %r2,__SF_EMPTY(%r15) # save control block pointer
939 stg %r3,__SF_EMPTY+8(%r15) # save guest register save area
940 xc __SF_EMPTY+16(8,%r15),__SF_EMPTY+16(%r15) # host id == 0
941 lmg %r0,%r13,0(%r3) # load guest gprs 0-13
942 # some program checks are suppressing. C code (e.g. do_protection_exception)
943 # will rewind the PSW by the ILC, which is 4 bytes in case of SIE. Other
944 # instructions in the sie_loop should not cause program interrupts. So
945 # lets use a nop (47 00 00 00) as a landing pad.
946 # See also HANDLE_SIE_INTERCEPT
950 lg %r14,__LC_THREAD_INFO # pointer thread_info struct
951 tm __TI_flags+7(%r14),_TIF_EXIT_SIE
953 lg %r14,__LC_GMAP # get gmap pointer
956 lctlg %c1,%c1,__GMAP_ASCE(%r14) # load primary asce
958 lg %r14,__SF_EMPTY(%r15) # get control block pointer
959 LPP __SF_EMPTY(%r15) # set guest id
962 LPP __SF_EMPTY+16(%r15) # set host id
963 lg %r14,__LC_THREAD_INFO # pointer thread_info struct
965 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
966 lg %r14,__SF_EMPTY+8(%r15) # load guest register save area
967 stmg %r0,%r13,0(%r14) # save guest gprs 0-13
968 lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers
972 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
973 lg %r14,__LC_THREAD_INFO # pointer thread_info struct
974 lg %r14,__SF_EMPTY+8(%r15) # load guest register save area
975 stmg %r0,%r13,0(%r14) # save guest gprs 0-13
976 lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers
984 .quad sie_done - sie_loop
988 EX_TABLE(rewind_pad,sie_fault)
989 EX_TABLE(sie_loop,sie_fault)
992 .section .rodata, "a"
993 #define SYSCALL(esa,esame,emu) .long esame
994 .globl sys_call_table
996 #include "syscalls.S"
1001 #define SYSCALL(esa,esame,emu) .long emu
1002 .globl sys_call_table_emu
1004 #include "syscalls.S"