blob: 02ec8fe7d03fe575c3969e14b750b3a6bf81c0b6 [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
Heiko Carstens2bc89b52008-02-05 16:50:40 +010012#include <linux/init.h>
Jan Glauber144d6342011-07-24 10:48:19 +020013#include <linux/linkage.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 */
Jan Glauber144d6342011-07-24 10:48:19 +0200200ENTRY(__switch_to)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200201 basr %r1,0
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +01002020: l %r4,__THREAD_info(%r2) # get thread_info of prev
203 l %r5,__THREAD_info(%r3) # get thread_info of next
Heiko Carstens77fa2242005-06-25 14:55:30 -0700204 tm __TI_flags+3(%r4),_TIF_MCCK_PENDING # machine check pending?
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100205 bz 1f-0b(%r1)
206 ni __TI_flags+3(%r4),255-_TIF_MCCK_PENDING # clear flag in prev
207 oi __TI_flags+3(%r5),_TIF_MCCK_PENDING # set it in next
2081: stm %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task
209 st %r15,__THREAD_ksp(%r2) # store kernel stack of prev
210 l %r15,__THREAD_ksp(%r3) # load kernel stack of next
211 lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4
212 lm %r6,%r15,__SF_GPRS(%r15) # load gprs of next task
213 st %r3,__LC_CURRENT # store task struct of next
Heiko Carstensf2db2e62011-05-23 10:24:34 +0200214 mvc __LC_CURRENT_PID(4,%r0),__TASK_pid(%r3) # store pid of next
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100215 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
Jan Glauber144d6342011-07-24 10:48:19 +0200226ENTRY(system_call)
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100227 stpt __LC_SYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228sysc_saveall:
Martin Schwidefsky987ad702007-07-10 11:24:18 +0200229 SAVE_ALL_SVC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100230 CREATE_STACK_FRAME __LC_SAVE_AREA
231 mvc SP_PSW(8,%r15),__LC_SVC_OLD_PSW
232 mvc SP_ILC(4,%r15),__LC_SVC_ILC
233 l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234sysc_vtime:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
236sysc_stime:
237 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
238sysc_update:
239 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240sysc_do_svc:
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100241 xr %r7,%r7
242 icm %r7,3,SP_SVCNR(%r15) # load svc number and test for svc 0
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200243 bnz BASED(sysc_nr_ok) # svc number > 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 # svc 0: system call number in %r1
245 cl %r1,BASED(.Lnr_syscalls)
246 bnl BASED(sysc_nr_ok)
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100247 sth %r1,SP_SVCNR(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200248 lr %r7,%r1 # copy svc number to %r7
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249sysc_nr_ok:
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100250 sll %r7,2 # svc number *4
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100251 l %r10,BASED(.Lsysc_table)
252 tm __TI_flags+2(%r12),_TIF_SYSCALL
Martin Schwidefskybaa07152010-10-25 16:10:40 +0200253 mvc SP_ARGS(4,%r15),SP_R7(%r15)
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100254 l %r8,0(%r7,%r10) # get system call addr.
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200255 bnz BASED(sysc_tracesys)
256 basr %r14,%r8 # call sys_xxxx
257 st %r2,SP_R2(%r15) # store return value (change R2 on stack)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258
259sysc_return:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200260 LOCKDEP_SYS_EXIT
261sysc_tif:
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100262 tm __TI_flags+3(%r12),_TIF_WORK_SVC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 bnz BASED(sysc_work) # there is work to do (signals etc.)
Heiko Carstens411788e2007-11-20 11:13:32 +0100264sysc_restore:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200265 RESTORE_ALL __LC_RETURN_PSW,1
Heiko Carstens411788e2007-11-20 11:13:32 +0100266sysc_done:
267
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268#
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200269# There is work to do, but first we need to check if we return to userspace.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270#
271sysc_work:
Martin Schwidefsky26889052008-05-07 09:22:52 +0200272 tm SP_PSW+1(%r15),0x01 # returning to user ?
273 bno BASED(sysc_restore)
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200274
275#
276# One of the work bits is on. Find out which one.
277#
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200278sysc_work_tif:
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100279 tm __TI_flags+3(%r12),_TIF_MCCK_PENDING
Heiko Carstens77fa2242005-06-25 14:55:30 -0700280 bo BASED(sysc_mcck_pending)
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100281 tm __TI_flags+3(%r12),_TIF_NEED_RESCHED
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 bo BASED(sysc_reschedule)
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100283 tm __TI_flags+3(%r12),_TIF_SIGPENDING
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200284 bo BASED(sysc_sigpending)
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100285 tm __TI_flags+3(%r12),_TIF_NOTIFY_RESUME
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200286 bo BASED(sysc_notify_resume)
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100287 tm __TI_flags+3(%r12),_TIF_RESTART_SVC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 bo BASED(sysc_restart)
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100289 tm __TI_flags+3(%r12),_TIF_PER_TRAP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290 bo BASED(sysc_singlestep)
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200291 b BASED(sysc_return) # beware of critical section cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292
293#
294# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200295#
296sysc_reschedule:
297 l %r1,BASED(.Lschedule)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200298 la %r14,BASED(sysc_return)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200299 br %r1 # call scheduler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300
301#
Heiko Carstens77fa2242005-06-25 14:55:30 -0700302# _TIF_MCCK_PENDING is set, call handler
303#
304sysc_mcck_pending:
305 l %r1,BASED(.Ls390_handle_mcck)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200306 la %r14,BASED(sysc_return)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700307 br %r1 # TIF bit will be cleared by handler
308
309#
Roland McGrath02a029b2008-04-30 00:53:08 -0700310# _TIF_SIGPENDING is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311#
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200312sysc_sigpending:
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100313 ni __TI_flags+3(%r12),255-_TIF_PER_TRAP # clear TIF_PER_TRAP
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200314 la %r2,SP_PTREGS(%r15) # load pt_regs
315 l %r1,BASED(.Ldo_signal)
316 basr %r14,%r1 # call do_signal
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100317 tm __TI_flags+3(%r12),_TIF_RESTART_SVC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 bo BASED(sysc_restart)
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100319 tm __TI_flags+3(%r12),_TIF_PER_TRAP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320 bo BASED(sysc_singlestep)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200321 b BASED(sysc_return)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322
323#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200324# _TIF_NOTIFY_RESUME is set, call do_notify_resume
325#
326sysc_notify_resume:
327 la %r2,SP_PTREGS(%r15) # load pt_regs
328 l %r1,BASED(.Ldo_notify_resume)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200329 la %r14,BASED(sysc_return)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200330 br %r1 # call do_notify_resume
331
332
333#
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334# _TIF_RESTART_SVC is set, set up registers and restart svc
335#
336sysc_restart:
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100337 ni __TI_flags+3(%r12),255-_TIF_RESTART_SVC # clear TIF_RESTART_SVC
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200338 l %r7,SP_R2(%r15) # load new svc number
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 mvc SP_R2(4,%r15),SP_ORIG_R2(%r15) # restore first argument
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200340 lm %r2,%r6,SP_R2(%r15) # load svc arguments
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100341 sth %r7,SP_SVCNR(%r15)
Martin Schwidefskybaa07152010-10-25 16:10:40 +0200342 b BASED(sysc_nr_ok) # restart svc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343
344#
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100345# _TIF_PER_TRAP is set, call do_per_trap
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346#
347sysc_singlestep:
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100348 ni __TI_flags+3(%r12),255-_TIF_PER_TRAP # clear TIF_PER_TRAP
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100349 xc SP_SVCNR(2,%r15),SP_SVCNR(%r15) # clear svc number
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 la %r2,SP_PTREGS(%r15) # address of register-save area
351 l %r1,BASED(.Lhandle_per) # load adr. of per handler
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200352 la %r14,BASED(sysc_return) # load adr. of system return
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100353 br %r1 # branch to do_per_trap
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200356# call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
357# and after the system call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358#
359sysc_tracesys:
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200360 l %r1,BASED(.Ltrace_entry)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200361 la %r2,SP_PTREGS(%r15) # load pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 la %r3,0
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100363 xr %r0,%r0
364 icm %r0,3,SP_SVCNR(%r15)
365 st %r0,SP_R2(%r15)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366 basr %r14,%r1
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200367 cl %r2,BASED(.Lnr_syscalls)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 bnl BASED(sysc_tracenogo)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200369 lr %r7,%r2
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100370 sll %r7,2 # svc number *4
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100371 l %r8,0(%r7,%r10)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372sysc_tracego:
373 lm %r3,%r6,SP_R3(%r15)
Martin Schwidefskybaa07152010-10-25 16:10:40 +0200374 mvc SP_ARGS(4,%r15),SP_R7(%r15)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 l %r2,SP_ORIG_R2(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200376 basr %r14,%r8 # call sys_xxx
377 st %r2,SP_R2(%r15) # store return value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378sysc_tracenogo:
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100379 tm __TI_flags+2(%r12),_TIF_SYSCALL
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200380 bz BASED(sysc_return)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200381 l %r1,BASED(.Ltrace_exit)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200382 la %r2,SP_PTREGS(%r15) # load pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383 la %r14,BASED(sysc_return)
384 br %r1
385
386#
387# a new process exits the kernel with ret_from_fork
388#
Jan Glauber144d6342011-07-24 10:48:19 +0200389ENTRY(ret_from_fork)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 l %r13,__LC_SVC_NEW_PSW+4
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100391 l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392 tm SP_PSW+1(%r15),0x01 # forking a kernel thread ?
393 bo BASED(0f)
394 st %r15,SP_R15(%r15) # store stack pointer for new kthread
Heiko Carstens25d83cb2006-09-28 16:56:37 +02003950: l %r1,BASED(.Lschedtail)
396 basr %r14,%r1
Heiko Carstens1f194a42006-07-03 00:24:46 -0700397 TRACE_IRQS_ON
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200398 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
Al Viro8f2961c2008-12-25 13:37:58 +0100399 b BASED(sysc_tracenogo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400
401#
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200402# kernel_execve function needs to deal with pt_regs that is not
403# at the usual place
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404#
Jan Glauber144d6342011-07-24 10:48:19 +0200405ENTRY(kernel_execve)
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200406 stm %r12,%r15,48(%r15)
407 lr %r14,%r15
408 l %r13,__LC_SVC_NEW_PSW+4
409 s %r15,BASED(.Lc_spsize)
410 st %r14,__SF_BACKCHAIN(%r15)
411 la %r12,SP_PTREGS(%r15)
412 xc 0(__PT_SIZE,%r12),0(%r12)
413 l %r1,BASED(.Ldo_execve)
414 lr %r5,%r12
415 basr %r14,%r1
416 ltr %r2,%r2
417 be BASED(0f)
418 a %r15,BASED(.Lc_spsize)
419 lm %r12,%r15,48(%r15)
420 br %r14
421 # execve succeeded.
4220: stnsm __SF_EMPTY(%r15),0xfc # disable interrupts
423 l %r15,__LC_KERNEL_STACK # load ksp
424 s %r15,BASED(.Lc_spsize) # make room for registers & psw
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200425 mvc SP_PTREGS(__PT_SIZE,%r15),0(%r12) # copy pt_regs
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100426 l %r12,__LC_THREAD_INFO
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200427 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15)
428 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
429 l %r1,BASED(.Lexecve_tail)
430 basr %r14,%r1
431 b BASED(sysc_return)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432
433/*
434 * Program check handler routine
435 */
436
Jan Glauber144d6342011-07-24 10:48:19 +0200437ENTRY(pgm_check_handler)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438/*
439 * First we need to check for a special case:
440 * Single stepping an instruction that disables the PER event mask will
441 * cause a PER event AFTER the mask has been set. Example: SVC or LPSW.
442 * For a single stepped SVC the program check handler gets control after
443 * the SVC new PSW has been loaded. But we want to execute the SVC first and
444 * then handle the PER event. Therefore we update the SVC old PSW to point
445 * to the pgm_check_handler and branch to the SVC handler after we checked
446 * if we have to load the kernel stack register.
447 * For every other possible cause for PER event without the PER mask set
448 * we just ignore the PER event (FIXME: is there anything we have to do
449 * for LPSW?).
450 */
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100451 stpt __LC_SYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452 SAVE_ALL_BASE __LC_SAVE_AREA
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200453 tm __LC_PGM_INT_CODE+1,0x80 # check whether we got a per exception
454 bnz BASED(pgm_per) # got per exception -> special case
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100455 SAVE_ALL_PGM __LC_PGM_OLD_PSW,__LC_SAVE_AREA
456 CREATE_STACK_FRAME __LC_SAVE_AREA
457 xc SP_ILC(4,%r15),SP_ILC(%r15)
458 mvc SP_PSW(8,%r15),__LC_PGM_OLD_PSW
459 l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
461 bz BASED(pgm_no_vtime)
462 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
463 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
464 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
465pgm_no_vtime:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200466 l %r3,__LC_PGM_ILC # load program interruption code
Martin Schwidefsky1e546222010-10-25 16:10:37 +0200467 l %r4,__LC_TRANS_EXC_CODE
468 REENABLE_IRQS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 la %r8,0x7f
470 nr %r8,%r3
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200471 sll %r8,2
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100472 l %r1,BASED(.Ljump_table)
473 l %r1,0(%r8,%r1) # load address of handler routine
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200474 la %r2,SP_PTREGS(%r15) # address of register-save area
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100475 basr %r14,%r1 # branch to interrupt-handler
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200476pgm_exit:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200477 b BASED(sysc_return)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478
479#
480# handle per exception
481#
482pgm_per:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200483 tm __LC_PGM_OLD_PSW,0x40 # test if per event recording is on
484 bnz BASED(pgm_per_std) # ok, normal per event from user space
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485# ok its one of the special cases, now we need to find out which one
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200486 clc __LC_PGM_OLD_PSW(8),__LC_SVC_NEW_PSW
487 be BASED(pgm_svcper)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488# no interesting special case, ignore PER event
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200489 lm %r12,%r15,__LC_SAVE_AREA
490 lpsw 0x28
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491
492#
493# Normal per exception
494#
495pgm_per_std:
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100496 SAVE_ALL_PGM __LC_PGM_OLD_PSW,__LC_SAVE_AREA
497 CREATE_STACK_FRAME __LC_SAVE_AREA
498 mvc SP_PSW(8,%r15),__LC_PGM_OLD_PSW
499 l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
501 bz BASED(pgm_no_vtime2)
502 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
503 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
504 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
505pgm_no_vtime2:
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100506 l %r1,__TI_task(%r12)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200507 tm SP_PSW+1(%r15),0x01 # kernel per event ?
508 bz BASED(kernel_per)
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100509 mvc __THREAD_per_cause(2,%r1),__LC_PER_CAUSE
510 mvc __THREAD_per_address(4,%r1),__LC_PER_ADDRESS
511 mvc __THREAD_per_paid(1,%r1),__LC_PER_PAID
512 oi __TI_flags+3(%r12),_TIF_PER_TRAP # set TIF_PER_TRAP
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200513 l %r3,__LC_PGM_ILC # load program interruption code
Martin Schwidefsky1e546222010-10-25 16:10:37 +0200514 l %r4,__LC_TRANS_EXC_CODE
515 REENABLE_IRQS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516 la %r8,0x7f
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200517 nr %r8,%r3 # clear per-event-bit and ilc
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200518 be BASED(pgm_exit2) # only per or per+check ?
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200519 sll %r8,2
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100520 l %r1,BASED(.Ljump_table)
521 l %r1,0(%r8,%r1) # load address of handler routine
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200522 la %r2,SP_PTREGS(%r15) # address of register-save area
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100523 basr %r14,%r1 # branch to interrupt-handler
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200524pgm_exit2:
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200525 b BASED(sysc_return)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526
527#
528# it was a single stepped SVC that is causing all the trouble
529#
530pgm_svcper:
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100531 SAVE_ALL_PGM __LC_SVC_OLD_PSW,__LC_SAVE_AREA
532 CREATE_STACK_FRAME __LC_SAVE_AREA
533 mvc SP_PSW(8,%r15),__LC_SVC_OLD_PSW
534 mvc SP_ILC(4,%r15),__LC_SVC_ILC
535 l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
537 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
538 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100539 l %r8,__TI_task(%r12)
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100540 mvc __THREAD_per_cause(2,%r8),__LC_PER_CAUSE
541 mvc __THREAD_per_address(4,%r8),__LC_PER_ADDRESS
542 mvc __THREAD_per_paid(1,%r8),__LC_PER_PAID
543 oi __TI_flags+3(%r12),_TIF_PER_TRAP # set TIF_PER_TRAP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200545 lm %r2,%r6,SP_R2(%r15) # load svc arguments
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 b BASED(sysc_do_svc)
547
Michael Grundy4ba069b2006-09-20 15:58:39 +0200548#
549# per was called from kernel, must be kprobes
550#
551kernel_per:
Martin Schwidefsky9ec27082010-10-29 16:50:45 +0200552 REENABLE_IRQS
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100553 xc SP_SVCNR(2,%r15),SP_SVCNR(%r15)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200554 la %r2,SP_PTREGS(%r15) # address of register-save area
555 l %r1,BASED(.Lhandle_per) # load adr. of per handler
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200556 basr %r14,%r1 # branch to do_single_step
557 b BASED(pgm_exit)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200558
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559/*
560 * IO interrupt handler routine
561 */
562
Jan Glauber144d6342011-07-24 10:48:19 +0200563ENTRY(io_int_handler)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 stck __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100565 stpt __LC_ASYNC_ENTER_TIMER
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200566 SAVE_ALL_ASYNC __LC_IO_OLD_PSW,__LC_SAVE_AREA+16
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100567 CREATE_STACK_FRAME __LC_SAVE_AREA+16
568 mvc SP_PSW(8,%r15),0(%r12) # move user PSW to stack
569 l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
571 bz BASED(io_no_vtime)
572 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
573 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
574 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
575io_no_vtime:
Heiko Carstens1f194a42006-07-03 00:24:46 -0700576 TRACE_IRQS_OFF
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200577 l %r1,BASED(.Ldo_IRQ) # load address of do_IRQ
578 la %r2,SP_PTREGS(%r15) # address of register-save area
579 basr %r14,%r1 # branch to standard irq handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580io_return:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200581 LOCKDEP_SYS_EXIT
582 TRACE_IRQS_ON
583io_tif:
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100584 tm __TI_flags+3(%r12),_TIF_WORK_INT
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200585 bnz BASED(io_work) # there is work to do (signals etc.)
Heiko Carstens411788e2007-11-20 11:13:32 +0100586io_restore:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200587 RESTORE_ALL __LC_RETURN_PSW,0
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700588io_done:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589
Martin Schwidefsky26889052008-05-07 09:22:52 +0200590#
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200591# There is work todo, find out in which context we have been interrupted:
592# 1) if we return to user space we can do all _TIF_WORK_INT work
593# 2) if we return to kernel code and preemptive scheduling is enabled check
594# the preemption counter and if it is zero call preempt_schedule_irq
595# Before any work can be done, a switch to the kernel stack is required.
Martin Schwidefsky26889052008-05-07 09:22:52 +0200596#
597io_work:
598 tm SP_PSW+1(%r15),0x01 # returning to user ?
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200599 bo BASED(io_work_user) # yes -> do resched & signal
600#ifdef CONFIG_PREEMPT
Martin Schwidefsky26889052008-05-07 09:22:52 +0200601 # check for preemptive scheduling
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100602 icm %r0,15,__TI_precount(%r12)
Martin Schwidefsky26889052008-05-07 09:22:52 +0200603 bnz BASED(io_restore) # preemption disabled
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100604 tm __TI_flags+3(%r12),_TIF_NEED_RESCHED
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200605 bno BASED(io_restore)
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200606 # switch to kernel stack
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607 l %r1,SP_R15(%r15)
608 s %r1,BASED(.Lc_spsize)
609 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200610 xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1) # clear back chain
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 lr %r15,%r1
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200612 # TRACE_IRQS_ON already done at io_return, call
613 # TRACE_IRQS_OFF to keep things symmetrical
614 TRACE_IRQS_OFF
Heiko Carstensb8e7a542007-11-20 11:13:35 +0100615 l %r1,BASED(.Lpreempt_schedule_irq)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200616 basr %r14,%r1 # call preempt_schedule_irq
617 b BASED(io_return)
618#else
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200619 b BASED(io_restore)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200620#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200622#
623# Need to do work before returning to userspace, switch to kernel stack
624#
Martin Schwidefsky26889052008-05-07 09:22:52 +0200625io_work_user:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626 l %r1,__LC_KERNEL_STACK
627 s %r1,BASED(.Lc_spsize)
628 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200629 xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1) # clear back chain
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 lr %r15,%r1
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200631
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632#
633# One of the work bits is on. Find out which one.
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200634# Checked are: _TIF_SIGPENDING, _TIF_NOTIFY_RESUME, _TIF_NEED_RESCHED
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200635# and _TIF_MCCK_PENDING
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636#
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200637io_work_tif:
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100638 tm __TI_flags+3(%r12),_TIF_MCCK_PENDING
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200639 bo BASED(io_mcck_pending)
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100640 tm __TI_flags+3(%r12),_TIF_NEED_RESCHED
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 bo BASED(io_reschedule)
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100642 tm __TI_flags+3(%r12),_TIF_SIGPENDING
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200643 bo BASED(io_sigpending)
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100644 tm __TI_flags+3(%r12),_TIF_NOTIFY_RESUME
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200645 bo BASED(io_notify_resume)
646 b BASED(io_return) # beware of critical section cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647
648#
Heiko Carstens77fa2242005-06-25 14:55:30 -0700649# _TIF_MCCK_PENDING is set, call handler
650#
651io_mcck_pending:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200652 # TRACE_IRQS_ON already done at io_return
Heiko Carstens77fa2242005-06-25 14:55:30 -0700653 l %r1,BASED(.Ls390_handle_mcck)
Heiko Carstensb771aea2007-07-27 12:29:18 +0200654 basr %r14,%r1 # TIF bit will be cleared by handler
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200655 TRACE_IRQS_OFF
656 b BASED(io_return)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700657
658#
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200660#
661io_reschedule:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200662 # TRACE_IRQS_ON already done at io_return
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200663 l %r1,BASED(.Lschedule)
664 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
665 basr %r14,%r1 # call scheduler
666 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100667 TRACE_IRQS_OFF
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200668 b BASED(io_return)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669
670#
Roland McGrath02a029b2008-04-30 00:53:08 -0700671# _TIF_SIGPENDING is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672#
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200673io_sigpending:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200674 # TRACE_IRQS_ON already done at io_return
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200675 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
676 la %r2,SP_PTREGS(%r15) # load pt_regs
677 l %r1,BASED(.Ldo_signal)
678 basr %r14,%r1 # call do_signal
679 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100680 TRACE_IRQS_OFF
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200681 b BASED(io_return)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200683#
684# _TIF_SIGPENDING is set, call do_signal
685#
686io_notify_resume:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200687 # TRACE_IRQS_ON already done at io_return
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200688 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
689 la %r2,SP_PTREGS(%r15) # load pt_regs
690 l %r1,BASED(.Ldo_notify_resume)
691 basr %r14,%r1 # call do_signal
692 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
693 TRACE_IRQS_OFF
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200694 b BASED(io_return)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200695
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696/*
697 * External interrupt handler routine
698 */
699
Jan Glauber144d6342011-07-24 10:48:19 +0200700ENTRY(ext_int_handler)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 stck __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100702 stpt __LC_ASYNC_ENTER_TIMER
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200703 SAVE_ALL_ASYNC __LC_EXT_OLD_PSW,__LC_SAVE_AREA+16
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100704 CREATE_STACK_FRAME __LC_SAVE_AREA+16
705 mvc SP_PSW(8,%r15),0(%r12) # move user PSW to stack
706 l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
708 bz BASED(ext_no_vtime)
709 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
710 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
711 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
712ext_no_vtime:
Heiko Carstens1f194a42006-07-03 00:24:46 -0700713 TRACE_IRQS_OFF
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200714 la %r2,SP_PTREGS(%r15) # address of register-save area
Martin Schwidefskyf6649a72010-10-25 16:10:38 +0200715 l %r3,__LC_CPU_ADDRESS # get cpu address + interruption code
716 l %r4,__LC_EXT_PARAMS # get external parameters
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 l %r1,BASED(.Ldo_extint)
718 basr %r14,%r1
719 b BASED(io_return)
720
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700721__critical_end:
722
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723/*
724 * Machine check handler routines
725 */
726
Jan Glauber144d6342011-07-24 10:48:19 +0200727ENTRY(mcck_int_handler)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200728 stck __LC_MCCK_CLOCK
Heiko Carstens77fa2242005-06-25 14:55:30 -0700729 spt __LC_CPU_TIMER_SAVE_AREA # revalidate cpu timer
730 lm %r0,%r15,__LC_GPREGS_SAVE_AREA # revalidate gprs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 SAVE_ALL_BASE __LC_SAVE_AREA+32
Heiko Carstens77fa2242005-06-25 14:55:30 -0700732 la %r12,__LC_MCK_OLD_PSW
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200733 tm __LC_MCCK_CODE,0x80 # system damage?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700734 bo BASED(mcck_int_main) # yes -> rest of mcck code invalid
Martin Schwidefsky63779812010-05-17 10:00:03 +0200735 mvc __LC_MCCK_ENTER_TIMER(8),__LC_CPU_TIMER_SAVE_AREA
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200736 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
737 bo BASED(1f)
738 la %r14,__LC_SYNC_ENTER_TIMER
739 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
740 bl BASED(0f)
741 la %r14,__LC_ASYNC_ENTER_TIMER
7420: clc 0(8,%r14),__LC_EXIT_TIMER
743 bl BASED(0f)
744 la %r14,__LC_EXIT_TIMER
7450: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
746 bl BASED(0f)
747 la %r14,__LC_LAST_UPDATE_TIMER
7480: spt 0(%r14)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200749 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
Martin Schwidefskyc185b782008-12-25 13:39:25 +01007501: tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700751 bno BASED(mcck_int_main) # no -> skip cleanup critical
752 tm __LC_MCK_OLD_PSW+1,0x01 # test problem state bit
753 bnz BASED(mcck_int_main) # from user -> load async stack
754 clc __LC_MCK_OLD_PSW+4(4),BASED(.Lcritical_end)
755 bhe BASED(mcck_int_main)
756 clc __LC_MCK_OLD_PSW+4(4),BASED(.Lcritical_start)
757 bl BASED(mcck_int_main)
758 l %r14,BASED(.Lcleanup_critical)
759 basr %r14,%r14
760mcck_int_main:
761 l %r14,__LC_PANIC_STACK # are we already on the panic stack?
762 slr %r14,%r15
763 sra %r14,PAGE_SHIFT
764 be BASED(0f)
765 l %r15,__LC_PANIC_STACK # load panic stack
Martin Schwidefsky1de34472011-01-05 12:47:57 +01007660: s %r15,BASED(.Lc_spsize) # make room for registers & psw
767 CREATE_STACK_FRAME __LC_SAVE_AREA+32
768 mvc SP_PSW(8,%r15),0(%r12)
769 l %r12,__LC_THREAD_INFO # load pointer to thread_info struct
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200770 tm __LC_MCCK_CODE+2,0x08 # mwp of old psw valid?
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700771 bno BASED(mcck_no_vtime) # no -> skip cleanup critical
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200772 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700773 bz BASED(mcck_no_vtime)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200774 UPDATE_VTIME __LC_EXIT_TIMER,__LC_MCCK_ENTER_TIMER,__LC_USER_TIMER
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700775 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
Martin Schwidefsky63779812010-05-17 10:00:03 +0200776 mvc __LC_LAST_UPDATE_TIMER(8),__LC_MCCK_ENTER_TIMER
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700777mcck_no_vtime:
Heiko Carstens77fa2242005-06-25 14:55:30 -0700778 la %r2,SP_PTREGS(%r15) # load pt_regs
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200779 l %r1,BASED(.Ls390_mcck)
780 basr %r14,%r1 # call machine check handler
781 tm SP_PSW+1(%r15),0x01 # returning to user ?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700782 bno BASED(mcck_return)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200783 l %r1,__LC_KERNEL_STACK # switch to kernel stack
Heiko Carstens77fa2242005-06-25 14:55:30 -0700784 s %r1,BASED(.Lc_spsize)
785 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200786 xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1) # clear back chain
Heiko Carstens77fa2242005-06-25 14:55:30 -0700787 lr %r15,%r1
788 stosm __SF_EMPTY(%r15),0x04 # turn dat on
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100789 tm __TI_flags+3(%r12),_TIF_MCCK_PENDING
Heiko Carstens77fa2242005-06-25 14:55:30 -0700790 bno BASED(mcck_return)
Heiko Carstens1f194a42006-07-03 00:24:46 -0700791 TRACE_IRQS_OFF
Heiko Carstens77fa2242005-06-25 14:55:30 -0700792 l %r1,BASED(.Ls390_handle_mcck)
793 basr %r14,%r1 # call machine check handler
Heiko Carstens1f194a42006-07-03 00:24:46 -0700794 TRACE_IRQS_ON
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795mcck_return:
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200796 mvc __LC_RETURN_MCCK_PSW(8),SP_PSW(%r15) # move return PSW
797 ni __LC_RETURN_MCCK_PSW+1,0xfd # clear wait state bit
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200798 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
799 bno BASED(0f)
800 lm %r0,%r15,SP_R0(%r15) # load gprs 0-15
801 stpt __LC_EXIT_TIMER
802 lpsw __LC_RETURN_MCCK_PSW # back to caller
Martin Schwidefskyc185b782008-12-25 13:39:25 +01008030: lm %r0,%r15,SP_R0(%r15) # load gprs 0-15
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200804 lpsw __LC_RETURN_MCCK_PSW # back to caller
805
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200806 RESTORE_ALL __LC_RETURN_MCCK_PSW,0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808/*
809 * Restart interruption handler, kick starter for additional CPUs
810 */
Heiko Carstens84b36a82007-06-19 13:10:03 +0200811#ifdef CONFIG_SMP
Heiko Carstens2bc89b52008-02-05 16:50:40 +0100812 __CPUINIT
Jan Glauber144d6342011-07-24 10:48:19 +0200813ENTRY(restart_int_handler)
Martin Schwidefsky5b409ed2009-04-14 15:36:27 +0200814 basr %r1,0
815restart_base:
816 spt restart_vtime-restart_base(%r1)
817 stck __LC_LAST_UPDATE_CLOCK
818 mvc __LC_LAST_UPDATE_TIMER(8),restart_vtime-restart_base(%r1)
819 mvc __LC_EXIT_TIMER(8),restart_vtime-restart_base(%r1)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200820 l %r15,__LC_SAVE_AREA+60 # load ksp
821 lctl %c0,%c15,__LC_CREGS_SAVE_AREA # get new ctl regs
822 lam %a0,%a15,__LC_AREGS_SAVE_AREA
823 lm %r6,%r15,__SF_GPRS(%r15) # load registers from clone
Martin Schwidefsky5b409ed2009-04-14 15:36:27 +0200824 l %r1,__LC_THREAD_INFO
825 mvc __LC_USER_TIMER(8),__TI_user_timer(%r1)
826 mvc __LC_SYSTEM_TIMER(8),__TI_system_timer(%r1)
827 xc __LC_STEAL_TIMER(8),__LC_STEAL_TIMER
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200828 stosm __SF_EMPTY(%r15),0x04 # now we can turn dat on
829 basr %r14,0
830 l %r14,restart_addr-.(%r14)
Michael Holzheu8eb4bd62011-05-10 17:13:39 +0200831 basr %r14,%r14 # branch to start_secondary
Linus Torvalds1da177e2005-04-16 15:20:36 -0700832restart_addr:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200833 .long start_secondary
Martin Schwidefsky5b409ed2009-04-14 15:36:27 +0200834 .align 8
835restart_vtime:
836 .long 0x7fffffff,0xffffffff
Heiko Carstens84b36a82007-06-19 13:10:03 +0200837 .previous
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838#else
839/*
840 * If we do not run with SMP enabled, let the new CPU crash ...
841 */
Jan Glauber144d6342011-07-24 10:48:19 +0200842ENTRY(restart_int_handler)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200843 basr %r1,0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844restart_base:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200845 lpsw restart_crash-restart_base(%r1)
846 .align 8
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847restart_crash:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200848 .long 0x000a0000,0x00000000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849restart_go:
850#endif
851
Michael Holzheu7dd6b332011-08-03 16:44:19 +0200852#
853# PSW restart interrupt handler
854#
855ENTRY(psw_restart_int_handler)
856 st %r15,__LC_SAVE_AREA_64(%r0) # save r15
857 basr %r15,0
8580: l %r15,.Lrestart_stack-0b(%r15) # load restart stack
859 l %r15,0(%r15)
860 ahi %r15,-SP_SIZE # make room for pt_regs
861 stm %r0,%r14,SP_R0(%r15) # store gprs %r0-%r14 to stack
862 mvc SP_R15(4,%r15),__LC_SAVE_AREA_64(%r0)# store saved %r15 to stack
863 mvc SP_PSW(8,%r15),__LC_RST_OLD_PSW(%r0) # store restart old psw
864 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15) # set backchain to 0
865 basr %r14,0
8661: l %r14,.Ldo_restart-1b(%r14)
867 basr %r14,%r14
868
869 basr %r14,0 # load disabled wait PSW if
8702: lpsw restart_psw_crash-2b(%r14) # do_restart returns
871 .align 4
872.Ldo_restart:
873 .long do_restart
874.Lrestart_stack:
875 .long restart_stack
876 .align 8
877restart_psw_crash:
878 .long 0x000a0000,0x00000000 + restart_psw_crash
879
Martin Schwidefsky860dba42011-01-05 12:47:25 +0100880 .section .kprobes.text, "ax"
881
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882#ifdef CONFIG_CHECK_STACK
883/*
884 * The synchronous or the asynchronous stack overflowed. We are dead.
885 * No need to properly save the registers, we are going to panic anyway.
886 * Setup a pt_regs so that show_trace can provide a good call trace.
887 */
888stack_overflow:
889 l %r15,__LC_PANIC_STACK # change to panic stack
890 sl %r15,BASED(.Lc_spsize)
891 mvc SP_PSW(8,%r15),0(%r12) # move user PSW to stack
892 stm %r0,%r11,SP_R0(%r15) # store gprs %r0-%r11 to kernel stack
893 la %r1,__LC_SAVE_AREA
894 ch %r12,BASED(.L0x020) # old psw addr == __LC_SVC_OLD_PSW ?
895 be BASED(0f)
896 ch %r12,BASED(.L0x028) # old psw addr == __LC_PGM_OLD_PSW ?
897 be BASED(0f)
898 la %r1,__LC_SAVE_AREA+16
8990: mvc SP_R12(16,%r15),0(%r1) # move %r12-%r15 to stack
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200900 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15) # clear back chain
Linus Torvalds1da177e2005-04-16 15:20:36 -0700901 l %r1,BASED(1f) # branch to kernel_stack_overflow
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200902 la %r2,SP_PTREGS(%r15) # load pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700903 br %r1
Heiko Carstens25d83cb2006-09-28 16:56:37 +02009041: .long kernel_stack_overflow
Linus Torvalds1da177e2005-04-16 15:20:36 -0700905#endif
906
907cleanup_table_system_call:
908 .long system_call + 0x80000000, sysc_do_svc + 0x80000000
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200909cleanup_table_sysc_tif:
910 .long sysc_tif + 0x80000000, sysc_restore + 0x80000000
911cleanup_table_sysc_restore:
912 .long sysc_restore + 0x80000000, sysc_done + 0x80000000
913cleanup_table_io_tif:
914 .long io_tif + 0x80000000, io_restore + 0x80000000
915cleanup_table_io_restore:
916 .long io_restore + 0x80000000, io_done + 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700917
918cleanup_critical:
919 clc 4(4,%r12),BASED(cleanup_table_system_call)
920 bl BASED(0f)
921 clc 4(4,%r12),BASED(cleanup_table_system_call+4)
922 bl BASED(cleanup_system_call)
9230:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200924 clc 4(4,%r12),BASED(cleanup_table_sysc_tif)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700925 bl BASED(0f)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200926 clc 4(4,%r12),BASED(cleanup_table_sysc_tif+4)
927 bl BASED(cleanup_sysc_tif)
Linus Torvalds1da177e2005-04-16 15:20:36 -07009280:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200929 clc 4(4,%r12),BASED(cleanup_table_sysc_restore)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700930 bl BASED(0f)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200931 clc 4(4,%r12),BASED(cleanup_table_sysc_restore+4)
932 bl BASED(cleanup_sysc_restore)
Linus Torvalds1da177e2005-04-16 15:20:36 -07009330:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200934 clc 4(4,%r12),BASED(cleanup_table_io_tif)
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200935 bl BASED(0f)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200936 clc 4(4,%r12),BASED(cleanup_table_io_tif+4)
937 bl BASED(cleanup_io_tif)
Martin Schwidefsky63b12242006-06-29 14:58:05 +02009380:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200939 clc 4(4,%r12),BASED(cleanup_table_io_restore)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700940 bl BASED(0f)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200941 clc 4(4,%r12),BASED(cleanup_table_io_restore+4)
942 bl BASED(cleanup_io_restore)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07009430:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700944 br %r14
945
946cleanup_system_call:
947 mvc __LC_RETURN_PSW(8),0(%r12)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700948 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+4)
949 bh BASED(0f)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200950 mvc __LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER
951 c %r12,BASED(.Lmck_old_psw)
952 be BASED(0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700953 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
Martin Schwidefsky63779812010-05-17 10:00:03 +02009540: c %r12,BASED(.Lmck_old_psw)
955 la %r12,__LC_SAVE_AREA+32
956 be BASED(0f)
957 la %r12,__LC_SAVE_AREA+16
Linus Torvalds1da177e2005-04-16 15:20:36 -07009580: clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+8)
959 bhe BASED(cleanup_vtime)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700960 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn)
961 bh BASED(0f)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700962 mvc __LC_SAVE_AREA(16),0(%r12)
9630: st %r13,4(%r12)
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100964 l %r15,__LC_KERNEL_STACK # problem state -> load ksp
965 s %r15,BASED(.Lc_spsize) # make room for registers & psw
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700966 st %r15,12(%r12)
Martin Schwidefsky1de34472011-01-05 12:47:57 +0100967 CREATE_STACK_FRAME __LC_SAVE_AREA
968 mvc SP_PSW(8,%r15),__LC_SVC_OLD_PSW
969 mvc SP_ILC(4,%r15),__LC_SVC_ILC
970 mvc 0(4,%r12),__LC_THREAD_INFO
Linus Torvalds1da177e2005-04-16 15:20:36 -0700971cleanup_vtime:
972 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+12)
973 bhe BASED(cleanup_stime)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700974 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
975cleanup_stime:
976 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+16)
977 bh BASED(cleanup_update)
978 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
979cleanup_update:
980 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700981 mvc __LC_RETURN_PSW+4(4),BASED(cleanup_table_system_call+4)
982 la %r12,__LC_RETURN_PSW
983 br %r14
984cleanup_system_call_insn:
985 .long sysc_saveall + 0x80000000
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200986 .long system_call + 0x80000000
987 .long sysc_vtime + 0x80000000
988 .long sysc_stime + 0x80000000
989 .long sysc_update + 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700990
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200991cleanup_sysc_tif:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700992 mvc __LC_RETURN_PSW(4),0(%r12)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200993 mvc __LC_RETURN_PSW+4(4),BASED(cleanup_table_sysc_tif)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700994 la %r12,__LC_RETURN_PSW
995 br %r14
996
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200997cleanup_sysc_restore:
998 clc 4(4,%r12),BASED(cleanup_sysc_restore_insn)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700999 be BASED(2f)
Martin Schwidefsky63779812010-05-17 10:00:03 +02001000 mvc __LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
1001 c %r12,BASED(.Lmck_old_psw)
1002 be BASED(0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001003 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
Martin Schwidefsky63779812010-05-17 10:00:03 +020010040: clc 4(4,%r12),BASED(cleanup_sysc_restore_insn+4)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001005 be BASED(2f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001006 mvc __LC_RETURN_PSW(8),SP_PSW(%r15)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001007 c %r12,BASED(.Lmck_old_psw)
Martin Schwidefsky63779812010-05-17 10:00:03 +02001008 la %r12,__LC_SAVE_AREA+32
1009 be BASED(1f)
1010 la %r12,__LC_SAVE_AREA+16
10111: mvc 0(16,%r12),SP_R12(%r15)
1012 lm %r0,%r11,SP_R0(%r15)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001013 l %r15,SP_R15(%r15)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -070010142: la %r12,__LC_RETURN_PSW
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015 br %r14
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +02001016cleanup_sysc_restore_insn:
Heiko Carstens411788e2007-11-20 11:13:32 +01001017 .long sysc_done - 4 + 0x80000000
Heiko Carstens411788e2007-11-20 11:13:32 +01001018 .long sysc_done - 8 + 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -07001019
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +02001020cleanup_io_tif:
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001021 mvc __LC_RETURN_PSW(4),0(%r12)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +02001022 mvc __LC_RETURN_PSW+4(4),BASED(cleanup_table_io_tif)
Martin Schwidefsky176b1802010-04-09 13:43:00 +02001023 la %r12,__LC_RETURN_PSW
1024 br %r14
1025
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +02001026cleanup_io_restore:
1027 clc 4(4,%r12),BASED(cleanup_io_restore_insn)
Martin Schwidefsky63779812010-05-17 10:00:03 +02001028 be BASED(1f)
1029 mvc __LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +02001030 clc 4(4,%r12),BASED(cleanup_io_restore_insn+4)
Martin Schwidefsky63779812010-05-17 10:00:03 +02001031 be BASED(1f)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001032 mvc __LC_RETURN_PSW(8),SP_PSW(%r15)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001033 mvc __LC_SAVE_AREA+32(16),SP_R12(%r15)
Martin Schwidefsky63779812010-05-17 10:00:03 +02001034 lm %r0,%r11,SP_R0(%r15)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001035 l %r15,SP_R15(%r15)
Martin Schwidefsky63779812010-05-17 10:00:03 +020010361: la %r12,__LC_RETURN_PSW
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001037 br %r14
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +02001038cleanup_io_restore_insn:
Heiko Carstens411788e2007-11-20 11:13:32 +01001039 .long io_done - 4 + 0x80000000
Heiko Carstens411788e2007-11-20 11:13:32 +01001040 .long io_done - 8 + 0x80000000
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001041
Linus Torvalds1da177e2005-04-16 15:20:36 -07001042/*
1043 * Integer constants
1044 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001045 .align 4
1046.Lc_spsize: .long SP_SIZE
1047.Lc_overhead: .long STACK_FRAME_OVERHEAD
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001048.Lnr_syscalls: .long NR_syscalls
1049.L0x018: .short 0x018
1050.L0x020: .short 0x020
1051.L0x028: .short 0x028
1052.L0x030: .short 0x030
1053.L0x038: .short 0x038
1054.Lc_1: .long 1
Linus Torvalds1da177e2005-04-16 15:20:36 -07001055
1056/*
1057 * Symbol constants
1058 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001059.Ls390_mcck: .long s390_do_machine_check
Heiko Carstens77fa2242005-06-25 14:55:30 -07001060.Ls390_handle_mcck:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001061 .long s390_handle_mcck
1062.Lmck_old_psw: .long __LC_MCK_OLD_PSW
1063.Ldo_IRQ: .long do_IRQ
1064.Ldo_extint: .long do_extint
1065.Ldo_signal: .long do_signal
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +02001066.Ldo_notify_resume:
1067 .long do_notify_resume
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +01001068.Lhandle_per: .long do_per_trap
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +02001069.Ldo_execve: .long do_execve
1070.Lexecve_tail: .long execve_tail
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001071.Ljump_table: .long pgm_check_table
1072.Lschedule: .long schedule
Christian Borntraegerab1809b2007-12-04 16:09:04 +01001073#ifdef CONFIG_PREEMPT
Heiko Carstensb8e7a542007-11-20 11:13:35 +01001074.Lpreempt_schedule_irq:
1075 .long preempt_schedule_irq
Christian Borntraegerab1809b2007-12-04 16:09:04 +01001076#endif
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +02001077.Ltrace_entry: .long do_syscall_trace_enter
1078.Ltrace_exit: .long do_syscall_trace_exit
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001079.Lschedtail: .long schedule_tail
1080.Lsysc_table: .long sys_call_table
Heiko Carstens1f194a42006-07-03 00:24:46 -07001081#ifdef CONFIG_TRACE_IRQFLAGS
Heiko Carstens50bec4c2008-11-14 18:18:05 +01001082.Ltrace_irq_on_caller:
1083 .long trace_hardirqs_on_caller
1084.Ltrace_irq_off_caller:
1085 .long trace_hardirqs_off_caller
Heiko Carstensaf4c68742008-11-14 18:18:03 +01001086#endif
1087#ifdef CONFIG_LOCKDEP
Heiko Carstens523b44c2007-10-11 22:11:12 +02001088.Llockdep_sys_exit:
1089 .long lockdep_sys_exit
Heiko Carstens1f194a42006-07-03 00:24:46 -07001090#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001091.Lcritical_start:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001092 .long __critical_start + 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -07001093.Lcritical_end:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001094 .long __critical_end + 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -07001095.Lcleanup_critical:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001096 .long cleanup_critical
Linus Torvalds1da177e2005-04-16 15:20:36 -07001097
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001098 .section .rodata, "a"
Linus Torvalds1da177e2005-04-16 15:20:36 -07001099#define SYSCALL(esa,esame,emu) .long esa
Heiko Carstens9bf12262009-06-12 10:26:47 +02001100 .globl sys_call_table
Linus Torvalds1da177e2005-04-16 15:20:36 -07001101sys_call_table:
1102#include "syscalls.S"
1103#undef SYSCALL