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)
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_LPP
79 .insn s,0xb2800000,\newpp
83 .macro HANDLE_SIE_INTERCEPT scratch,reason
84 #if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
85 tmhh %r8,0x0001 # interrupting from user ?
88 slg \scratch,BASED(.Lsie_critical)
89 clg \scratch,BASED(.Lsie_critical_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 %r14,__SF_EMPTY(%r15) # get control block pointer
99 LPP __SF_EMPTY+16(%r15) # set host id
100 ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE
101 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
102 larl %r9,sie_exit # skip forward to sie_exit
103 mvi __SF_EMPTY+31(%r15),\reason # set exit reason
107 .macro CHECK_STACK stacksize,savearea
108 #ifdef CONFIG_CHECK_STACK
109 tml %r15,\stacksize - CONFIG_STACK_GUARD
115 .macro SWITCH_ASYNC savearea,stack,shift
116 tmhh %r8,0x0001 # interrupting from user ?
119 slg %r14,BASED(.Lcritical_start)
120 clg %r14,BASED(.Lcritical_length)
122 lghi %r11,\savearea # inside critical section, do cleanup
123 brasl %r14,cleanup_critical
124 tmhh %r8,0x0001 # retest problem state after cleanup
126 0: lg %r14,\stack # are we already on the target stack?
128 srag %r14,%r14,\shift
130 CHECK_STACK 1<<\shift,\savearea
131 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
133 1: lg %r15,\stack # load target stack
134 2: la %r11,STACK_FRAME_OVERHEAD(%r15)
137 .macro UPDATE_VTIME scratch,enter_timer
138 lg \scratch,__LC_EXIT_TIMER
139 slg \scratch,\enter_timer
140 alg \scratch,__LC_USER_TIMER
141 stg \scratch,__LC_USER_TIMER
142 lg \scratch,__LC_LAST_UPDATE_TIMER
143 slg \scratch,__LC_EXIT_TIMER
144 alg \scratch,__LC_SYSTEM_TIMER
145 stg \scratch,__LC_SYSTEM_TIMER
146 mvc __LC_LAST_UPDATE_TIMER(8),\enter_timer
149 .macro LAST_BREAK scratch
150 srag \scratch,%r10,23
152 stg %r10,__TI_last_break(%r12)
156 stg %r8,__LC_RETURN_PSW
157 ni __LC_RETURN_PSW,0xbf
162 #ifdef CONFIG_HAVE_MARCH_Z9_109_FEATURES
163 .insn s,0xb27c0000,\savearea # store clock fast
165 .insn s,0xb2050000,\savearea # store clock
169 .section .kprobes.text, "ax"
172 * Scheduler resume function, called by switch_to
173 * gpr2 = (task_struct *) prev
174 * gpr3 = (task_struct *) next
179 stmg %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task
180 stg %r15,__THREAD_ksp(%r2) # store kernel stack of prev
181 lg %r4,__THREAD_info(%r2) # get thread_info of prev
182 lg %r5,__THREAD_info(%r3) # get thread_info of next
184 aghi %r15,STACK_INIT # end of kernel stack of next
185 stg %r3,__LC_CURRENT # store task struct of next
186 stg %r5,__LC_THREAD_INFO # store thread info of next
187 stg %r15,__LC_KERNEL_STACK # store end of kernel stack
188 lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4
189 mvc __LC_CURRENT_PID+4(4,%r0),__TASK_pid(%r3) # store pid of next
190 lg %r15,__THREAD_ksp(%r3) # load kernel stack of next
191 tm __TI_flags+7(%r4),_TIF_MCCK_PENDING # machine check pending?
193 ni __TI_flags+7(%r4),255-_TIF_MCCK_PENDING # clear flag in prev
194 oi __TI_flags+7(%r5),_TIF_MCCK_PENDING # set it in next
195 0: lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task
200 * SVC interrupt handler routine. System calls are synchronous events and
201 * are executed with interrupts enabled.
205 stpt __LC_SYNC_ENTER_TIMER
207 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
208 lg %r10,__LC_LAST_BREAK
209 lg %r12,__LC_THREAD_INFO
211 lg %r15,__LC_KERNEL_STACK
212 la %r11,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs
214 UPDATE_VTIME %r13,__LC_SYNC_ENTER_TIMER
216 stmg %r0,%r7,__PT_R0(%r11)
217 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
218 mvc __PT_PSW(16,%r11),__LC_SVC_OLD_PSW
219 mvc __PT_INT_CODE(4,%r11),__LC_SVC_ILC
221 oi __TI_flags+7(%r12),_TIF_SYSCALL
222 lg %r10,__TI_sysc_table(%r12) # address of system call table
223 llgh %r8,__PT_INT_CODE+2(%r11)
224 slag %r8,%r8,2 # shift and test for svc 0
226 # svc 0: system call number in %r1
227 llgfr %r1,%r1 # clear high word in r1
230 sth %r1,__PT_INT_CODE+2(%r11)
233 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
234 stg %r2,__PT_ORIG_GPR2(%r11)
235 stg %r7,STACK_FRAME_OVERHEAD(%r15)
236 lgf %r9,0(%r8,%r10) # get system call add.
237 tm __TI_flags+6(%r12),_TIF_TRACE >> 8
239 basr %r14,%r9 # call sys_xxxx
240 stg %r2,__PT_R2(%r11) # store return value
245 tm __PT_PSW+1(%r11),0x01 # returning to user ?
247 tm __TI_flags+7(%r12),_TIF_WORK_SVC
248 jnz sysc_work # check for work
249 ni __TI_flags+7(%r12),255-_TIF_SYSCALL
251 lg %r14,__LC_VDSO_PER_CPU
252 lmg %r0,%r10,__PT_R0(%r11)
253 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
255 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
256 lmg %r11,%r15,__PT_R11(%r11)
257 lpswe __LC_RETURN_PSW
261 # One of the work bits is on. Find out which one.
264 tm __TI_flags+7(%r12),_TIF_MCCK_PENDING
266 tm __TI_flags+7(%r12),_TIF_NEED_RESCHED
268 tm __TI_flags+7(%r12),_TIF_PER_TRAP
270 tm __TI_flags+7(%r12),_TIF_SIGPENDING
272 tm __TI_flags+7(%r12),_TIF_NOTIFY_RESUME
273 jo sysc_notify_resume
274 j sysc_return # beware of critical section cleanup
277 # _TIF_NEED_RESCHED is set, call schedule
280 larl %r14,sysc_return
284 # _TIF_MCCK_PENDING is set, call handler
287 larl %r14,sysc_return
288 jg s390_handle_mcck # TIF bit will be cleared by handler
291 # _TIF_SIGPENDING is set, call do_signal
294 lgr %r2,%r11 # pass pointer to pt_regs
296 tm __TI_flags+7(%r12),_TIF_SYSCALL
298 lmg %r2,%r7,__PT_R2(%r11) # load svc arguments
299 lghi %r8,0 # svc 0 returns -ENOSYS
300 llgh %r1,__PT_INT_CODE+2(%r11) # load new svc number
302 jnl sysc_nr_ok # invalid svc number -> do svc 0
304 j sysc_nr_ok # restart svc
307 # _TIF_NOTIFY_RESUME is set, call do_notify_resume
310 lgr %r2,%r11 # pass pointer to pt_regs
311 larl %r14,sysc_return
315 # _TIF_PER_TRAP is set, call do_per_trap
318 ni __TI_flags+7(%r12),255-_TIF_PER_TRAP
319 lgr %r2,%r11 # pass pointer to pt_regs
320 larl %r14,sysc_return
324 # call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
325 # and after the system call
328 lgr %r2,%r11 # pass pointer to pt_regs
330 llgh %r0,__PT_INT_CODE+2(%r11)
331 stg %r0,__PT_R2(%r11)
332 brasl %r14,do_syscall_trace_enter
339 lmg %r3,%r7,__PT_R3(%r11)
340 stg %r7,STACK_FRAME_OVERHEAD(%r15)
341 lg %r2,__PT_ORIG_GPR2(%r11)
342 basr %r14,%r9 # call sys_xxx
343 stg %r2,__PT_R2(%r11) # store return value
345 tm __TI_flags+6(%r12),_TIF_TRACE >> 8
347 lgr %r2,%r11 # pass pointer to pt_regs
348 larl %r14,sysc_return
349 jg do_syscall_trace_exit
352 # a new process exits the kernel with ret_from_fork
355 la %r11,STACK_FRAME_OVERHEAD(%r15)
356 lg %r12,__LC_THREAD_INFO
357 brasl %r14,schedule_tail
359 ssm __LC_SVC_NEW_PSW # reenable interrupts
360 tm __PT_PSW+1(%r11),0x01 # forking a kernel thread ?
362 # it's a kernel thread
363 lmg %r9,%r10,__PT_R9(%r11) # load gprs
364 ENTRY(kernel_thread_starter)
370 * Program check handler routine
373 ENTRY(pgm_check_handler)
374 stpt __LC_SYNC_ENTER_TIMER
375 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
376 lg %r10,__LC_LAST_BREAK
377 lg %r12,__LC_THREAD_INFO
378 larl %r13,system_call
379 lmg %r8,%r9,__LC_PGM_OLD_PSW
380 HANDLE_SIE_INTERCEPT %r14,1
381 tmhh %r8,0x0001 # test problem state bit
382 jnz 1f # -> fault in user space
383 tmhh %r8,0x4000 # PER bit set in old PSW ?
384 jnz 0f # -> enabled, can't be a double fault
385 tm __LC_PGM_ILC+3,0x80 # check for per exception
386 jnz pgm_svcper # -> single stepped svc
387 0: CHECK_STACK STACK_SIZE,__LC_SAVE_AREA_SYNC
388 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
390 1: UPDATE_VTIME %r14,__LC_SYNC_ENTER_TIMER
392 lg %r15,__LC_KERNEL_STACK
393 lg %r14,__TI_task(%r12)
394 lghi %r13,__LC_PGM_TDB
395 tm __LC_PGM_ILC+2,0x02 # check for transaction abort
397 mvc __THREAD_trap_tdb(256,%r14),0(%r13)
398 2: la %r11,STACK_FRAME_OVERHEAD(%r15)
399 stmg %r0,%r7,__PT_R0(%r11)
400 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
401 stmg %r8,%r9,__PT_PSW(%r11)
402 mvc __PT_INT_CODE(4,%r11),__LC_PGM_ILC
403 mvc __PT_INT_PARM_LONG(8,%r11),__LC_TRANS_EXC_CODE
404 stg %r10,__PT_ARGS(%r11)
405 tm __LC_PGM_ILC+3,0x80 # check for per exception
407 tmhh %r8,0x0001 # kernel per event ?
409 oi __TI_flags+7(%r12),_TIF_PER_TRAP
410 mvc __THREAD_per_address(8,%r14),__LC_PER_ADDRESS
411 mvc __THREAD_per_cause(2,%r14),__LC_PER_CAUSE
412 mvc __THREAD_per_paid(1,%r14),__LC_PER_PAID
414 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
415 larl %r1,pgm_check_table
416 llgh %r10,__PT_INT_CODE+2(%r11)
420 lgf %r1,0(%r10,%r1) # load address of handler routine
421 lgr %r2,%r11 # pass pointer to pt_regs
422 basr %r14,%r1 # branch to interrupt-handler
426 # PER event in supervisor state, must be kprobes
430 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
431 lgr %r2,%r11 # pass pointer to pt_regs
432 brasl %r14,do_per_trap
436 # single stepped system call
439 oi __TI_flags+7(%r12),_TIF_PER_TRAP
440 mvc __LC_RETURN_PSW(8),__LC_SVC_NEW_PSW
442 stg %r14,__LC_RETURN_PSW+8
443 lpswe __LC_RETURN_PSW # branch to sysc_per and enable irqs
446 * IO interrupt handler routine
448 ENTRY(io_int_handler)
450 stpt __LC_ASYNC_ENTER_TIMER
451 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
452 lg %r10,__LC_LAST_BREAK
453 lg %r12,__LC_THREAD_INFO
454 larl %r13,system_call
455 lmg %r8,%r9,__LC_IO_OLD_PSW
456 HANDLE_SIE_INTERCEPT %r14,2
457 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_STACK,STACK_SHIFT
458 tmhh %r8,0x0001 # interrupting from user?
460 UPDATE_VTIME %r14,__LC_ASYNC_ENTER_TIMER
463 stmg %r0,%r7,__PT_R0(%r11)
464 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
465 stmg %r8,%r9,__PT_PSW(%r11)
466 mvc __PT_INT_CODE(12,%r11),__LC_SUBCHANNEL_ID
468 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
470 lgr %r2,%r11 # pass pointer to pt_regs
472 tm __LC_MACHINE_FLAGS+6,0x10 # MACHINE_FLAG_LPAR
476 mvc __PT_INT_CODE(12,%r11),__LC_SUBCHANNEL_ID
482 tm __TI_flags+7(%r12),_TIF_WORK_INT
483 jnz io_work # there is work to do (signals etc.)
485 lg %r14,__LC_VDSO_PER_CPU
486 lmg %r0,%r10,__PT_R0(%r11)
487 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
489 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
490 lmg %r11,%r15,__PT_R11(%r11)
491 lpswe __LC_RETURN_PSW
495 # There is work todo, find out in which context we have been interrupted:
496 # 1) if we return to user space we can do all _TIF_WORK_INT work
497 # 2) if we return to kernel code and kvm is enabled check if we need to
498 # modify the psw to leave SIE
499 # 3) if we return to kernel code and preemptive scheduling is enabled check
500 # the preemption counter and if it is zero call preempt_schedule_irq
501 # Before any work can be done, a switch to the kernel stack is required.
504 tm __PT_PSW+1(%r11),0x01 # returning to user ?
505 jo io_work_user # yes -> do resched & signal
506 #ifdef CONFIG_PREEMPT
507 # check for preemptive scheduling
508 icm %r0,15,__TI_precount(%r12)
509 jnz io_restore # preemption is disabled
510 tm __TI_flags+7(%r12),_TIF_NEED_RESCHED
512 # switch to kernel stack
513 lg %r1,__PT_R15(%r11)
514 aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
515 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
516 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
517 la %r11,STACK_FRAME_OVERHEAD(%r1)
519 # TRACE_IRQS_ON already done at io_return, call
520 # TRACE_IRQS_OFF to keep things symmetrical
522 brasl %r14,preempt_schedule_irq
529 # Need to do work before returning to userspace, switch to kernel stack
532 lg %r1,__LC_KERNEL_STACK
533 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
534 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
535 la %r11,STACK_FRAME_OVERHEAD(%r1)
539 # One of the work bits is on. Find out which one.
540 # Checked are: _TIF_SIGPENDING, _TIF_NOTIFY_RESUME, _TIF_NEED_RESCHED
541 # and _TIF_MCCK_PENDING
544 tm __TI_flags+7(%r12),_TIF_MCCK_PENDING
546 tm __TI_flags+7(%r12),_TIF_NEED_RESCHED
548 tm __TI_flags+7(%r12),_TIF_SIGPENDING
550 tm __TI_flags+7(%r12),_TIF_NOTIFY_RESUME
552 j io_return # beware of critical section cleanup
555 # _TIF_MCCK_PENDING is set, call handler
558 # TRACE_IRQS_ON already done at io_return
559 brasl %r14,s390_handle_mcck # TIF bit will be cleared by handler
564 # _TIF_NEED_RESCHED is set, call schedule
567 # TRACE_IRQS_ON already done at io_return
568 ssm __LC_SVC_NEW_PSW # reenable interrupts
569 brasl %r14,schedule # call scheduler
570 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
575 # _TIF_SIGPENDING or is set, call do_signal
578 # TRACE_IRQS_ON already done at io_return
579 ssm __LC_SVC_NEW_PSW # reenable interrupts
580 lgr %r2,%r11 # pass pointer to pt_regs
582 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
587 # _TIF_NOTIFY_RESUME or is set, call do_notify_resume
590 # TRACE_IRQS_ON already done at io_return
591 ssm __LC_SVC_NEW_PSW # reenable interrupts
592 lgr %r2,%r11 # pass pointer to pt_regs
593 brasl %r14,do_notify_resume
594 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
599 * External interrupt handler routine
601 ENTRY(ext_int_handler)
603 stpt __LC_ASYNC_ENTER_TIMER
604 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
605 lg %r10,__LC_LAST_BREAK
606 lg %r12,__LC_THREAD_INFO
607 larl %r13,system_call
608 lmg %r8,%r9,__LC_EXT_OLD_PSW
609 HANDLE_SIE_INTERCEPT %r14,3
610 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_STACK,STACK_SHIFT
611 tmhh %r8,0x0001 # interrupting from user ?
613 UPDATE_VTIME %r14,__LC_ASYNC_ENTER_TIMER
616 stmg %r0,%r7,__PT_R0(%r11)
617 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
618 stmg %r8,%r9,__PT_PSW(%r11)
619 lghi %r1,__LC_EXT_PARAMS2
620 mvc __PT_INT_CODE(4,%r11),__LC_EXT_CPU_ADDR
621 mvc __PT_INT_PARM(4,%r11),__LC_EXT_PARAMS
622 mvc __PT_INT_PARM_LONG(8,%r11),0(%r1)
624 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
625 lgr %r2,%r11 # pass pointer to pt_regs
630 * Load idle PSW. The second "half" of this function is in cleanup_idle.
633 stg %r3,__SF_EMPTY(%r15)
634 larl %r1,psw_idle_lpsw+4
635 stg %r1,__SF_EMPTY+8(%r15)
636 STCK __CLOCK_IDLE_ENTER(%r2)
637 stpt __TIMER_IDLE_ENTER(%r2)
639 lpswe __SF_EMPTY(%r15)
646 * Machine check handler routines
648 ENTRY(mcck_int_handler)
650 la %r1,4095 # revalidate r1
651 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # revalidate cpu timer
652 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# revalidate gprs
653 lg %r10,__LC_LAST_BREAK
654 lg %r12,__LC_THREAD_INFO
655 larl %r13,system_call
656 lmg %r8,%r9,__LC_MCK_OLD_PSW
657 HANDLE_SIE_INTERCEPT %r14,4
658 tm __LC_MCCK_CODE,0x80 # system damage?
659 jo mcck_panic # yes -> rest of mcck code invalid
660 lghi %r14,__LC_CPU_TIMER_SAVE_AREA
661 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
662 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
664 la %r14,__LC_SYNC_ENTER_TIMER
665 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
667 la %r14,__LC_ASYNC_ENTER_TIMER
668 0: clc 0(8,%r14),__LC_EXIT_TIMER
670 la %r14,__LC_EXIT_TIMER
671 1: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
673 la %r14,__LC_LAST_UPDATE_TIMER
675 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
676 3: tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid?
677 jno mcck_panic # no -> skip cleanup critical
678 SWITCH_ASYNC __LC_GPREGS_SAVE_AREA+64,__LC_PANIC_STACK,PAGE_SHIFT
679 tm %r8,0x0001 # interrupting from user ?
681 UPDATE_VTIME %r14,__LC_MCCK_ENTER_TIMER
684 lghi %r14,__LC_GPREGS_SAVE_AREA+64
685 stmg %r0,%r7,__PT_R0(%r11)
686 mvc __PT_R8(64,%r11),0(%r14)
687 stmg %r8,%r9,__PT_PSW(%r11)
688 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
689 lgr %r2,%r11 # pass pointer to pt_regs
690 brasl %r14,s390_do_machine_check
691 tm __PT_PSW+1(%r11),0x01 # returning to user ?
693 lg %r1,__LC_KERNEL_STACK # switch to kernel stack
694 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
695 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
696 la %r11,STACK_FRAME_OVERHEAD(%r1)
698 ssm __LC_PGM_NEW_PSW # turn dat on, keep irqs off
699 tm __TI_flags+7(%r12),_TIF_MCCK_PENDING
702 brasl %r14,s390_handle_mcck
705 lg %r14,__LC_VDSO_PER_CPU
706 lmg %r0,%r10,__PT_R0(%r11)
707 mvc __LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW
708 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
711 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
712 0: lmg %r11,%r15,__PT_R11(%r11)
713 lpswe __LC_RETURN_MCCK_PSW
716 lg %r14,__LC_PANIC_STACK
718 srag %r14,%r14,PAGE_SHIFT
720 lg %r15,__LC_PANIC_STACK
721 0: aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
725 # PSW restart interrupt handler
727 ENTRY(restart_int_handler)
728 stg %r15,__LC_SAVE_AREA_RESTART
729 lg %r15,__LC_RESTART_STACK
730 aghi %r15,-__PT_SIZE # create pt_regs on stack
731 xc 0(__PT_SIZE,%r15),0(%r15)
732 stmg %r0,%r14,__PT_R0(%r15)
733 mvc __PT_R15(8,%r15),__LC_SAVE_AREA_RESTART
734 mvc __PT_PSW(16,%r15),__LC_RST_OLD_PSW # store restart old psw
735 aghi %r15,-STACK_FRAME_OVERHEAD # create stack frame on stack
736 xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15)
737 lg %r1,__LC_RESTART_FN # load fn, parm & source cpu
738 lg %r2,__LC_RESTART_DATA
739 lg %r3,__LC_RESTART_SOURCE
740 ltgr %r3,%r3 # test source cpu address
741 jm 1f # negative -> skip source stop
742 0: sigp %r4,%r3,SIGP_SENSE # sigp sense to source cpu
743 brc 10,0b # wait for status stored
744 1: basr %r14,%r1 # call function
745 stap __SF_EMPTY(%r15) # store cpu address
746 llgh %r3,__SF_EMPTY(%r15)
747 2: sigp %r4,%r3,SIGP_STOP # sigp stop to current cpu
751 .section .kprobes.text, "ax"
753 #ifdef CONFIG_CHECK_STACK
755 * The synchronous or the asynchronous stack overflowed. We are dead.
756 * No need to properly save the registers, we are going to panic anyway.
757 * Setup a pt_regs so that show_trace can provide a good call trace.
760 lg %r15,__LC_PANIC_STACK # change to panic stack
761 la %r11,STACK_FRAME_OVERHEAD(%r15)
762 stmg %r0,%r7,__PT_R0(%r11)
763 stmg %r8,%r9,__PT_PSW(%r11)
764 mvc __PT_R8(64,%r11),0(%r14)
765 stg %r10,__PT_ORIG_GPR2(%r11) # store last break to orig_gpr2
766 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
767 lgr %r2,%r11 # pass pointer to pt_regs
768 jg kernel_stack_overflow
785 clg %r9,BASED(cleanup_table) # system_call
787 clg %r9,BASED(cleanup_table+8) # sysc_do_svc
788 jl cleanup_system_call
789 clg %r9,BASED(cleanup_table+16) # sysc_tif
791 clg %r9,BASED(cleanup_table+24) # sysc_restore
793 clg %r9,BASED(cleanup_table+32) # sysc_done
794 jl cleanup_sysc_restore
795 clg %r9,BASED(cleanup_table+40) # io_tif
797 clg %r9,BASED(cleanup_table+48) # io_restore
799 clg %r9,BASED(cleanup_table+56) # io_done
800 jl cleanup_io_restore
801 clg %r9,BASED(cleanup_table+64) # psw_idle
803 clg %r9,BASED(cleanup_table+72) # psw_idle_end
809 # check if stpt has been executed
810 clg %r9,BASED(cleanup_system_call_insn)
812 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
813 cghi %r11,__LC_SAVE_AREA_ASYNC
815 mvc __LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER
816 0: # check if stmg has been executed
817 clg %r9,BASED(cleanup_system_call_insn+8)
819 mvc __LC_SAVE_AREA_SYNC(64),0(%r11)
820 0: # check if base register setup + TIF bit load has been done
821 clg %r9,BASED(cleanup_system_call_insn+16)
823 # set up saved registers r10 and r12
824 stg %r10,16(%r11) # r10 last break
825 stg %r12,32(%r11) # r12 thread-info pointer
826 0: # check if the user time update has been done
827 clg %r9,BASED(cleanup_system_call_insn+24)
829 lg %r15,__LC_EXIT_TIMER
830 slg %r15,__LC_SYNC_ENTER_TIMER
831 alg %r15,__LC_USER_TIMER
832 stg %r15,__LC_USER_TIMER
833 0: # check if the system time update has been done
834 clg %r9,BASED(cleanup_system_call_insn+32)
836 lg %r15,__LC_LAST_UPDATE_TIMER
837 slg %r15,__LC_EXIT_TIMER
838 alg %r15,__LC_SYSTEM_TIMER
839 stg %r15,__LC_SYSTEM_TIMER
840 0: # update accounting time stamp
841 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
846 mvc __TI_last_break(8,%r12),16(%r11)
847 0: # set up saved register r11
848 lg %r15,__LC_KERNEL_STACK
849 la %r9,STACK_FRAME_OVERHEAD(%r15)
850 stg %r9,24(%r11) # r11 pt_regs pointer
852 mvc __PT_R8(64,%r9),__LC_SAVE_AREA_SYNC
853 stmg %r0,%r7,__PT_R0(%r9)
854 mvc __PT_PSW(16,%r9),__LC_SVC_OLD_PSW
855 mvc __PT_INT_CODE(4,%r9),__LC_SVC_ILC
856 # setup saved register r15
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(16,%r15),__SF_EMPTY+16(%r15) # host id & reason
952 lmg %r0,%r13,0(%r3) # load guest gprs 0-13
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 oi __SIE_PROG0C+3(%r14),1 # we are going into SIE now
960 tm __SIE_PROG20+3(%r14),1 # last exit...
962 LPP __SF_EMPTY(%r15) # set guest id
965 LPP __SF_EMPTY+16(%r15) # set host id
966 ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE
967 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
968 # some program checks are suppressing. C code (e.g. do_protection_exception)
969 # will rewind the PSW by the ILC, which is 4 bytes in case of SIE. Other
970 # instructions beween sie64a and sie_done should not cause program
971 # interrupts. So lets use a nop (47 00 00 00) as a landing pad.
972 # See also HANDLE_SIE_INTERCEPT
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
980 lg %r2,__SF_EMPTY+24(%r15) # return exit reason code
984 stg %r14,__SF_EMPTY+24(%r15) # set exit reason code
990 .Lsie_critical_length:
991 .quad sie_done - sie_gmap
993 EX_TABLE(rewind_pad,sie_fault)
994 EX_TABLE(sie_exit,sie_fault)
997 .section .rodata, "a"
998 #define SYSCALL(esa,esame,emu) .long esame
999 .globl sys_call_table
1001 #include "syscalls.S"
1004 #ifdef CONFIG_COMPAT
1006 #define SYSCALL(esa,esame,emu) .long emu
1007 .globl sys_call_table_emu
1009 #include "syscalls.S"