blob: 1b67fc6ebdc25f1407e569f3114bc3cb4827fd72 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * arch/s390/kernel/entry.S
3 * S390 low-level entry points.
4 *
Heiko Carstens54dfe5d2006-02-01 03:06:38 -08005 * Copyright (C) IBM Corp. 1999,2006
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
Heiko Carstens25d83cb2006-09-28 16:56:37 +02007 * Hartmut Penner (hp@de.ibm.com),
8 * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
Heiko Carstens77fa2242005-06-25 14:55:30 -07009 * Heiko Carstens <heiko.carstens@de.ibm.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 */
11
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/linkage.h>
Heiko Carstens2bc89b52008-02-05 16:50:40 +010013#include <linux/init.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <asm/cache.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <asm/errno.h>
16#include <asm/ptrace.h>
17#include <asm/thread_info.h>
Sam Ravnborg0013a852005-09-09 20:57:26 +020018#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <asm/unistd.h>
20#include <asm/page.h>
21
22/*
23 * Stack layout for the system_call stack entry.
24 * The first few entries are identical to the user_regs_struct.
25 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +020026SP_PTREGS = STACK_FRAME_OVERHEAD
27SP_ARGS = STACK_FRAME_OVERHEAD + __PT_ARGS
28SP_PSW = STACK_FRAME_OVERHEAD + __PT_PSW
29SP_R0 = STACK_FRAME_OVERHEAD + __PT_GPRS
30SP_R1 = STACK_FRAME_OVERHEAD + __PT_GPRS + 4
31SP_R2 = STACK_FRAME_OVERHEAD + __PT_GPRS + 8
32SP_R3 = STACK_FRAME_OVERHEAD + __PT_GPRS + 12
33SP_R4 = STACK_FRAME_OVERHEAD + __PT_GPRS + 16
34SP_R5 = STACK_FRAME_OVERHEAD + __PT_GPRS + 20
35SP_R6 = STACK_FRAME_OVERHEAD + __PT_GPRS + 24
36SP_R7 = STACK_FRAME_OVERHEAD + __PT_GPRS + 28
37SP_R8 = STACK_FRAME_OVERHEAD + __PT_GPRS + 32
38SP_R9 = STACK_FRAME_OVERHEAD + __PT_GPRS + 36
39SP_R10 = STACK_FRAME_OVERHEAD + __PT_GPRS + 40
40SP_R11 = STACK_FRAME_OVERHEAD + __PT_GPRS + 44
41SP_R12 = STACK_FRAME_OVERHEAD + __PT_GPRS + 48
42SP_R13 = STACK_FRAME_OVERHEAD + __PT_GPRS + 52
43SP_R14 = STACK_FRAME_OVERHEAD + __PT_GPRS + 56
44SP_R15 = STACK_FRAME_OVERHEAD + __PT_GPRS + 60
45SP_ORIG_R2 = STACK_FRAME_OVERHEAD + __PT_ORIG_GPR2
46SP_ILC = STACK_FRAME_OVERHEAD + __PT_ILC
Martin Schwidefsky59da2132008-11-27 11:05:55 +010047SP_SVCNR = STACK_FRAME_OVERHEAD + __PT_SVCNR
Heiko Carstens25d83cb2006-09-28 16:56:37 +020048SP_SIZE = STACK_FRAME_OVERHEAD + __PT_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +020050_TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +010051 _TIF_MCCK_PENDING | _TIF_RESTART_SVC | _TIF_PER_TRAP )
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +020052_TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
Heiko Carstens54dfe5d2006-02-01 03:06:38 -080053 _TIF_MCCK_PENDING)
Heiko Carstens9bf12262009-06-12 10:26:47 +020054_TIF_SYSCALL = (_TIF_SYSCALL_TRACE>>8 | _TIF_SYSCALL_AUDIT>>8 | \
Josh Stone66700002009-08-24 14:43:11 -070055 _TIF_SECCOMP>>8 | _TIF_SYSCALL_TRACEPOINT>>8)
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
57STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
58STACK_SIZE = 1 << STACK_SHIFT
59
60#define BASED(name) name-system_call(%r13)
61
Heiko Carstens1f194a42006-07-03 00:24:46 -070062#ifdef CONFIG_TRACE_IRQFLAGS
63 .macro TRACE_IRQS_ON
Heiko Carstens50bec4c2008-11-14 18:18:05 +010064 basr %r2,%r0
65 l %r1,BASED(.Ltrace_irq_on_caller)
Heiko Carstens1f194a42006-07-03 00:24:46 -070066 basr %r14,%r1
67 .endm
68
69 .macro TRACE_IRQS_OFF
Heiko Carstens50bec4c2008-11-14 18:18:05 +010070 basr %r2,%r0
71 l %r1,BASED(.Ltrace_irq_off_caller)
Heiko Carstens1f194a42006-07-03 00:24:46 -070072 basr %r14,%r1
73 .endm
74#else
75#define TRACE_IRQS_ON
76#define TRACE_IRQS_OFF
Heiko Carstens411788e2007-11-20 11:13:32 +010077#endif
78
79#ifdef CONFIG_LOCKDEP
80 .macro LOCKDEP_SYS_EXIT
81 tm SP_PSW+1(%r15),0x01 # returning to user ?
82 jz 0f
83 l %r1,BASED(.Llockdep_sys_exit)
84 basr %r14,%r1
850:
86 .endm
87#else
Heiko Carstens523b44c2007-10-11 22:11:12 +020088#define LOCKDEP_SYS_EXIT
Heiko Carstens1f194a42006-07-03 00:24:46 -070089#endif
90
Linus Torvalds1da177e2005-04-16 15:20:36 -070091/*
92 * Register usage in interrupt handlers:
93 * R9 - pointer to current task structure
94 * R13 - pointer to literal pool
95 * R14 - return register for function calls
96 * R15 - kernel stack pointer
97 */
98
Heiko Carstens25d83cb2006-09-28 16:56:37 +020099 .macro UPDATE_VTIME lc_from,lc_to,lc_sum
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 lm %r10,%r11,\lc_from
101 sl %r10,\lc_to
102 sl %r11,\lc_to+4
103 bc 3,BASED(0f)
104 sl %r10,BASED(.Lc_1)
1050: al %r10,\lc_sum
106 al %r11,\lc_sum+4
107 bc 12,BASED(1f)
108 al %r10,BASED(.Lc_1)
1091: stm %r10,%r11,\lc_sum
110 .endm
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100112 .macro SAVE_ALL_SVC psworg,savearea
113 stm %r12,%r15,\savearea
114 l %r13,__LC_SVC_NEW_PSW+4 # load &system_call to %r13
115 l %r15,__LC_KERNEL_STACK # problem state -> load ksp
116 s %r15,BASED(.Lc_spsize) # make room for registers & psw
117 .endm
118
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 .macro SAVE_ALL_BASE savearea
120 stm %r12,%r15,\savearea
121 l %r13,__LC_SVC_NEW_PSW+4 # load &system_call to %r13
122 .endm
123
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100124 .macro SAVE_ALL_PGM psworg,savearea
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 tm \psworg+1,0x01 # test problem state bit
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200126#ifdef CONFIG_CHECK_STACK
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100127 bnz BASED(1f)
128 tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
129 bnz BASED(2f)
130 la %r12,\psworg
131 b BASED(stack_overflow)
132#else
133 bz BASED(2f)
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200134#endif
Martin Schwidefsky1de34472011-01-05 12:47:57 +01001351: l %r15,__LC_KERNEL_STACK # problem state -> load ksp
1362: s %r15,BASED(.Lc_spsize) # make room for registers & psw
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200137 .endm
138
139 .macro SAVE_ALL_ASYNC psworg,savearea
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100140 stm %r12,%r15,\savearea
141 l %r13,__LC_SVC_NEW_PSW+4 # load &system_call to %r13
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200142 la %r12,\psworg
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 tm \psworg+1,0x01 # test problem state bit
144 bnz BASED(1f) # from user -> load async stack
145 clc \psworg+4(4),BASED(.Lcritical_end)
146 bhe BASED(0f)
147 clc \psworg+4(4),BASED(.Lcritical_start)
148 bl BASED(0f)
149 l %r14,BASED(.Lcleanup_critical)
150 basr %r14,%r14
Peter Oberparleiter6add9f72005-09-16 19:27:42 -0700151 tm 1(%r12),0x01 # retest problem state after cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 bnz BASED(1f)
1530: l %r14,__LC_ASYNC_STACK # are we already on the async stack ?
154 slr %r14,%r15
155 sra %r14,STACK_SHIFT
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156#ifdef CONFIG_CHECK_STACK
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100157 bnz BASED(1f)
158 tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
159 bnz BASED(2f)
160 b BASED(stack_overflow)
161#else
162 bz BASED(2f)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163#endif
Martin Schwidefsky1de34472011-01-05 12:47:57 +01001641: l %r15,__LC_ASYNC_STACK
1652: s %r15,BASED(.Lc_spsize) # make room for registers & psw
Heiko Carstens77fa2242005-06-25 14:55:30 -0700166 .endm
167
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100168 .macro CREATE_STACK_FRAME savearea
169 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 st %r2,SP_ORIG_R2(%r15) # store original content of gpr 2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 mvc SP_R12(16,%r15),\savearea # move %r12-%r15 to stack
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100172 stm %r0,%r11,SP_R0(%r15) # store gprs %r0-%r11 to kernel stack
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 .endm
174
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200175 .macro RESTORE_ALL psworg,sync
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700176 mvc \psworg(8),SP_PSW(%r15) # move user PSW to lowcore
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 .if !\sync
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700178 ni \psworg+1,0xfd # clear wait state bit
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 .endif
180 lm %r0,%r15,SP_R0(%r15) # load gprs 0-15 of user
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100181 stpt __LC_EXIT_TIMER
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700182 lpsw \psworg # back to caller
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 .endm
184
Martin Schwidefsky1e546222010-10-25 16:10:37 +0200185 .macro REENABLE_IRQS
186 mvc __SF_EMPTY(1,%r15),SP_PSW(%r15)
187 ni __SF_EMPTY(%r15),0xbf
188 ssm __SF_EMPTY(%r15)
189 .endm
190
Martin Schwidefsky860dba42011-01-05 12:47:25 +0100191 .section .kprobes.text, "ax"
192
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193/*
194 * Scheduler resume function, called by switch_to
195 * gpr2 = (task_struct *) prev
196 * gpr3 = (task_struct *) next
197 * Returns:
198 * gpr2 = prev
199 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200200 .globl __switch_to
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201__switch_to:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200202 basr %r1,0
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +01002030: l %r4,__THREAD_info(%r2) # get thread_info of prev
204 l %r5,__THREAD_info(%r3) # get thread_info of next
Heiko Carstens77fa2242005-06-25 14:55:30 -0700205 tm __TI_flags+3(%r4),_TIF_MCCK_PENDING # machine check pending?
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100206 bz 1f-0b(%r1)
207 ni __TI_flags+3(%r4),255-_TIF_MCCK_PENDING # clear flag in prev
208 oi __TI_flags+3(%r5),_TIF_MCCK_PENDING # set it in next
2091: stm %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task
210 st %r15,__THREAD_ksp(%r2) # store kernel stack of prev
211 l %r15,__THREAD_ksp(%r3) # load kernel stack of next
212 lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4
213 lm %r6,%r15,__SF_GPRS(%r15) # load gprs of next task
214 st %r3,__LC_CURRENT # store task struct of next
215 st %r5,__LC_THREAD_INFO # store thread info of next
216 ahi %r5,STACK_SIZE # end of kernel stack of next
217 st %r5,__LC_KERNEL_STACK # store end of kernel stack
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 br %r14
219
220__critical_start:
221/*
222 * SVC interrupt handler routine. System calls are synchronous events and
223 * are executed with interrupts enabled.
224 */
225
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200226 .globl system_call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227system_call:
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100228 stpt __LC_SYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229sysc_saveall:
Martin Schwidefsky987ad702007-07-10 11:24:18 +0200230 SAVE_ALL_SVC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100231 CREATE_STACK_FRAME __LC_SAVE_AREA
232 mvc SP_PSW(8,%r15),__LC_SVC_OLD_PSW
233 mvc SP_ILC(4,%r15),__LC_SVC_ILC
234 l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235sysc_vtime:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
237sysc_stime:
238 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
239sysc_update:
240 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241sysc_do_svc:
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100242 xr %r7,%r7
243 icm %r7,3,SP_SVCNR(%r15) # load svc number and test for svc 0
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200244 bnz BASED(sysc_nr_ok) # svc number > 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 # svc 0: system call number in %r1
246 cl %r1,BASED(.Lnr_syscalls)
247 bnl BASED(sysc_nr_ok)
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100248 sth %r1,SP_SVCNR(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200249 lr %r7,%r1 # copy svc number to %r7
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250sysc_nr_ok:
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100251 sll %r7,2 # svc number *4
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100252 l %r10,BASED(.Lsysc_table)
253 tm __TI_flags+2(%r12),_TIF_SYSCALL
Martin Schwidefskybaa07152010-10-25 16:10:40 +0200254 mvc SP_ARGS(4,%r15),SP_R7(%r15)
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100255 l %r8,0(%r7,%r10) # get system call addr.
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200256 bnz BASED(sysc_tracesys)
257 basr %r14,%r8 # call sys_xxxx
258 st %r2,SP_R2(%r15) # store return value (change R2 on stack)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259
260sysc_return:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200261 LOCKDEP_SYS_EXIT
262sysc_tif:
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100263 tm __TI_flags+3(%r12),_TIF_WORK_SVC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 bnz BASED(sysc_work) # there is work to do (signals etc.)
Heiko Carstens411788e2007-11-20 11:13:32 +0100265sysc_restore:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200266 RESTORE_ALL __LC_RETURN_PSW,1
Heiko Carstens411788e2007-11-20 11:13:32 +0100267sysc_done:
268
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269#
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200270# There is work to do, but first we need to check if we return to userspace.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271#
272sysc_work:
Martin Schwidefsky26889052008-05-07 09:22:52 +0200273 tm SP_PSW+1(%r15),0x01 # returning to user ?
274 bno BASED(sysc_restore)
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200275
276#
277# One of the work bits is on. Find out which one.
278#
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200279sysc_work_tif:
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100280 tm __TI_flags+3(%r12),_TIF_MCCK_PENDING
Heiko Carstens77fa2242005-06-25 14:55:30 -0700281 bo BASED(sysc_mcck_pending)
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100282 tm __TI_flags+3(%r12),_TIF_NEED_RESCHED
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 bo BASED(sysc_reschedule)
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100284 tm __TI_flags+3(%r12),_TIF_SIGPENDING
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200285 bo BASED(sysc_sigpending)
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100286 tm __TI_flags+3(%r12),_TIF_NOTIFY_RESUME
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200287 bo BASED(sysc_notify_resume)
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100288 tm __TI_flags+3(%r12),_TIF_RESTART_SVC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 bo BASED(sysc_restart)
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100290 tm __TI_flags+3(%r12),_TIF_PER_TRAP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 bo BASED(sysc_singlestep)
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200292 b BASED(sysc_return) # beware of critical section cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293
294#
295# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200296#
297sysc_reschedule:
298 l %r1,BASED(.Lschedule)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200299 la %r14,BASED(sysc_return)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200300 br %r1 # call scheduler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301
302#
Heiko Carstens77fa2242005-06-25 14:55:30 -0700303# _TIF_MCCK_PENDING is set, call handler
304#
305sysc_mcck_pending:
306 l %r1,BASED(.Ls390_handle_mcck)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200307 la %r14,BASED(sysc_return)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700308 br %r1 # TIF bit will be cleared by handler
309
310#
Roland McGrath02a029b2008-04-30 00:53:08 -0700311# _TIF_SIGPENDING is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312#
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200313sysc_sigpending:
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100314 ni __TI_flags+3(%r12),255-_TIF_PER_TRAP # clear TIF_PER_TRAP
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200315 la %r2,SP_PTREGS(%r15) # load pt_regs
316 l %r1,BASED(.Ldo_signal)
317 basr %r14,%r1 # call do_signal
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100318 tm __TI_flags+3(%r12),_TIF_RESTART_SVC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 bo BASED(sysc_restart)
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100320 tm __TI_flags+3(%r12),_TIF_PER_TRAP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 bo BASED(sysc_singlestep)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200322 b BASED(sysc_return)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323
324#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200325# _TIF_NOTIFY_RESUME is set, call do_notify_resume
326#
327sysc_notify_resume:
328 la %r2,SP_PTREGS(%r15) # load pt_regs
329 l %r1,BASED(.Ldo_notify_resume)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200330 la %r14,BASED(sysc_return)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200331 br %r1 # call do_notify_resume
332
333
334#
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335# _TIF_RESTART_SVC is set, set up registers and restart svc
336#
337sysc_restart:
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100338 ni __TI_flags+3(%r12),255-_TIF_RESTART_SVC # clear TIF_RESTART_SVC
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200339 l %r7,SP_R2(%r15) # load new svc number
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 mvc SP_R2(4,%r15),SP_ORIG_R2(%r15) # restore first argument
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200341 lm %r2,%r6,SP_R2(%r15) # load svc arguments
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100342 sth %r7,SP_SVCNR(%r15)
Martin Schwidefskybaa07152010-10-25 16:10:40 +0200343 b BASED(sysc_nr_ok) # restart svc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344
345#
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100346# _TIF_PER_TRAP is set, call do_per_trap
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347#
348sysc_singlestep:
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100349 ni __TI_flags+3(%r12),255-_TIF_PER_TRAP # clear TIF_PER_TRAP
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100350 xc SP_SVCNR(2,%r15),SP_SVCNR(%r15) # clear svc number
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351 la %r2,SP_PTREGS(%r15) # address of register-save area
352 l %r1,BASED(.Lhandle_per) # load adr. of per handler
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200353 la %r14,BASED(sysc_return) # load adr. of system return
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100354 br %r1 # branch to do_per_trap
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200357# call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
358# and after the system call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359#
360sysc_tracesys:
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200361 l %r1,BASED(.Ltrace_entry)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200362 la %r2,SP_PTREGS(%r15) # load pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 la %r3,0
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100364 xr %r0,%r0
365 icm %r0,3,SP_SVCNR(%r15)
366 st %r0,SP_R2(%r15)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 basr %r14,%r1
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200368 cl %r2,BASED(.Lnr_syscalls)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 bnl BASED(sysc_tracenogo)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200370 lr %r7,%r2
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100371 sll %r7,2 # svc number *4
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100372 l %r8,0(%r7,%r10)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373sysc_tracego:
374 lm %r3,%r6,SP_R3(%r15)
Martin Schwidefskybaa07152010-10-25 16:10:40 +0200375 mvc SP_ARGS(4,%r15),SP_R7(%r15)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 l %r2,SP_ORIG_R2(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200377 basr %r14,%r8 # call sys_xxx
378 st %r2,SP_R2(%r15) # store return value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379sysc_tracenogo:
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100380 tm __TI_flags+2(%r12),_TIF_SYSCALL
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200381 bz BASED(sysc_return)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200382 l %r1,BASED(.Ltrace_exit)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200383 la %r2,SP_PTREGS(%r15) # load pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384 la %r14,BASED(sysc_return)
385 br %r1
386
387#
388# a new process exits the kernel with ret_from_fork
389#
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200390 .globl ret_from_fork
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391ret_from_fork:
392 l %r13,__LC_SVC_NEW_PSW+4
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100393 l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394 tm SP_PSW+1(%r15),0x01 # forking a kernel thread ?
395 bo BASED(0f)
396 st %r15,SP_R15(%r15) # store stack pointer for new kthread
Heiko Carstens25d83cb2006-09-28 16:56:37 +02003970: l %r1,BASED(.Lschedtail)
398 basr %r14,%r1
Heiko Carstens1f194a42006-07-03 00:24:46 -0700399 TRACE_IRQS_ON
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200400 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
Al Viro8f2961c2008-12-25 13:37:58 +0100401 b BASED(sysc_tracenogo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402
403#
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200404# kernel_execve function needs to deal with pt_regs that is not
405# at the usual place
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406#
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200407 .globl kernel_execve
408kernel_execve:
409 stm %r12,%r15,48(%r15)
410 lr %r14,%r15
411 l %r13,__LC_SVC_NEW_PSW+4
412 s %r15,BASED(.Lc_spsize)
413 st %r14,__SF_BACKCHAIN(%r15)
414 la %r12,SP_PTREGS(%r15)
415 xc 0(__PT_SIZE,%r12),0(%r12)
416 l %r1,BASED(.Ldo_execve)
417 lr %r5,%r12
418 basr %r14,%r1
419 ltr %r2,%r2
420 be BASED(0f)
421 a %r15,BASED(.Lc_spsize)
422 lm %r12,%r15,48(%r15)
423 br %r14
424 # execve succeeded.
4250: stnsm __SF_EMPTY(%r15),0xfc # disable interrupts
426 l %r15,__LC_KERNEL_STACK # load ksp
427 s %r15,BASED(.Lc_spsize) # make room for registers & psw
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200428 mvc SP_PTREGS(__PT_SIZE,%r15),0(%r12) # copy pt_regs
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100429 l %r12,__LC_THREAD_INFO
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200430 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15)
431 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
432 l %r1,BASED(.Lexecve_tail)
433 basr %r14,%r1
434 b BASED(sysc_return)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435
436/*
437 * Program check handler routine
438 */
439
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200440 .globl pgm_check_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441pgm_check_handler:
442/*
443 * First we need to check for a special case:
444 * Single stepping an instruction that disables the PER event mask will
445 * cause a PER event AFTER the mask has been set. Example: SVC or LPSW.
446 * For a single stepped SVC the program check handler gets control after
447 * the SVC new PSW has been loaded. But we want to execute the SVC first and
448 * then handle the PER event. Therefore we update the SVC old PSW to point
449 * to the pgm_check_handler and branch to the SVC handler after we checked
450 * if we have to load the kernel stack register.
451 * For every other possible cause for PER event without the PER mask set
452 * we just ignore the PER event (FIXME: is there anything we have to do
453 * for LPSW?).
454 */
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100455 stpt __LC_SYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456 SAVE_ALL_BASE __LC_SAVE_AREA
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200457 tm __LC_PGM_INT_CODE+1,0x80 # check whether we got a per exception
458 bnz BASED(pgm_per) # got per exception -> special case
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100459 SAVE_ALL_PGM __LC_PGM_OLD_PSW,__LC_SAVE_AREA
460 CREATE_STACK_FRAME __LC_SAVE_AREA
461 xc SP_ILC(4,%r15),SP_ILC(%r15)
462 mvc SP_PSW(8,%r15),__LC_PGM_OLD_PSW
463 l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
465 bz BASED(pgm_no_vtime)
466 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
467 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
468 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
469pgm_no_vtime:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200470 l %r3,__LC_PGM_ILC # load program interruption code
Martin Schwidefsky1e546222010-10-25 16:10:37 +0200471 l %r4,__LC_TRANS_EXC_CODE
472 REENABLE_IRQS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 la %r8,0x7f
474 nr %r8,%r3
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200475 sll %r8,2
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100476 l %r1,BASED(.Ljump_table)
477 l %r1,0(%r8,%r1) # load address of handler routine
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200478 la %r2,SP_PTREGS(%r15) # address of register-save area
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100479 basr %r14,%r1 # branch to interrupt-handler
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200480pgm_exit:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200481 b BASED(sysc_return)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482
483#
484# handle per exception
485#
486pgm_per:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200487 tm __LC_PGM_OLD_PSW,0x40 # test if per event recording is on
488 bnz BASED(pgm_per_std) # ok, normal per event from user space
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489# ok its one of the special cases, now we need to find out which one
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200490 clc __LC_PGM_OLD_PSW(8),__LC_SVC_NEW_PSW
491 be BASED(pgm_svcper)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492# no interesting special case, ignore PER event
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200493 lm %r12,%r15,__LC_SAVE_AREA
494 lpsw 0x28
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495
496#
497# Normal per exception
498#
499pgm_per_std:
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100500 SAVE_ALL_PGM __LC_PGM_OLD_PSW,__LC_SAVE_AREA
501 CREATE_STACK_FRAME __LC_SAVE_AREA
502 mvc SP_PSW(8,%r15),__LC_PGM_OLD_PSW
503 l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
505 bz BASED(pgm_no_vtime2)
506 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
507 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
508 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
509pgm_no_vtime2:
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100510 l %r1,__TI_task(%r12)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200511 tm SP_PSW+1(%r15),0x01 # kernel per event ?
512 bz BASED(kernel_per)
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100513 mvc __THREAD_per_cause(2,%r1),__LC_PER_CAUSE
514 mvc __THREAD_per_address(4,%r1),__LC_PER_ADDRESS
515 mvc __THREAD_per_paid(1,%r1),__LC_PER_PAID
516 oi __TI_flags+3(%r12),_TIF_PER_TRAP # set TIF_PER_TRAP
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200517 l %r3,__LC_PGM_ILC # load program interruption code
Martin Schwidefsky1e546222010-10-25 16:10:37 +0200518 l %r4,__LC_TRANS_EXC_CODE
519 REENABLE_IRQS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 la %r8,0x7f
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200521 nr %r8,%r3 # clear per-event-bit and ilc
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200522 be BASED(pgm_exit2) # only per or per+check ?
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200523 sll %r8,2
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100524 l %r1,BASED(.Ljump_table)
525 l %r1,0(%r8,%r1) # load address of handler routine
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200526 la %r2,SP_PTREGS(%r15) # address of register-save area
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100527 basr %r14,%r1 # branch to interrupt-handler
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200528pgm_exit2:
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200529 b BASED(sysc_return)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530
531#
532# it was a single stepped SVC that is causing all the trouble
533#
534pgm_svcper:
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100535 SAVE_ALL_PGM __LC_SVC_OLD_PSW,__LC_SAVE_AREA
536 CREATE_STACK_FRAME __LC_SAVE_AREA
537 mvc SP_PSW(8,%r15),__LC_SVC_OLD_PSW
538 mvc SP_ILC(4,%r15),__LC_SVC_ILC
539 l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
541 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
542 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100543 l %r8,__TI_task(%r12)
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100544 mvc __THREAD_per_cause(2,%r8),__LC_PER_CAUSE
545 mvc __THREAD_per_address(4,%r8),__LC_PER_ADDRESS
546 mvc __THREAD_per_paid(1,%r8),__LC_PER_PAID
547 oi __TI_flags+3(%r12),_TIF_PER_TRAP # set TIF_PER_TRAP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200549 lm %r2,%r6,SP_R2(%r15) # load svc arguments
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 b BASED(sysc_do_svc)
551
Michael Grundy4ba069b2006-09-20 15:58:39 +0200552#
553# per was called from kernel, must be kprobes
554#
555kernel_per:
Martin Schwidefsky9ec27082010-10-29 16:50:45 +0200556 REENABLE_IRQS
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100557 xc SP_SVCNR(2,%r15),SP_SVCNR(%r15)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200558 la %r2,SP_PTREGS(%r15) # address of register-save area
559 l %r1,BASED(.Lhandle_per) # load adr. of per handler
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200560 basr %r14,%r1 # branch to do_single_step
561 b BASED(pgm_exit)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200562
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563/*
564 * IO interrupt handler routine
565 */
566
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200567 .globl io_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568io_int_handler:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 stck __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100570 stpt __LC_ASYNC_ENTER_TIMER
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200571 SAVE_ALL_ASYNC __LC_IO_OLD_PSW,__LC_SAVE_AREA+16
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100572 CREATE_STACK_FRAME __LC_SAVE_AREA+16
573 mvc SP_PSW(8,%r15),0(%r12) # move user PSW to stack
574 l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
576 bz BASED(io_no_vtime)
577 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
578 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
579 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
580io_no_vtime:
Heiko Carstens1f194a42006-07-03 00:24:46 -0700581 TRACE_IRQS_OFF
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200582 l %r1,BASED(.Ldo_IRQ) # load address of do_IRQ
583 la %r2,SP_PTREGS(%r15) # address of register-save area
584 basr %r14,%r1 # branch to standard irq handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585io_return:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200586 LOCKDEP_SYS_EXIT
587 TRACE_IRQS_ON
588io_tif:
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100589 tm __TI_flags+3(%r12),_TIF_WORK_INT
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200590 bnz BASED(io_work) # there is work to do (signals etc.)
Heiko Carstens411788e2007-11-20 11:13:32 +0100591io_restore:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200592 RESTORE_ALL __LC_RETURN_PSW,0
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700593io_done:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594
Martin Schwidefsky26889052008-05-07 09:22:52 +0200595#
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200596# There is work todo, find out in which context we have been interrupted:
597# 1) if we return to user space we can do all _TIF_WORK_INT work
598# 2) if we return to kernel code and preemptive scheduling is enabled check
599# the preemption counter and if it is zero call preempt_schedule_irq
600# Before any work can be done, a switch to the kernel stack is required.
Martin Schwidefsky26889052008-05-07 09:22:52 +0200601#
602io_work:
603 tm SP_PSW+1(%r15),0x01 # returning to user ?
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200604 bo BASED(io_work_user) # yes -> do resched & signal
605#ifdef CONFIG_PREEMPT
Martin Schwidefsky26889052008-05-07 09:22:52 +0200606 # check for preemptive scheduling
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100607 icm %r0,15,__TI_precount(%r12)
Martin Schwidefsky26889052008-05-07 09:22:52 +0200608 bnz BASED(io_restore) # preemption disabled
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100609 tm __TI_flags+3(%r12),_TIF_NEED_RESCHED
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200610 bno BASED(io_restore)
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200611 # switch to kernel stack
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 l %r1,SP_R15(%r15)
613 s %r1,BASED(.Lc_spsize)
614 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200615 xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1) # clear back chain
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 lr %r15,%r1
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200617 # TRACE_IRQS_ON already done at io_return, call
618 # TRACE_IRQS_OFF to keep things symmetrical
619 TRACE_IRQS_OFF
Heiko Carstensb8e7a542007-11-20 11:13:35 +0100620 l %r1,BASED(.Lpreempt_schedule_irq)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200621 basr %r14,%r1 # call preempt_schedule_irq
622 b BASED(io_return)
623#else
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200624 b BASED(io_restore)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200625#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200627#
628# Need to do work before returning to userspace, switch to kernel stack
629#
Martin Schwidefsky26889052008-05-07 09:22:52 +0200630io_work_user:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 l %r1,__LC_KERNEL_STACK
632 s %r1,BASED(.Lc_spsize)
633 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200634 xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1) # clear back chain
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 lr %r15,%r1
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200636
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637#
638# One of the work bits is on. Find out which one.
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200639# Checked are: _TIF_SIGPENDING, _TIF_NOTIFY_RESUME, _TIF_NEED_RESCHED
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200640# and _TIF_MCCK_PENDING
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641#
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200642io_work_tif:
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100643 tm __TI_flags+3(%r12),_TIF_MCCK_PENDING
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200644 bo BASED(io_mcck_pending)
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100645 tm __TI_flags+3(%r12),_TIF_NEED_RESCHED
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 bo BASED(io_reschedule)
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100647 tm __TI_flags+3(%r12),_TIF_SIGPENDING
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200648 bo BASED(io_sigpending)
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100649 tm __TI_flags+3(%r12),_TIF_NOTIFY_RESUME
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200650 bo BASED(io_notify_resume)
651 b BASED(io_return) # beware of critical section cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652
653#
Heiko Carstens77fa2242005-06-25 14:55:30 -0700654# _TIF_MCCK_PENDING is set, call handler
655#
656io_mcck_pending:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200657 # TRACE_IRQS_ON already done at io_return
Heiko Carstens77fa2242005-06-25 14:55:30 -0700658 l %r1,BASED(.Ls390_handle_mcck)
Heiko Carstensb771aea2007-07-27 12:29:18 +0200659 basr %r14,%r1 # TIF bit will be cleared by handler
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200660 TRACE_IRQS_OFF
661 b BASED(io_return)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700662
663#
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200665#
666io_reschedule:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200667 # TRACE_IRQS_ON already done at io_return
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200668 l %r1,BASED(.Lschedule)
669 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
670 basr %r14,%r1 # call scheduler
671 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100672 TRACE_IRQS_OFF
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200673 b BASED(io_return)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674
675#
Roland McGrath02a029b2008-04-30 00:53:08 -0700676# _TIF_SIGPENDING is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677#
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200678io_sigpending:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200679 # TRACE_IRQS_ON already done at io_return
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200680 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
681 la %r2,SP_PTREGS(%r15) # load pt_regs
682 l %r1,BASED(.Ldo_signal)
683 basr %r14,%r1 # call do_signal
684 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100685 TRACE_IRQS_OFF
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200686 b BASED(io_return)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200688#
689# _TIF_SIGPENDING is set, call do_signal
690#
691io_notify_resume:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200692 # TRACE_IRQS_ON already done at io_return
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200693 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
694 la %r2,SP_PTREGS(%r15) # load pt_regs
695 l %r1,BASED(.Ldo_notify_resume)
696 basr %r14,%r1 # call do_signal
697 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
698 TRACE_IRQS_OFF
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200699 b BASED(io_return)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200700
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701/*
702 * External interrupt handler routine
703 */
704
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200705 .globl ext_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706ext_int_handler:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707 stck __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100708 stpt __LC_ASYNC_ENTER_TIMER
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200709 SAVE_ALL_ASYNC __LC_EXT_OLD_PSW,__LC_SAVE_AREA+16
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100710 CREATE_STACK_FRAME __LC_SAVE_AREA+16
711 mvc SP_PSW(8,%r15),0(%r12) # move user PSW to stack
712 l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
714 bz BASED(ext_no_vtime)
715 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
716 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
717 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
718ext_no_vtime:
Heiko Carstens1f194a42006-07-03 00:24:46 -0700719 TRACE_IRQS_OFF
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200720 la %r2,SP_PTREGS(%r15) # address of register-save area
Martin Schwidefskyf6649a72010-10-25 16:10:38 +0200721 l %r3,__LC_CPU_ADDRESS # get cpu address + interruption code
722 l %r4,__LC_EXT_PARAMS # get external parameters
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 l %r1,BASED(.Ldo_extint)
724 basr %r14,%r1
725 b BASED(io_return)
726
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700727__critical_end:
728
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729/*
730 * Machine check handler routines
731 */
732
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200733 .globl mcck_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734mcck_int_handler:
Martin Schwidefsky63779812010-05-17 10:00:03 +0200735 stck __LC_MCCK_CLOCK
Heiko Carstens77fa2242005-06-25 14:55:30 -0700736 spt __LC_CPU_TIMER_SAVE_AREA # revalidate cpu timer
737 lm %r0,%r15,__LC_GPREGS_SAVE_AREA # revalidate gprs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738 SAVE_ALL_BASE __LC_SAVE_AREA+32
Heiko Carstens77fa2242005-06-25 14:55:30 -0700739 la %r12,__LC_MCK_OLD_PSW
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200740 tm __LC_MCCK_CODE,0x80 # system damage?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700741 bo BASED(mcck_int_main) # yes -> rest of mcck code invalid
Martin Schwidefsky63779812010-05-17 10:00:03 +0200742 mvc __LC_MCCK_ENTER_TIMER(8),__LC_CPU_TIMER_SAVE_AREA
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200743 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
744 bo BASED(1f)
745 la %r14,__LC_SYNC_ENTER_TIMER
746 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
747 bl BASED(0f)
748 la %r14,__LC_ASYNC_ENTER_TIMER
7490: clc 0(8,%r14),__LC_EXIT_TIMER
750 bl BASED(0f)
751 la %r14,__LC_EXIT_TIMER
7520: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
753 bl BASED(0f)
754 la %r14,__LC_LAST_UPDATE_TIMER
7550: spt 0(%r14)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200756 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
Martin Schwidefskyc185b782008-12-25 13:39:25 +01007571: tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700758 bno BASED(mcck_int_main) # no -> skip cleanup critical
759 tm __LC_MCK_OLD_PSW+1,0x01 # test problem state bit
760 bnz BASED(mcck_int_main) # from user -> load async stack
761 clc __LC_MCK_OLD_PSW+4(4),BASED(.Lcritical_end)
762 bhe BASED(mcck_int_main)
763 clc __LC_MCK_OLD_PSW+4(4),BASED(.Lcritical_start)
764 bl BASED(mcck_int_main)
765 l %r14,BASED(.Lcleanup_critical)
766 basr %r14,%r14
767mcck_int_main:
768 l %r14,__LC_PANIC_STACK # are we already on the panic stack?
769 slr %r14,%r15
770 sra %r14,PAGE_SHIFT
771 be BASED(0f)
772 l %r15,__LC_PANIC_STACK # load panic stack
Martin Schwidefsky1de34472011-01-05 12:47:57 +01007730: s %r15,BASED(.Lc_spsize) # make room for registers & psw
774 CREATE_STACK_FRAME __LC_SAVE_AREA+32
775 mvc SP_PSW(8,%r15),0(%r12)
776 l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200777 tm __LC_MCCK_CODE+2,0x08 # mwp of old psw valid?
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700778 bno BASED(mcck_no_vtime) # no -> skip cleanup critical
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200779 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700780 bz BASED(mcck_no_vtime)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200781 UPDATE_VTIME __LC_EXIT_TIMER,__LC_MCCK_ENTER_TIMER,__LC_USER_TIMER
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700782 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
Martin Schwidefsky63779812010-05-17 10:00:03 +0200783 mvc __LC_LAST_UPDATE_TIMER(8),__LC_MCCK_ENTER_TIMER
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700784mcck_no_vtime:
Heiko Carstens77fa2242005-06-25 14:55:30 -0700785 la %r2,SP_PTREGS(%r15) # load pt_regs
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200786 l %r1,BASED(.Ls390_mcck)
787 basr %r14,%r1 # call machine check handler
788 tm SP_PSW+1(%r15),0x01 # returning to user ?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700789 bno BASED(mcck_return)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200790 l %r1,__LC_KERNEL_STACK # switch to kernel stack
Heiko Carstens77fa2242005-06-25 14:55:30 -0700791 s %r1,BASED(.Lc_spsize)
792 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200793 xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1) # clear back chain
Heiko Carstens77fa2242005-06-25 14:55:30 -0700794 lr %r15,%r1
795 stosm __SF_EMPTY(%r15),0x04 # turn dat on
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100796 tm __TI_flags+3(%r12),_TIF_MCCK_PENDING
Heiko Carstens77fa2242005-06-25 14:55:30 -0700797 bno BASED(mcck_return)
Heiko Carstens1f194a42006-07-03 00:24:46 -0700798 TRACE_IRQS_OFF
Heiko Carstens77fa2242005-06-25 14:55:30 -0700799 l %r1,BASED(.Ls390_handle_mcck)
800 basr %r14,%r1 # call machine check handler
Heiko Carstens1f194a42006-07-03 00:24:46 -0700801 TRACE_IRQS_ON
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802mcck_return:
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200803 mvc __LC_RETURN_MCCK_PSW(8),SP_PSW(%r15) # move return PSW
804 ni __LC_RETURN_MCCK_PSW+1,0xfd # clear wait state bit
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200805 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
806 bno BASED(0f)
807 lm %r0,%r15,SP_R0(%r15) # load gprs 0-15
808 stpt __LC_EXIT_TIMER
809 lpsw __LC_RETURN_MCCK_PSW # back to caller
Martin Schwidefskyc185b782008-12-25 13:39:25 +01008100: lm %r0,%r15,SP_R0(%r15) # load gprs 0-15
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200811 lpsw __LC_RETURN_MCCK_PSW # back to caller
812
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200813 RESTORE_ALL __LC_RETURN_MCCK_PSW,0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815/*
816 * Restart interruption handler, kick starter for additional CPUs
817 */
Heiko Carstens84b36a82007-06-19 13:10:03 +0200818#ifdef CONFIG_SMP
Heiko Carstens2bc89b52008-02-05 16:50:40 +0100819 __CPUINIT
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200820 .globl restart_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821restart_int_handler:
Martin Schwidefsky5b409ed2009-04-14 15:36:27 +0200822 basr %r1,0
823restart_base:
824 spt restart_vtime-restart_base(%r1)
825 stck __LC_LAST_UPDATE_CLOCK
826 mvc __LC_LAST_UPDATE_TIMER(8),restart_vtime-restart_base(%r1)
827 mvc __LC_EXIT_TIMER(8),restart_vtime-restart_base(%r1)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200828 l %r15,__LC_SAVE_AREA+60 # load ksp
829 lctl %c0,%c15,__LC_CREGS_SAVE_AREA # get new ctl regs
830 lam %a0,%a15,__LC_AREGS_SAVE_AREA
831 lm %r6,%r15,__SF_GPRS(%r15) # load registers from clone
Martin Schwidefsky5b409ed2009-04-14 15:36:27 +0200832 l %r1,__LC_THREAD_INFO
833 mvc __LC_USER_TIMER(8),__TI_user_timer(%r1)
834 mvc __LC_SYSTEM_TIMER(8),__TI_system_timer(%r1)
835 xc __LC_STEAL_TIMER(8),__LC_STEAL_TIMER
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200836 stosm __SF_EMPTY(%r15),0x04 # now we can turn dat on
837 basr %r14,0
838 l %r14,restart_addr-.(%r14)
Michael Holzheu8eb4bd62011-05-10 17:13:39 +0200839 basr %r14,%r14 # branch to start_secondary
Linus Torvalds1da177e2005-04-16 15:20:36 -0700840restart_addr:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200841 .long start_secondary
Martin Schwidefsky5b409ed2009-04-14 15:36:27 +0200842 .align 8
843restart_vtime:
844 .long 0x7fffffff,0xffffffff
Heiko Carstens84b36a82007-06-19 13:10:03 +0200845 .previous
Linus Torvalds1da177e2005-04-16 15:20:36 -0700846#else
847/*
848 * If we do not run with SMP enabled, let the new CPU crash ...
849 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200850 .globl restart_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700851restart_int_handler:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200852 basr %r1,0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700853restart_base:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200854 lpsw restart_crash-restart_base(%r1)
855 .align 8
Linus Torvalds1da177e2005-04-16 15:20:36 -0700856restart_crash:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200857 .long 0x000a0000,0x00000000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700858restart_go:
859#endif
860
Martin Schwidefsky860dba42011-01-05 12:47:25 +0100861 .section .kprobes.text, "ax"
862
Linus Torvalds1da177e2005-04-16 15:20:36 -0700863#ifdef CONFIG_CHECK_STACK
864/*
865 * The synchronous or the asynchronous stack overflowed. We are dead.
866 * No need to properly save the registers, we are going to panic anyway.
867 * Setup a pt_regs so that show_trace can provide a good call trace.
868 */
869stack_overflow:
870 l %r15,__LC_PANIC_STACK # change to panic stack
871 sl %r15,BASED(.Lc_spsize)
872 mvc SP_PSW(8,%r15),0(%r12) # move user PSW to stack
873 stm %r0,%r11,SP_R0(%r15) # store gprs %r0-%r11 to kernel stack
874 la %r1,__LC_SAVE_AREA
875 ch %r12,BASED(.L0x020) # old psw addr == __LC_SVC_OLD_PSW ?
876 be BASED(0f)
877 ch %r12,BASED(.L0x028) # old psw addr == __LC_PGM_OLD_PSW ?
878 be BASED(0f)
879 la %r1,__LC_SAVE_AREA+16
8800: mvc SP_R12(16,%r15),0(%r1) # move %r12-%r15 to stack
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200881 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15) # clear back chain
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882 l %r1,BASED(1f) # branch to kernel_stack_overflow
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200883 la %r2,SP_PTREGS(%r15) # load pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884 br %r1
Heiko Carstens25d83cb2006-09-28 16:56:37 +02008851: .long kernel_stack_overflow
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886#endif
887
888cleanup_table_system_call:
889 .long system_call + 0x80000000, sysc_do_svc + 0x80000000
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200890cleanup_table_sysc_tif:
891 .long sysc_tif + 0x80000000, sysc_restore + 0x80000000
892cleanup_table_sysc_restore:
893 .long sysc_restore + 0x80000000, sysc_done + 0x80000000
894cleanup_table_io_tif:
895 .long io_tif + 0x80000000, io_restore + 0x80000000
896cleanup_table_io_restore:
897 .long io_restore + 0x80000000, io_done + 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700898
899cleanup_critical:
900 clc 4(4,%r12),BASED(cleanup_table_system_call)
901 bl BASED(0f)
902 clc 4(4,%r12),BASED(cleanup_table_system_call+4)
903 bl BASED(cleanup_system_call)
9040:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200905 clc 4(4,%r12),BASED(cleanup_table_sysc_tif)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906 bl BASED(0f)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200907 clc 4(4,%r12),BASED(cleanup_table_sysc_tif+4)
908 bl BASED(cleanup_sysc_tif)
Linus Torvalds1da177e2005-04-16 15:20:36 -07009090:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200910 clc 4(4,%r12),BASED(cleanup_table_sysc_restore)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700911 bl BASED(0f)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200912 clc 4(4,%r12),BASED(cleanup_table_sysc_restore+4)
913 bl BASED(cleanup_sysc_restore)
Linus Torvalds1da177e2005-04-16 15:20:36 -07009140:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200915 clc 4(4,%r12),BASED(cleanup_table_io_tif)
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200916 bl BASED(0f)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200917 clc 4(4,%r12),BASED(cleanup_table_io_tif+4)
918 bl BASED(cleanup_io_tif)
Martin Schwidefsky63b12242006-06-29 14:58:05 +02009190:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200920 clc 4(4,%r12),BASED(cleanup_table_io_restore)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700921 bl BASED(0f)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200922 clc 4(4,%r12),BASED(cleanup_table_io_restore+4)
923 bl BASED(cleanup_io_restore)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07009240:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700925 br %r14
926
927cleanup_system_call:
928 mvc __LC_RETURN_PSW(8),0(%r12)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700929 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+4)
930 bh BASED(0f)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200931 mvc __LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER
932 c %r12,BASED(.Lmck_old_psw)
933 be BASED(0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700934 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
Martin Schwidefsky63779812010-05-17 10:00:03 +02009350: c %r12,BASED(.Lmck_old_psw)
936 la %r12,__LC_SAVE_AREA+32
937 be BASED(0f)
938 la %r12,__LC_SAVE_AREA+16
Linus Torvalds1da177e2005-04-16 15:20:36 -07009390: clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+8)
940 bhe BASED(cleanup_vtime)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700941 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn)
942 bh BASED(0f)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700943 mvc __LC_SAVE_AREA(16),0(%r12)
9440: st %r13,4(%r12)
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100945 l %r15,__LC_KERNEL_STACK # problem state -> load ksp
946 s %r15,BASED(.Lc_spsize) # make room for registers & psw
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700947 st %r15,12(%r12)
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100948 CREATE_STACK_FRAME __LC_SAVE_AREA
949 mvc SP_PSW(8,%r15),__LC_SVC_OLD_PSW
950 mvc SP_ILC(4,%r15),__LC_SVC_ILC
951 mvc 0(4,%r12),__LC_THREAD_INFO
Linus Torvalds1da177e2005-04-16 15:20:36 -0700952cleanup_vtime:
953 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+12)
954 bhe BASED(cleanup_stime)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
956cleanup_stime:
957 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+16)
958 bh BASED(cleanup_update)
959 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
960cleanup_update:
961 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700962 mvc __LC_RETURN_PSW+4(4),BASED(cleanup_table_system_call+4)
963 la %r12,__LC_RETURN_PSW
964 br %r14
965cleanup_system_call_insn:
966 .long sysc_saveall + 0x80000000
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200967 .long system_call + 0x80000000
968 .long sysc_vtime + 0x80000000
969 .long sysc_stime + 0x80000000
970 .long sysc_update + 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700971
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200972cleanup_sysc_tif:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700973 mvc __LC_RETURN_PSW(4),0(%r12)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200974 mvc __LC_RETURN_PSW+4(4),BASED(cleanup_table_sysc_tif)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700975 la %r12,__LC_RETURN_PSW
976 br %r14
977
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200978cleanup_sysc_restore:
979 clc 4(4,%r12),BASED(cleanup_sysc_restore_insn)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700980 be BASED(2f)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200981 mvc __LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
982 c %r12,BASED(.Lmck_old_psw)
983 be BASED(0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700984 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
Martin Schwidefsky63779812010-05-17 10:00:03 +02009850: clc 4(4,%r12),BASED(cleanup_sysc_restore_insn+4)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700986 be BASED(2f)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987 mvc __LC_RETURN_PSW(8),SP_PSW(%r15)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700988 c %r12,BASED(.Lmck_old_psw)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200989 la %r12,__LC_SAVE_AREA+32
990 be BASED(1f)
991 la %r12,__LC_SAVE_AREA+16
9921: mvc 0(16,%r12),SP_R12(%r15)
993 lm %r0,%r11,SP_R0(%r15)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700994 l %r15,SP_R15(%r15)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07009952: la %r12,__LC_RETURN_PSW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700996 br %r14
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200997cleanup_sysc_restore_insn:
Heiko Carstens411788e2007-11-20 11:13:32 +0100998 .long sysc_done - 4 + 0x80000000
Heiko Carstens411788e2007-11-20 11:13:32 +0100999 .long sysc_done - 8 + 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -07001000
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +02001001cleanup_io_tif:
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001002 mvc __LC_RETURN_PSW(4),0(%r12)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +02001003 mvc __LC_RETURN_PSW+4(4),BASED(cleanup_table_io_tif)
Martin Schwidefsky176b1802010-04-09 13:43:00 +02001004 la %r12,__LC_RETURN_PSW
1005 br %r14
1006
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +02001007cleanup_io_restore:
1008 clc 4(4,%r12),BASED(cleanup_io_restore_insn)
Martin Schwidefsky63779812010-05-17 10:00:03 +02001009 be BASED(1f)
1010 mvc __LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +02001011 clc 4(4,%r12),BASED(cleanup_io_restore_insn+4)
Martin Schwidefsky63779812010-05-17 10:00:03 +02001012 be BASED(1f)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001013 mvc __LC_RETURN_PSW(8),SP_PSW(%r15)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001014 mvc __LC_SAVE_AREA+32(16),SP_R12(%r15)
Martin Schwidefsky63779812010-05-17 10:00:03 +02001015 lm %r0,%r11,SP_R0(%r15)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001016 l %r15,SP_R15(%r15)
Martin Schwidefsky63779812010-05-17 10:00:03 +020010171: la %r12,__LC_RETURN_PSW
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001018 br %r14
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +02001019cleanup_io_restore_insn:
Heiko Carstens411788e2007-11-20 11:13:32 +01001020 .long io_done - 4 + 0x80000000
Heiko Carstens411788e2007-11-20 11:13:32 +01001021 .long io_done - 8 + 0x80000000
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001022
Linus Torvalds1da177e2005-04-16 15:20:36 -07001023/*
1024 * Integer constants
1025 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001026 .align 4
1027.Lc_spsize: .long SP_SIZE
1028.Lc_overhead: .long STACK_FRAME_OVERHEAD
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001029.Lnr_syscalls: .long NR_syscalls
1030.L0x018: .short 0x018
1031.L0x020: .short 0x020
1032.L0x028: .short 0x028
1033.L0x030: .short 0x030
1034.L0x038: .short 0x038
1035.Lc_1: .long 1
Linus Torvalds1da177e2005-04-16 15:20:36 -07001036
1037/*
1038 * Symbol constants
1039 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001040.Ls390_mcck: .long s390_do_machine_check
Heiko Carstens77fa2242005-06-25 14:55:30 -07001041.Ls390_handle_mcck:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001042 .long s390_handle_mcck
1043.Lmck_old_psw: .long __LC_MCK_OLD_PSW
1044.Ldo_IRQ: .long do_IRQ
1045.Ldo_extint: .long do_extint
1046.Ldo_signal: .long do_signal
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +02001047.Ldo_notify_resume:
1048 .long do_notify_resume
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +01001049.Lhandle_per: .long do_per_trap
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +02001050.Ldo_execve: .long do_execve
1051.Lexecve_tail: .long execve_tail
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001052.Ljump_table: .long pgm_check_table
1053.Lschedule: .long schedule
Christian Borntraegerab1809b2007-12-04 16:09:04 +01001054#ifdef CONFIG_PREEMPT
Heiko Carstensb8e7a542007-11-20 11:13:35 +01001055.Lpreempt_schedule_irq:
1056 .long preempt_schedule_irq
Christian Borntraegerab1809b2007-12-04 16:09:04 +01001057#endif
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +02001058.Ltrace_entry: .long do_syscall_trace_enter
1059.Ltrace_exit: .long do_syscall_trace_exit
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001060.Lschedtail: .long schedule_tail
1061.Lsysc_table: .long sys_call_table
Heiko Carstens1f194a42006-07-03 00:24:46 -07001062#ifdef CONFIG_TRACE_IRQFLAGS
Heiko Carstens50bec4c2008-11-14 18:18:05 +01001063.Ltrace_irq_on_caller:
1064 .long trace_hardirqs_on_caller
1065.Ltrace_irq_off_caller:
1066 .long trace_hardirqs_off_caller
Heiko Carstensaf4c68742008-11-14 18:18:03 +01001067#endif
1068#ifdef CONFIG_LOCKDEP
Heiko Carstens523b44c2007-10-11 22:11:12 +02001069.Llockdep_sys_exit:
1070 .long lockdep_sys_exit
Heiko Carstens1f194a42006-07-03 00:24:46 -07001071#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001072.Lcritical_start:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001073 .long __critical_start + 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -07001074.Lcritical_end:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001075 .long __critical_end + 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -07001076.Lcleanup_critical:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001077 .long cleanup_critical
Linus Torvalds1da177e2005-04-16 15:20:36 -07001078
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001079 .section .rodata, "a"
Linus Torvalds1da177e2005-04-16 15:20:36 -07001080#define SYSCALL(esa,esame,emu) .long esa
Heiko Carstens9bf12262009-06-12 10:26:47 +02001081 .globl sys_call_table
Linus Torvalds1da177e2005-04-16 15:20:36 -07001082sys_call_table:
1083#include "syscalls.S"
1084#undef SYSCALL