1 /* SPDX-License-Identifier: GPL-2.0 */
3 * S390 low-level entry points.
5 * Copyright IBM Corp. 1999, 2012
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
7 * Hartmut Penner (hp@de.ibm.com),
8 * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
9 * Heiko Carstens <heiko.carstens@de.ibm.com>
12 #include <linux/init.h>
13 #include <linux/linkage.h>
14 #include <asm/alternative-asm.h>
15 #include <asm/processor.h>
16 #include <asm/cache.h>
17 #include <asm/ctl_reg.h>
18 #include <asm/dwarf.h>
19 #include <asm/errno.h>
20 #include <asm/ptrace.h>
21 #include <asm/thread_info.h>
22 #include <asm/asm-offsets.h>
23 #include <asm/unistd.h>
27 #include <asm/vx-insn.h>
28 #include <asm/setup.h>
30 #include <asm/export.h>
31 #include <asm/nospec-insn.h>
34 __PT_R1 = __PT_GPRS + 8
35 __PT_R2 = __PT_GPRS + 16
36 __PT_R3 = __PT_GPRS + 24
37 __PT_R4 = __PT_GPRS + 32
38 __PT_R5 = __PT_GPRS + 40
39 __PT_R6 = __PT_GPRS + 48
40 __PT_R7 = __PT_GPRS + 56
41 __PT_R8 = __PT_GPRS + 64
42 __PT_R9 = __PT_GPRS + 72
43 __PT_R10 = __PT_GPRS + 80
44 __PT_R11 = __PT_GPRS + 88
45 __PT_R12 = __PT_GPRS + 96
46 __PT_R13 = __PT_GPRS + 104
47 __PT_R14 = __PT_GPRS + 112
48 __PT_R15 = __PT_GPRS + 120
50 STACK_SHIFT = PAGE_SHIFT + THREAD_SIZE_ORDER
51 STACK_SIZE = 1 << STACK_SHIFT
52 STACK_INIT = STACK_SIZE - STACK_FRAME_OVERHEAD - __PT_SIZE
54 _TIF_WORK = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
55 _TIF_UPROBE | _TIF_GUARDED_STORAGE | _TIF_PATCH_PENDING)
56 _TIF_TRACE = (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | \
57 _TIF_SYSCALL_TRACEPOINT)
58 _CIF_WORK = (_CIF_MCCK_PENDING | _CIF_ASCE_PRIMARY | \
59 _CIF_ASCE_SECONDARY | _CIF_FPU)
60 _PIF_WORK = (_PIF_PER_TRAP | _PIF_SYSCALL_RESTART)
62 _LPP_OFFSET = __LC_LPP
64 #define BASED(name) name-cleanup_critical(%r13)
67 #ifdef CONFIG_TRACE_IRQFLAGS
69 brasl %r14,trace_hardirqs_on_caller
74 #ifdef CONFIG_TRACE_IRQFLAGS
76 brasl %r14,trace_hardirqs_off_caller
80 .macro LOCKDEP_SYS_EXIT
82 tm __PT_PSW+1(%r11),0x01 # returning to user ?
84 brasl %r14,lockdep_sys_exit
88 .macro CHECK_STACK savearea
89 #ifdef CONFIG_CHECK_STACK
90 tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
96 .macro CHECK_VMAP_STACK savearea,oklabel
97 #ifdef CONFIG_VMAP_STACK
99 nill %r14,0x10000 - STACK_SIZE
101 clg %r14,__LC_KERNEL_STACK
103 clg %r14,__LC_ASYNC_STACK
105 clg %r14,__LC_NODAT_STACK
107 clg %r14,__LC_RESTART_STACK
116 .macro SWITCH_ASYNC savearea,timer
117 tmhh %r8,0x0001 # interrupting from user ?
120 cghi %r14,__LC_RETURN_LPSWE
122 slg %r14,BASED(.Lcritical_start)
123 clg %r14,BASED(.Lcritical_length)
126 lghi %r11,\savearea # inside critical section, do cleanup
127 brasl %r14,cleanup_critical
128 tmhh %r8,0x0001 # retest problem state after cleanup
130 1: lg %r14,__LC_ASYNC_STACK # are we already on the target stack?
132 srag %r14,%r14,STACK_SHIFT
134 CHECK_STACK \savearea
135 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
137 2: UPDATE_VTIME %r14,%r15,\timer
138 BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
139 3: lg %r15,__LC_ASYNC_STACK # load async stack
140 4: la %r11,STACK_FRAME_OVERHEAD(%r15)
143 .macro UPDATE_VTIME w1,w2,enter_timer
144 lg \w1,__LC_EXIT_TIMER
145 lg \w2,__LC_LAST_UPDATE_TIMER
147 slg \w2,__LC_EXIT_TIMER
148 alg \w1,__LC_USER_TIMER
149 alg \w2,__LC_SYSTEM_TIMER
150 stg \w1,__LC_USER_TIMER
151 stg \w2,__LC_SYSTEM_TIMER
152 mvc __LC_LAST_UPDATE_TIMER(8),\enter_timer
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
170 * The TSTMSK macro generates a test-under-mask instruction by
171 * calculating the memory offset for the specified mask value.
172 * Mask value can be any constant. The macro shifts the mask
173 * value to calculate the memory offset for the test-under-mask
176 .macro TSTMSK addr, mask, size=8, bytepos=0
177 .if (\bytepos < \size) && (\mask >> 8)
179 .error "Mask exceeds byte boundary"
181 TSTMSK \addr, "(\mask >> 8)", \size, "(\bytepos + 1)"
185 .error "Mask must not be zero"
187 off = \size - \bytepos - 1
192 ALTERNATIVE "", ".long 0xb2e8c000", 82
196 ALTERNATIVE "", ".long 0xb2e8d000", 82
199 .macro BPENTER tif_ptr,tif_mask
200 ALTERNATIVE "TSTMSK \tif_ptr,\tif_mask; jz .+8; .long 0xb2e8d000", \
204 .macro BPEXIT tif_ptr,tif_mask
205 TSTMSK \tif_ptr,\tif_mask
206 ALTERNATIVE "jz .+8; .long 0xb2e8c000", \
207 "jnz .+8; .long 0xb2e8d000", 82
212 GEN_BR_THUNK %r14,%r11
214 .section .kprobes.text, "ax"
217 * This nop exists only in order to avoid that __switch_to starts at
218 * the beginning of the kprobes text section. In that case we would
219 * have several symbols at the same address. E.g. objdump would take
220 * an arbitrary symbol name when disassembling this code.
221 * With the added nop in between the __switch_to symbol is unique
233 * Scheduler resume function, called by switch_to
234 * gpr2 = (task_struct *) prev
235 * gpr3 = (task_struct *) next
240 stmg %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task
241 lghi %r4,__TASK_stack
242 lghi %r1,__TASK_thread
244 stg %r15,__THREAD_ksp(%r1,%r2) # store kernel stack of prev
245 lg %r15,0(%r4,%r3) # start of kernel stack of next
246 agr %r15,%r5 # end of kernel stack of next
247 stg %r3,__LC_CURRENT # store task struct of next
248 stg %r15,__LC_KERNEL_STACK # store end of kernel stack
249 lg %r15,__THREAD_ksp(%r1,%r3) # load kernel stack of next
251 mvc __LC_CURRENT_PID(4,%r0),0(%r3) # store pid of next
252 lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task
253 ALTERNATIVE "", ".insn s,0xb2800000,_LPP_OFFSET", 40
259 #if IS_ENABLED(CONFIG_KVM)
261 * sie64a calling convention:
262 * %r2 pointer to sie control block
263 * %r3 guest register save area
266 stmg %r6,%r14,__SF_GPRS(%r15) # save kernel registers
268 stg %r2,__SF_SIE_CONTROL(%r15) # save control block pointer
269 stg %r3,__SF_SIE_SAVEAREA(%r15) # save guest register save area
270 xc __SF_SIE_REASON(8,%r15),__SF_SIE_REASON(%r15) # reason code = 0
271 mvc __SF_SIE_FLAGS(8,%r15),__TI_flags(%r12) # copy thread flags
272 TSTMSK __LC_CPU_FLAGS,_CIF_FPU # load guest fp/vx registers ?
273 jno .Lsie_load_guest_gprs
274 brasl %r14,load_fpu_regs # load guest fp/vx regs
275 .Lsie_load_guest_gprs:
276 lmg %r0,%r13,0(%r3) # load guest gprs 0-13
277 lg %r14,__LC_GMAP # get gmap pointer
280 lctlg %c1,%c1,__GMAP_ASCE(%r14) # load primary asce
282 lg %r14,__SF_SIE_CONTROL(%r15) # get control block pointer
283 oi __SIE_PROG0C+3(%r14),1 # we are going into SIE now
284 tm __SIE_PROG20+3(%r14),3 # last exit...
286 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
287 jo .Lsie_skip # exit if fp/vx regs changed
288 BPEXIT __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
293 BPENTER __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
295 ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE
296 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
298 # some program checks are suppressing. C code (e.g. do_protection_exception)
299 # will rewind the PSW by the ILC, which is often 4 bytes in case of SIE. There
300 # are some corner cases (e.g. runtime instrumentation) where ILC is unpredictable.
301 # Other instructions between sie64a and .Lsie_done should not cause program
302 # interrupts. So lets use 3 nops as a landing pad for all possible rewinds.
303 # See also .Lcleanup_sie
312 lg %r14,__SF_SIE_SAVEAREA(%r15) # load guest register save area
313 stmg %r0,%r13,0(%r14) # save guest gprs 0-13
314 xgr %r0,%r0 # clear guest registers to
315 xgr %r1,%r1 # prevent speculative use
320 lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers
321 lg %r2,__SF_SIE_REASON(%r15) # return exit reason code
325 stg %r14,__SF_SIE_REASON(%r15) # set exit reason code
328 EX_TABLE(.Lrewind_pad6,.Lsie_fault)
329 EX_TABLE(.Lrewind_pad4,.Lsie_fault)
330 EX_TABLE(.Lrewind_pad2,.Lsie_fault)
331 EX_TABLE(sie_exit,.Lsie_fault)
333 EXPORT_SYMBOL(sie64a)
334 EXPORT_SYMBOL(sie_exit)
338 * SVC interrupt handler routine. System calls are synchronous events and
339 * are executed with interrupts enabled.
343 stpt __LC_SYNC_ENTER_TIMER
345 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
348 lghi %r13,__TASK_thread
349 lghi %r14,_PIF_SYSCALL
351 lg %r15,__LC_KERNEL_STACK
352 la %r11,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs
354 UPDATE_VTIME %r8,%r9,__LC_SYNC_ENTER_TIMER
355 BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
356 stmg %r0,%r7,__PT_R0(%r11)
357 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
358 mvc __PT_PSW(16,%r11),__LC_SVC_OLD_PSW
359 mvc __PT_INT_CODE(4,%r11),__LC_SVC_ILC
360 stg %r14,__PT_FLAGS(%r11)
362 # clear user controlled register to prevent speculative use
364 # load address of system call table
365 lg %r10,__THREAD_sysc_table(%r13,%r12)
366 llgh %r8,__PT_INT_CODE+2(%r11)
367 slag %r8,%r8,3 # shift and test for svc 0
369 # svc 0: system call number in %r1
370 llgfr %r1,%r1 # clear high word in r1
373 sth %r1,__PT_INT_CODE+2(%r11)
376 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
377 stg %r2,__PT_ORIG_GPR2(%r11)
378 stg %r7,STACK_FRAME_OVERHEAD(%r15)
379 lg %r9,0(%r8,%r10) # get system call add.
380 TSTMSK __TI_flags(%r12),_TIF_TRACE
382 BASR_EX %r14,%r9 # call sys_xxxx
383 stg %r2,__PT_R2(%r11) # store return value
386 #ifdef CONFIG_DEBUG_RSEQ
388 brasl %r14,rseq_syscall
392 TSTMSK __PT_FLAGS(%r11),_PIF_WORK
394 TSTMSK __TI_flags(%r12),_TIF_WORK
395 jnz .Lsysc_work # check for work
396 TSTMSK __LC_CPU_FLAGS,_CIF_WORK
398 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
400 lg %r14,__LC_VDSO_PER_CPU
401 lmg %r0,%r10,__PT_R0(%r11)
402 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
405 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
406 lmg %r11,%r15,__PT_R11(%r11)
407 b __LC_RETURN_LPSWE(%r0)
411 # One of the work bits is on. Find out which one.
414 TSTMSK __LC_CPU_FLAGS,_CIF_MCCK_PENDING
415 jo .Lsysc_mcck_pending
416 TSTMSK __TI_flags(%r12),_TIF_NEED_RESCHED
418 TSTMSK __PT_FLAGS(%r11),_PIF_SYSCALL_RESTART
419 jo .Lsysc_syscall_restart
420 #ifdef CONFIG_UPROBES
421 TSTMSK __TI_flags(%r12),_TIF_UPROBE
422 jo .Lsysc_uprobe_notify
424 TSTMSK __TI_flags(%r12),_TIF_GUARDED_STORAGE
425 jo .Lsysc_guarded_storage
426 TSTMSK __PT_FLAGS(%r11),_PIF_PER_TRAP
428 #ifdef CONFIG_LIVEPATCH
429 TSTMSK __TI_flags(%r12),_TIF_PATCH_PENDING
430 jo .Lsysc_patch_pending # handle live patching just before
431 # signals and possible syscall restart
433 TSTMSK __PT_FLAGS(%r11),_PIF_SYSCALL_RESTART
434 jo .Lsysc_syscall_restart
435 TSTMSK __TI_flags(%r12),_TIF_SIGPENDING
437 TSTMSK __TI_flags(%r12),_TIF_NOTIFY_RESUME
438 jo .Lsysc_notify_resume
439 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
441 TSTMSK __LC_CPU_FLAGS,(_CIF_ASCE_PRIMARY|_CIF_ASCE_SECONDARY)
443 j .Lsysc_return # beware of critical section cleanup
446 # _TIF_NEED_RESCHED is set, call schedule
449 larl %r14,.Lsysc_return
453 # _CIF_MCCK_PENDING is set, call handler
456 larl %r14,.Lsysc_return
457 jg s390_handle_mcck # TIF bit will be cleared by handler
460 # _CIF_ASCE_PRIMARY and/or _CIF_ASCE_SECONDARY set, load user space asce
463 ni __LC_CPU_FLAGS+7,255-_CIF_ASCE_SECONDARY
464 lctlg %c7,%c7,__LC_VDSO_ASCE # load secondary asce
465 TSTMSK __LC_CPU_FLAGS,_CIF_ASCE_PRIMARY
467 #ifndef CONFIG_HAVE_MARCH_Z10_FEATURES
468 tm __LC_STFLE_FAC_LIST+3,0x10 # has MVCOS ?
469 jnz .Lsysc_set_fs_fixup
470 ni __LC_CPU_FLAGS+7,255-_CIF_ASCE_PRIMARY
471 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
475 larl %r14,.Lsysc_return
479 # CIF_FPU is set, restore floating-point controls and floating-point registers.
482 larl %r14,.Lsysc_return
486 # _TIF_SIGPENDING is set, call do_signal
489 lgr %r2,%r11 # pass pointer to pt_regs
491 TSTMSK __PT_FLAGS(%r11),_PIF_SYSCALL
494 lghi %r13,__TASK_thread
495 lmg %r2,%r7,__PT_R2(%r11) # load svc arguments
496 lghi %r1,0 # svc 0 returns -ENOSYS
500 # _TIF_NOTIFY_RESUME is set, call do_notify_resume
502 .Lsysc_notify_resume:
503 lgr %r2,%r11 # pass pointer to pt_regs
504 larl %r14,.Lsysc_return
508 # _TIF_UPROBE is set, call uprobe_notify_resume
510 #ifdef CONFIG_UPROBES
511 .Lsysc_uprobe_notify:
512 lgr %r2,%r11 # pass pointer to pt_regs
513 larl %r14,.Lsysc_return
514 jg uprobe_notify_resume
518 # _TIF_GUARDED_STORAGE is set, call guarded_storage_load
520 .Lsysc_guarded_storage:
521 lgr %r2,%r11 # pass pointer to pt_regs
522 larl %r14,.Lsysc_return
525 # _TIF_PATCH_PENDING is set, call klp_update_patch_state
527 #ifdef CONFIG_LIVEPATCH
528 .Lsysc_patch_pending:
529 lg %r2,__LC_CURRENT # pass pointer to task struct
530 larl %r14,.Lsysc_return
531 jg klp_update_patch_state
535 # _PIF_PER_TRAP is set, call do_per_trap
538 ni __PT_FLAGS+7(%r11),255-_PIF_PER_TRAP
539 lgr %r2,%r11 # pass pointer to pt_regs
540 larl %r14,.Lsysc_return
544 # _PIF_SYSCALL_RESTART is set, repeat the current system call
546 .Lsysc_syscall_restart:
547 ni __PT_FLAGS+7(%r11),255-_PIF_SYSCALL_RESTART
548 lmg %r1,%r7,__PT_R1(%r11) # load svc arguments
549 lg %r2,__PT_ORIG_GPR2(%r11)
553 # call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
554 # and after the system call
557 lgr %r2,%r11 # pass pointer to pt_regs
559 llgh %r0,__PT_INT_CODE+2(%r11)
560 stg %r0,__PT_R2(%r11)
561 brasl %r14,do_syscall_trace_enter
568 lmg %r3,%r7,__PT_R3(%r11)
569 stg %r7,STACK_FRAME_OVERHEAD(%r15)
570 lg %r2,__PT_ORIG_GPR2(%r11)
571 BASR_EX %r14,%r9 # call sys_xxx
572 stg %r2,__PT_R2(%r11) # store return value
574 TSTMSK __TI_flags(%r12),_TIF_TRACE
576 lgr %r2,%r11 # pass pointer to pt_regs
577 larl %r14,.Lsysc_return
578 jg do_syscall_trace_exit
582 # a new process exits the kernel with ret_from_fork
585 la %r11,STACK_FRAME_OVERHEAD(%r15)
587 brasl %r14,schedule_tail
589 ssm __LC_SVC_NEW_PSW # reenable interrupts
590 tm __PT_PSW+1(%r11),0x01 # forking a kernel thread ?
592 # it's a kernel thread
593 lmg %r9,%r10,__PT_R9(%r11) # load gprs
597 ENDPROC(ret_from_fork)
599 ENTRY(kernel_thread_starter)
603 ENDPROC(kernel_thread_starter)
606 * Program check handler routine
609 ENTRY(pgm_check_handler)
610 stpt __LC_SYNC_ENTER_TIMER
612 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
613 lg %r10,__LC_LAST_BREAK
616 /* if __LC_LAST_BREAK is < 4096, it contains one of
617 * the lpswe addresses in lowcore. Set it to 1 (initial state)
618 * to prevent leaking that address to userspace.
621 0: lg %r12,__LC_CURRENT
623 larl %r13,cleanup_critical
624 lmg %r8,%r9,__LC_PGM_OLD_PSW
625 tmhh %r8,0x0001 # test problem state bit
626 jnz 3f # -> fault in user space
627 #if IS_ENABLED(CONFIG_KVM)
628 # cleanup critical section for program checks in sie64a
630 slg %r14,BASED(.Lsie_critical_start)
631 clg %r14,BASED(.Lsie_critical_length)
633 lg %r14,__SF_SIE_CONTROL(%r15) # get control block pointer
634 ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE
635 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
636 larl %r9,sie_exit # skip forward to sie_exit
637 lghi %r11,_PIF_GUEST_FAULT
639 1: tmhh %r8,0x4000 # PER bit set in old PSW ?
640 jnz 2f # -> enabled, can't be a double fault
641 tm __LC_PGM_ILC+3,0x80 # check for per exception
642 jnz .Lpgm_svcper # -> single stepped svc
643 2: CHECK_STACK __LC_SAVE_AREA_SYNC
644 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
645 # CHECK_VMAP_STACK branches to stack_overflow or 5f
646 CHECK_VMAP_STACK __LC_SAVE_AREA_SYNC,5f
647 3: UPDATE_VTIME %r14,%r15,__LC_SYNC_ENTER_TIMER
648 BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
649 lg %r15,__LC_KERNEL_STACK
651 aghi %r14,__TASK_thread # pointer to thread_struct
652 lghi %r13,__LC_PGM_TDB
653 tm __LC_PGM_ILC+2,0x02 # check for transaction abort
655 mvc __THREAD_trap_tdb(256,%r14),0(%r13)
656 4: stg %r10,__THREAD_last_break(%r14)
658 la %r11,STACK_FRAME_OVERHEAD(%r15)
659 stmg %r0,%r7,__PT_R0(%r11)
660 # clear user controlled registers to prevent speculative use
669 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
670 stmg %r8,%r9,__PT_PSW(%r11)
671 mvc __PT_INT_CODE(4,%r11),__LC_PGM_ILC
672 mvc __PT_INT_PARM_LONG(8,%r11),__LC_TRANS_EXC_CODE
673 stg %r13,__PT_FLAGS(%r11)
674 stg %r10,__PT_ARGS(%r11)
675 tm __LC_PGM_ILC+3,0x80 # check for per exception
677 tmhh %r8,0x0001 # kernel per event ?
679 oi __PT_FLAGS+7(%r11),_PIF_PER_TRAP
680 mvc __THREAD_per_address(8,%r14),__LC_PER_ADDRESS
681 mvc __THREAD_per_cause(2,%r14),__LC_PER_CODE
682 mvc __THREAD_per_paid(1,%r14),__LC_PER_ACCESS_ID
684 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
685 larl %r1,pgm_check_table
686 llgh %r10,__PT_INT_CODE+2(%r11)
690 lg %r9,0(%r10,%r1) # load address of handler routine
691 lgr %r2,%r11 # pass pointer to pt_regs
692 BASR_EX %r14,%r9 # branch to interrupt-handler
695 tm __PT_PSW+1(%r11),0x01 # returning to user ?
697 TSTMSK __PT_FLAGS(%r11),_PIF_SYSCALL
702 # PER event in supervisor state, must be kprobes
706 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
707 lgr %r2,%r11 # pass pointer to pt_regs
708 brasl %r14,do_per_trap
712 # single stepped system call
715 mvc __LC_RETURN_PSW(8),__LC_SVC_NEW_PSW
716 lghi %r13,__TASK_thread
718 stg %r14,__LC_RETURN_PSW+8
719 lghi %r14,_PIF_SYSCALL | _PIF_PER_TRAP
720 lpswe __LC_RETURN_PSW # branch to .Lsysc_per and enable irqs
721 ENDPROC(pgm_check_handler)
724 * IO interrupt handler routine
726 ENTRY(io_int_handler)
728 stpt __LC_ASYNC_ENTER_TIMER
730 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
732 larl %r13,cleanup_critical
733 lmg %r8,%r9,__LC_IO_OLD_PSW
734 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER
735 stmg %r0,%r7,__PT_R0(%r11)
736 # clear user controlled registers to prevent speculative use
746 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
747 stmg %r8,%r9,__PT_PSW(%r11)
748 mvc __PT_INT_CODE(12,%r11),__LC_SUBCHANNEL_ID
749 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
750 TSTMSK __LC_CPU_FLAGS,_CIF_IGNORE_IRQ
753 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
755 lgr %r2,%r11 # pass pointer to pt_regs
756 lghi %r3,IO_INTERRUPT
757 tm __PT_INT_CODE+8(%r11),0x80 # adapter interrupt ?
759 lghi %r3,THIN_INTERRUPT
762 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_LPAR
766 mvc __PT_INT_CODE(12,%r11),__LC_SUBCHANNEL_ID
772 TSTMSK __TI_flags(%r12),_TIF_WORK
773 jnz .Lio_work # there is work to do (signals etc.)
774 TSTMSK __LC_CPU_FLAGS,_CIF_WORK
777 lg %r14,__LC_VDSO_PER_CPU
778 lmg %r0,%r10,__PT_R0(%r11)
779 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
780 tm __PT_PSW+1(%r11),0x01 # returning to user ?
782 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
785 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
787 lmg %r11,%r15,__PT_R11(%r11)
788 b __LC_RETURN_LPSWE(%r0)
792 # There is work todo, find out in which context we have been interrupted:
793 # 1) if we return to user space we can do all _TIF_WORK work
794 # 2) if we return to kernel code and kvm is enabled check if we need to
795 # modify the psw to leave SIE
796 # 3) if we return to kernel code and preemptive scheduling is enabled check
797 # the preemption counter and if it is zero call preempt_schedule_irq
798 # Before any work can be done, a switch to the kernel stack is required.
801 tm __PT_PSW+1(%r11),0x01 # returning to user ?
802 jo .Lio_work_user # yes -> do resched & signal
803 #ifdef CONFIG_PREEMPTION
804 # check for preemptive scheduling
805 icm %r0,15,__LC_PREEMPT_COUNT
806 jnz .Lio_restore # preemption is disabled
807 TSTMSK __TI_flags(%r12),_TIF_NEED_RESCHED
809 # switch to kernel stack
810 lg %r1,__PT_R15(%r11)
811 aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
812 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
813 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
814 la %r11,STACK_FRAME_OVERHEAD(%r1)
816 # TRACE_IRQS_ON already done at .Lio_return, call
817 # TRACE_IRQS_OFF to keep things symmetrical
819 brasl %r14,preempt_schedule_irq
826 # Need to do work before returning to userspace, switch to kernel stack
829 lg %r1,__LC_KERNEL_STACK
830 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
831 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
832 la %r11,STACK_FRAME_OVERHEAD(%r1)
836 # One of the work bits is on. Find out which one.
839 TSTMSK __LC_CPU_FLAGS,_CIF_MCCK_PENDING
841 TSTMSK __TI_flags(%r12),_TIF_NEED_RESCHED
843 #ifdef CONFIG_LIVEPATCH
844 TSTMSK __TI_flags(%r12),_TIF_PATCH_PENDING
845 jo .Lio_patch_pending
847 TSTMSK __TI_flags(%r12),_TIF_SIGPENDING
849 TSTMSK __TI_flags(%r12),_TIF_NOTIFY_RESUME
850 jo .Lio_notify_resume
851 TSTMSK __TI_flags(%r12),_TIF_GUARDED_STORAGE
852 jo .Lio_guarded_storage
853 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
855 TSTMSK __LC_CPU_FLAGS,(_CIF_ASCE_PRIMARY|_CIF_ASCE_SECONDARY)
857 j .Lio_return # beware of critical section cleanup
860 # _CIF_MCCK_PENDING is set, call handler
863 # TRACE_IRQS_ON already done at .Lio_return
864 brasl %r14,s390_handle_mcck # TIF bit will be cleared by handler
869 # _CIF_ASCE_PRIMARY and/or CIF_ASCE_SECONDARY set, load user space asce
872 ni __LC_CPU_FLAGS+7,255-_CIF_ASCE_SECONDARY
873 lctlg %c7,%c7,__LC_VDSO_ASCE # load secondary asce
874 TSTMSK __LC_CPU_FLAGS,_CIF_ASCE_PRIMARY
876 #ifndef CONFIG_HAVE_MARCH_Z10_FEATURES
877 tm __LC_STFLE_FAC_LIST+3,0x10 # has MVCOS ?
878 jnz .Lio_set_fs_fixup
879 ni __LC_CPU_FLAGS+7,255-_CIF_ASCE_PRIMARY
880 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
884 larl %r14,.Lio_return
888 # CIF_FPU is set, restore floating-point controls and floating-point registers.
891 larl %r14,.Lio_return
895 # _TIF_GUARDED_STORAGE is set, call guarded_storage_load
897 .Lio_guarded_storage:
898 # TRACE_IRQS_ON already done at .Lio_return
899 ssm __LC_SVC_NEW_PSW # reenable interrupts
900 lgr %r2,%r11 # pass pointer to pt_regs
901 brasl %r14,gs_load_bc_cb
902 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
907 # _TIF_NEED_RESCHED is set, call schedule
910 # TRACE_IRQS_ON already done at .Lio_return
911 ssm __LC_SVC_NEW_PSW # reenable interrupts
912 brasl %r14,schedule # call scheduler
913 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
918 # _TIF_PATCH_PENDING is set, call klp_update_patch_state
920 #ifdef CONFIG_LIVEPATCH
922 lg %r2,__LC_CURRENT # pass pointer to task struct
923 larl %r14,.Lio_return
924 jg klp_update_patch_state
928 # _TIF_SIGPENDING or is set, call do_signal
931 # TRACE_IRQS_ON already done at .Lio_return
932 ssm __LC_SVC_NEW_PSW # reenable interrupts
933 lgr %r2,%r11 # pass pointer to pt_regs
935 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
940 # _TIF_NOTIFY_RESUME or is set, call do_notify_resume
943 # TRACE_IRQS_ON already done at .Lio_return
944 ssm __LC_SVC_NEW_PSW # reenable interrupts
945 lgr %r2,%r11 # pass pointer to pt_regs
946 brasl %r14,do_notify_resume
947 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
950 ENDPROC(io_int_handler)
953 * External interrupt handler routine
955 ENTRY(ext_int_handler)
957 stpt __LC_ASYNC_ENTER_TIMER
959 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
961 larl %r13,cleanup_critical
962 lmg %r8,%r9,__LC_EXT_OLD_PSW
963 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER
964 stmg %r0,%r7,__PT_R0(%r11)
965 # clear user controlled registers to prevent speculative use
975 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
976 stmg %r8,%r9,__PT_PSW(%r11)
977 lghi %r1,__LC_EXT_PARAMS2
978 mvc __PT_INT_CODE(4,%r11),__LC_EXT_CPU_ADDR
979 mvc __PT_INT_PARM(4,%r11),__LC_EXT_PARAMS
980 mvc __PT_INT_PARM_LONG(8,%r11),0(%r1)
981 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
982 TSTMSK __LC_CPU_FLAGS,_CIF_IGNORE_IRQ
985 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
986 lgr %r2,%r11 # pass pointer to pt_regs
987 lghi %r3,EXT_INTERRUPT
990 ENDPROC(ext_int_handler)
993 * Load idle PSW. The second "half" of this function is in .Lcleanup_idle.
996 stg %r3,__SF_EMPTY(%r15)
997 larl %r1,.Lpsw_idle_lpsw+4
998 stg %r1,__SF_EMPTY+8(%r15)
999 larl %r1,smp_cpu_mtid
1002 jz .Lpsw_idle_stcctm
1003 .insn rsy,0xeb0000000017,%r1,5,__SF_EMPTY+16(%r15)
1005 oi __LC_CPU_FLAGS+7,_CIF_ENABLED_WAIT
1007 STCK __CLOCK_IDLE_ENTER(%r2)
1008 stpt __TIMER_IDLE_ENTER(%r2)
1010 lpswe __SF_EMPTY(%r15)
1016 * Store floating-point controls and floating-point or vector register
1017 * depending whether the vector facility is available. A critical section
1018 * cleanup assures that the registers are stored even if interrupted for
1019 * some other work. The CIF_FPU flag is set to trigger a lazy restore
1020 * of the register contents at return from io or a system call.
1022 ENTRY(save_fpu_regs)
1024 aghi %r2,__TASK_thread
1025 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
1026 jo .Lsave_fpu_regs_exit
1027 stfpc __THREAD_FPU_fpc(%r2)
1028 lg %r3,__THREAD_FPU_regs(%r2)
1029 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
1030 jz .Lsave_fpu_regs_fp # no -> store FP regs
1031 VSTM %v0,%v15,0,%r3 # vstm 0,15,0(3)
1032 VSTM %v16,%v31,256,%r3 # vstm 16,31,256(3)
1033 j .Lsave_fpu_regs_done # -> set CIF_FPU flag
1051 .Lsave_fpu_regs_done:
1052 oi __LC_CPU_FLAGS+7,_CIF_FPU
1053 .Lsave_fpu_regs_exit:
1055 .Lsave_fpu_regs_end:
1056 ENDPROC(save_fpu_regs)
1057 EXPORT_SYMBOL(save_fpu_regs)
1060 * Load floating-point controls and floating-point or vector registers.
1061 * A critical section cleanup assures that the register contents are
1062 * loaded even if interrupted for some other work.
1064 * There are special calling conventions to fit into sysc and io return work:
1065 * %r15: <kernel stack>
1066 * The function requires:
1071 aghi %r4,__TASK_thread
1072 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
1073 jno .Lload_fpu_regs_exit
1074 lfpc __THREAD_FPU_fpc(%r4)
1075 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
1076 lg %r4,__THREAD_FPU_regs(%r4) # %r4 <- reg save area
1077 jz .Lload_fpu_regs_fp # -> no VX, load FP regs
1079 VLM %v16,%v31,256,%r4
1080 j .Lload_fpu_regs_done
1098 .Lload_fpu_regs_done:
1099 ni __LC_CPU_FLAGS+7,255-_CIF_FPU
1100 .Lload_fpu_regs_exit:
1102 .Lload_fpu_regs_end:
1103 ENDPROC(load_fpu_regs)
1108 * Machine check handler routines
1110 ENTRY(mcck_int_handler)
1111 STCK __LC_MCCK_CLOCK
1113 la %r1,4095 # validate r1
1114 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # validate cpu timer
1115 sckc __LC_CLOCK_COMPARATOR # validate comparator
1116 lam %a0,%a15,__LC_AREGS_SAVE_AREA-4095(%r1) # validate acrs
1117 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# validate gprs
1118 lg %r12,__LC_CURRENT
1119 larl %r13,cleanup_critical
1120 lmg %r8,%r9,__LC_MCK_OLD_PSW
1121 TSTMSK __LC_MCCK_CODE,MCCK_CODE_SYSTEM_DAMAGE
1122 jo .Lmcck_panic # yes -> rest of mcck code invalid
1123 TSTMSK __LC_MCCK_CODE,MCCK_CODE_CR_VALID
1124 jno .Lmcck_panic # control registers invalid -> panic
1126 lctlg %c0,%c15,__LC_CREGS_SAVE_AREA-4095(%r14) # validate ctl regs
1128 lg %r11,__LC_MCESAD-4095(%r14) # extended machine check save area
1129 nill %r11,0xfc00 # MCESA_ORIGIN_MASK
1130 TSTMSK __LC_CREGS_SAVE_AREA+16-4095(%r14),CR2_GUARDED_STORAGE
1132 TSTMSK __LC_MCCK_CODE,MCCK_CODE_GS_VALID
1134 .insn rxy,0xe3000000004d,0,__MCESA_GS_SAVE_AREA(%r11) # LGSC
1135 0: l %r14,__LC_FP_CREG_SAVE_AREA-4095(%r14)
1136 TSTMSK __LC_MCCK_CODE,MCCK_CODE_FC_VALID
1140 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
1142 lghi %r14,__LC_FPREGS_SAVE_AREA
1160 0: VLM %v0,%v15,0,%r11
1161 VLM %v16,%v31,256,%r11
1162 1: lghi %r14,__LC_CPU_TIMER_SAVE_AREA
1163 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
1164 TSTMSK __LC_MCCK_CODE,MCCK_CODE_CPU_TIMER_VALID
1166 la %r14,__LC_SYNC_ENTER_TIMER
1167 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
1169 la %r14,__LC_ASYNC_ENTER_TIMER
1170 0: clc 0(8,%r14),__LC_EXIT_TIMER
1172 la %r14,__LC_EXIT_TIMER
1173 1: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
1175 la %r14,__LC_LAST_UPDATE_TIMER
1177 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
1178 3: TSTMSK __LC_MCCK_CODE,MCCK_CODE_PSW_MWP_VALID
1180 tmhh %r8,0x0001 # interrupting from user ?
1182 TSTMSK __LC_MCCK_CODE,MCCK_CODE_PSW_IA_VALID
1184 4: ssm __LC_PGM_NEW_PSW # turn dat on, keep irqs off
1185 SWITCH_ASYNC __LC_GPREGS_SAVE_AREA+64,__LC_MCCK_ENTER_TIMER
1187 lghi %r14,__LC_GPREGS_SAVE_AREA+64
1188 stmg %r0,%r7,__PT_R0(%r11)
1189 # clear user controlled registers to prevent speculative use
1199 mvc __PT_R8(64,%r11),0(%r14)
1200 stmg %r8,%r9,__PT_PSW(%r11)
1201 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
1202 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
1203 lgr %r2,%r11 # pass pointer to pt_regs
1204 brasl %r14,s390_do_machine_check
1205 tm __PT_PSW+1(%r11),0x01 # returning to user ?
1207 lg %r1,__LC_KERNEL_STACK # switch to kernel stack
1208 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
1209 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
1210 la %r11,STACK_FRAME_OVERHEAD(%r1)
1212 TSTMSK __LC_CPU_FLAGS,_CIF_MCCK_PENDING
1215 brasl %r14,s390_handle_mcck
1218 lg %r14,__LC_VDSO_PER_CPU
1219 lmg %r0,%r10,__PT_R0(%r11)
1220 mvc __LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW
1221 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
1223 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
1224 stpt __LC_EXIT_TIMER
1225 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
1226 0: lmg %r11,%r15,__PT_R11(%r11)
1227 b __LC_RETURN_MCCK_LPSWE
1230 lg %r15,__LC_NODAT_STACK
1231 la %r11,STACK_FRAME_OVERHEAD(%r15)
1233 ENDPROC(mcck_int_handler)
1236 # PSW restart interrupt handler
1238 ENTRY(restart_int_handler)
1239 ALTERNATIVE "", ".insn s,0xb2800000,_LPP_OFFSET", 40
1240 stg %r15,__LC_SAVE_AREA_RESTART
1241 lg %r15,__LC_RESTART_STACK
1242 xc STACK_FRAME_OVERHEAD(__PT_SIZE,%r15),STACK_FRAME_OVERHEAD(%r15)
1243 stmg %r0,%r14,STACK_FRAME_OVERHEAD+__PT_R0(%r15)
1244 mvc STACK_FRAME_OVERHEAD+__PT_R15(8,%r15),__LC_SAVE_AREA_RESTART
1245 mvc STACK_FRAME_OVERHEAD+__PT_PSW(16,%r15),__LC_RST_OLD_PSW
1246 xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15)
1247 lg %r1,__LC_RESTART_FN # load fn, parm & source cpu
1248 lg %r2,__LC_RESTART_DATA
1249 lg %r3,__LC_RESTART_SOURCE
1250 ltgr %r3,%r3 # test source cpu address
1251 jm 1f # negative -> skip source stop
1252 0: sigp %r4,%r3,SIGP_SENSE # sigp sense to source cpu
1253 brc 10,0b # wait for status stored
1254 1: basr %r14,%r1 # call function
1255 stap __SF_EMPTY(%r15) # store cpu address
1256 llgh %r3,__SF_EMPTY(%r15)
1257 2: sigp %r4,%r3,SIGP_STOP # sigp stop to current cpu
1260 ENDPROC(restart_int_handler)
1262 .section .kprobes.text, "ax"
1264 #if defined(CONFIG_CHECK_STACK) || defined(CONFIG_VMAP_STACK)
1266 * The synchronous or the asynchronous stack overflowed. We are dead.
1267 * No need to properly save the registers, we are going to panic anyway.
1268 * Setup a pt_regs so that show_trace can provide a good call trace.
1270 ENTRY(stack_overflow)
1271 lg %r15,__LC_NODAT_STACK # change to panic stack
1272 la %r11,STACK_FRAME_OVERHEAD(%r15)
1273 stmg %r0,%r7,__PT_R0(%r11)
1274 stmg %r8,%r9,__PT_PSW(%r11)
1275 mvc __PT_R8(64,%r11),0(%r14)
1276 stg %r10,__PT_ORIG_GPR2(%r11) # store last break to orig_gpr2
1277 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
1278 lgr %r2,%r11 # pass pointer to pt_regs
1279 jg kernel_stack_overflow
1280 ENDPROC(stack_overflow)
1283 ENTRY(cleanup_critical)
1284 cghi %r9,__LC_RETURN_LPSWE
1286 #if IS_ENABLED(CONFIG_KVM)
1287 clg %r9,BASED(.Lcleanup_table_sie) # .Lsie_gmap
1289 clg %r9,BASED(.Lcleanup_table_sie+8)# .Lsie_done
1292 clg %r9,BASED(.Lcleanup_table) # system_call
1294 clg %r9,BASED(.Lcleanup_table+8) # .Lsysc_do_svc
1295 jl .Lcleanup_system_call
1296 clg %r9,BASED(.Lcleanup_table+16) # .Lsysc_tif
1298 clg %r9,BASED(.Lcleanup_table+24) # .Lsysc_restore
1299 jl .Lcleanup_sysc_tif
1300 clg %r9,BASED(.Lcleanup_table+32) # .Lsysc_done
1301 jl .Lcleanup_sysc_restore
1302 clg %r9,BASED(.Lcleanup_table+40) # .Lio_tif
1304 clg %r9,BASED(.Lcleanup_table+48) # .Lio_restore
1306 clg %r9,BASED(.Lcleanup_table+56) # .Lio_done
1307 jl .Lcleanup_io_restore
1308 clg %r9,BASED(.Lcleanup_table+64) # psw_idle
1310 clg %r9,BASED(.Lcleanup_table+72) # .Lpsw_idle_end
1312 clg %r9,BASED(.Lcleanup_table+80) # save_fpu_regs
1314 clg %r9,BASED(.Lcleanup_table+88) # .Lsave_fpu_regs_end
1315 jl .Lcleanup_save_fpu_regs
1316 clg %r9,BASED(.Lcleanup_table+96) # load_fpu_regs
1318 clg %r9,BASED(.Lcleanup_table+104) # .Lload_fpu_regs_end
1319 jl .Lcleanup_load_fpu_regs
1321 ENDPROC(cleanup_critical)
1328 .quad .Lsysc_restore
1334 .quad .Lpsw_idle_end
1336 .quad .Lsave_fpu_regs_end
1338 .quad .Lload_fpu_regs_end
1340 #if IS_ENABLED(CONFIG_KVM)
1341 .Lcleanup_table_sie:
1346 cghi %r11,__LC_SAVE_AREA_ASYNC #Is this in normal interrupt?
1348 slg %r9,BASED(.Lsie_crit_mcck_start)
1349 clg %r9,BASED(.Lsie_crit_mcck_length)
1351 oi __LC_CPU_FLAGS+7, _CIF_MCCK_GUEST
1352 1: BPENTER __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
1353 lg %r9,__SF_SIE_CONTROL(%r15) # get control block pointer
1354 ni __SIE_PROG0C+3(%r9),0xfe # no longer in SIE
1355 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
1356 larl %r9,sie_exit # skip forward to sie_exit
1360 .Lcleanup_system_call:
1361 # check if stpt has been executed
1362 clg %r9,BASED(.Lcleanup_system_call_insn)
1364 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
1365 cghi %r11,__LC_SAVE_AREA_ASYNC
1367 mvc __LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER
1368 0: # check if stmg has been executed
1369 clg %r9,BASED(.Lcleanup_system_call_insn+8)
1371 mvc __LC_SAVE_AREA_SYNC(64),0(%r11)
1372 0: # check if base register setup + TIF bit load has been done
1373 clg %r9,BASED(.Lcleanup_system_call_insn+16)
1375 # set up saved register r12 task struct pointer
1377 # set up saved register r13 __TASK_thread offset
1378 mvc 40(8,%r11),BASED(.Lcleanup_system_call_const)
1379 0: # check if the user time update has been done
1380 clg %r9,BASED(.Lcleanup_system_call_insn+24)
1382 lg %r15,__LC_EXIT_TIMER
1383 slg %r15,__LC_SYNC_ENTER_TIMER
1384 alg %r15,__LC_USER_TIMER
1385 stg %r15,__LC_USER_TIMER
1386 0: # check if the system time update has been done
1387 clg %r9,BASED(.Lcleanup_system_call_insn+32)
1389 lg %r15,__LC_LAST_UPDATE_TIMER
1390 slg %r15,__LC_EXIT_TIMER
1391 alg %r15,__LC_SYSTEM_TIMER
1392 stg %r15,__LC_SYSTEM_TIMER
1393 0: # update accounting time stamp
1394 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
1395 BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
1396 # set up saved register r11
1397 lg %r15,__LC_KERNEL_STACK
1398 la %r9,STACK_FRAME_OVERHEAD(%r15)
1399 stg %r9,24(%r11) # r11 pt_regs pointer
1401 mvc __PT_R8(64,%r9),__LC_SAVE_AREA_SYNC
1402 stmg %r0,%r7,__PT_R0(%r9)
1403 mvc __PT_PSW(16,%r9),__LC_SVC_OLD_PSW
1404 mvc __PT_INT_CODE(4,%r9),__LC_SVC_ILC
1405 xc __PT_FLAGS(8,%r9),__PT_FLAGS(%r9)
1406 mvi __PT_FLAGS+7(%r9),_PIF_SYSCALL
1407 # setup saved register r15
1408 stg %r15,56(%r11) # r15 stack pointer
1409 # set new psw address and exit
1410 larl %r9,.Lsysc_do_svc
1412 .Lcleanup_system_call_insn:
1416 .quad .Lsysc_vtime+36
1417 .quad .Lsysc_vtime+42
1418 .Lcleanup_system_call_const:
1425 .Lcleanup_sysc_restore:
1426 # check if stpt has been executed
1427 clg %r9,BASED(.Lcleanup_sysc_restore_insn)
1429 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
1430 cghi %r11,__LC_SAVE_AREA_ASYNC
1432 mvc __LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
1433 0: clg %r9,BASED(.Lcleanup_sysc_restore_insn+8)
1435 lg %r9,24(%r11) # get saved pointer to pt_regs
1436 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
1437 mvc 0(64,%r11),__PT_R8(%r9)
1438 lmg %r0,%r7,__PT_R0(%r9)
1440 1: lmg %r8,%r9,__LC_RETURN_PSW
1442 .Lcleanup_sysc_restore_insn:
1443 .quad .Lsysc_exit_timer
1444 .quad .Lsysc_done - 4
1450 .Lcleanup_io_restore:
1451 # check if stpt has been executed
1452 clg %r9,BASED(.Lcleanup_io_restore_insn)
1454 mvc __LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
1455 0: clg %r9,BASED(.Lcleanup_io_restore_insn+8)
1457 lg %r9,24(%r11) # get saved r11 pointer to pt_regs
1458 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
1459 mvc 0(64,%r11),__PT_R8(%r9)
1460 lmg %r0,%r7,__PT_R0(%r9)
1461 1: lmg %r8,%r9,__LC_RETURN_PSW
1463 .Lcleanup_io_restore_insn:
1464 .quad .Lio_exit_timer
1468 ni __LC_CPU_FLAGS+7,255-_CIF_ENABLED_WAIT
1469 # copy interrupt clock & cpu timer
1470 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_INT_CLOCK
1471 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_ASYNC_ENTER_TIMER
1472 cghi %r11,__LC_SAVE_AREA_ASYNC
1474 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_MCCK_CLOCK
1475 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_MCCK_ENTER_TIMER
1476 0: # check if stck & stpt have been executed
1477 clg %r9,BASED(.Lcleanup_idle_insn)
1479 mvc __CLOCK_IDLE_ENTER(8,%r2),__CLOCK_IDLE_EXIT(%r2)
1480 mvc __TIMER_IDLE_ENTER(8,%r2),__TIMER_IDLE_EXIT(%r2)
1481 1: # calculate idle cycles
1482 clg %r9,BASED(.Lcleanup_idle_insn)
1484 larl %r1,smp_cpu_mtid
1488 .insn rsy,0xeb0000000017,%r1,5,__SF_EMPTY+80(%r15)
1490 ag %r3,__LC_PERCPU_OFFSET
1491 la %r4,__SF_EMPTY+16(%r15)
1499 3: # account system time going idle
1500 lg %r9,__LC_STEAL_TIMER
1501 alg %r9,__CLOCK_IDLE_ENTER(%r2)
1502 slg %r9,__LC_LAST_UPDATE_CLOCK
1503 stg %r9,__LC_STEAL_TIMER
1504 mvc __LC_LAST_UPDATE_CLOCK(8),__CLOCK_IDLE_EXIT(%r2)
1505 lg %r9,__LC_SYSTEM_TIMER
1506 alg %r9,__LC_LAST_UPDATE_TIMER
1507 slg %r9,__TIMER_IDLE_ENTER(%r2)
1508 stg %r9,__LC_SYSTEM_TIMER
1509 mvc __LC_LAST_UPDATE_TIMER(8),__TIMER_IDLE_EXIT(%r2)
1510 # prepare return psw
1511 nihh %r8,0xfcfd # clear irq & wait state bits
1512 lg %r9,48(%r11) # return from psw_idle
1514 .Lcleanup_idle_insn:
1515 .quad .Lpsw_idle_lpsw
1517 .Lcleanup_save_fpu_regs:
1518 larl %r9,save_fpu_regs
1521 .Lcleanup_load_fpu_regs:
1522 larl %r9,load_fpu_regs
1530 .quad .L__critical_start
1532 .quad .L__critical_end - .L__critical_start
1533 #if IS_ENABLED(CONFIG_KVM)
1534 .Lsie_critical_start:
1536 .Lsie_critical_length:
1537 .quad .Lsie_done - .Lsie_gmap
1538 .Lsie_crit_mcck_start:
1540 .Lsie_crit_mcck_length:
1541 .quad .Lsie_skip - .Lsie_entry
1543 .section .rodata, "a"
1544 #define SYSCALL(esame,emu) .quad __s390x_ ## esame
1545 .globl sys_call_table
1547 #include "asm/syscall_table.h"
1550 #ifdef CONFIG_COMPAT
1552 #define SYSCALL(esame,emu) .quad __s390_ ## emu
1553 .globl sys_call_table_emu
1555 #include "asm/syscall_table.h"