blob: 68d1a02db6be263fadaf6aa9a4ec5111ca3021c8 [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
12#include <linux/sys.h>
13#include <linux/linkage.h>
Heiko Carstens2bc89b52008-02-05 16:50:40 +010014#include <linux/init.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <asm/cache.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <asm/errno.h>
17#include <asm/ptrace.h>
18#include <asm/thread_info.h>
Sam Ravnborg0013a852005-09-09 20:57:26 +020019#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <asm/unistd.h>
21#include <asm/page.h>
22
23/*
24 * Stack layout for the system_call stack entry.
25 * The first few entries are identical to the user_regs_struct.
26 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +020027SP_PTREGS = STACK_FRAME_OVERHEAD
28SP_ARGS = STACK_FRAME_OVERHEAD + __PT_ARGS
29SP_PSW = STACK_FRAME_OVERHEAD + __PT_PSW
30SP_R0 = STACK_FRAME_OVERHEAD + __PT_GPRS
31SP_R1 = STACK_FRAME_OVERHEAD + __PT_GPRS + 4
32SP_R2 = STACK_FRAME_OVERHEAD + __PT_GPRS + 8
33SP_R3 = STACK_FRAME_OVERHEAD + __PT_GPRS + 12
34SP_R4 = STACK_FRAME_OVERHEAD + __PT_GPRS + 16
35SP_R5 = STACK_FRAME_OVERHEAD + __PT_GPRS + 20
36SP_R6 = STACK_FRAME_OVERHEAD + __PT_GPRS + 24
37SP_R7 = STACK_FRAME_OVERHEAD + __PT_GPRS + 28
38SP_R8 = STACK_FRAME_OVERHEAD + __PT_GPRS + 32
39SP_R9 = STACK_FRAME_OVERHEAD + __PT_GPRS + 36
40SP_R10 = STACK_FRAME_OVERHEAD + __PT_GPRS + 40
41SP_R11 = STACK_FRAME_OVERHEAD + __PT_GPRS + 44
42SP_R12 = STACK_FRAME_OVERHEAD + __PT_GPRS + 48
43SP_R13 = STACK_FRAME_OVERHEAD + __PT_GPRS + 52
44SP_R14 = STACK_FRAME_OVERHEAD + __PT_GPRS + 56
45SP_R15 = STACK_FRAME_OVERHEAD + __PT_GPRS + 60
46SP_ORIG_R2 = STACK_FRAME_OVERHEAD + __PT_ORIG_GPR2
47SP_ILC = STACK_FRAME_OVERHEAD + __PT_ILC
Martin Schwidefsky59da2132008-11-27 11:05:55 +010048SP_SVCNR = STACK_FRAME_OVERHEAD + __PT_SVCNR
Heiko Carstens25d83cb2006-09-28 16:56:37 +020049SP_SIZE = STACK_FRAME_OVERHEAD + __PT_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +020051_TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
Heiko Carstens54dfe5d2006-02-01 03:06:38 -080052 _TIF_MCCK_PENDING | _TIF_RESTART_SVC | _TIF_SINGLE_STEP )
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +020053_TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
Heiko Carstens54dfe5d2006-02-01 03:06:38 -080054 _TIF_MCCK_PENDING)
Heiko Carstens9bf12262009-06-12 10:26:47 +020055_TIF_SYSCALL = (_TIF_SYSCALL_TRACE>>8 | _TIF_SYSCALL_AUDIT>>8 | \
Josh Stone66700002009-08-24 14:43:11 -070056 _TIF_SECCOMP>>8 | _TIF_SYSCALL_TRACEPOINT>>8)
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
58STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
59STACK_SIZE = 1 << STACK_SHIFT
60
61#define BASED(name) name-system_call(%r13)
62
Heiko Carstens1f194a42006-07-03 00:24:46 -070063#ifdef CONFIG_TRACE_IRQFLAGS
64 .macro TRACE_IRQS_ON
Heiko Carstens50bec4c2008-11-14 18:18:05 +010065 basr %r2,%r0
66 l %r1,BASED(.Ltrace_irq_on_caller)
Heiko Carstens1f194a42006-07-03 00:24:46 -070067 basr %r14,%r1
68 .endm
69
70 .macro TRACE_IRQS_OFF
Heiko Carstens50bec4c2008-11-14 18:18:05 +010071 basr %r2,%r0
72 l %r1,BASED(.Ltrace_irq_off_caller)
Heiko Carstens1f194a42006-07-03 00:24:46 -070073 basr %r14,%r1
74 .endm
75#else
76#define TRACE_IRQS_ON
77#define TRACE_IRQS_OFF
Heiko Carstens411788e2007-11-20 11:13:32 +010078#endif
79
80#ifdef CONFIG_LOCKDEP
81 .macro LOCKDEP_SYS_EXIT
82 tm SP_PSW+1(%r15),0x01 # returning to user ?
83 jz 0f
84 l %r1,BASED(.Llockdep_sys_exit)
85 basr %r14,%r1
860:
87 .endm
88#else
Heiko Carstens523b44c2007-10-11 22:11:12 +020089#define LOCKDEP_SYS_EXIT
Heiko Carstens1f194a42006-07-03 00:24:46 -070090#endif
91
Linus Torvalds1da177e2005-04-16 15:20:36 -070092/*
93 * Register usage in interrupt handlers:
94 * R9 - pointer to current task structure
95 * R13 - pointer to literal pool
96 * R14 - return register for function calls
97 * R15 - kernel stack pointer
98 */
99
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200100 .macro UPDATE_VTIME lc_from,lc_to,lc_sum
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 lm %r10,%r11,\lc_from
102 sl %r10,\lc_to
103 sl %r11,\lc_to+4
104 bc 3,BASED(0f)
105 sl %r10,BASED(.Lc_1)
1060: al %r10,\lc_sum
107 al %r11,\lc_sum+4
108 bc 12,BASED(1f)
109 al %r10,BASED(.Lc_1)
1101: stm %r10,%r11,\lc_sum
111 .endm
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
113 .macro SAVE_ALL_BASE savearea
114 stm %r12,%r15,\savearea
115 l %r13,__LC_SVC_NEW_PSW+4 # load &system_call to %r13
116 .endm
117
Martin Schwidefsky987ad702007-07-10 11:24:18 +0200118 .macro SAVE_ALL_SVC psworg,savearea
119 la %r12,\psworg
120 l %r15,__LC_KERNEL_STACK # problem state -> load ksp
121 .endm
122
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200123 .macro SAVE_ALL_SYNC psworg,savearea
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 la %r12,\psworg
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 tm \psworg+1,0x01 # test problem state bit
126 bz BASED(2f) # skip stack setup save
127 l %r15,__LC_KERNEL_STACK # problem state -> load ksp
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200128#ifdef CONFIG_CHECK_STACK
129 b BASED(3f)
1302: tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
131 bz BASED(stack_overflow)
1323:
133#endif
1342:
135 .endm
136
137 .macro SAVE_ALL_ASYNC psworg,savearea
138 la %r12,\psworg
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 tm \psworg+1,0x01 # test problem state bit
140 bnz BASED(1f) # from user -> load async stack
141 clc \psworg+4(4),BASED(.Lcritical_end)
142 bhe BASED(0f)
143 clc \psworg+4(4),BASED(.Lcritical_start)
144 bl BASED(0f)
145 l %r14,BASED(.Lcleanup_critical)
146 basr %r14,%r14
Peter Oberparleiter6add9f72005-09-16 19:27:42 -0700147 tm 1(%r12),0x01 # retest problem state after cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 bnz BASED(1f)
1490: l %r14,__LC_ASYNC_STACK # are we already on the async stack ?
150 slr %r14,%r15
151 sra %r14,STACK_SHIFT
152 be BASED(2f)
1531: l %r15,__LC_ASYNC_STACK
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154#ifdef CONFIG_CHECK_STACK
155 b BASED(3f)
1562: tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
157 bz BASED(stack_overflow)
1583:
159#endif
Heiko Carstens77fa2242005-06-25 14:55:30 -07001602:
161 .endm
162
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200163 .macro CREATE_STACK_FRAME psworg,savearea
Heiko Carstens77fa2242005-06-25 14:55:30 -0700164 s %r15,BASED(.Lc_spsize) # make room for registers & psw
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 mvc SP_PSW(8,%r15),0(%r12) # move user PSW to stack
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 st %r2,SP_ORIG_R2(%r15) # store original content of gpr 2
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200167 icm %r12,12,__LC_SVC_ILC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 stm %r0,%r11,SP_R0(%r15) # store gprs %r0-%r11 to kernel stack
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200169 st %r12,SP_ILC(%r15)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 mvc SP_R12(16,%r15),\savearea # move %r12-%r15 to stack
171 la %r12,0
172 st %r12,__SF_BACKCHAIN(%r15) # clear back chain
173 .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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203__switch_to_base:
204 tm __THREAD_per(%r3),0xe8 # new process is using per ?
205 bz __switch_to_noper-__switch_to_base(%r1) # if not we're fine
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200206 stctl %c9,%c11,__SF_EMPTY(%r15) # We are using per stuff
207 clc __THREAD_per(12,%r3),__SF_EMPTY(%r15)
208 be __switch_to_noper-__switch_to_base(%r1) # we got away w/o bashing TLB's
209 lctl %c9,%c11,__THREAD_per(%r3) # Nope we didn't
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210__switch_to_noper:
Heiko Carstens77fa2242005-06-25 14:55:30 -0700211 l %r4,__THREAD_info(%r2) # get thread_info of prev
212 tm __TI_flags+3(%r4),_TIF_MCCK_PENDING # machine check pending?
213 bz __switch_to_no_mcck-__switch_to_base(%r1)
214 ni __TI_flags+3(%r4),255-_TIF_MCCK_PENDING # clear flag in prev
215 l %r4,__THREAD_info(%r3) # get thread_info of next
216 oi __TI_flags+3(%r4),_TIF_MCCK_PENDING # set it in next
217__switch_to_no_mcck:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200218 stm %r6,%r15,__SF_GPRS(%r15)# store __switch_to registers of prev task
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 st %r15,__THREAD_ksp(%r2) # store kernel stack to prev->tss.ksp
220 l %r15,__THREAD_ksp(%r3) # load kernel stack from next->tss.ksp
221 lm %r6,%r15,__SF_GPRS(%r15)# load __switch_to registers of next task
222 st %r3,__LC_CURRENT # __LC_CURRENT = current task struct
223 lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200224 l %r3,__THREAD_info(%r3) # load thread_info from task struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 st %r3,__LC_THREAD_INFO
226 ahi %r3,STACK_SIZE
227 st %r3,__LC_KERNEL_STACK # __LC_KERNEL_STACK = new kernel stack
228 br %r14
229
230__critical_start:
231/*
232 * SVC interrupt handler routine. System calls are synchronous events and
233 * are executed with interrupts enabled.
234 */
235
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200236 .globl system_call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237system_call:
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100238 stpt __LC_SYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239sysc_saveall:
240 SAVE_ALL_BASE __LC_SAVE_AREA
Martin Schwidefsky987ad702007-07-10 11:24:18 +0200241 SAVE_ALL_SVC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Heiko Carstens77fa2242005-06-25 14:55:30 -0700242 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 lh %r7,0x8a # get svc number from lowcore
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244sysc_vtime:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
246sysc_stime:
247 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
248sysc_update:
249 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250sysc_do_svc:
251 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100252 ltr %r7,%r7 # test for svc 0
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200253 bnz BASED(sysc_nr_ok) # svc number > 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 # svc 0: system call number in %r1
255 cl %r1,BASED(.Lnr_syscalls)
256 bnl BASED(sysc_nr_ok)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200257 lr %r7,%r1 # copy svc number to %r7
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258sysc_nr_ok:
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100259 sth %r7,SP_SVCNR(%r15)
260 sll %r7,2 # svc number *4
Heiko Carstensd882b172006-07-01 04:36:31 -0700261 l %r8,BASED(.Lsysc_table)
Heiko Carstensbcf5cef2009-06-12 10:26:26 +0200262 tm __TI_flags+2(%r9),_TIF_SYSCALL
Martin Schwidefskybaa07152010-10-25 16:10:40 +0200263 mvc SP_ARGS(4,%r15),SP_R7(%r15)
Heiko Carstensd882b172006-07-01 04:36:31 -0700264 l %r8,0(%r7,%r8) # get system call addr.
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200265 bnz BASED(sysc_tracesys)
266 basr %r14,%r8 # call sys_xxxx
267 st %r2,SP_R2(%r15) # store return value (change R2 on stack)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268
269sysc_return:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200270 LOCKDEP_SYS_EXIT
271sysc_tif:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272 tm __TI_flags+3(%r9),_TIF_WORK_SVC
273 bnz BASED(sysc_work) # there is work to do (signals etc.)
Heiko Carstens411788e2007-11-20 11:13:32 +0100274sysc_restore:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200275 RESTORE_ALL __LC_RETURN_PSW,1
Heiko Carstens411788e2007-11-20 11:13:32 +0100276sysc_done:
277
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278#
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200279# There is work to do, but first we need to check if we return to userspace.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280#
281sysc_work:
Martin Schwidefsky26889052008-05-07 09:22:52 +0200282 tm SP_PSW+1(%r15),0x01 # returning to user ?
283 bno BASED(sysc_restore)
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200284
285#
286# One of the work bits is on. Find out which one.
287#
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200288sysc_work_tif:
Heiko Carstens77fa2242005-06-25 14:55:30 -0700289 tm __TI_flags+3(%r9),_TIF_MCCK_PENDING
290 bo BASED(sysc_mcck_pending)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED
292 bo BASED(sysc_reschedule)
Roland McGrath02a029b2008-04-30 00:53:08 -0700293 tm __TI_flags+3(%r9),_TIF_SIGPENDING
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200294 bo BASED(sysc_sigpending)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200295 tm __TI_flags+3(%r9),_TIF_NOTIFY_RESUME
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200296 bo BASED(sysc_notify_resume)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 tm __TI_flags+3(%r9),_TIF_RESTART_SVC
298 bo BASED(sysc_restart)
299 tm __TI_flags+3(%r9),_TIF_SINGLE_STEP
300 bo BASED(sysc_singlestep)
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200301 b BASED(sysc_return) # beware of critical section cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302
303#
304# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200305#
306sysc_reschedule:
307 l %r1,BASED(.Lschedule)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200308 la %r14,BASED(sysc_return)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200309 br %r1 # call scheduler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310
311#
Heiko Carstens77fa2242005-06-25 14:55:30 -0700312# _TIF_MCCK_PENDING is set, call handler
313#
314sysc_mcck_pending:
315 l %r1,BASED(.Ls390_handle_mcck)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200316 la %r14,BASED(sysc_return)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700317 br %r1 # TIF bit will be cleared by handler
318
319#
Roland McGrath02a029b2008-04-30 00:53:08 -0700320# _TIF_SIGPENDING is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321#
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200322sysc_sigpending:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 ni __TI_flags+3(%r9),255-_TIF_SINGLE_STEP # clear TIF_SINGLE_STEP
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200324 la %r2,SP_PTREGS(%r15) # load pt_regs
325 l %r1,BASED(.Ldo_signal)
326 basr %r14,%r1 # call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327 tm __TI_flags+3(%r9),_TIF_RESTART_SVC
328 bo BASED(sysc_restart)
329 tm __TI_flags+3(%r9),_TIF_SINGLE_STEP
330 bo BASED(sysc_singlestep)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200331 b BASED(sysc_return)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332
333#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200334# _TIF_NOTIFY_RESUME is set, call do_notify_resume
335#
336sysc_notify_resume:
337 la %r2,SP_PTREGS(%r15) # load pt_regs
338 l %r1,BASED(.Ldo_notify_resume)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200339 la %r14,BASED(sysc_return)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200340 br %r1 # call do_notify_resume
341
342
343#
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344# _TIF_RESTART_SVC is set, set up registers and restart svc
345#
346sysc_restart:
347 ni __TI_flags+3(%r9),255-_TIF_RESTART_SVC # clear TIF_RESTART_SVC
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200348 l %r7,SP_R2(%r15) # load new svc number
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 mvc SP_R2(4,%r15),SP_ORIG_R2(%r15) # restore first argument
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200350 lm %r2,%r6,SP_R2(%r15) # load svc arguments
Martin Schwidefskybaa07152010-10-25 16:10:40 +0200351 b BASED(sysc_nr_ok) # restart svc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352
353#
354# _TIF_SINGLE_STEP is set, call do_single_step
355#
356sysc_singlestep:
357 ni __TI_flags+3(%r9),255-_TIF_SINGLE_STEP # clear TIF_SINGLE_STEP
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100358 mvi SP_SVCNR(%r15),0xff # set trap indication to pgm check
359 mvi SP_SVCNR+1(%r15),0xff
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 la %r2,SP_PTREGS(%r15) # address of register-save area
361 l %r1,BASED(.Lhandle_per) # load adr. of per handler
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200362 la %r14,BASED(sysc_return) # load adr. of system return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 br %r1 # branch to do_single_step
364
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200366# call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
367# and after the system call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368#
369sysc_tracesys:
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200370 l %r1,BASED(.Ltrace_entry)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200371 la %r2,SP_PTREGS(%r15) # load pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 la %r3,0
373 srl %r7,2
374 st %r7,SP_R2(%r15)
375 basr %r14,%r1
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200376 cl %r2,BASED(.Lnr_syscalls)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 bnl BASED(sysc_tracenogo)
Heiko Carstensd882b172006-07-01 04:36:31 -0700378 l %r8,BASED(.Lsysc_table)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200379 lr %r7,%r2
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100380 sll %r7,2 # svc number *4
Heiko Carstensd882b172006-07-01 04:36:31 -0700381 l %r8,0(%r7,%r8)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382sysc_tracego:
383 lm %r3,%r6,SP_R3(%r15)
Martin Schwidefskybaa07152010-10-25 16:10:40 +0200384 mvc SP_ARGS(4,%r15),SP_R7(%r15)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 l %r2,SP_ORIG_R2(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200386 basr %r14,%r8 # call sys_xxx
387 st %r2,SP_R2(%r15) # store return value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388sysc_tracenogo:
Heiko Carstensbcf5cef2009-06-12 10:26:26 +0200389 tm __TI_flags+2(%r9),_TIF_SYSCALL
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200390 bz BASED(sysc_return)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200391 l %r1,BASED(.Ltrace_exit)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200392 la %r2,SP_PTREGS(%r15) # load pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 la %r14,BASED(sysc_return)
394 br %r1
395
396#
397# a new process exits the kernel with ret_from_fork
398#
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200399 .globl ret_from_fork
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400ret_from_fork:
401 l %r13,__LC_SVC_NEW_PSW+4
402 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
403 tm SP_PSW+1(%r15),0x01 # forking a kernel thread ?
404 bo BASED(0f)
405 st %r15,SP_R15(%r15) # store stack pointer for new kthread
Heiko Carstens25d83cb2006-09-28 16:56:37 +02004060: l %r1,BASED(.Lschedtail)
407 basr %r14,%r1
Heiko Carstens1f194a42006-07-03 00:24:46 -0700408 TRACE_IRQS_ON
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200409 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
Al Viro8f2961c2008-12-25 13:37:58 +0100410 b BASED(sysc_tracenogo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411
412#
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200413# kernel_execve function needs to deal with pt_regs that is not
414# at the usual place
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415#
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200416 .globl kernel_execve
417kernel_execve:
418 stm %r12,%r15,48(%r15)
419 lr %r14,%r15
420 l %r13,__LC_SVC_NEW_PSW+4
421 s %r15,BASED(.Lc_spsize)
422 st %r14,__SF_BACKCHAIN(%r15)
423 la %r12,SP_PTREGS(%r15)
424 xc 0(__PT_SIZE,%r12),0(%r12)
425 l %r1,BASED(.Ldo_execve)
426 lr %r5,%r12
427 basr %r14,%r1
428 ltr %r2,%r2
429 be BASED(0f)
430 a %r15,BASED(.Lc_spsize)
431 lm %r12,%r15,48(%r15)
432 br %r14
433 # execve succeeded.
4340: stnsm __SF_EMPTY(%r15),0xfc # disable interrupts
435 l %r15,__LC_KERNEL_STACK # load ksp
436 s %r15,BASED(.Lc_spsize) # make room for registers & psw
437 l %r9,__LC_THREAD_INFO
438 mvc SP_PTREGS(__PT_SIZE,%r15),0(%r12) # copy pt_regs
439 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15)
440 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
441 l %r1,BASED(.Lexecve_tail)
442 basr %r14,%r1
443 b BASED(sysc_return)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444
445/*
446 * Program check handler routine
447 */
448
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200449 .globl pgm_check_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450pgm_check_handler:
451/*
452 * First we need to check for a special case:
453 * Single stepping an instruction that disables the PER event mask will
454 * cause a PER event AFTER the mask has been set. Example: SVC or LPSW.
455 * For a single stepped SVC the program check handler gets control after
456 * the SVC new PSW has been loaded. But we want to execute the SVC first and
457 * then handle the PER event. Therefore we update the SVC old PSW to point
458 * to the pgm_check_handler and branch to the SVC handler after we checked
459 * if we have to load the kernel stack register.
460 * For every other possible cause for PER event without the PER mask set
461 * we just ignore the PER event (FIXME: is there anything we have to do
462 * for LPSW?).
463 */
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100464 stpt __LC_SYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 SAVE_ALL_BASE __LC_SAVE_AREA
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200466 tm __LC_PGM_INT_CODE+1,0x80 # check whether we got a per exception
467 bnz BASED(pgm_per) # got per exception -> special case
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200468 SAVE_ALL_SYNC __LC_PGM_OLD_PSW,__LC_SAVE_AREA
Heiko Carstens77fa2242005-06-25 14:55:30 -0700469 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
471 bz BASED(pgm_no_vtime)
472 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
473 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
474 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
475pgm_no_vtime:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200477 l %r3,__LC_PGM_ILC # load program interruption code
Martin Schwidefsky1e546222010-10-25 16:10:37 +0200478 l %r4,__LC_TRANS_EXC_CODE
479 REENABLE_IRQS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 la %r8,0x7f
481 nr %r8,%r3
482pgm_do_call:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200483 l %r7,BASED(.Ljump_table)
484 sll %r8,2
485 l %r7,0(%r8,%r7) # load address of handler routine
486 la %r2,SP_PTREGS(%r15) # address of register-save area
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200487 basr %r14,%r7 # branch to interrupt-handler
488pgm_exit:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200489 b BASED(sysc_return)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490
491#
492# handle per exception
493#
494pgm_per:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200495 tm __LC_PGM_OLD_PSW,0x40 # test if per event recording is on
496 bnz BASED(pgm_per_std) # ok, normal per event from user space
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497# ok its one of the special cases, now we need to find out which one
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200498 clc __LC_PGM_OLD_PSW(8),__LC_SVC_NEW_PSW
499 be BASED(pgm_svcper)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500# no interesting special case, ignore PER event
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200501 lm %r12,%r15,__LC_SAVE_AREA
502 lpsw 0x28
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503
504#
505# Normal per exception
506#
507pgm_per_std:
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200508 SAVE_ALL_SYNC __LC_PGM_OLD_PSW,__LC_SAVE_AREA
Heiko Carstens77fa2242005-06-25 14:55:30 -0700509 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
511 bz BASED(pgm_no_vtime2)
512 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
513 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
514 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
515pgm_no_vtime2:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
517 l %r1,__TI_task(%r9)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200518 tm SP_PSW+1(%r15),0x01 # kernel per event ?
519 bz BASED(kernel_per)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 mvc __THREAD_per+__PER_atmid(2,%r1),__LC_PER_ATMID
521 mvc __THREAD_per+__PER_address(4,%r1),__LC_PER_ADDRESS
522 mvc __THREAD_per+__PER_access_id(1,%r1),__LC_PER_ACCESS_ID
523 oi __TI_flags+3(%r9),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200524 l %r3,__LC_PGM_ILC # load program interruption code
Martin Schwidefsky1e546222010-10-25 16:10:37 +0200525 l %r4,__LC_TRANS_EXC_CODE
526 REENABLE_IRQS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 la %r8,0x7f
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200528 nr %r8,%r3 # clear per-event-bit and ilc
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200529 be BASED(pgm_exit2) # only per or per+check ?
530 l %r7,BASED(.Ljump_table)
531 sll %r8,2
532 l %r7,0(%r8,%r7) # load address of handler routine
533 la %r2,SP_PTREGS(%r15) # address of register-save area
534 basr %r14,%r7 # branch to interrupt-handler
535pgm_exit2:
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200536 b BASED(sysc_return)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537
538#
539# it was a single stepped SVC that is causing all the trouble
540#
541pgm_svcper:
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200542 SAVE_ALL_SYNC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Heiko Carstens77fa2242005-06-25 14:55:30 -0700543 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
545 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
546 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547 lh %r7,0x8a # get svc number from lowcore
548 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
Christian Borntraegerbcc65252009-11-13 15:43:54 +0100549 l %r8,__TI_task(%r9)
550 mvc __THREAD_per+__PER_atmid(2,%r8),__LC_PER_ATMID
551 mvc __THREAD_per+__PER_address(4,%r8),__LC_PER_ADDRESS
552 mvc __THREAD_per+__PER_access_id(1,%r8),__LC_PER_ACCESS_ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 oi __TI_flags+3(%r9),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP
554 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200555 lm %r2,%r6,SP_R2(%r15) # load svc arguments
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 b BASED(sysc_do_svc)
557
Michael Grundy4ba069b2006-09-20 15:58:39 +0200558#
559# per was called from kernel, must be kprobes
560#
561kernel_per:
Martin Schwidefsky9ec27082010-10-29 16:50:45 +0200562 REENABLE_IRQS
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100563 mvi SP_SVCNR(%r15),0xff # set trap indication to pgm check
564 mvi SP_SVCNR+1(%r15),0xff
Michael Grundy4ba069b2006-09-20 15:58:39 +0200565 la %r2,SP_PTREGS(%r15) # address of register-save area
566 l %r1,BASED(.Lhandle_per) # load adr. of per handler
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200567 basr %r14,%r1 # branch to do_single_step
568 b BASED(pgm_exit)
Michael Grundy4ba069b2006-09-20 15:58:39 +0200569
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570/*
571 * IO interrupt handler routine
572 */
573
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200574 .globl io_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575io_int_handler:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 stck __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100577 stpt __LC_ASYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 SAVE_ALL_BASE __LC_SAVE_AREA+16
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200579 SAVE_ALL_ASYNC __LC_IO_OLD_PSW,__LC_SAVE_AREA+16
Heiko Carstens77fa2242005-06-25 14:55:30 -0700580 CREATE_STACK_FRAME __LC_IO_OLD_PSW,__LC_SAVE_AREA+16
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
582 bz BASED(io_no_vtime)
583 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
584 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
585 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
586io_no_vtime:
Heiko Carstens1f194a42006-07-03 00:24:46 -0700587 TRACE_IRQS_OFF
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200588 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200589 l %r1,BASED(.Ldo_IRQ) # load address of do_IRQ
590 la %r2,SP_PTREGS(%r15) # address of register-save area
591 basr %r14,%r1 # branch to standard irq handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592io_return:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200593 LOCKDEP_SYS_EXIT
594 TRACE_IRQS_ON
595io_tif:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 tm __TI_flags+3(%r9),_TIF_WORK_INT
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200597 bnz BASED(io_work) # there is work to do (signals etc.)
Heiko Carstens411788e2007-11-20 11:13:32 +0100598io_restore:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200599 RESTORE_ALL __LC_RETURN_PSW,0
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700600io_done:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601
Martin Schwidefsky26889052008-05-07 09:22:52 +0200602#
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200603# There is work todo, find out in which context we have been interrupted:
604# 1) if we return to user space we can do all _TIF_WORK_INT work
605# 2) if we return to kernel code and preemptive scheduling is enabled check
606# the preemption counter and if it is zero call preempt_schedule_irq
607# Before any work can be done, a switch to the kernel stack is required.
Martin Schwidefsky26889052008-05-07 09:22:52 +0200608#
609io_work:
610 tm SP_PSW+1(%r15),0x01 # returning to user ?
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200611 bo BASED(io_work_user) # yes -> do resched & signal
612#ifdef CONFIG_PREEMPT
Martin Schwidefsky26889052008-05-07 09:22:52 +0200613 # check for preemptive scheduling
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 icm %r0,15,__TI_precount(%r9)
Martin Schwidefsky26889052008-05-07 09:22:52 +0200615 bnz BASED(io_restore) # preemption disabled
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200616 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED
617 bno BASED(io_restore)
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200618 # switch to kernel stack
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 l %r1,SP_R15(%r15)
620 s %r1,BASED(.Lc_spsize)
621 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200622 xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1) # clear back chain
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 lr %r15,%r1
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200624 # TRACE_IRQS_ON already done at io_return, call
625 # TRACE_IRQS_OFF to keep things symmetrical
626 TRACE_IRQS_OFF
Heiko Carstensb8e7a542007-11-20 11:13:35 +0100627 l %r1,BASED(.Lpreempt_schedule_irq)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200628 basr %r14,%r1 # call preempt_schedule_irq
629 b BASED(io_return)
630#else
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200631 b BASED(io_restore)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200632#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200634#
635# Need to do work before returning to userspace, switch to kernel stack
636#
Martin Schwidefsky26889052008-05-07 09:22:52 +0200637io_work_user:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638 l %r1,__LC_KERNEL_STACK
639 s %r1,BASED(.Lc_spsize)
640 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200641 xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1) # clear back chain
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642 lr %r15,%r1
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200643
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644#
645# One of the work bits is on. Find out which one.
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200646# Checked are: _TIF_SIGPENDING, _TIF_NOTIFY_RESUME, _TIF_NEED_RESCHED
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200647# and _TIF_MCCK_PENDING
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648#
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200649io_work_tif:
Heiko Carstens77fa2242005-06-25 14:55:30 -0700650 tm __TI_flags+3(%r9),_TIF_MCCK_PENDING
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200651 bo BASED(io_mcck_pending)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED
653 bo BASED(io_reschedule)
Roland McGrath02a029b2008-04-30 00:53:08 -0700654 tm __TI_flags+3(%r9),_TIF_SIGPENDING
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200655 bo BASED(io_sigpending)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200656 tm __TI_flags+3(%r9),_TIF_NOTIFY_RESUME
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200657 bo BASED(io_notify_resume)
658 b BASED(io_return) # beware of critical section cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659
660#
Heiko Carstens77fa2242005-06-25 14:55:30 -0700661# _TIF_MCCK_PENDING is set, call handler
662#
663io_mcck_pending:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200664 # TRACE_IRQS_ON already done at io_return
Heiko Carstens77fa2242005-06-25 14:55:30 -0700665 l %r1,BASED(.Ls390_handle_mcck)
Heiko Carstensb771aea2007-07-27 12:29:18 +0200666 basr %r14,%r1 # TIF bit will be cleared by handler
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200667 TRACE_IRQS_OFF
668 b BASED(io_return)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700669
670#
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200672#
673io_reschedule:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200674 # TRACE_IRQS_ON already done at io_return
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200675 l %r1,BASED(.Lschedule)
676 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
677 basr %r14,%r1 # call scheduler
678 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100679 TRACE_IRQS_OFF
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200680 b BASED(io_return)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681
682#
Roland McGrath02a029b2008-04-30 00:53:08 -0700683# _TIF_SIGPENDING is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684#
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200685io_sigpending:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200686 # TRACE_IRQS_ON already done at io_return
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200687 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
688 la %r2,SP_PTREGS(%r15) # load pt_regs
689 l %r1,BASED(.Ldo_signal)
690 basr %r14,%r1 # call do_signal
691 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100692 TRACE_IRQS_OFF
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200693 b BASED(io_return)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200695#
696# _TIF_SIGPENDING is set, call do_signal
697#
698io_notify_resume:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200699 # TRACE_IRQS_ON already done at io_return
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200700 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
701 la %r2,SP_PTREGS(%r15) # load pt_regs
702 l %r1,BASED(.Ldo_notify_resume)
703 basr %r14,%r1 # call do_signal
704 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
705 TRACE_IRQS_OFF
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200706 b BASED(io_return)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200707
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708/*
709 * External interrupt handler routine
710 */
711
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200712 .globl ext_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713ext_int_handler:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 stck __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100715 stpt __LC_ASYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 SAVE_ALL_BASE __LC_SAVE_AREA+16
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200717 SAVE_ALL_ASYNC __LC_EXT_OLD_PSW,__LC_SAVE_AREA+16
Heiko Carstens77fa2242005-06-25 14:55:30 -0700718 CREATE_STACK_FRAME __LC_EXT_OLD_PSW,__LC_SAVE_AREA+16
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
720 bz BASED(ext_no_vtime)
721 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
722 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
723 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
724ext_no_vtime:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
Heiko Carstens1f194a42006-07-03 00:24:46 -0700726 TRACE_IRQS_OFF
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200727 la %r2,SP_PTREGS(%r15) # address of register-save area
Martin Schwidefskyf6649a72010-10-25 16:10:38 +0200728 l %r3,__LC_CPU_ADDRESS # get cpu address + interruption code
729 l %r4,__LC_EXT_PARAMS # get external parameters
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730 l %r1,BASED(.Ldo_extint)
731 basr %r14,%r1
732 b BASED(io_return)
733
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700734__critical_end:
735
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736/*
737 * Machine check handler routines
738 */
739
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200740 .globl mcck_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741mcck_int_handler:
Martin Schwidefsky63779812010-05-17 10:00:03 +0200742 stck __LC_MCCK_CLOCK
Heiko Carstens77fa2242005-06-25 14:55:30 -0700743 spt __LC_CPU_TIMER_SAVE_AREA # revalidate cpu timer
744 lm %r0,%r15,__LC_GPREGS_SAVE_AREA # revalidate gprs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 SAVE_ALL_BASE __LC_SAVE_AREA+32
Heiko Carstens77fa2242005-06-25 14:55:30 -0700746 la %r12,__LC_MCK_OLD_PSW
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200747 tm __LC_MCCK_CODE,0x80 # system damage?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700748 bo BASED(mcck_int_main) # yes -> rest of mcck code invalid
Martin Schwidefsky63779812010-05-17 10:00:03 +0200749 mvc __LC_MCCK_ENTER_TIMER(8),__LC_CPU_TIMER_SAVE_AREA
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200750 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
751 bo BASED(1f)
752 la %r14,__LC_SYNC_ENTER_TIMER
753 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
754 bl BASED(0f)
755 la %r14,__LC_ASYNC_ENTER_TIMER
7560: clc 0(8,%r14),__LC_EXIT_TIMER
757 bl BASED(0f)
758 la %r14,__LC_EXIT_TIMER
7590: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
760 bl BASED(0f)
761 la %r14,__LC_LAST_UPDATE_TIMER
7620: spt 0(%r14)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200763 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
Martin Schwidefskyc185b782008-12-25 13:39:25 +01007641: tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700765 bno BASED(mcck_int_main) # no -> skip cleanup critical
766 tm __LC_MCK_OLD_PSW+1,0x01 # test problem state bit
767 bnz BASED(mcck_int_main) # from user -> load async stack
768 clc __LC_MCK_OLD_PSW+4(4),BASED(.Lcritical_end)
769 bhe BASED(mcck_int_main)
770 clc __LC_MCK_OLD_PSW+4(4),BASED(.Lcritical_start)
771 bl BASED(mcck_int_main)
772 l %r14,BASED(.Lcleanup_critical)
773 basr %r14,%r14
774mcck_int_main:
775 l %r14,__LC_PANIC_STACK # are we already on the panic stack?
776 slr %r14,%r15
777 sra %r14,PAGE_SHIFT
778 be BASED(0f)
779 l %r15,__LC_PANIC_STACK # load panic stack
7800: CREATE_STACK_FRAME __LC_MCK_OLD_PSW,__LC_SAVE_AREA+32
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200781 tm __LC_MCCK_CODE+2,0x08 # mwp of old psw valid?
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700782 bno BASED(mcck_no_vtime) # no -> skip cleanup critical
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200783 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700784 bz BASED(mcck_no_vtime)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200785 UPDATE_VTIME __LC_EXIT_TIMER,__LC_MCCK_ENTER_TIMER,__LC_USER_TIMER
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700786 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
Martin Schwidefsky63779812010-05-17 10:00:03 +0200787 mvc __LC_LAST_UPDATE_TIMER(8),__LC_MCCK_ENTER_TIMER
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700788mcck_no_vtime:
Heiko Carstens77fa2242005-06-25 14:55:30 -0700789 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
790 la %r2,SP_PTREGS(%r15) # load pt_regs
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200791 l %r1,BASED(.Ls390_mcck)
792 basr %r14,%r1 # call machine check handler
793 tm SP_PSW+1(%r15),0x01 # returning to user ?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700794 bno BASED(mcck_return)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200795 l %r1,__LC_KERNEL_STACK # switch to kernel stack
Heiko Carstens77fa2242005-06-25 14:55:30 -0700796 s %r1,BASED(.Lc_spsize)
797 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200798 xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1) # clear back chain
Heiko Carstens77fa2242005-06-25 14:55:30 -0700799 lr %r15,%r1
800 stosm __SF_EMPTY(%r15),0x04 # turn dat on
801 tm __TI_flags+3(%r9),_TIF_MCCK_PENDING
802 bno BASED(mcck_return)
Heiko Carstens1f194a42006-07-03 00:24:46 -0700803 TRACE_IRQS_OFF
Heiko Carstens77fa2242005-06-25 14:55:30 -0700804 l %r1,BASED(.Ls390_handle_mcck)
805 basr %r14,%r1 # call machine check handler
Heiko Carstens1f194a42006-07-03 00:24:46 -0700806 TRACE_IRQS_ON
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807mcck_return:
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200808 mvc __LC_RETURN_MCCK_PSW(8),SP_PSW(%r15) # move return PSW
809 ni __LC_RETURN_MCCK_PSW+1,0xfd # clear wait state bit
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200810 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
811 bno BASED(0f)
812 lm %r0,%r15,SP_R0(%r15) # load gprs 0-15
813 stpt __LC_EXIT_TIMER
814 lpsw __LC_RETURN_MCCK_PSW # back to caller
Martin Schwidefskyc185b782008-12-25 13:39:25 +01008150: lm %r0,%r15,SP_R0(%r15) # load gprs 0-15
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200816 lpsw __LC_RETURN_MCCK_PSW # back to caller
817
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200818 RESTORE_ALL __LC_RETURN_MCCK_PSW,0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820/*
821 * Restart interruption handler, kick starter for additional CPUs
822 */
Heiko Carstens84b36a82007-06-19 13:10:03 +0200823#ifdef CONFIG_SMP
Heiko Carstens2bc89b52008-02-05 16:50:40 +0100824 __CPUINIT
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200825 .globl restart_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826restart_int_handler:
Martin Schwidefsky5b409ed2009-04-14 15:36:27 +0200827 basr %r1,0
828restart_base:
829 spt restart_vtime-restart_base(%r1)
830 stck __LC_LAST_UPDATE_CLOCK
831 mvc __LC_LAST_UPDATE_TIMER(8),restart_vtime-restart_base(%r1)
832 mvc __LC_EXIT_TIMER(8),restart_vtime-restart_base(%r1)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200833 l %r15,__LC_SAVE_AREA+60 # load ksp
834 lctl %c0,%c15,__LC_CREGS_SAVE_AREA # get new ctl regs
835 lam %a0,%a15,__LC_AREGS_SAVE_AREA
836 lm %r6,%r15,__SF_GPRS(%r15) # load registers from clone
Martin Schwidefsky5b409ed2009-04-14 15:36:27 +0200837 l %r1,__LC_THREAD_INFO
838 mvc __LC_USER_TIMER(8),__TI_user_timer(%r1)
839 mvc __LC_SYSTEM_TIMER(8),__TI_system_timer(%r1)
840 xc __LC_STEAL_TIMER(8),__LC_STEAL_TIMER
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200841 stosm __SF_EMPTY(%r15),0x04 # now we can turn dat on
842 basr %r14,0
843 l %r14,restart_addr-.(%r14)
844 br %r14 # branch to start_secondary
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845restart_addr:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200846 .long start_secondary
Martin Schwidefsky5b409ed2009-04-14 15:36:27 +0200847 .align 8
848restart_vtime:
849 .long 0x7fffffff,0xffffffff
Heiko Carstens84b36a82007-06-19 13:10:03 +0200850 .previous
Linus Torvalds1da177e2005-04-16 15:20:36 -0700851#else
852/*
853 * If we do not run with SMP enabled, let the new CPU crash ...
854 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200855 .globl restart_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700856restart_int_handler:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200857 basr %r1,0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700858restart_base:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200859 lpsw restart_crash-restart_base(%r1)
860 .align 8
Linus Torvalds1da177e2005-04-16 15:20:36 -0700861restart_crash:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200862 .long 0x000a0000,0x00000000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700863restart_go:
864#endif
865
Martin Schwidefsky860dba42011-01-05 12:47:25 +0100866 .section .kprobes.text, "ax"
867
Linus Torvalds1da177e2005-04-16 15:20:36 -0700868#ifdef CONFIG_CHECK_STACK
869/*
870 * The synchronous or the asynchronous stack overflowed. We are dead.
871 * No need to properly save the registers, we are going to panic anyway.
872 * Setup a pt_regs so that show_trace can provide a good call trace.
873 */
874stack_overflow:
875 l %r15,__LC_PANIC_STACK # change to panic stack
876 sl %r15,BASED(.Lc_spsize)
877 mvc SP_PSW(8,%r15),0(%r12) # move user PSW to stack
878 stm %r0,%r11,SP_R0(%r15) # store gprs %r0-%r11 to kernel stack
879 la %r1,__LC_SAVE_AREA
880 ch %r12,BASED(.L0x020) # old psw addr == __LC_SVC_OLD_PSW ?
881 be BASED(0f)
882 ch %r12,BASED(.L0x028) # old psw addr == __LC_PGM_OLD_PSW ?
883 be BASED(0f)
884 la %r1,__LC_SAVE_AREA+16
8850: mvc SP_R12(16,%r15),0(%r1) # move %r12-%r15 to stack
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200886 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15) # clear back chain
Linus Torvalds1da177e2005-04-16 15:20:36 -0700887 l %r1,BASED(1f) # branch to kernel_stack_overflow
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200888 la %r2,SP_PTREGS(%r15) # load pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700889 br %r1
Heiko Carstens25d83cb2006-09-28 16:56:37 +02008901: .long kernel_stack_overflow
Linus Torvalds1da177e2005-04-16 15:20:36 -0700891#endif
892
893cleanup_table_system_call:
894 .long system_call + 0x80000000, sysc_do_svc + 0x80000000
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200895cleanup_table_sysc_tif:
896 .long sysc_tif + 0x80000000, sysc_restore + 0x80000000
897cleanup_table_sysc_restore:
898 .long sysc_restore + 0x80000000, sysc_done + 0x80000000
899cleanup_table_io_tif:
900 .long io_tif + 0x80000000, io_restore + 0x80000000
901cleanup_table_io_restore:
902 .long io_restore + 0x80000000, io_done + 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700903
904cleanup_critical:
905 clc 4(4,%r12),BASED(cleanup_table_system_call)
906 bl BASED(0f)
907 clc 4(4,%r12),BASED(cleanup_table_system_call+4)
908 bl BASED(cleanup_system_call)
9090:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200910 clc 4(4,%r12),BASED(cleanup_table_sysc_tif)
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_tif+4)
913 bl BASED(cleanup_sysc_tif)
Linus Torvalds1da177e2005-04-16 15:20:36 -07009140:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200915 clc 4(4,%r12),BASED(cleanup_table_sysc_restore)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700916 bl BASED(0f)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200917 clc 4(4,%r12),BASED(cleanup_table_sysc_restore+4)
918 bl BASED(cleanup_sysc_restore)
Linus Torvalds1da177e2005-04-16 15:20:36 -07009190:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200920 clc 4(4,%r12),BASED(cleanup_table_io_tif)
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200921 bl BASED(0f)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200922 clc 4(4,%r12),BASED(cleanup_table_io_tif+4)
923 bl BASED(cleanup_io_tif)
Martin Schwidefsky63b12242006-06-29 14:58:05 +02009240:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200925 clc 4(4,%r12),BASED(cleanup_table_io_restore)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700926 bl BASED(0f)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200927 clc 4(4,%r12),BASED(cleanup_table_io_restore+4)
928 bl BASED(cleanup_io_restore)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07009290:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700930 br %r14
931
932cleanup_system_call:
933 mvc __LC_RETURN_PSW(8),0(%r12)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700934 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+4)
935 bh BASED(0f)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200936 mvc __LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER
937 c %r12,BASED(.Lmck_old_psw)
938 be BASED(0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700939 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
Martin Schwidefsky63779812010-05-17 10:00:03 +02009400: c %r12,BASED(.Lmck_old_psw)
941 la %r12,__LC_SAVE_AREA+32
942 be BASED(0f)
943 la %r12,__LC_SAVE_AREA+16
Linus Torvalds1da177e2005-04-16 15:20:36 -07009440: clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+8)
945 bhe BASED(cleanup_vtime)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700946 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn)
947 bh BASED(0f)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700948 mvc __LC_SAVE_AREA(16),0(%r12)
9490: st %r13,4(%r12)
950 st %r12,__LC_SAVE_AREA+48 # argh
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200951 SAVE_ALL_SYNC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Heiko Carstens77fa2242005-06-25 14:55:30 -0700952 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700953 l %r12,__LC_SAVE_AREA+48 # argh
954 st %r15,12(%r12)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955 lh %r7,0x8a
Linus Torvalds1da177e2005-04-16 15:20:36 -0700956cleanup_vtime:
957 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+12)
958 bhe BASED(cleanup_stime)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700959 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
960cleanup_stime:
961 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+16)
962 bh BASED(cleanup_update)
963 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
964cleanup_update:
965 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700966 mvc __LC_RETURN_PSW+4(4),BASED(cleanup_table_system_call+4)
967 la %r12,__LC_RETURN_PSW
968 br %r14
969cleanup_system_call_insn:
970 .long sysc_saveall + 0x80000000
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200971 .long system_call + 0x80000000
972 .long sysc_vtime + 0x80000000
973 .long sysc_stime + 0x80000000
974 .long sysc_update + 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700975
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200976cleanup_sysc_tif:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700977 mvc __LC_RETURN_PSW(4),0(%r12)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200978 mvc __LC_RETURN_PSW+4(4),BASED(cleanup_table_sysc_tif)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700979 la %r12,__LC_RETURN_PSW
980 br %r14
981
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200982cleanup_sysc_restore:
983 clc 4(4,%r12),BASED(cleanup_sysc_restore_insn)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700984 be BASED(2f)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200985 mvc __LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
986 c %r12,BASED(.Lmck_old_psw)
987 be BASED(0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700988 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
Martin Schwidefsky63779812010-05-17 10:00:03 +02009890: clc 4(4,%r12),BASED(cleanup_sysc_restore_insn+4)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700990 be BASED(2f)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700991 mvc __LC_RETURN_PSW(8),SP_PSW(%r15)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700992 c %r12,BASED(.Lmck_old_psw)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200993 la %r12,__LC_SAVE_AREA+32
994 be BASED(1f)
995 la %r12,__LC_SAVE_AREA+16
9961: mvc 0(16,%r12),SP_R12(%r15)
997 lm %r0,%r11,SP_R0(%r15)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700998 l %r15,SP_R15(%r15)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07009992: la %r12,__LC_RETURN_PSW
Linus Torvalds1da177e2005-04-16 15:20:36 -07001000 br %r14
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +02001001cleanup_sysc_restore_insn:
Heiko Carstens411788e2007-11-20 11:13:32 +01001002 .long sysc_done - 4 + 0x80000000
Heiko Carstens411788e2007-11-20 11:13:32 +01001003 .long sysc_done - 8 + 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -07001004
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +02001005cleanup_io_tif:
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001006 mvc __LC_RETURN_PSW(4),0(%r12)
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +02001007 mvc __LC_RETURN_PSW+4(4),BASED(cleanup_table_io_tif)
Martin Schwidefsky176b1802010-04-09 13:43:00 +02001008 la %r12,__LC_RETURN_PSW
1009 br %r14
1010
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +02001011cleanup_io_restore:
1012 clc 4(4,%r12),BASED(cleanup_io_restore_insn)
Martin Schwidefsky63779812010-05-17 10:00:03 +02001013 be BASED(1f)
1014 mvc __LC_EXIT_TIMER(8),__LC_MCCK_ENTER_TIMER
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +02001015 clc 4(4,%r12),BASED(cleanup_io_restore_insn+4)
Martin Schwidefsky63779812010-05-17 10:00:03 +02001016 be BASED(1f)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001017 mvc __LC_RETURN_PSW(8),SP_PSW(%r15)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001018 mvc __LC_SAVE_AREA+32(16),SP_R12(%r15)
Martin Schwidefsky63779812010-05-17 10:00:03 +02001019 lm %r0,%r11,SP_R0(%r15)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001020 l %r15,SP_R15(%r15)
Martin Schwidefsky63779812010-05-17 10:00:03 +020010211: la %r12,__LC_RETURN_PSW
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001022 br %r14
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +02001023cleanup_io_restore_insn:
Heiko Carstens411788e2007-11-20 11:13:32 +01001024 .long io_done - 4 + 0x80000000
Heiko Carstens411788e2007-11-20 11:13:32 +01001025 .long io_done - 8 + 0x80000000
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001026
Linus Torvalds1da177e2005-04-16 15:20:36 -07001027/*
1028 * Integer constants
1029 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001030 .align 4
1031.Lc_spsize: .long SP_SIZE
1032.Lc_overhead: .long STACK_FRAME_OVERHEAD
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001033.Lnr_syscalls: .long NR_syscalls
1034.L0x018: .short 0x018
1035.L0x020: .short 0x020
1036.L0x028: .short 0x028
1037.L0x030: .short 0x030
1038.L0x038: .short 0x038
1039.Lc_1: .long 1
Linus Torvalds1da177e2005-04-16 15:20:36 -07001040
1041/*
1042 * Symbol constants
1043 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001044.Ls390_mcck: .long s390_do_machine_check
Heiko Carstens77fa2242005-06-25 14:55:30 -07001045.Ls390_handle_mcck:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001046 .long s390_handle_mcck
1047.Lmck_old_psw: .long __LC_MCK_OLD_PSW
1048.Ldo_IRQ: .long do_IRQ
1049.Ldo_extint: .long do_extint
1050.Ldo_signal: .long do_signal
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +02001051.Ldo_notify_resume:
1052 .long do_notify_resume
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001053.Lhandle_per: .long do_single_step
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +02001054.Ldo_execve: .long do_execve
1055.Lexecve_tail: .long execve_tail
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001056.Ljump_table: .long pgm_check_table
1057.Lschedule: .long schedule
Christian Borntraegerab1809b2007-12-04 16:09:04 +01001058#ifdef CONFIG_PREEMPT
Heiko Carstensb8e7a542007-11-20 11:13:35 +01001059.Lpreempt_schedule_irq:
1060 .long preempt_schedule_irq
Christian Borntraegerab1809b2007-12-04 16:09:04 +01001061#endif
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +02001062.Ltrace_entry: .long do_syscall_trace_enter
1063.Ltrace_exit: .long do_syscall_trace_exit
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001064.Lschedtail: .long schedule_tail
1065.Lsysc_table: .long sys_call_table
Heiko Carstens1f194a42006-07-03 00:24:46 -07001066#ifdef CONFIG_TRACE_IRQFLAGS
Heiko Carstens50bec4c2008-11-14 18:18:05 +01001067.Ltrace_irq_on_caller:
1068 .long trace_hardirqs_on_caller
1069.Ltrace_irq_off_caller:
1070 .long trace_hardirqs_off_caller
Heiko Carstensaf4c68742008-11-14 18:18:03 +01001071#endif
1072#ifdef CONFIG_LOCKDEP
Heiko Carstens523b44c2007-10-11 22:11:12 +02001073.Llockdep_sys_exit:
1074 .long lockdep_sys_exit
Heiko Carstens1f194a42006-07-03 00:24:46 -07001075#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001076.Lcritical_start:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001077 .long __critical_start + 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -07001078.Lcritical_end:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001079 .long __critical_end + 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -07001080.Lcleanup_critical:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001081 .long cleanup_critical
Linus Torvalds1da177e2005-04-16 15:20:36 -07001082
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001083 .section .rodata, "a"
Linus Torvalds1da177e2005-04-16 15:20:36 -07001084#define SYSCALL(esa,esame,emu) .long esa
Heiko Carstens9bf12262009-06-12 10:26:47 +02001085 .globl sys_call_table
Linus Torvalds1da177e2005-04-16 15:20:36 -07001086sys_call_table:
1087#include "syscalls.S"
1088#undef SYSCALL