entry.S (7041d28115e91f2144f811ffe8a195c696b1e1d0) entry.S (d768bd892fc8f066cd3aa000eb1867bcf32db0ee)
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * S390 low-level entry points.
4 *
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),

--- 145 unchanged lines hidden (view full) ---

154 .endif
155 .ifeq \mask
156 .error "Mask must not be zero"
157 .endif
158 off = \size - \bytepos - 1
159 tm off+\addr, \mask
160 .endm
161
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * S390 low-level entry points.
4 *
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),

--- 145 unchanged lines hidden (view full) ---

154 .endif
155 .ifeq \mask
156 .error "Mask must not be zero"
157 .endif
158 off = \size - \bytepos - 1
159 tm off+\addr, \mask
160 .endm
161
162 .macro BPOFF
163 .pushsection .altinstr_replacement, "ax"
164660: .long 0xb2e8c000
165 .popsection
166661: .long 0x47000000
167 .pushsection .altinstructions, "a"
168 .long 661b - .
169 .long 660b - .
170 .word 82
171 .byte 4
172 .byte 4
173 .popsection
174 .endm
175
176 .macro BPON
177 .pushsection .altinstr_replacement, "ax"
178662: .long 0xb2e8d000
179 .popsection
180663: .long 0x47000000
181 .pushsection .altinstructions, "a"
182 .long 663b - .
183 .long 662b - .
184 .word 82
185 .byte 4
186 .byte 4
187 .popsection
188 .endm
189
162 .section .kprobes.text, "ax"
163.Ldummy:
164 /*
165 * This nop exists only in order to avoid that __switch_to starts at
166 * the beginning of the kprobes text section. In that case we would
167 * have several symbols at the same address. E.g. objdump would take
168 * an arbitrary symbol name when disassembling this code.
169 * With the added nop in between the __switch_to symbol is unique
170 * again.
171 */
172 nop 0
173
190 .section .kprobes.text, "ax"
191.Ldummy:
192 /*
193 * This nop exists only in order to avoid that __switch_to starts at
194 * the beginning of the kprobes text section. In that case we would
195 * have several symbols at the same address. E.g. objdump would take
196 * an arbitrary symbol name when disassembling this code.
197 * With the added nop in between the __switch_to symbol is unique
198 * again.
199 */
200 nop 0
201
202ENTRY(__bpon)
203 .globl __bpon
204 BPON
205 br %r14
206
174/*
175 * Scheduler resume function, called by switch_to
176 * gpr2 = (task_struct *) prev
177 * gpr3 = (task_struct *) next
178 * Returns:
179 * gpr2 = prev
180 */
181ENTRY(__switch_to)

--- 39 unchanged lines hidden (view full) ---

221 lctlg %c1,%c1,__GMAP_ASCE(%r14) # load primary asce
222.Lsie_gmap:
223 lg %r14,__SF_EMPTY(%r15) # get control block pointer
224 oi __SIE_PROG0C+3(%r14),1 # we are going into SIE now
225 tm __SIE_PROG20+3(%r14),3 # last exit...
226 jnz .Lsie_skip
227 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
228 jo .Lsie_skip # exit if fp/vx regs changed
207/*
208 * Scheduler resume function, called by switch_to
209 * gpr2 = (task_struct *) prev
210 * gpr3 = (task_struct *) next
211 * Returns:
212 * gpr2 = prev
213 */
214ENTRY(__switch_to)

--- 39 unchanged lines hidden (view full) ---

254 lctlg %c1,%c1,__GMAP_ASCE(%r14) # load primary asce
255.Lsie_gmap:
256 lg %r14,__SF_EMPTY(%r15) # get control block pointer
257 oi __SIE_PROG0C+3(%r14),1 # we are going into SIE now
258 tm __SIE_PROG20+3(%r14),3 # last exit...
259 jnz .Lsie_skip
260 TSTMSK __LC_CPU_FLAGS,_CIF_FPU
261 jo .Lsie_skip # exit if fp/vx regs changed
262 BPON
229.Lsie_entry:
230 sie 0(%r14)
263.Lsie_entry:
264 sie 0(%r14)
265.Lsie_exit:
266 BPOFF
231.Lsie_skip:
232 ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE
233 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
234.Lsie_done:
235# some program checks are suppressing. C code (e.g. do_protection_exception)
236# will rewind the PSW by the ILC, which is often 4 bytes in case of SIE. There
237# are some corner cases (e.g. runtime instrumentation) where ILC is unpredictable.
238# Other instructions between sie64a and .Lsie_done should not cause program

--- 35 unchanged lines hidden (view full) ---

274 * SVC interrupt handler routine. System calls are synchronous events and
275 * are executed with interrupts enabled.
276 */
277
278ENTRY(system_call)
279 stpt __LC_SYNC_ENTER_TIMER
280.Lsysc_stmg:
281 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
267.Lsie_skip:
268 ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE
269 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
270.Lsie_done:
271# some program checks are suppressing. C code (e.g. do_protection_exception)
272# will rewind the PSW by the ILC, which is often 4 bytes in case of SIE. There
273# are some corner cases (e.g. runtime instrumentation) where ILC is unpredictable.
274# Other instructions between sie64a and .Lsie_done should not cause program

--- 35 unchanged lines hidden (view full) ---

310 * SVC interrupt handler routine. System calls are synchronous events and
311 * are executed with interrupts enabled.
312 */
313
314ENTRY(system_call)
315 stpt __LC_SYNC_ENTER_TIMER
316.Lsysc_stmg:
317 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
318 BPOFF
282 lg %r12,__LC_CURRENT
283 lghi %r13,__TASK_thread
284 lghi %r14,_PIF_SYSCALL
285.Lsysc_per:
286 lg %r15,__LC_KERNEL_STACK
287 la %r11,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs
288.Lsysc_vtime:
289 UPDATE_VTIME %r8,%r9,__LC_SYNC_ENTER_TIMER

--- 30 unchanged lines hidden (view full) ---

320 LOCKDEP_SYS_EXIT
321.Lsysc_tif:
322 TSTMSK __PT_FLAGS(%r11),_PIF_WORK
323 jnz .Lsysc_work
324 TSTMSK __TI_flags(%r12),_TIF_WORK
325 jnz .Lsysc_work # check for work
326 TSTMSK __LC_CPU_FLAGS,_CIF_WORK
327 jnz .Lsysc_work
319 lg %r12,__LC_CURRENT
320 lghi %r13,__TASK_thread
321 lghi %r14,_PIF_SYSCALL
322.Lsysc_per:
323 lg %r15,__LC_KERNEL_STACK
324 la %r11,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs
325.Lsysc_vtime:
326 UPDATE_VTIME %r8,%r9,__LC_SYNC_ENTER_TIMER

--- 30 unchanged lines hidden (view full) ---

357 LOCKDEP_SYS_EXIT
358.Lsysc_tif:
359 TSTMSK __PT_FLAGS(%r11),_PIF_WORK
360 jnz .Lsysc_work
361 TSTMSK __TI_flags(%r12),_TIF_WORK
362 jnz .Lsysc_work # check for work
363 TSTMSK __LC_CPU_FLAGS,_CIF_WORK
364 jnz .Lsysc_work
365 BPON
328.Lsysc_restore:
329 lg %r14,__LC_VDSO_PER_CPU
330 lmg %r0,%r10,__PT_R0(%r11)
331 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
332.Lsysc_exit_timer:
333 stpt __LC_EXIT_TIMER
334 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
335 lmg %r11,%r15,__PT_R11(%r11)

--- 189 unchanged lines hidden (view full) ---

525 j .Lsysc_tracenogo
526
527/*
528 * Program check handler routine
529 */
530
531ENTRY(pgm_check_handler)
532 stpt __LC_SYNC_ENTER_TIMER
366.Lsysc_restore:
367 lg %r14,__LC_VDSO_PER_CPU
368 lmg %r0,%r10,__PT_R0(%r11)
369 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
370.Lsysc_exit_timer:
371 stpt __LC_EXIT_TIMER
372 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
373 lmg %r11,%r15,__PT_R11(%r11)

--- 189 unchanged lines hidden (view full) ---

563 j .Lsysc_tracenogo
564
565/*
566 * Program check handler routine
567 */
568
569ENTRY(pgm_check_handler)
570 stpt __LC_SYNC_ENTER_TIMER
571 BPOFF
533 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
534 lg %r10,__LC_LAST_BREAK
535 lg %r12,__LC_CURRENT
536 lghi %r11,0
537 larl %r13,cleanup_critical
538 lmg %r8,%r9,__LC_PGM_OLD_PSW
539 tmhh %r8,0x0001 # test problem state bit
540 jnz 2f # -> fault in user space

--- 91 unchanged lines hidden (view full) ---

632 lpswe __LC_RETURN_PSW # branch to .Lsysc_per and enable irqs
633
634/*
635 * IO interrupt handler routine
636 */
637ENTRY(io_int_handler)
638 STCK __LC_INT_CLOCK
639 stpt __LC_ASYNC_ENTER_TIMER
572 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
573 lg %r10,__LC_LAST_BREAK
574 lg %r12,__LC_CURRENT
575 lghi %r11,0
576 larl %r13,cleanup_critical
577 lmg %r8,%r9,__LC_PGM_OLD_PSW
578 tmhh %r8,0x0001 # test problem state bit
579 jnz 2f # -> fault in user space

--- 91 unchanged lines hidden (view full) ---

671 lpswe __LC_RETURN_PSW # branch to .Lsysc_per and enable irqs
672
673/*
674 * IO interrupt handler routine
675 */
676ENTRY(io_int_handler)
677 STCK __LC_INT_CLOCK
678 stpt __LC_ASYNC_ENTER_TIMER
679 BPOFF
640 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
641 lg %r12,__LC_CURRENT
642 larl %r13,cleanup_critical
643 lmg %r8,%r9,__LC_IO_OLD_PSW
644 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER
645 stmg %r0,%r7,__PT_R0(%r11)
646 # clear user controlled registers to prevent speculative use
647 xgr %r0,%r0

--- 34 unchanged lines hidden (view full) ---

682 TSTMSK __TI_flags(%r12),_TIF_WORK
683 jnz .Lio_work # there is work to do (signals etc.)
684 TSTMSK __LC_CPU_FLAGS,_CIF_WORK
685 jnz .Lio_work
686.Lio_restore:
687 lg %r14,__LC_VDSO_PER_CPU
688 lmg %r0,%r10,__PT_R0(%r11)
689 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
680 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
681 lg %r12,__LC_CURRENT
682 larl %r13,cleanup_critical
683 lmg %r8,%r9,__LC_IO_OLD_PSW
684 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER
685 stmg %r0,%r7,__PT_R0(%r11)
686 # clear user controlled registers to prevent speculative use
687 xgr %r0,%r0

--- 34 unchanged lines hidden (view full) ---

722 TSTMSK __TI_flags(%r12),_TIF_WORK
723 jnz .Lio_work # there is work to do (signals etc.)
724 TSTMSK __LC_CPU_FLAGS,_CIF_WORK
725 jnz .Lio_work
726.Lio_restore:
727 lg %r14,__LC_VDSO_PER_CPU
728 lmg %r0,%r10,__PT_R0(%r11)
729 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
730 tm __PT_PSW+1(%r11),0x01 # returning to user ?
731 jno .Lio_exit_kernel
732 BPON
690.Lio_exit_timer:
691 stpt __LC_EXIT_TIMER
692 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
733.Lio_exit_timer:
734 stpt __LC_EXIT_TIMER
735 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
736.Lio_exit_kernel:
693 lmg %r11,%r15,__PT_R11(%r11)
694 lpswe __LC_RETURN_PSW
695.Lio_done:
696
697#
698# There is work todo, find out in which context we have been interrupted:
699# 1) if we return to user space we can do all _TIF_WORK work
700# 2) if we return to kernel code and kvm is enabled check if we need to

--- 154 unchanged lines hidden (view full) ---

855 j .Lio_return
856
857/*
858 * External interrupt handler routine
859 */
860ENTRY(ext_int_handler)
861 STCK __LC_INT_CLOCK
862 stpt __LC_ASYNC_ENTER_TIMER
737 lmg %r11,%r15,__PT_R11(%r11)
738 lpswe __LC_RETURN_PSW
739.Lio_done:
740
741#
742# There is work todo, find out in which context we have been interrupted:
743# 1) if we return to user space we can do all _TIF_WORK work
744# 2) if we return to kernel code and kvm is enabled check if we need to

--- 154 unchanged lines hidden (view full) ---

899 j .Lio_return
900
901/*
902 * External interrupt handler routine
903 */
904ENTRY(ext_int_handler)
905 STCK __LC_INT_CLOCK
906 stpt __LC_ASYNC_ENTER_TIMER
907 BPOFF
863 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
864 lg %r12,__LC_CURRENT
865 larl %r13,cleanup_critical
866 lmg %r8,%r9,__LC_EXT_OLD_PSW
867 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER
868 stmg %r0,%r7,__PT_R0(%r11)
869 # clear user controlled registers to prevent speculative use
870 xgr %r0,%r0

--- 32 unchanged lines hidden (view full) ---

903 larl %r1,smp_cpu_mtid
904 llgf %r1,0(%r1)
905 ltgr %r1,%r1
906 jz .Lpsw_idle_stcctm
907 .insn rsy,0xeb0000000017,%r1,5,__SF_EMPTY+16(%r15)
908.Lpsw_idle_stcctm:
909#endif
910 oi __LC_CPU_FLAGS+7,_CIF_ENABLED_WAIT
908 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
909 lg %r12,__LC_CURRENT
910 larl %r13,cleanup_critical
911 lmg %r8,%r9,__LC_EXT_OLD_PSW
912 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER
913 stmg %r0,%r7,__PT_R0(%r11)
914 # clear user controlled registers to prevent speculative use
915 xgr %r0,%r0

--- 32 unchanged lines hidden (view full) ---

948 larl %r1,smp_cpu_mtid
949 llgf %r1,0(%r1)
950 ltgr %r1,%r1
951 jz .Lpsw_idle_stcctm
952 .insn rsy,0xeb0000000017,%r1,5,__SF_EMPTY+16(%r15)
953.Lpsw_idle_stcctm:
954#endif
955 oi __LC_CPU_FLAGS+7,_CIF_ENABLED_WAIT
956 BPON
911 STCK __CLOCK_IDLE_ENTER(%r2)
912 stpt __TIMER_IDLE_ENTER(%r2)
913.Lpsw_idle_lpsw:
914 lpswe __SF_EMPTY(%r15)
915 br %r14
916.Lpsw_idle_end:
917
918/*

--- 84 unchanged lines hidden (view full) ---

1003
1004.L__critical_end:
1005
1006/*
1007 * Machine check handler routines
1008 */
1009ENTRY(mcck_int_handler)
1010 STCK __LC_MCCK_CLOCK
957 STCK __CLOCK_IDLE_ENTER(%r2)
958 stpt __TIMER_IDLE_ENTER(%r2)
959.Lpsw_idle_lpsw:
960 lpswe __SF_EMPTY(%r15)
961 br %r14
962.Lpsw_idle_end:
963
964/*

--- 84 unchanged lines hidden (view full) ---

1049
1050.L__critical_end:
1051
1052/*
1053 * Machine check handler routines
1054 */
1055ENTRY(mcck_int_handler)
1056 STCK __LC_MCCK_CLOCK
1057 BPOFF
1011 la %r1,4095 # validate r1
1012 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # validate cpu timer
1013 sckc __LC_CLOCK_COMPARATOR # validate comparator
1014 lam %a0,%a15,__LC_AREGS_SAVE_AREA-4095(%r1) # validate acrs
1015 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# validate gprs
1016 lg %r12,__LC_CURRENT
1017 larl %r13,cleanup_critical
1018 lmg %r8,%r9,__LC_MCK_OLD_PSW

--- 94 unchanged lines hidden (view full) ---

1113 brasl %r14,s390_handle_mcck
1114 TRACE_IRQS_ON
1115.Lmcck_return:
1116 lg %r14,__LC_VDSO_PER_CPU
1117 lmg %r0,%r10,__PT_R0(%r11)
1118 mvc __LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW
1119 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
1120 jno 0f
1058 la %r1,4095 # validate r1
1059 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # validate cpu timer
1060 sckc __LC_CLOCK_COMPARATOR # validate comparator
1061 lam %a0,%a15,__LC_AREGS_SAVE_AREA-4095(%r1) # validate acrs
1062 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# validate gprs
1063 lg %r12,__LC_CURRENT
1064 larl %r13,cleanup_critical
1065 lmg %r8,%r9,__LC_MCK_OLD_PSW

--- 94 unchanged lines hidden (view full) ---

1160 brasl %r14,s390_handle_mcck
1161 TRACE_IRQS_ON
1162.Lmcck_return:
1163 lg %r14,__LC_VDSO_PER_CPU
1164 lmg %r0,%r10,__PT_R0(%r11)
1165 mvc __LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW
1166 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
1167 jno 0f
1168 BPON
1121 stpt __LC_EXIT_TIMER
1122 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
11230: lmg %r11,%r15,__PT_R11(%r11)
1124 lpswe __LC_RETURN_MCCK_PSW
1125
1126.Lmcck_panic:
1127 lg %r15,__LC_PANIC_STACK
1128 la %r11,STACK_FRAME_OVERHEAD(%r15)

--- 324 unchanged lines hidden ---
1169 stpt __LC_EXIT_TIMER
1170 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
11710: lmg %r11,%r15,__PT_R11(%r11)
1172 lpswe __LC_RETURN_MCCK_PSW
1173
1174.Lmcck_panic:
1175 lg %r15,__LC_PANIC_STACK
1176 la %r11,STACK_FRAME_OVERHEAD(%r15)

--- 324 unchanged lines hidden ---