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 slg %r14,BASED(.Lcritical_start)
121 clg %r14,BASED(.Lcritical_length)
123 lghi %r11,\savearea # inside critical section, do cleanup
124 brasl %r14,cleanup_critical
125 tmhh %r8,0x0001 # retest problem state after cleanup
127 0: lg %r14,__LC_ASYNC_STACK # are we already on the target stack?
129 srag %r14,%r14,STACK_SHIFT
131 CHECK_STACK \savearea
132 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
134 1: UPDATE_VTIME %r14,%r15,\timer
135 BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
136 2: lg %r15,__LC_ASYNC_STACK # load async stack
137 3: la %r11,STACK_FRAME_OVERHEAD(%r15)
140 .macro UPDATE_VTIME w1,w2,enter_timer
141 lg \w1,__LC_EXIT_TIMER
142 lg \w2,__LC_LAST_UPDATE_TIMER
144 slg \w2,__LC_EXIT_TIMER
145 alg \w1,__LC_USER_TIMER
146 alg \w2,__LC_SYSTEM_TIMER
147 stg \w1,__LC_USER_TIMER
148 stg \w2,__LC_SYSTEM_TIMER
149 mvc __LC_LAST_UPDATE_TIMER(8),\enter_timer
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
167 * The TSTMSK macro generates a test-under-mask instruction by
168 * calculating the memory offset for the specified mask value.
169 * Mask value can be any constant. The macro shifts the mask
170 * value to calculate the memory offset for the test-under-mask
173 .macro TSTMSK addr, mask, size=8, bytepos=0
174 .if (\bytepos < \size) && (\mask >> 8)
176 .error "Mask exceeds byte boundary"
178 TSTMSK \addr, "(\mask >> 8)", \size, "(\bytepos + 1)"
182 .error "Mask must not be zero"
184 off = \size - \bytepos - 1
189 ALTERNATIVE "", ".long 0xb2e8c000", 82
193 ALTERNATIVE "", ".long 0xb2e8d000", 82
196 .macro BPENTER tif_ptr,tif_mask
197 ALTERNATIVE "TSTMSK \tif_ptr,\tif_mask; jz .+8; .long 0xb2e8d000", \
201 .macro BPEXIT tif_ptr,tif_mask
202 TSTMSK \tif_ptr,\tif_mask
203 ALTERNATIVE "jz .+8; .long 0xb2e8c000", \
204 "jnz .+8; .long 0xb2e8d000", 82
209 GEN_BR_THUNK %r14,%r11
211 .section .kprobes.text, "ax"
214 * This nop exists only in order to avoid that __switch_to starts at
215 * the beginning of the kprobes text section. In that case we would
216 * have several symbols at the same address. E.g. objdump would take
217 * an arbitrary symbol name when disassembling this code.
218 * With the added nop in between the __switch_to symbol is unique
230 * Scheduler resume function, called by switch_to
231 * gpr2 = (task_struct *) prev
232 * gpr3 = (task_struct *) next
237 stmg %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task
238 lghi %r4,__TASK_stack
239 lghi %r1,__TASK_thread
241 stg %r15,__THREAD_ksp(%r1,%r2) # store kernel stack of prev
242 lg %r15,0(%r4,%r3) # start of kernel stack of next
243 agr %r15,%r5 # end of kernel stack of next
244 stg %r3,__LC_CURRENT # store task struct of next
245 stg %r15,__LC_KERNEL_STACK # store end of kernel stack
246 lg %r15,__THREAD_ksp(%r1,%r3) # load kernel stack of next
248 mvc __LC_CURRENT_PID(4,%r0),0(%r3) # store pid of next
249 lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task
250 ALTERNATIVE "", ".insn s,0xb2800000,_LPP_OFFSET", 40
256 #if IS_ENABLED(CONFIG_KVM)
258 * sie64a calling convention:
259 * %r2 pointer to sie control block
260 * %r3 guest register save area
263 stmg %r6,%r14,__SF_GPRS(%r15) # save kernel registers
265 stg %r2,__SF_SIE_CONTROL(%r15) # save control block pointer
266 stg %r3,__SF_SIE_SAVEAREA(%r15) # save guest register save area
267 xc __SF_SIE_REASON(8,%r15),__SF_SIE_REASON(%r15) # reason code = 0
268 mvc __SF_SIE_FLAGS(8,%r15),__TI_flags(%r12) # copy thread flags
269 TSTMSK __LC_CPU_FLAGS,_CIF_FPU # load guest fp/vx registers ?
270 jno .Lsie_load_guest_gprs
271 brasl %r14,load_fpu_regs # load guest fp/vx regs
272 .Lsie_load_guest_gprs:
273 lmg %r0,%r13,0(%r3) # load guest gprs 0-13
274 lg %r14,__LC_GMAP # get gmap pointer
277 lctlg %c1,%c1,__GMAP_ASCE(%r14) # load primary asce
279 lg %r14,__SF_SIE_CONTROL(%r15) # get control block pointer
280 oi __SIE_PROG0C+3(%r14),1 # we are going into SIE now
281 tm __SIE_PROG20+3(%r14),3 # last exit...
283 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
284 jo .Lsie_skip # exit if fp/vx regs changed
285 BPEXIT __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
290 BPENTER __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
292 ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE
293 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
295 # some program checks are suppressing. C code (e.g. do_protection_exception)
296 # will rewind the PSW by the ILC, which is often 4 bytes in case of SIE. There
297 # are some corner cases (e.g. runtime instrumentation) where ILC is unpredictable.
298 # Other instructions between sie64a and .Lsie_done should not cause program
299 # interrupts. So lets use 3 nops as a landing pad for all possible rewinds.
300 # See also .Lcleanup_sie
309 lg %r14,__SF_SIE_SAVEAREA(%r15) # load guest register save area
310 stmg %r0,%r13,0(%r14) # save guest gprs 0-13
311 xgr %r0,%r0 # clear guest registers to
312 xgr %r1,%r1 # prevent speculative use
317 lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers
318 lg %r2,__SF_SIE_REASON(%r15) # return exit reason code
322 stg %r14,__SF_SIE_REASON(%r15) # set exit reason code
325 EX_TABLE(.Lrewind_pad6,.Lsie_fault)
326 EX_TABLE(.Lrewind_pad4,.Lsie_fault)
327 EX_TABLE(.Lrewind_pad2,.Lsie_fault)
328 EX_TABLE(sie_exit,.Lsie_fault)
330 EXPORT_SYMBOL(sie64a)
331 EXPORT_SYMBOL(sie_exit)
335 * SVC interrupt handler routine. System calls are synchronous events and
336 * are executed with interrupts enabled.
340 stpt __LC_SYNC_ENTER_TIMER
342 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
345 lghi %r13,__TASK_thread
346 lghi %r14,_PIF_SYSCALL
348 lg %r15,__LC_KERNEL_STACK
349 la %r11,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs
351 UPDATE_VTIME %r8,%r9,__LC_SYNC_ENTER_TIMER
352 BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
353 stmg %r0,%r7,__PT_R0(%r11)
354 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
355 mvc __PT_PSW(16,%r11),__LC_SVC_OLD_PSW
356 mvc __PT_INT_CODE(4,%r11),__LC_SVC_ILC
357 stg %r14,__PT_FLAGS(%r11)
359 # clear user controlled register to prevent speculative use
361 # load address of system call table
362 lg %r10,__THREAD_sysc_table(%r13,%r12)
363 llgh %r8,__PT_INT_CODE+2(%r11)
364 slag %r8,%r8,3 # shift and test for svc 0
366 # svc 0: system call number in %r1
367 llgfr %r1,%r1 # clear high word in r1
370 sth %r1,__PT_INT_CODE+2(%r11)
373 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
374 stg %r2,__PT_ORIG_GPR2(%r11)
375 stg %r7,STACK_FRAME_OVERHEAD(%r15)
376 lg %r9,0(%r8,%r10) # get system call add.
377 TSTMSK __TI_flags(%r12),_TIF_TRACE
379 BASR_EX %r14,%r9 # call sys_xxxx
380 stg %r2,__PT_R2(%r11) # store return value
383 #ifdef CONFIG_DEBUG_RSEQ
385 brasl %r14,rseq_syscall
389 TSTMSK __PT_FLAGS(%r11),_PIF_WORK
391 TSTMSK __TI_flags(%r12),_TIF_WORK
392 jnz .Lsysc_work # check for work
393 TSTMSK __LC_CPU_FLAGS,_CIF_WORK
395 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
397 lg %r14,__LC_VDSO_PER_CPU
398 lmg %r0,%r10,__PT_R0(%r11)
399 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
402 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
403 lmg %r11,%r15,__PT_R11(%r11)
404 lpswe __LC_RETURN_PSW
408 # One of the work bits is on. Find out which one.
411 TSTMSK __LC_CPU_FLAGS,_CIF_MCCK_PENDING
412 jo .Lsysc_mcck_pending
413 TSTMSK __TI_flags(%r12),_TIF_NEED_RESCHED
415 TSTMSK __PT_FLAGS(%r11),_PIF_SYSCALL_RESTART
416 jo .Lsysc_syscall_restart
417 #ifdef CONFIG_UPROBES
418 TSTMSK __TI_flags(%r12),_TIF_UPROBE
419 jo .Lsysc_uprobe_notify
421 TSTMSK __TI_flags(%r12),_TIF_GUARDED_STORAGE
422 jo .Lsysc_guarded_storage
423 TSTMSK __PT_FLAGS(%r11),_PIF_PER_TRAP
425 #ifdef CONFIG_LIVEPATCH
426 TSTMSK __TI_flags(%r12),_TIF_PATCH_PENDING
427 jo .Lsysc_patch_pending # handle live patching just before
428 # signals and possible syscall restart
430 TSTMSK __PT_FLAGS(%r11),_PIF_SYSCALL_RESTART
431 jo .Lsysc_syscall_restart
432 TSTMSK __TI_flags(%r12),_TIF_SIGPENDING
434 TSTMSK __TI_flags(%r12),_TIF_NOTIFY_RESUME
435 jo .Lsysc_notify_resume
436 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
438 TSTMSK __LC_CPU_FLAGS,(_CIF_ASCE_PRIMARY|_CIF_ASCE_SECONDARY)
440 j .Lsysc_return # beware of critical section cleanup
443 # _TIF_NEED_RESCHED is set, call schedule
446 larl %r14,.Lsysc_return
450 # _CIF_MCCK_PENDING is set, call handler
453 larl %r14,.Lsysc_return
454 jg s390_handle_mcck # TIF bit will be cleared by handler
457 # _CIF_ASCE_PRIMARY and/or _CIF_ASCE_SECONDARY set, load user space asce
460 ni __LC_CPU_FLAGS+7,255-_CIF_ASCE_SECONDARY
461 lctlg %c7,%c7,__LC_VDSO_ASCE # load secondary asce
462 TSTMSK __LC_CPU_FLAGS,_CIF_ASCE_PRIMARY
464 #ifndef CONFIG_HAVE_MARCH_Z10_FEATURES
465 tm __LC_STFLE_FAC_LIST+3,0x10 # has MVCOS ?
466 jnz .Lsysc_set_fs_fixup
467 ni __LC_CPU_FLAGS+7,255-_CIF_ASCE_PRIMARY
468 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
472 larl %r14,.Lsysc_return
476 # CIF_FPU is set, restore floating-point controls and floating-point registers.
479 larl %r14,.Lsysc_return
483 # _TIF_SIGPENDING is set, call do_signal
486 lgr %r2,%r11 # pass pointer to pt_regs
488 TSTMSK __PT_FLAGS(%r11),_PIF_SYSCALL
491 lghi %r13,__TASK_thread
492 lmg %r2,%r7,__PT_R2(%r11) # load svc arguments
493 lghi %r1,0 # svc 0 returns -ENOSYS
497 # _TIF_NOTIFY_RESUME is set, call do_notify_resume
499 .Lsysc_notify_resume:
500 lgr %r2,%r11 # pass pointer to pt_regs
501 larl %r14,.Lsysc_return
505 # _TIF_UPROBE is set, call uprobe_notify_resume
507 #ifdef CONFIG_UPROBES
508 .Lsysc_uprobe_notify:
509 lgr %r2,%r11 # pass pointer to pt_regs
510 larl %r14,.Lsysc_return
511 jg uprobe_notify_resume
515 # _TIF_GUARDED_STORAGE is set, call guarded_storage_load
517 .Lsysc_guarded_storage:
518 lgr %r2,%r11 # pass pointer to pt_regs
519 larl %r14,.Lsysc_return
522 # _TIF_PATCH_PENDING is set, call klp_update_patch_state
524 #ifdef CONFIG_LIVEPATCH
525 .Lsysc_patch_pending:
526 lg %r2,__LC_CURRENT # pass pointer to task struct
527 larl %r14,.Lsysc_return
528 jg klp_update_patch_state
532 # _PIF_PER_TRAP is set, call do_per_trap
535 ni __PT_FLAGS+7(%r11),255-_PIF_PER_TRAP
536 lgr %r2,%r11 # pass pointer to pt_regs
537 larl %r14,.Lsysc_return
541 # _PIF_SYSCALL_RESTART is set, repeat the current system call
543 .Lsysc_syscall_restart:
544 ni __PT_FLAGS+7(%r11),255-_PIF_SYSCALL_RESTART
545 lmg %r1,%r7,__PT_R1(%r11) # load svc arguments
546 lg %r2,__PT_ORIG_GPR2(%r11)
550 # call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
551 # and after the system call
554 lgr %r2,%r11 # pass pointer to pt_regs
556 llgh %r0,__PT_INT_CODE+2(%r11)
557 stg %r0,__PT_R2(%r11)
558 brasl %r14,do_syscall_trace_enter
565 lmg %r3,%r7,__PT_R3(%r11)
566 stg %r7,STACK_FRAME_OVERHEAD(%r15)
567 lg %r2,__PT_ORIG_GPR2(%r11)
568 BASR_EX %r14,%r9 # call sys_xxx
569 stg %r2,__PT_R2(%r11) # store return value
571 TSTMSK __TI_flags(%r12),_TIF_TRACE
573 lgr %r2,%r11 # pass pointer to pt_regs
574 larl %r14,.Lsysc_return
575 jg do_syscall_trace_exit
579 # a new process exits the kernel with ret_from_fork
582 la %r11,STACK_FRAME_OVERHEAD(%r15)
584 brasl %r14,schedule_tail
586 ssm __LC_SVC_NEW_PSW # reenable interrupts
587 tm __PT_PSW+1(%r11),0x01 # forking a kernel thread ?
589 # it's a kernel thread
590 lmg %r9,%r10,__PT_R9(%r11) # load gprs
594 ENDPROC(ret_from_fork)
596 ENTRY(kernel_thread_starter)
600 ENDPROC(kernel_thread_starter)
603 * Program check handler routine
606 ENTRY(pgm_check_handler)
607 stpt __LC_SYNC_ENTER_TIMER
609 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
610 lg %r10,__LC_LAST_BREAK
613 larl %r13,cleanup_critical
614 lmg %r8,%r9,__LC_PGM_OLD_PSW
615 tmhh %r8,0x0001 # test problem state bit
616 jnz 2f # -> fault in user space
617 #if IS_ENABLED(CONFIG_KVM)
618 # cleanup critical section for program checks in sie64a
620 slg %r14,BASED(.Lsie_critical_start)
621 clg %r14,BASED(.Lsie_critical_length)
623 lg %r14,__SF_SIE_CONTROL(%r15) # get control block pointer
624 ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE
625 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
626 larl %r9,sie_exit # skip forward to sie_exit
627 lghi %r11,_PIF_GUEST_FAULT
629 0: tmhh %r8,0x4000 # PER bit set in old PSW ?
630 jnz 1f # -> enabled, can't be a double fault
631 tm __LC_PGM_ILC+3,0x80 # check for per exception
632 jnz .Lpgm_svcper # -> single stepped svc
633 1: CHECK_STACK __LC_SAVE_AREA_SYNC
634 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
635 # CHECK_VMAP_STACK branches to stack_overflow or 4f
636 CHECK_VMAP_STACK __LC_SAVE_AREA_SYNC,4f
637 2: UPDATE_VTIME %r14,%r15,__LC_SYNC_ENTER_TIMER
638 BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
639 lg %r15,__LC_KERNEL_STACK
641 aghi %r14,__TASK_thread # pointer to thread_struct
642 lghi %r13,__LC_PGM_TDB
643 tm __LC_PGM_ILC+2,0x02 # check for transaction abort
645 mvc __THREAD_trap_tdb(256,%r14),0(%r13)
646 3: stg %r10,__THREAD_last_break(%r14)
648 la %r11,STACK_FRAME_OVERHEAD(%r15)
649 stmg %r0,%r7,__PT_R0(%r11)
650 # clear user controlled registers to prevent speculative use
659 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
660 stmg %r8,%r9,__PT_PSW(%r11)
661 mvc __PT_INT_CODE(4,%r11),__LC_PGM_ILC
662 mvc __PT_INT_PARM_LONG(8,%r11),__LC_TRANS_EXC_CODE
663 stg %r13,__PT_FLAGS(%r11)
664 stg %r10,__PT_ARGS(%r11)
665 tm __LC_PGM_ILC+3,0x80 # check for per exception
667 tmhh %r8,0x0001 # kernel per event ?
669 oi __PT_FLAGS+7(%r11),_PIF_PER_TRAP
670 mvc __THREAD_per_address(8,%r14),__LC_PER_ADDRESS
671 mvc __THREAD_per_cause(2,%r14),__LC_PER_CODE
672 mvc __THREAD_per_paid(1,%r14),__LC_PER_ACCESS_ID
674 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
675 larl %r1,pgm_check_table
676 llgh %r10,__PT_INT_CODE+2(%r11)
680 lg %r9,0(%r10,%r1) # load address of handler routine
681 lgr %r2,%r11 # pass pointer to pt_regs
682 BASR_EX %r14,%r9 # branch to interrupt-handler
685 tm __PT_PSW+1(%r11),0x01 # returning to user ?
687 TSTMSK __PT_FLAGS(%r11),_PIF_SYSCALL
692 # PER event in supervisor state, must be kprobes
696 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
697 lgr %r2,%r11 # pass pointer to pt_regs
698 brasl %r14,do_per_trap
702 # single stepped system call
705 mvc __LC_RETURN_PSW(8),__LC_SVC_NEW_PSW
706 lghi %r13,__TASK_thread
708 stg %r14,__LC_RETURN_PSW+8
709 lghi %r14,_PIF_SYSCALL | _PIF_PER_TRAP
710 lpswe __LC_RETURN_PSW # branch to .Lsysc_per and enable irqs
711 ENDPROC(pgm_check_handler)
714 * IO interrupt handler routine
716 ENTRY(io_int_handler)
718 stpt __LC_ASYNC_ENTER_TIMER
720 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
722 larl %r13,cleanup_critical
723 lmg %r8,%r9,__LC_IO_OLD_PSW
724 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER
725 stmg %r0,%r7,__PT_R0(%r11)
726 # clear user controlled registers to prevent speculative use
736 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
737 stmg %r8,%r9,__PT_PSW(%r11)
738 mvc __PT_INT_CODE(12,%r11),__LC_SUBCHANNEL_ID
739 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
740 TSTMSK __LC_CPU_FLAGS,_CIF_IGNORE_IRQ
743 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
745 lgr %r2,%r11 # pass pointer to pt_regs
746 lghi %r3,IO_INTERRUPT
747 tm __PT_INT_CODE+8(%r11),0x80 # adapter interrupt ?
749 lghi %r3,THIN_INTERRUPT
752 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_LPAR
756 mvc __PT_INT_CODE(12,%r11),__LC_SUBCHANNEL_ID
762 TSTMSK __TI_flags(%r12),_TIF_WORK
763 jnz .Lio_work # there is work to do (signals etc.)
764 TSTMSK __LC_CPU_FLAGS,_CIF_WORK
767 lg %r14,__LC_VDSO_PER_CPU
768 lmg %r0,%r10,__PT_R0(%r11)
769 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
770 tm __PT_PSW+1(%r11),0x01 # returning to user ?
772 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
775 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
777 lmg %r11,%r15,__PT_R11(%r11)
778 lpswe __LC_RETURN_PSW
782 # There is work todo, find out in which context we have been interrupted:
783 # 1) if we return to user space we can do all _TIF_WORK work
784 # 2) if we return to kernel code and kvm is enabled check if we need to
785 # modify the psw to leave SIE
786 # 3) if we return to kernel code and preemptive scheduling is enabled check
787 # the preemption counter and if it is zero call preempt_schedule_irq
788 # Before any work can be done, a switch to the kernel stack is required.
791 tm __PT_PSW+1(%r11),0x01 # returning to user ?
792 jo .Lio_work_user # yes -> do resched & signal
793 #ifdef CONFIG_PREEMPT
794 # check for preemptive scheduling
795 icm %r0,15,__LC_PREEMPT_COUNT
796 jnz .Lio_restore # preemption is disabled
797 TSTMSK __TI_flags(%r12),_TIF_NEED_RESCHED
799 # switch to kernel stack
800 lg %r1,__PT_R15(%r11)
801 aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
802 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
803 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
804 la %r11,STACK_FRAME_OVERHEAD(%r1)
806 # TRACE_IRQS_ON already done at .Lio_return, call
807 # TRACE_IRQS_OFF to keep things symmetrical
809 brasl %r14,preempt_schedule_irq
816 # Need to do work before returning to userspace, switch to kernel stack
819 lg %r1,__LC_KERNEL_STACK
820 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
821 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
822 la %r11,STACK_FRAME_OVERHEAD(%r1)
826 # One of the work bits is on. Find out which one.
829 TSTMSK __LC_CPU_FLAGS,_CIF_MCCK_PENDING
831 TSTMSK __TI_flags(%r12),_TIF_NEED_RESCHED
833 #ifdef CONFIG_LIVEPATCH
834 TSTMSK __TI_flags(%r12),_TIF_PATCH_PENDING
835 jo .Lio_patch_pending
837 TSTMSK __TI_flags(%r12),_TIF_SIGPENDING
839 TSTMSK __TI_flags(%r12),_TIF_NOTIFY_RESUME
840 jo .Lio_notify_resume
841 TSTMSK __TI_flags(%r12),_TIF_GUARDED_STORAGE
842 jo .Lio_guarded_storage
843 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
845 TSTMSK __LC_CPU_FLAGS,(_CIF_ASCE_PRIMARY|_CIF_ASCE_SECONDARY)
847 j .Lio_return # beware of critical section cleanup
850 # _CIF_MCCK_PENDING is set, call handler
853 # TRACE_IRQS_ON already done at .Lio_return
854 brasl %r14,s390_handle_mcck # TIF bit will be cleared by handler
859 # _CIF_ASCE_PRIMARY and/or CIF_ASCE_SECONDARY set, load user space asce
862 ni __LC_CPU_FLAGS+7,255-_CIF_ASCE_SECONDARY
863 lctlg %c7,%c7,__LC_VDSO_ASCE # load secondary asce
864 TSTMSK __LC_CPU_FLAGS,_CIF_ASCE_PRIMARY
866 #ifndef CONFIG_HAVE_MARCH_Z10_FEATURES
867 tm __LC_STFLE_FAC_LIST+3,0x10 # has MVCOS ?
868 jnz .Lio_set_fs_fixup
869 ni __LC_CPU_FLAGS+7,255-_CIF_ASCE_PRIMARY
870 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
874 larl %r14,.Lio_return
878 # CIF_FPU is set, restore floating-point controls and floating-point registers.
881 larl %r14,.Lio_return
885 # _TIF_GUARDED_STORAGE is set, call guarded_storage_load
887 .Lio_guarded_storage:
888 # TRACE_IRQS_ON already done at .Lio_return
889 ssm __LC_SVC_NEW_PSW # reenable interrupts
890 lgr %r2,%r11 # pass pointer to pt_regs
891 brasl %r14,gs_load_bc_cb
892 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
897 # _TIF_NEED_RESCHED is set, call schedule
900 # TRACE_IRQS_ON already done at .Lio_return
901 ssm __LC_SVC_NEW_PSW # reenable interrupts
902 brasl %r14,schedule # call scheduler
903 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
908 # _TIF_PATCH_PENDING is set, call klp_update_patch_state
910 #ifdef CONFIG_LIVEPATCH
912 lg %r2,__LC_CURRENT # pass pointer to task struct
913 larl %r14,.Lio_return
914 jg klp_update_patch_state
918 # _TIF_SIGPENDING or is set, call do_signal
921 # TRACE_IRQS_ON already done at .Lio_return
922 ssm __LC_SVC_NEW_PSW # reenable interrupts
923 lgr %r2,%r11 # pass pointer to pt_regs
925 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
930 # _TIF_NOTIFY_RESUME or is set, call do_notify_resume
933 # TRACE_IRQS_ON already done at .Lio_return
934 ssm __LC_SVC_NEW_PSW # reenable interrupts
935 lgr %r2,%r11 # pass pointer to pt_regs
936 brasl %r14,do_notify_resume
937 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
940 ENDPROC(io_int_handler)
943 * External interrupt handler routine
945 ENTRY(ext_int_handler)
947 stpt __LC_ASYNC_ENTER_TIMER
949 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
951 larl %r13,cleanup_critical
952 lmg %r8,%r9,__LC_EXT_OLD_PSW
953 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER
954 stmg %r0,%r7,__PT_R0(%r11)
955 # clear user controlled registers to prevent speculative use
965 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
966 stmg %r8,%r9,__PT_PSW(%r11)
967 lghi %r1,__LC_EXT_PARAMS2
968 mvc __PT_INT_CODE(4,%r11),__LC_EXT_CPU_ADDR
969 mvc __PT_INT_PARM(4,%r11),__LC_EXT_PARAMS
970 mvc __PT_INT_PARM_LONG(8,%r11),0(%r1)
971 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
972 TSTMSK __LC_CPU_FLAGS,_CIF_IGNORE_IRQ
975 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
976 lgr %r2,%r11 # pass pointer to pt_regs
977 lghi %r3,EXT_INTERRUPT
980 ENDPROC(ext_int_handler)
983 * Load idle PSW. The second "half" of this function is in .Lcleanup_idle.
986 stg %r3,__SF_EMPTY(%r15)
987 larl %r1,.Lpsw_idle_lpsw+4
988 stg %r1,__SF_EMPTY+8(%r15)
990 larl %r1,smp_cpu_mtid
994 .insn rsy,0xeb0000000017,%r1,5,__SF_EMPTY+16(%r15)
997 oi __LC_CPU_FLAGS+7,_CIF_ENABLED_WAIT
999 STCK __CLOCK_IDLE_ENTER(%r2)
1000 stpt __TIMER_IDLE_ENTER(%r2)
1002 lpswe __SF_EMPTY(%r15)
1008 * Store floating-point controls and floating-point or vector register
1009 * depending whether the vector facility is available. A critical section
1010 * cleanup assures that the registers are stored even if interrupted for
1011 * some other work. The CIF_FPU flag is set to trigger a lazy restore
1012 * of the register contents at return from io or a system call.
1014 ENTRY(save_fpu_regs)
1016 aghi %r2,__TASK_thread
1017 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
1018 jo .Lsave_fpu_regs_exit
1019 stfpc __THREAD_FPU_fpc(%r2)
1020 lg %r3,__THREAD_FPU_regs(%r2)
1021 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
1022 jz .Lsave_fpu_regs_fp # no -> store FP regs
1023 VSTM %v0,%v15,0,%r3 # vstm 0,15,0(3)
1024 VSTM %v16,%v31,256,%r3 # vstm 16,31,256(3)
1025 j .Lsave_fpu_regs_done # -> set CIF_FPU flag
1043 .Lsave_fpu_regs_done:
1044 oi __LC_CPU_FLAGS+7,_CIF_FPU
1045 .Lsave_fpu_regs_exit:
1047 .Lsave_fpu_regs_end:
1048 ENDPROC(save_fpu_regs)
1049 EXPORT_SYMBOL(save_fpu_regs)
1052 * Load floating-point controls and floating-point or vector registers.
1053 * A critical section cleanup assures that the register contents are
1054 * loaded even if interrupted for some other work.
1056 * There are special calling conventions to fit into sysc and io return work:
1057 * %r15: <kernel stack>
1058 * The function requires:
1063 aghi %r4,__TASK_thread
1064 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
1065 jno .Lload_fpu_regs_exit
1066 lfpc __THREAD_FPU_fpc(%r4)
1067 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
1068 lg %r4,__THREAD_FPU_regs(%r4) # %r4 <- reg save area
1069 jz .Lload_fpu_regs_fp # -> no VX, load FP regs
1071 VLM %v16,%v31,256,%r4
1072 j .Lload_fpu_regs_done
1090 .Lload_fpu_regs_done:
1091 ni __LC_CPU_FLAGS+7,255-_CIF_FPU
1092 .Lload_fpu_regs_exit:
1094 .Lload_fpu_regs_end:
1095 ENDPROC(load_fpu_regs)
1100 * Machine check handler routines
1102 ENTRY(mcck_int_handler)
1103 STCK __LC_MCCK_CLOCK
1105 la %r1,4095 # validate r1
1106 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # validate cpu timer
1107 sckc __LC_CLOCK_COMPARATOR # validate comparator
1108 lam %a0,%a15,__LC_AREGS_SAVE_AREA-4095(%r1) # validate acrs
1109 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# validate gprs
1110 lg %r12,__LC_CURRENT
1111 larl %r13,cleanup_critical
1112 lmg %r8,%r9,__LC_MCK_OLD_PSW
1113 TSTMSK __LC_MCCK_CODE,MCCK_CODE_SYSTEM_DAMAGE
1114 jo .Lmcck_panic # yes -> rest of mcck code invalid
1115 TSTMSK __LC_MCCK_CODE,MCCK_CODE_CR_VALID
1116 jno .Lmcck_panic # control registers invalid -> panic
1118 lctlg %c0,%c15,__LC_CREGS_SAVE_AREA-4095(%r14) # validate ctl regs
1120 lg %r11,__LC_MCESAD-4095(%r14) # extended machine check save area
1121 nill %r11,0xfc00 # MCESA_ORIGIN_MASK
1122 TSTMSK __LC_CREGS_SAVE_AREA+16-4095(%r14),CR2_GUARDED_STORAGE
1124 TSTMSK __LC_MCCK_CODE,MCCK_CODE_GS_VALID
1126 .insn rxy,0xe3000000004d,0,__MCESA_GS_SAVE_AREA(%r11) # LGSC
1127 0: l %r14,__LC_FP_CREG_SAVE_AREA-4095(%r14)
1128 TSTMSK __LC_MCCK_CODE,MCCK_CODE_FC_VALID
1132 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
1134 lghi %r14,__LC_FPREGS_SAVE_AREA
1152 0: VLM %v0,%v15,0,%r11
1153 VLM %v16,%v31,256,%r11
1154 1: lghi %r14,__LC_CPU_TIMER_SAVE_AREA
1155 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
1156 TSTMSK __LC_MCCK_CODE,MCCK_CODE_CPU_TIMER_VALID
1158 la %r14,__LC_SYNC_ENTER_TIMER
1159 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
1161 la %r14,__LC_ASYNC_ENTER_TIMER
1162 0: clc 0(8,%r14),__LC_EXIT_TIMER
1164 la %r14,__LC_EXIT_TIMER
1165 1: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
1167 la %r14,__LC_LAST_UPDATE_TIMER
1169 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
1170 3: TSTMSK __LC_MCCK_CODE,MCCK_CODE_PSW_MWP_VALID
1172 tmhh %r8,0x0001 # interrupting from user ?
1174 TSTMSK __LC_MCCK_CODE,MCCK_CODE_PSW_IA_VALID
1176 4: ssm __LC_PGM_NEW_PSW # turn dat on, keep irqs off
1177 SWITCH_ASYNC __LC_GPREGS_SAVE_AREA+64,__LC_MCCK_ENTER_TIMER
1179 lghi %r14,__LC_GPREGS_SAVE_AREA+64
1180 stmg %r0,%r7,__PT_R0(%r11)
1181 # clear user controlled registers to prevent speculative use
1191 mvc __PT_R8(64,%r11),0(%r14)
1192 stmg %r8,%r9,__PT_PSW(%r11)
1193 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
1194 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
1195 lgr %r2,%r11 # pass pointer to pt_regs
1196 brasl %r14,s390_do_machine_check
1197 tm __PT_PSW+1(%r11),0x01 # returning to user ?
1199 lg %r1,__LC_KERNEL_STACK # switch to kernel stack
1200 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
1201 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
1202 la %r11,STACK_FRAME_OVERHEAD(%r1)
1204 TSTMSK __LC_CPU_FLAGS,_CIF_MCCK_PENDING
1207 brasl %r14,s390_handle_mcck
1210 lg %r14,__LC_VDSO_PER_CPU
1211 lmg %r0,%r10,__PT_R0(%r11)
1212 mvc __LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW
1213 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
1215 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
1216 stpt __LC_EXIT_TIMER
1217 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
1218 0: lmg %r11,%r15,__PT_R11(%r11)
1219 lpswe __LC_RETURN_MCCK_PSW
1222 lg %r15,__LC_NODAT_STACK
1223 la %r11,STACK_FRAME_OVERHEAD(%r15)
1225 ENDPROC(mcck_int_handler)
1228 # PSW restart interrupt handler
1230 ENTRY(restart_int_handler)
1231 ALTERNATIVE "", ".insn s,0xb2800000,_LPP_OFFSET", 40
1232 stg %r15,__LC_SAVE_AREA_RESTART
1233 lg %r15,__LC_RESTART_STACK
1234 xc STACK_FRAME_OVERHEAD(__PT_SIZE,%r15),STACK_FRAME_OVERHEAD(%r15)
1235 stmg %r0,%r14,STACK_FRAME_OVERHEAD+__PT_R0(%r15)
1236 mvc STACK_FRAME_OVERHEAD+__PT_R15(8,%r15),__LC_SAVE_AREA_RESTART
1237 mvc STACK_FRAME_OVERHEAD+__PT_PSW(16,%r15),__LC_RST_OLD_PSW
1238 xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15)
1239 lg %r1,__LC_RESTART_FN # load fn, parm & source cpu
1240 lg %r2,__LC_RESTART_DATA
1241 lg %r3,__LC_RESTART_SOURCE
1242 ltgr %r3,%r3 # test source cpu address
1243 jm 1f # negative -> skip source stop
1244 0: sigp %r4,%r3,SIGP_SENSE # sigp sense to source cpu
1245 brc 10,0b # wait for status stored
1246 1: basr %r14,%r1 # call function
1247 stap __SF_EMPTY(%r15) # store cpu address
1248 llgh %r3,__SF_EMPTY(%r15)
1249 2: sigp %r4,%r3,SIGP_STOP # sigp stop to current cpu
1252 ENDPROC(restart_int_handler)
1254 .section .kprobes.text, "ax"
1256 #if defined(CONFIG_CHECK_STACK) || defined(CONFIG_VMAP_STACK)
1258 * The synchronous or the asynchronous stack overflowed. We are dead.
1259 * No need to properly save the registers, we are going to panic anyway.
1260 * Setup a pt_regs so that show_trace can provide a good call trace.
1262 ENTRY(stack_overflow)
1263 lg %r15,__LC_NODAT_STACK # change to panic stack
1264 la %r11,STACK_FRAME_OVERHEAD(%r15)
1265 stmg %r0,%r7,__PT_R0(%r11)
1266 stmg %r8,%r9,__PT_PSW(%r11)
1267 mvc __PT_R8(64,%r11),0(%r14)
1268 stg %r10,__PT_ORIG_GPR2(%r11) # store last break to orig_gpr2
1269 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
1270 lgr %r2,%r11 # pass pointer to pt_regs
1271 jg kernel_stack_overflow
1272 ENDPROC(stack_overflow)
1275 ENTRY(cleanup_critical)
1276 #if IS_ENABLED(CONFIG_KVM)
1277 clg %r9,BASED(.Lcleanup_table_sie) # .Lsie_gmap
1279 clg %r9,BASED(.Lcleanup_table_sie+8)# .Lsie_done
1282 clg %r9,BASED(.Lcleanup_table) # system_call
1284 clg %r9,BASED(.Lcleanup_table+8) # .Lsysc_do_svc
1285 jl .Lcleanup_system_call
1286 clg %r9,BASED(.Lcleanup_table+16) # .Lsysc_tif
1288 clg %r9,BASED(.Lcleanup_table+24) # .Lsysc_restore
1289 jl .Lcleanup_sysc_tif
1290 clg %r9,BASED(.Lcleanup_table+32) # .Lsysc_done
1291 jl .Lcleanup_sysc_restore
1292 clg %r9,BASED(.Lcleanup_table+40) # .Lio_tif
1294 clg %r9,BASED(.Lcleanup_table+48) # .Lio_restore
1296 clg %r9,BASED(.Lcleanup_table+56) # .Lio_done
1297 jl .Lcleanup_io_restore
1298 clg %r9,BASED(.Lcleanup_table+64) # psw_idle
1300 clg %r9,BASED(.Lcleanup_table+72) # .Lpsw_idle_end
1302 clg %r9,BASED(.Lcleanup_table+80) # save_fpu_regs
1304 clg %r9,BASED(.Lcleanup_table+88) # .Lsave_fpu_regs_end
1305 jl .Lcleanup_save_fpu_regs
1306 clg %r9,BASED(.Lcleanup_table+96) # load_fpu_regs
1308 clg %r9,BASED(.Lcleanup_table+104) # .Lload_fpu_regs_end
1309 jl .Lcleanup_load_fpu_regs
1311 ENDPROC(cleanup_critical)
1318 .quad .Lsysc_restore
1324 .quad .Lpsw_idle_end
1326 .quad .Lsave_fpu_regs_end
1328 .quad .Lload_fpu_regs_end
1330 #if IS_ENABLED(CONFIG_KVM)
1331 .Lcleanup_table_sie:
1336 cghi %r11,__LC_SAVE_AREA_ASYNC #Is this in normal interrupt?
1338 slg %r9,BASED(.Lsie_crit_mcck_start)
1339 clg %r9,BASED(.Lsie_crit_mcck_length)
1341 oi __LC_CPU_FLAGS+7, _CIF_MCCK_GUEST
1342 1: BPENTER __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
1343 lg %r9,__SF_SIE_CONTROL(%r15) # get control block pointer
1344 ni __SIE_PROG0C+3(%r9),0xfe # no longer in SIE
1345 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
1346 larl %r9,sie_exit # skip forward to sie_exit
1350 .Lcleanup_system_call:
1351 # check if stpt has been executed
1352 clg %r9,BASED(.Lcleanup_system_call_insn)
1354 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
1355 cghi %r11,__LC_SAVE_AREA_ASYNC
1357 mvc __LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER
1358 0: # check if stmg has been executed
1359 clg %r9,BASED(.Lcleanup_system_call_insn+8)
1361 mvc __LC_SAVE_AREA_SYNC(64),0(%r11)
1362 0: # check if base register setup + TIF bit load has been done
1363 clg %r9,BASED(.Lcleanup_system_call_insn+16)
1365 # set up saved register r12 task struct pointer
1367 # set up saved register r13 __TASK_thread offset
1368 mvc 40(8,%r11),BASED(.Lcleanup_system_call_const)
1369 0: # check if the user time update has been done
1370 clg %r9,BASED(.Lcleanup_system_call_insn+24)
1372 lg %r15,__LC_EXIT_TIMER
1373 slg %r15,__LC_SYNC_ENTER_TIMER
1374 alg %r15,__LC_USER_TIMER
1375 stg %r15,__LC_USER_TIMER
1376 0: # check if the system time update has been done
1377 clg %r9,BASED(.Lcleanup_system_call_insn+32)
1379 lg %r15,__LC_LAST_UPDATE_TIMER
1380 slg %r15,__LC_EXIT_TIMER
1381 alg %r15,__LC_SYSTEM_TIMER
1382 stg %r15,__LC_SYSTEM_TIMER
1383 0: # update accounting time stamp
1384 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
1385 BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
1386 # set up saved register r11
1387 lg %r15,__LC_KERNEL_STACK
1388 la %r9,STACK_FRAME_OVERHEAD(%r15)
1389 stg %r9,24(%r11) # r11 pt_regs pointer
1391 mvc __PT_R8(64,%r9),__LC_SAVE_AREA_SYNC
1392 stmg %r0,%r7,__PT_R0(%r9)
1393 mvc __PT_PSW(16,%r9),__LC_SVC_OLD_PSW
1394 mvc __PT_INT_CODE(4,%r9),__LC_SVC_ILC
1395 xc __PT_FLAGS(8,%r9),__PT_FLAGS(%r9)
1396 mvi __PT_FLAGS+7(%r9),_PIF_SYSCALL
1397 # setup saved register r15
1398 stg %r15,56(%r11) # r15 stack pointer
1399 # set new psw address and exit
1400 larl %r9,.Lsysc_do_svc
1402 .Lcleanup_system_call_insn:
1406 .quad .Lsysc_vtime+36
1407 .quad .Lsysc_vtime+42
1408 .Lcleanup_system_call_const:
1415 .Lcleanup_sysc_restore:
1416 # check if stpt has been executed
1417 clg %r9,BASED(.Lcleanup_sysc_restore_insn)
1419 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
1420 cghi %r11,__LC_SAVE_AREA_ASYNC
1422 mvc __LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
1423 0: clg %r9,BASED(.Lcleanup_sysc_restore_insn+8)
1425 lg %r9,24(%r11) # get saved pointer to pt_regs
1426 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
1427 mvc 0(64,%r11),__PT_R8(%r9)
1428 lmg %r0,%r7,__PT_R0(%r9)
1429 1: lmg %r8,%r9,__LC_RETURN_PSW
1431 .Lcleanup_sysc_restore_insn:
1432 .quad .Lsysc_exit_timer
1433 .quad .Lsysc_done - 4
1439 .Lcleanup_io_restore:
1440 # check if stpt has been executed
1441 clg %r9,BASED(.Lcleanup_io_restore_insn)
1443 mvc __LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
1444 0: clg %r9,BASED(.Lcleanup_io_restore_insn+8)
1446 lg %r9,24(%r11) # get saved r11 pointer to pt_regs
1447 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
1448 mvc 0(64,%r11),__PT_R8(%r9)
1449 lmg %r0,%r7,__PT_R0(%r9)
1450 1: lmg %r8,%r9,__LC_RETURN_PSW
1452 .Lcleanup_io_restore_insn:
1453 .quad .Lio_exit_timer
1457 ni __LC_CPU_FLAGS+7,255-_CIF_ENABLED_WAIT
1458 # copy interrupt clock & cpu timer
1459 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_INT_CLOCK
1460 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_ASYNC_ENTER_TIMER
1461 cghi %r11,__LC_SAVE_AREA_ASYNC
1463 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_MCCK_CLOCK
1464 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_MCCK_ENTER_TIMER
1465 0: # check if stck & stpt have been executed
1466 clg %r9,BASED(.Lcleanup_idle_insn)
1468 mvc __CLOCK_IDLE_ENTER(8,%r2),__CLOCK_IDLE_EXIT(%r2)
1469 mvc __TIMER_IDLE_ENTER(8,%r2),__TIMER_IDLE_EXIT(%r2)
1470 1: # calculate idle cycles
1472 clg %r9,BASED(.Lcleanup_idle_insn)
1474 larl %r1,smp_cpu_mtid
1478 .insn rsy,0xeb0000000017,%r1,5,__SF_EMPTY+80(%r15)
1480 ag %r3,__LC_PERCPU_OFFSET
1481 la %r4,__SF_EMPTY+16(%r15)
1490 3: # account system time going idle
1491 lg %r9,__LC_STEAL_TIMER
1492 alg %r9,__CLOCK_IDLE_ENTER(%r2)
1493 slg %r9,__LC_LAST_UPDATE_CLOCK
1494 stg %r9,__LC_STEAL_TIMER
1495 mvc __LC_LAST_UPDATE_CLOCK(8),__CLOCK_IDLE_EXIT(%r2)
1496 lg %r9,__LC_SYSTEM_TIMER
1497 alg %r9,__LC_LAST_UPDATE_TIMER
1498 slg %r9,__TIMER_IDLE_ENTER(%r2)
1499 stg %r9,__LC_SYSTEM_TIMER
1500 mvc __LC_LAST_UPDATE_TIMER(8),__TIMER_IDLE_EXIT(%r2)
1501 # prepare return psw
1502 nihh %r8,0xfcfd # clear irq & wait state bits
1503 lg %r9,48(%r11) # return from psw_idle
1505 .Lcleanup_idle_insn:
1506 .quad .Lpsw_idle_lpsw
1508 .Lcleanup_save_fpu_regs:
1509 larl %r9,save_fpu_regs
1512 .Lcleanup_load_fpu_regs:
1513 larl %r9,load_fpu_regs
1521 .quad .L__critical_start
1523 .quad .L__critical_end - .L__critical_start
1524 #if IS_ENABLED(CONFIG_KVM)
1525 .Lsie_critical_start:
1527 .Lsie_critical_length:
1528 .quad .Lsie_done - .Lsie_gmap
1529 .Lsie_crit_mcck_start:
1531 .Lsie_crit_mcck_length:
1532 .quad .Lsie_skip - .Lsie_entry
1534 .section .rodata, "a"
1535 #define SYSCALL(esame,emu) .quad __s390x_ ## esame
1536 .globl sys_call_table
1538 #include "asm/syscall_table.h"
1541 #ifdef CONFIG_COMPAT
1543 #define SYSCALL(esame,emu) .quad __s390_ ## emu
1544 .globl sys_call_table_emu
1546 #include "asm/syscall_table.h"