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)
989 larl %r1,smp_cpu_mtid
993 .insn rsy,0xeb0000000017,%r1,5,__SF_EMPTY+16(%r15)
995 oi __LC_CPU_FLAGS+7,_CIF_ENABLED_WAIT
997 STCK __CLOCK_IDLE_ENTER(%r2)
998 stpt __TIMER_IDLE_ENTER(%r2)
1000 lpswe __SF_EMPTY(%r15)
1006 * Store floating-point controls and floating-point or vector register
1007 * depending whether the vector facility is available. A critical section
1008 * cleanup assures that the registers are stored even if interrupted for
1009 * some other work. The CIF_FPU flag is set to trigger a lazy restore
1010 * of the register contents at return from io or a system call.
1012 ENTRY(save_fpu_regs)
1014 aghi %r2,__TASK_thread
1015 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
1016 jo .Lsave_fpu_regs_exit
1017 stfpc __THREAD_FPU_fpc(%r2)
1018 lg %r3,__THREAD_FPU_regs(%r2)
1019 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
1020 jz .Lsave_fpu_regs_fp # no -> store FP regs
1021 VSTM %v0,%v15,0,%r3 # vstm 0,15,0(3)
1022 VSTM %v16,%v31,256,%r3 # vstm 16,31,256(3)
1023 j .Lsave_fpu_regs_done # -> set CIF_FPU flag
1041 .Lsave_fpu_regs_done:
1042 oi __LC_CPU_FLAGS+7,_CIF_FPU
1043 .Lsave_fpu_regs_exit:
1045 .Lsave_fpu_regs_end:
1046 ENDPROC(save_fpu_regs)
1047 EXPORT_SYMBOL(save_fpu_regs)
1050 * Load floating-point controls and floating-point or vector registers.
1051 * A critical section cleanup assures that the register contents are
1052 * loaded even if interrupted for some other work.
1054 * There are special calling conventions to fit into sysc and io return work:
1055 * %r15: <kernel stack>
1056 * The function requires:
1061 aghi %r4,__TASK_thread
1062 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
1063 jno .Lload_fpu_regs_exit
1064 lfpc __THREAD_FPU_fpc(%r4)
1065 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
1066 lg %r4,__THREAD_FPU_regs(%r4) # %r4 <- reg save area
1067 jz .Lload_fpu_regs_fp # -> no VX, load FP regs
1069 VLM %v16,%v31,256,%r4
1070 j .Lload_fpu_regs_done
1088 .Lload_fpu_regs_done:
1089 ni __LC_CPU_FLAGS+7,255-_CIF_FPU
1090 .Lload_fpu_regs_exit:
1092 .Lload_fpu_regs_end:
1093 ENDPROC(load_fpu_regs)
1098 * Machine check handler routines
1100 ENTRY(mcck_int_handler)
1101 STCK __LC_MCCK_CLOCK
1103 la %r1,4095 # validate r1
1104 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # validate cpu timer
1105 sckc __LC_CLOCK_COMPARATOR # validate comparator
1106 lam %a0,%a15,__LC_AREGS_SAVE_AREA-4095(%r1) # validate acrs
1107 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# validate gprs
1108 lg %r12,__LC_CURRENT
1109 larl %r13,cleanup_critical
1110 lmg %r8,%r9,__LC_MCK_OLD_PSW
1111 TSTMSK __LC_MCCK_CODE,MCCK_CODE_SYSTEM_DAMAGE
1112 jo .Lmcck_panic # yes -> rest of mcck code invalid
1113 TSTMSK __LC_MCCK_CODE,MCCK_CODE_CR_VALID
1114 jno .Lmcck_panic # control registers invalid -> panic
1116 lctlg %c0,%c15,__LC_CREGS_SAVE_AREA-4095(%r14) # validate ctl regs
1118 lg %r11,__LC_MCESAD-4095(%r14) # extended machine check save area
1119 nill %r11,0xfc00 # MCESA_ORIGIN_MASK
1120 TSTMSK __LC_CREGS_SAVE_AREA+16-4095(%r14),CR2_GUARDED_STORAGE
1122 TSTMSK __LC_MCCK_CODE,MCCK_CODE_GS_VALID
1124 .insn rxy,0xe3000000004d,0,__MCESA_GS_SAVE_AREA(%r11) # LGSC
1125 0: l %r14,__LC_FP_CREG_SAVE_AREA-4095(%r14)
1126 TSTMSK __LC_MCCK_CODE,MCCK_CODE_FC_VALID
1130 TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX
1132 lghi %r14,__LC_FPREGS_SAVE_AREA
1150 0: VLM %v0,%v15,0,%r11
1151 VLM %v16,%v31,256,%r11
1152 1: lghi %r14,__LC_CPU_TIMER_SAVE_AREA
1153 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
1154 TSTMSK __LC_MCCK_CODE,MCCK_CODE_CPU_TIMER_VALID
1156 la %r14,__LC_SYNC_ENTER_TIMER
1157 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
1159 la %r14,__LC_ASYNC_ENTER_TIMER
1160 0: clc 0(8,%r14),__LC_EXIT_TIMER
1162 la %r14,__LC_EXIT_TIMER
1163 1: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
1165 la %r14,__LC_LAST_UPDATE_TIMER
1167 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
1168 3: TSTMSK __LC_MCCK_CODE,MCCK_CODE_PSW_MWP_VALID
1170 tmhh %r8,0x0001 # interrupting from user ?
1172 TSTMSK __LC_MCCK_CODE,MCCK_CODE_PSW_IA_VALID
1174 4: ssm __LC_PGM_NEW_PSW # turn dat on, keep irqs off
1175 SWITCH_ASYNC __LC_GPREGS_SAVE_AREA+64,__LC_MCCK_ENTER_TIMER
1177 lghi %r14,__LC_GPREGS_SAVE_AREA+64
1178 stmg %r0,%r7,__PT_R0(%r11)
1179 # clear user controlled registers to prevent speculative use
1189 mvc __PT_R8(64,%r11),0(%r14)
1190 stmg %r8,%r9,__PT_PSW(%r11)
1191 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
1192 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
1193 lgr %r2,%r11 # pass pointer to pt_regs
1194 brasl %r14,s390_do_machine_check
1195 tm __PT_PSW+1(%r11),0x01 # returning to user ?
1197 lg %r1,__LC_KERNEL_STACK # switch to kernel stack
1198 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
1199 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
1200 la %r11,STACK_FRAME_OVERHEAD(%r1)
1202 TSTMSK __LC_CPU_FLAGS,_CIF_MCCK_PENDING
1205 brasl %r14,s390_handle_mcck
1208 lg %r14,__LC_VDSO_PER_CPU
1209 lmg %r0,%r10,__PT_R0(%r11)
1210 mvc __LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW
1211 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
1213 BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP
1214 stpt __LC_EXIT_TIMER
1215 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
1216 0: lmg %r11,%r15,__PT_R11(%r11)
1217 lpswe __LC_RETURN_MCCK_PSW
1220 lg %r15,__LC_NODAT_STACK
1221 la %r11,STACK_FRAME_OVERHEAD(%r15)
1223 ENDPROC(mcck_int_handler)
1226 # PSW restart interrupt handler
1228 ENTRY(restart_int_handler)
1229 ALTERNATIVE "", ".insn s,0xb2800000,_LPP_OFFSET", 40
1230 stg %r15,__LC_SAVE_AREA_RESTART
1231 lg %r15,__LC_RESTART_STACK
1232 xc STACK_FRAME_OVERHEAD(__PT_SIZE,%r15),STACK_FRAME_OVERHEAD(%r15)
1233 stmg %r0,%r14,STACK_FRAME_OVERHEAD+__PT_R0(%r15)
1234 mvc STACK_FRAME_OVERHEAD+__PT_R15(8,%r15),__LC_SAVE_AREA_RESTART
1235 mvc STACK_FRAME_OVERHEAD+__PT_PSW(16,%r15),__LC_RST_OLD_PSW
1236 xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15)
1237 lg %r1,__LC_RESTART_FN # load fn, parm & source cpu
1238 lg %r2,__LC_RESTART_DATA
1239 lg %r3,__LC_RESTART_SOURCE
1240 ltgr %r3,%r3 # test source cpu address
1241 jm 1f # negative -> skip source stop
1242 0: sigp %r4,%r3,SIGP_SENSE # sigp sense to source cpu
1243 brc 10,0b # wait for status stored
1244 1: basr %r14,%r1 # call function
1245 stap __SF_EMPTY(%r15) # store cpu address
1246 llgh %r3,__SF_EMPTY(%r15)
1247 2: sigp %r4,%r3,SIGP_STOP # sigp stop to current cpu
1250 ENDPROC(restart_int_handler)
1252 .section .kprobes.text, "ax"
1254 #if defined(CONFIG_CHECK_STACK) || defined(CONFIG_VMAP_STACK)
1256 * The synchronous or the asynchronous stack overflowed. We are dead.
1257 * No need to properly save the registers, we are going to panic anyway.
1258 * Setup a pt_regs so that show_trace can provide a good call trace.
1260 ENTRY(stack_overflow)
1261 lg %r15,__LC_NODAT_STACK # change to panic stack
1262 la %r11,STACK_FRAME_OVERHEAD(%r15)
1263 stmg %r0,%r7,__PT_R0(%r11)
1264 stmg %r8,%r9,__PT_PSW(%r11)
1265 mvc __PT_R8(64,%r11),0(%r14)
1266 stg %r10,__PT_ORIG_GPR2(%r11) # store last break to orig_gpr2
1267 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
1268 lgr %r2,%r11 # pass pointer to pt_regs
1269 jg kernel_stack_overflow
1270 ENDPROC(stack_overflow)
1273 ENTRY(cleanup_critical)
1274 #if IS_ENABLED(CONFIG_KVM)
1275 clg %r9,BASED(.Lcleanup_table_sie) # .Lsie_gmap
1277 clg %r9,BASED(.Lcleanup_table_sie+8)# .Lsie_done
1280 clg %r9,BASED(.Lcleanup_table) # system_call
1282 clg %r9,BASED(.Lcleanup_table+8) # .Lsysc_do_svc
1283 jl .Lcleanup_system_call
1284 clg %r9,BASED(.Lcleanup_table+16) # .Lsysc_tif
1286 clg %r9,BASED(.Lcleanup_table+24) # .Lsysc_restore
1287 jl .Lcleanup_sysc_tif
1288 clg %r9,BASED(.Lcleanup_table+32) # .Lsysc_done
1289 jl .Lcleanup_sysc_restore
1290 clg %r9,BASED(.Lcleanup_table+40) # .Lio_tif
1292 clg %r9,BASED(.Lcleanup_table+48) # .Lio_restore
1294 clg %r9,BASED(.Lcleanup_table+56) # .Lio_done
1295 jl .Lcleanup_io_restore
1296 clg %r9,BASED(.Lcleanup_table+64) # psw_idle
1298 clg %r9,BASED(.Lcleanup_table+72) # .Lpsw_idle_end
1300 clg %r9,BASED(.Lcleanup_table+80) # save_fpu_regs
1302 clg %r9,BASED(.Lcleanup_table+88) # .Lsave_fpu_regs_end
1303 jl .Lcleanup_save_fpu_regs
1304 clg %r9,BASED(.Lcleanup_table+96) # load_fpu_regs
1306 clg %r9,BASED(.Lcleanup_table+104) # .Lload_fpu_regs_end
1307 jl .Lcleanup_load_fpu_regs
1309 ENDPROC(cleanup_critical)
1316 .quad .Lsysc_restore
1322 .quad .Lpsw_idle_end
1324 .quad .Lsave_fpu_regs_end
1326 .quad .Lload_fpu_regs_end
1328 #if IS_ENABLED(CONFIG_KVM)
1329 .Lcleanup_table_sie:
1334 cghi %r11,__LC_SAVE_AREA_ASYNC #Is this in normal interrupt?
1336 slg %r9,BASED(.Lsie_crit_mcck_start)
1337 clg %r9,BASED(.Lsie_crit_mcck_length)
1339 oi __LC_CPU_FLAGS+7, _CIF_MCCK_GUEST
1340 1: BPENTER __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST)
1341 lg %r9,__SF_SIE_CONTROL(%r15) # get control block pointer
1342 ni __SIE_PROG0C+3(%r9),0xfe # no longer in SIE
1343 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
1344 larl %r9,sie_exit # skip forward to sie_exit
1348 .Lcleanup_system_call:
1349 # check if stpt has been executed
1350 clg %r9,BASED(.Lcleanup_system_call_insn)
1352 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
1353 cghi %r11,__LC_SAVE_AREA_ASYNC
1355 mvc __LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER
1356 0: # check if stmg has been executed
1357 clg %r9,BASED(.Lcleanup_system_call_insn+8)
1359 mvc __LC_SAVE_AREA_SYNC(64),0(%r11)
1360 0: # check if base register setup + TIF bit load has been done
1361 clg %r9,BASED(.Lcleanup_system_call_insn+16)
1363 # set up saved register r12 task struct pointer
1365 # set up saved register r13 __TASK_thread offset
1366 mvc 40(8,%r11),BASED(.Lcleanup_system_call_const)
1367 0: # check if the user time update has been done
1368 clg %r9,BASED(.Lcleanup_system_call_insn+24)
1370 lg %r15,__LC_EXIT_TIMER
1371 slg %r15,__LC_SYNC_ENTER_TIMER
1372 alg %r15,__LC_USER_TIMER
1373 stg %r15,__LC_USER_TIMER
1374 0: # check if the system time update has been done
1375 clg %r9,BASED(.Lcleanup_system_call_insn+32)
1377 lg %r15,__LC_LAST_UPDATE_TIMER
1378 slg %r15,__LC_EXIT_TIMER
1379 alg %r15,__LC_SYSTEM_TIMER
1380 stg %r15,__LC_SYSTEM_TIMER
1381 0: # update accounting time stamp
1382 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
1383 BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP
1384 # set up saved register r11
1385 lg %r15,__LC_KERNEL_STACK
1386 la %r9,STACK_FRAME_OVERHEAD(%r15)
1387 stg %r9,24(%r11) # r11 pt_regs pointer
1389 mvc __PT_R8(64,%r9),__LC_SAVE_AREA_SYNC
1390 stmg %r0,%r7,__PT_R0(%r9)
1391 mvc __PT_PSW(16,%r9),__LC_SVC_OLD_PSW
1392 mvc __PT_INT_CODE(4,%r9),__LC_SVC_ILC
1393 xc __PT_FLAGS(8,%r9),__PT_FLAGS(%r9)
1394 mvi __PT_FLAGS+7(%r9),_PIF_SYSCALL
1395 # setup saved register r15
1396 stg %r15,56(%r11) # r15 stack pointer
1397 # set new psw address and exit
1398 larl %r9,.Lsysc_do_svc
1400 .Lcleanup_system_call_insn:
1404 .quad .Lsysc_vtime+36
1405 .quad .Lsysc_vtime+42
1406 .Lcleanup_system_call_const:
1413 .Lcleanup_sysc_restore:
1414 # check if stpt has been executed
1415 clg %r9,BASED(.Lcleanup_sysc_restore_insn)
1417 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
1418 cghi %r11,__LC_SAVE_AREA_ASYNC
1420 mvc __LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
1421 0: clg %r9,BASED(.Lcleanup_sysc_restore_insn+8)
1423 lg %r9,24(%r11) # get saved pointer to pt_regs
1424 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
1425 mvc 0(64,%r11),__PT_R8(%r9)
1426 lmg %r0,%r7,__PT_R0(%r9)
1427 1: lmg %r8,%r9,__LC_RETURN_PSW
1429 .Lcleanup_sysc_restore_insn:
1430 .quad .Lsysc_exit_timer
1431 .quad .Lsysc_done - 4
1437 .Lcleanup_io_restore:
1438 # check if stpt has been executed
1439 clg %r9,BASED(.Lcleanup_io_restore_insn)
1441 mvc __LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
1442 0: clg %r9,BASED(.Lcleanup_io_restore_insn+8)
1444 lg %r9,24(%r11) # get saved r11 pointer to pt_regs
1445 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
1446 mvc 0(64,%r11),__PT_R8(%r9)
1447 lmg %r0,%r7,__PT_R0(%r9)
1448 1: lmg %r8,%r9,__LC_RETURN_PSW
1450 .Lcleanup_io_restore_insn:
1451 .quad .Lio_exit_timer
1455 ni __LC_CPU_FLAGS+7,255-_CIF_ENABLED_WAIT
1456 # copy interrupt clock & cpu timer
1457 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_INT_CLOCK
1458 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_ASYNC_ENTER_TIMER
1459 cghi %r11,__LC_SAVE_AREA_ASYNC
1461 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_MCCK_CLOCK
1462 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_MCCK_ENTER_TIMER
1463 0: # check if stck & stpt have been executed
1464 clg %r9,BASED(.Lcleanup_idle_insn)
1466 mvc __CLOCK_IDLE_ENTER(8,%r2),__CLOCK_IDLE_EXIT(%r2)
1467 mvc __TIMER_IDLE_ENTER(8,%r2),__TIMER_IDLE_EXIT(%r2)
1468 1: # calculate idle cycles
1469 clg %r9,BASED(.Lcleanup_idle_insn)
1471 larl %r1,smp_cpu_mtid
1475 .insn rsy,0xeb0000000017,%r1,5,__SF_EMPTY+80(%r15)
1477 ag %r3,__LC_PERCPU_OFFSET
1478 la %r4,__SF_EMPTY+16(%r15)
1486 3: # account system time going idle
1487 lg %r9,__LC_STEAL_TIMER
1488 alg %r9,__CLOCK_IDLE_ENTER(%r2)
1489 slg %r9,__LC_LAST_UPDATE_CLOCK
1490 stg %r9,__LC_STEAL_TIMER
1491 mvc __LC_LAST_UPDATE_CLOCK(8),__CLOCK_IDLE_EXIT(%r2)
1492 lg %r9,__LC_SYSTEM_TIMER
1493 alg %r9,__LC_LAST_UPDATE_TIMER
1494 slg %r9,__TIMER_IDLE_ENTER(%r2)
1495 stg %r9,__LC_SYSTEM_TIMER
1496 mvc __LC_LAST_UPDATE_TIMER(8),__TIMER_IDLE_EXIT(%r2)
1497 # prepare return psw
1498 nihh %r8,0xfcfd # clear irq & wait state bits
1499 lg %r9,48(%r11) # return from psw_idle
1501 .Lcleanup_idle_insn:
1502 .quad .Lpsw_idle_lpsw
1504 .Lcleanup_save_fpu_regs:
1505 larl %r9,save_fpu_regs
1508 .Lcleanup_load_fpu_regs:
1509 larl %r9,load_fpu_regs
1517 .quad .L__critical_start
1519 .quad .L__critical_end - .L__critical_start
1520 #if IS_ENABLED(CONFIG_KVM)
1521 .Lsie_critical_start:
1523 .Lsie_critical_length:
1524 .quad .Lsie_done - .Lsie_gmap
1525 .Lsie_crit_mcck_start:
1527 .Lsie_crit_mcck_length:
1528 .quad .Lsie_skip - .Lsie_entry
1530 .section .rodata, "a"
1531 #define SYSCALL(esame,emu) .quad __s390x_ ## esame
1532 .globl sys_call_table
1534 #include "asm/syscall_table.h"
1537 #ifdef CONFIG_COMPAT
1539 #define SYSCALL(esame,emu) .quad __s390_ ## emu
1540 .globl sys_call_table_emu
1542 #include "asm/syscall_table.h"