blob: e8ef21c51bbed02be140f797e24cec0e6c059fce [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>
16#include <asm/lowcore.h>
17#include <asm/errno.h>
18#include <asm/ptrace.h>
19#include <asm/thread_info.h>
Sam Ravnborg0013a852005-09-09 20:57:26 +020020#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <asm/unistd.h>
22#include <asm/page.h>
23
24/*
25 * Stack layout for the system_call stack entry.
26 * The first few entries are identical to the user_regs_struct.
27 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +020028SP_PTREGS = STACK_FRAME_OVERHEAD
29SP_ARGS = STACK_FRAME_OVERHEAD + __PT_ARGS
30SP_PSW = STACK_FRAME_OVERHEAD + __PT_PSW
31SP_R0 = STACK_FRAME_OVERHEAD + __PT_GPRS
32SP_R1 = STACK_FRAME_OVERHEAD + __PT_GPRS + 4
33SP_R2 = STACK_FRAME_OVERHEAD + __PT_GPRS + 8
34SP_R3 = STACK_FRAME_OVERHEAD + __PT_GPRS + 12
35SP_R4 = STACK_FRAME_OVERHEAD + __PT_GPRS + 16
36SP_R5 = STACK_FRAME_OVERHEAD + __PT_GPRS + 20
37SP_R6 = STACK_FRAME_OVERHEAD + __PT_GPRS + 24
38SP_R7 = STACK_FRAME_OVERHEAD + __PT_GPRS + 28
39SP_R8 = STACK_FRAME_OVERHEAD + __PT_GPRS + 32
40SP_R9 = STACK_FRAME_OVERHEAD + __PT_GPRS + 36
41SP_R10 = STACK_FRAME_OVERHEAD + __PT_GPRS + 40
42SP_R11 = STACK_FRAME_OVERHEAD + __PT_GPRS + 44
43SP_R12 = STACK_FRAME_OVERHEAD + __PT_GPRS + 48
44SP_R13 = STACK_FRAME_OVERHEAD + __PT_GPRS + 52
45SP_R14 = STACK_FRAME_OVERHEAD + __PT_GPRS + 56
46SP_R15 = STACK_FRAME_OVERHEAD + __PT_GPRS + 60
47SP_ORIG_R2 = STACK_FRAME_OVERHEAD + __PT_ORIG_GPR2
48SP_ILC = STACK_FRAME_OVERHEAD + __PT_ILC
Martin Schwidefsky59da2132008-11-27 11:05:55 +010049SP_SVCNR = STACK_FRAME_OVERHEAD + __PT_SVCNR
Heiko Carstens25d83cb2006-09-28 16:56:37 +020050SP_SIZE = STACK_FRAME_OVERHEAD + __PT_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +020052_TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
Heiko Carstens54dfe5d2006-02-01 03:06:38 -080053 _TIF_MCCK_PENDING | _TIF_RESTART_SVC | _TIF_SINGLE_STEP )
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +020054_TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
Heiko Carstens54dfe5d2006-02-01 03:06:38 -080055 _TIF_MCCK_PENDING)
Heiko Carstens9bf12262009-06-12 10:26:47 +020056_TIF_SYSCALL = (_TIF_SYSCALL_TRACE>>8 | _TIF_SYSCALL_AUDIT>>8 | \
Josh Stone66700002009-08-24 14:43:11 -070057 _TIF_SECCOMP>>8 | _TIF_SYSCALL_TRACEPOINT>>8)
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
59STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
60STACK_SIZE = 1 << STACK_SHIFT
61
62#define BASED(name) name-system_call(%r13)
63
Heiko Carstens1f194a42006-07-03 00:24:46 -070064#ifdef CONFIG_TRACE_IRQFLAGS
65 .macro TRACE_IRQS_ON
Heiko Carstens50bec4c2008-11-14 18:18:05 +010066 basr %r2,%r0
67 l %r1,BASED(.Ltrace_irq_on_caller)
Heiko Carstens1f194a42006-07-03 00:24:46 -070068 basr %r14,%r1
69 .endm
70
71 .macro TRACE_IRQS_OFF
Heiko Carstens50bec4c2008-11-14 18:18:05 +010072 basr %r2,%r0
73 l %r1,BASED(.Ltrace_irq_off_caller)
Heiko Carstens1f194a42006-07-03 00:24:46 -070074 basr %r14,%r1
75 .endm
Heiko Carstens523b44c2007-10-11 22:11:12 +020076
Heiko Carstens411788e2007-11-20 11:13:32 +010077 .macro TRACE_IRQS_CHECK
Heiko Carstens50bec4c2008-11-14 18:18:05 +010078 basr %r2,%r0
Heiko Carstens411788e2007-11-20 11:13:32 +010079 tm SP_PSW(%r15),0x03 # irqs enabled?
80 jz 0f
Heiko Carstens50bec4c2008-11-14 18:18:05 +010081 l %r1,BASED(.Ltrace_irq_on_caller)
Heiko Carstens523b44c2007-10-11 22:11:12 +020082 basr %r14,%r1
Heiko Carstens411788e2007-11-20 11:13:32 +010083 j 1f
Heiko Carstens50bec4c2008-11-14 18:18:05 +0100840: l %r1,BASED(.Ltrace_irq_off_caller)
Heiko Carstens411788e2007-11-20 11:13:32 +010085 basr %r14,%r1
861:
Heiko Carstens523b44c2007-10-11 22:11:12 +020087 .endm
Heiko Carstens1f194a42006-07-03 00:24:46 -070088#else
89#define TRACE_IRQS_ON
90#define TRACE_IRQS_OFF
Heiko Carstens411788e2007-11-20 11:13:32 +010091#define TRACE_IRQS_CHECK
92#endif
93
94#ifdef CONFIG_LOCKDEP
95 .macro LOCKDEP_SYS_EXIT
96 tm SP_PSW+1(%r15),0x01 # returning to user ?
97 jz 0f
98 l %r1,BASED(.Llockdep_sys_exit)
99 basr %r14,%r1
1000:
101 .endm
102#else
Heiko Carstens523b44c2007-10-11 22:11:12 +0200103#define LOCKDEP_SYS_EXIT
Heiko Carstens1f194a42006-07-03 00:24:46 -0700104#endif
105
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106/*
107 * Register usage in interrupt handlers:
108 * R9 - pointer to current task structure
109 * R13 - pointer to literal pool
110 * R14 - return register for function calls
111 * R15 - kernel stack pointer
112 */
113
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200114 .macro UPDATE_VTIME lc_from,lc_to,lc_sum
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 lm %r10,%r11,\lc_from
116 sl %r10,\lc_to
117 sl %r11,\lc_to+4
118 bc 3,BASED(0f)
119 sl %r10,BASED(.Lc_1)
1200: al %r10,\lc_sum
121 al %r11,\lc_sum+4
122 bc 12,BASED(1f)
123 al %r10,BASED(.Lc_1)
1241: stm %r10,%r11,\lc_sum
125 .endm
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126
127 .macro SAVE_ALL_BASE savearea
128 stm %r12,%r15,\savearea
129 l %r13,__LC_SVC_NEW_PSW+4 # load &system_call to %r13
130 .endm
131
Martin Schwidefsky987ad702007-07-10 11:24:18 +0200132 .macro SAVE_ALL_SVC psworg,savearea
133 la %r12,\psworg
134 l %r15,__LC_KERNEL_STACK # problem state -> load ksp
135 .endm
136
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200137 .macro SAVE_ALL_SYNC psworg,savearea
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 la %r12,\psworg
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 tm \psworg+1,0x01 # test problem state bit
140 bz BASED(2f) # skip stack setup save
141 l %r15,__LC_KERNEL_STACK # problem state -> load ksp
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200142#ifdef CONFIG_CHECK_STACK
143 b BASED(3f)
1442: tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
145 bz BASED(stack_overflow)
1463:
147#endif
1482:
149 .endm
150
151 .macro SAVE_ALL_ASYNC psworg,savearea
152 la %r12,\psworg
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 tm \psworg+1,0x01 # test problem state bit
154 bnz BASED(1f) # from user -> load async stack
155 clc \psworg+4(4),BASED(.Lcritical_end)
156 bhe BASED(0f)
157 clc \psworg+4(4),BASED(.Lcritical_start)
158 bl BASED(0f)
159 l %r14,BASED(.Lcleanup_critical)
160 basr %r14,%r14
Peter Oberparleiter6add9f72005-09-16 19:27:42 -0700161 tm 1(%r12),0x01 # retest problem state after cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 bnz BASED(1f)
1630: l %r14,__LC_ASYNC_STACK # are we already on the async stack ?
164 slr %r14,%r15
165 sra %r14,STACK_SHIFT
166 be BASED(2f)
1671: l %r15,__LC_ASYNC_STACK
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168#ifdef CONFIG_CHECK_STACK
169 b BASED(3f)
1702: tml %r15,STACK_SIZE - CONFIG_STACK_GUARD
171 bz BASED(stack_overflow)
1723:
173#endif
Heiko Carstens77fa2242005-06-25 14:55:30 -07001742:
175 .endm
176
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200177 .macro CREATE_STACK_FRAME psworg,savearea
Heiko Carstens77fa2242005-06-25 14:55:30 -0700178 s %r15,BASED(.Lc_spsize) # make room for registers & psw
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 mvc SP_PSW(8,%r15),0(%r12) # move user PSW to stack
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180 st %r2,SP_ORIG_R2(%r15) # store original content of gpr 2
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100181 icm %r12,3,__LC_SVC_ILC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 stm %r0,%r11,SP_R0(%r15) # store gprs %r0-%r11 to kernel stack
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100183 st %r12,SP_SVCNR(%r15)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 mvc SP_R12(16,%r15),\savearea # move %r12-%r15 to stack
185 la %r12,0
186 st %r12,__SF_BACKCHAIN(%r15) # clear back chain
187 .endm
188
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200189 .macro RESTORE_ALL psworg,sync
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700190 mvc \psworg(8),SP_PSW(%r15) # move user PSW to lowcore
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 .if !\sync
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700192 ni \psworg+1,0xfd # clear wait state bit
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 .endif
194 lm %r0,%r15,SP_R0(%r15) # load gprs 0-15 of user
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100195 stpt __LC_EXIT_TIMER
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700196 lpsw \psworg # back to caller
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 .endm
198
199/*
200 * Scheduler resume function, called by switch_to
201 * gpr2 = (task_struct *) prev
202 * gpr3 = (task_struct *) next
203 * Returns:
204 * gpr2 = prev
205 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200206 .globl __switch_to
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207__switch_to:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200208 basr %r1,0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209__switch_to_base:
210 tm __THREAD_per(%r3),0xe8 # new process is using per ?
211 bz __switch_to_noper-__switch_to_base(%r1) # if not we're fine
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200212 stctl %c9,%c11,__SF_EMPTY(%r15) # We are using per stuff
213 clc __THREAD_per(12,%r3),__SF_EMPTY(%r15)
214 be __switch_to_noper-__switch_to_base(%r1) # we got away w/o bashing TLB's
215 lctl %c9,%c11,__THREAD_per(%r3) # Nope we didn't
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216__switch_to_noper:
Heiko Carstens77fa2242005-06-25 14:55:30 -0700217 l %r4,__THREAD_info(%r2) # get thread_info of prev
218 tm __TI_flags+3(%r4),_TIF_MCCK_PENDING # machine check pending?
219 bz __switch_to_no_mcck-__switch_to_base(%r1)
220 ni __TI_flags+3(%r4),255-_TIF_MCCK_PENDING # clear flag in prev
221 l %r4,__THREAD_info(%r3) # get thread_info of next
222 oi __TI_flags+3(%r4),_TIF_MCCK_PENDING # set it in next
223__switch_to_no_mcck:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200224 stm %r6,%r15,__SF_GPRS(%r15)# store __switch_to registers of prev task
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 st %r15,__THREAD_ksp(%r2) # store kernel stack to prev->tss.ksp
226 l %r15,__THREAD_ksp(%r3) # load kernel stack from next->tss.ksp
227 lm %r6,%r15,__SF_GPRS(%r15)# load __switch_to registers of next task
228 st %r3,__LC_CURRENT # __LC_CURRENT = current task struct
229 lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200230 l %r3,__THREAD_info(%r3) # load thread_info from task struct
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 st %r3,__LC_THREAD_INFO
232 ahi %r3,STACK_SIZE
233 st %r3,__LC_KERNEL_STACK # __LC_KERNEL_STACK = new kernel stack
234 br %r14
235
236__critical_start:
237/*
238 * SVC interrupt handler routine. System calls are synchronous events and
239 * are executed with interrupts enabled.
240 */
241
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200242 .globl system_call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243system_call:
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100244 stpt __LC_SYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245sysc_saveall:
246 SAVE_ALL_BASE __LC_SAVE_AREA
Martin Schwidefsky987ad702007-07-10 11:24:18 +0200247 SAVE_ALL_SVC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Heiko Carstens77fa2242005-06-25 14:55:30 -0700248 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 lh %r7,0x8a # get svc number from lowcore
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250sysc_vtime:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
252sysc_stime:
253 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
254sysc_update:
255 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256sysc_do_svc:
257 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100258 ltr %r7,%r7 # test for svc 0
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200259 bnz BASED(sysc_nr_ok) # svc number > 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260 # svc 0: system call number in %r1
261 cl %r1,BASED(.Lnr_syscalls)
262 bnl BASED(sysc_nr_ok)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200263 lr %r7,%r1 # copy svc number to %r7
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264sysc_nr_ok:
265 mvc SP_ARGS(4,%r15),SP_R7(%r15)
266sysc_do_restart:
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100267 sth %r7,SP_SVCNR(%r15)
268 sll %r7,2 # svc number *4
Heiko Carstensd882b172006-07-01 04:36:31 -0700269 l %r8,BASED(.Lsysc_table)
Heiko Carstensbcf5cef2009-06-12 10:26:26 +0200270 tm __TI_flags+2(%r9),_TIF_SYSCALL
Heiko Carstensd882b172006-07-01 04:36:31 -0700271 l %r8,0(%r7,%r8) # get system call addr.
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200272 bnz BASED(sysc_tracesys)
273 basr %r14,%r8 # call sys_xxxx
274 st %r2,SP_R2(%r15) # store return value (change R2 on stack)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275
276sysc_return:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 tm __TI_flags+3(%r9),_TIF_WORK_SVC
278 bnz BASED(sysc_work) # there is work to do (signals etc.)
Heiko Carstens411788e2007-11-20 11:13:32 +0100279sysc_restore:
280#ifdef CONFIG_TRACE_IRQFLAGS
Hendrik Bruecknera8c3cb42009-09-11 10:28:42 +0200281 la %r1,BASED(sysc_restore_trace_psw_addr)
282 l %r1,0(%r1)
Heiko Carstens411788e2007-11-20 11:13:32 +0100283 lpsw 0(%r1)
284sysc_restore_trace:
285 TRACE_IRQS_CHECK
Heiko Carstens523b44c2007-10-11 22:11:12 +0200286 LOCKDEP_SYS_EXIT
Heiko Carstens411788e2007-11-20 11:13:32 +0100287#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288sysc_leave:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200289 RESTORE_ALL __LC_RETURN_PSW,1
Heiko Carstens411788e2007-11-20 11:13:32 +0100290sysc_done:
291
292#ifdef CONFIG_TRACE_IRQFLAGS
Hendrik Bruecknera8c3cb42009-09-11 10:28:42 +0200293sysc_restore_trace_psw_addr:
294 .long sysc_restore_trace_psw
295
296 .section .data,"aw",@progbits
Heiko Carstens411788e2007-11-20 11:13:32 +0100297 .align 8
298 .globl sysc_restore_trace_psw
299sysc_restore_trace_psw:
300 .long 0, sysc_restore_trace + 0x80000000
Hendrik Bruecknera8c3cb42009-09-11 10:28:42 +0200301 .previous
Heiko Carstens411788e2007-11-20 11:13:32 +0100302#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303
304#
305# recheck if there is more work to do
306#
307sysc_work_loop:
308 tm __TI_flags+3(%r9),_TIF_WORK_SVC
Heiko Carstens411788e2007-11-20 11:13:32 +0100309 bz BASED(sysc_restore) # there is no work to do
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310#
311# One of the work bits is on. Find out which one.
312#
313sysc_work:
Martin Schwidefsky26889052008-05-07 09:22:52 +0200314 tm SP_PSW+1(%r15),0x01 # returning to user ?
315 bno BASED(sysc_restore)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700316 tm __TI_flags+3(%r9),_TIF_MCCK_PENDING
317 bo BASED(sysc_mcck_pending)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED
319 bo BASED(sysc_reschedule)
Roland McGrath02a029b2008-04-30 00:53:08 -0700320 tm __TI_flags+3(%r9),_TIF_SIGPENDING
Heiko Carstens54dfe5d2006-02-01 03:06:38 -0800321 bnz BASED(sysc_sigpending)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200322 tm __TI_flags+3(%r9),_TIF_NOTIFY_RESUME
323 bnz BASED(sysc_notify_resume)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 tm __TI_flags+3(%r9),_TIF_RESTART_SVC
325 bo BASED(sysc_restart)
326 tm __TI_flags+3(%r9),_TIF_SINGLE_STEP
327 bo BASED(sysc_singlestep)
Heiko Carstens411788e2007-11-20 11:13:32 +0100328 b BASED(sysc_restore)
329sysc_work_done:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330
331#
332# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200333#
334sysc_reschedule:
335 l %r1,BASED(.Lschedule)
336 la %r14,BASED(sysc_work_loop)
337 br %r1 # call scheduler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338
339#
Heiko Carstens77fa2242005-06-25 14:55:30 -0700340# _TIF_MCCK_PENDING is set, call handler
341#
342sysc_mcck_pending:
343 l %r1,BASED(.Ls390_handle_mcck)
344 la %r14,BASED(sysc_work_loop)
345 br %r1 # TIF bit will be cleared by handler
346
347#
Roland McGrath02a029b2008-04-30 00:53:08 -0700348# _TIF_SIGPENDING is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349#
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200350sysc_sigpending:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351 ni __TI_flags+3(%r9),255-_TIF_SINGLE_STEP # clear TIF_SINGLE_STEP
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200352 la %r2,SP_PTREGS(%r15) # load pt_regs
353 l %r1,BASED(.Ldo_signal)
354 basr %r14,%r1 # call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 tm __TI_flags+3(%r9),_TIF_RESTART_SVC
356 bo BASED(sysc_restart)
357 tm __TI_flags+3(%r9),_TIF_SINGLE_STEP
358 bo BASED(sysc_singlestep)
Heiko Carstense1c3ad92005-11-07 00:59:02 -0800359 b BASED(sysc_work_loop)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360
361#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200362# _TIF_NOTIFY_RESUME is set, call do_notify_resume
363#
364sysc_notify_resume:
365 la %r2,SP_PTREGS(%r15) # load pt_regs
366 l %r1,BASED(.Ldo_notify_resume)
367 la %r14,BASED(sysc_work_loop)
368 br %r1 # call do_notify_resume
369
370
371#
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372# _TIF_RESTART_SVC is set, set up registers and restart svc
373#
374sysc_restart:
375 ni __TI_flags+3(%r9),255-_TIF_RESTART_SVC # clear TIF_RESTART_SVC
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200376 l %r7,SP_R2(%r15) # load new svc number
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 mvc SP_R2(4,%r15),SP_ORIG_R2(%r15) # restore first argument
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200378 lm %r2,%r6,SP_R2(%r15) # load svc arguments
379 b BASED(sysc_do_restart) # restart svc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380
381#
382# _TIF_SINGLE_STEP is set, call do_single_step
383#
384sysc_singlestep:
385 ni __TI_flags+3(%r9),255-_TIF_SINGLE_STEP # clear TIF_SINGLE_STEP
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100386 mvi SP_SVCNR(%r15),0xff # set trap indication to pgm check
387 mvi SP_SVCNR+1(%r15),0xff
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 la %r2,SP_PTREGS(%r15) # address of register-save area
389 l %r1,BASED(.Lhandle_per) # load adr. of per handler
390 la %r14,BASED(sysc_return) # load adr. of system return
391 br %r1 # branch to do_single_step
392
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200394# call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
395# and after the system call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396#
397sysc_tracesys:
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200398 l %r1,BASED(.Ltrace_entry)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200399 la %r2,SP_PTREGS(%r15) # load pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 la %r3,0
401 srl %r7,2
402 st %r7,SP_R2(%r15)
403 basr %r14,%r1
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200404 cl %r2,BASED(.Lnr_syscalls)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405 bnl BASED(sysc_tracenogo)
Heiko Carstensd882b172006-07-01 04:36:31 -0700406 l %r8,BASED(.Lsysc_table)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200407 lr %r7,%r2
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100408 sll %r7,2 # svc number *4
Heiko Carstensd882b172006-07-01 04:36:31 -0700409 l %r8,0(%r7,%r8)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410sysc_tracego:
411 lm %r3,%r6,SP_R3(%r15)
412 l %r2,SP_ORIG_R2(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200413 basr %r14,%r8 # call sys_xxx
414 st %r2,SP_R2(%r15) # store return value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415sysc_tracenogo:
Heiko Carstensbcf5cef2009-06-12 10:26:26 +0200416 tm __TI_flags+2(%r9),_TIF_SYSCALL
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200417 bz BASED(sysc_return)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200418 l %r1,BASED(.Ltrace_exit)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200419 la %r2,SP_PTREGS(%r15) # load pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 la %r14,BASED(sysc_return)
421 br %r1
422
423#
424# a new process exits the kernel with ret_from_fork
425#
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200426 .globl ret_from_fork
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427ret_from_fork:
428 l %r13,__LC_SVC_NEW_PSW+4
429 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
430 tm SP_PSW+1(%r15),0x01 # forking a kernel thread ?
431 bo BASED(0f)
432 st %r15,SP_R15(%r15) # store stack pointer for new kthread
Heiko Carstens25d83cb2006-09-28 16:56:37 +02004330: l %r1,BASED(.Lschedtail)
434 basr %r14,%r1
Heiko Carstens1f194a42006-07-03 00:24:46 -0700435 TRACE_IRQS_ON
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200436 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
Al Viro8f2961c2008-12-25 13:37:58 +0100437 b BASED(sysc_tracenogo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438
439#
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200440# kernel_execve function needs to deal with pt_regs that is not
441# at the usual place
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442#
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200443 .globl kernel_execve
444kernel_execve:
445 stm %r12,%r15,48(%r15)
446 lr %r14,%r15
447 l %r13,__LC_SVC_NEW_PSW+4
448 s %r15,BASED(.Lc_spsize)
449 st %r14,__SF_BACKCHAIN(%r15)
450 la %r12,SP_PTREGS(%r15)
451 xc 0(__PT_SIZE,%r12),0(%r12)
452 l %r1,BASED(.Ldo_execve)
453 lr %r5,%r12
454 basr %r14,%r1
455 ltr %r2,%r2
456 be BASED(0f)
457 a %r15,BASED(.Lc_spsize)
458 lm %r12,%r15,48(%r15)
459 br %r14
460 # execve succeeded.
4610: stnsm __SF_EMPTY(%r15),0xfc # disable interrupts
462 l %r15,__LC_KERNEL_STACK # load ksp
463 s %r15,BASED(.Lc_spsize) # make room for registers & psw
464 l %r9,__LC_THREAD_INFO
465 mvc SP_PTREGS(__PT_SIZE,%r15),0(%r12) # copy pt_regs
466 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15)
467 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
468 l %r1,BASED(.Lexecve_tail)
469 basr %r14,%r1
470 b BASED(sysc_return)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471
472/*
473 * Program check handler routine
474 */
475
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200476 .globl pgm_check_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477pgm_check_handler:
478/*
479 * First we need to check for a special case:
480 * Single stepping an instruction that disables the PER event mask will
481 * cause a PER event AFTER the mask has been set. Example: SVC or LPSW.
482 * For a single stepped SVC the program check handler gets control after
483 * the SVC new PSW has been loaded. But we want to execute the SVC first and
484 * then handle the PER event. Therefore we update the SVC old PSW to point
485 * to the pgm_check_handler and branch to the SVC handler after we checked
486 * if we have to load the kernel stack register.
487 * For every other possible cause for PER event without the PER mask set
488 * we just ignore the PER event (FIXME: is there anything we have to do
489 * for LPSW?).
490 */
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100491 stpt __LC_SYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 SAVE_ALL_BASE __LC_SAVE_AREA
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200493 tm __LC_PGM_INT_CODE+1,0x80 # check whether we got a per exception
494 bnz BASED(pgm_per) # got per exception -> special case
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200495 SAVE_ALL_SYNC __LC_PGM_OLD_PSW,__LC_SAVE_AREA
Heiko Carstens77fa2242005-06-25 14:55:30 -0700496 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
498 bz BASED(pgm_no_vtime)
499 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
500 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
501 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
502pgm_no_vtime:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
Heiko Carstens411788e2007-11-20 11:13:32 +0100504 TRACE_IRQS_OFF
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200505 l %r3,__LC_PGM_ILC # load program interruption code
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 la %r8,0x7f
507 nr %r8,%r3
508pgm_do_call:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200509 l %r7,BASED(.Ljump_table)
510 sll %r8,2
511 l %r7,0(%r8,%r7) # load address of handler routine
512 la %r2,SP_PTREGS(%r15) # address of register-save area
513 la %r14,BASED(sysc_return)
514 br %r7 # branch to interrupt-handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515
516#
517# handle per exception
518#
519pgm_per:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200520 tm __LC_PGM_OLD_PSW,0x40 # test if per event recording is on
521 bnz BASED(pgm_per_std) # ok, normal per event from user space
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522# ok its one of the special cases, now we need to find out which one
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200523 clc __LC_PGM_OLD_PSW(8),__LC_SVC_NEW_PSW
524 be BASED(pgm_svcper)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525# no interesting special case, ignore PER event
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200526 lm %r12,%r15,__LC_SAVE_AREA
527 lpsw 0x28
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528
529#
530# Normal per exception
531#
532pgm_per_std:
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200533 SAVE_ALL_SYNC __LC_PGM_OLD_PSW,__LC_SAVE_AREA
Heiko Carstens77fa2242005-06-25 14:55:30 -0700534 CREATE_STACK_FRAME __LC_PGM_OLD_PSW,__LC_SAVE_AREA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
536 bz BASED(pgm_no_vtime2)
537 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
538 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
539 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
540pgm_no_vtime2:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
Heiko Carstens411788e2007-11-20 11:13:32 +0100542 TRACE_IRQS_OFF
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 l %r1,__TI_task(%r9)
544 mvc __THREAD_per+__PER_atmid(2,%r1),__LC_PER_ATMID
545 mvc __THREAD_per+__PER_address(4,%r1),__LC_PER_ADDRESS
546 mvc __THREAD_per+__PER_access_id(1,%r1),__LC_PER_ACCESS_ID
547 oi __TI_flags+3(%r9),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP
Michael Grundy4ba069b2006-09-20 15:58:39 +0200548 tm SP_PSW+1(%r15),0x01 # kernel per event ?
549 bz BASED(kernel_per)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200550 l %r3,__LC_PGM_ILC # load program interruption code
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 la %r8,0x7f
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200552 nr %r8,%r3 # clear per-event-bit and ilc
553 be BASED(sysc_return) # only per or per+check ?
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554 b BASED(pgm_do_call)
555
556#
557# it was a single stepped SVC that is causing all the trouble
558#
559pgm_svcper:
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200560 SAVE_ALL_SYNC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Heiko Carstens77fa2242005-06-25 14:55:30 -0700561 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
563 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
564 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 lh %r7,0x8a # get svc number from lowcore
566 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
Heiko Carstens411788e2007-11-20 11:13:32 +0100567 TRACE_IRQS_OFF
Christian Borntraegerbcc65252009-11-13 15:43:54 +0100568 l %r8,__TI_task(%r9)
569 mvc __THREAD_per+__PER_atmid(2,%r8),__LC_PER_ATMID
570 mvc __THREAD_per+__PER_address(4,%r8),__LC_PER_ADDRESS
571 mvc __THREAD_per+__PER_access_id(1,%r8),__LC_PER_ACCESS_ID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 oi __TI_flags+3(%r9),_TIF_SINGLE_STEP # set TIF_SINGLE_STEP
Heiko Carstens1f194a42006-07-03 00:24:46 -0700573 TRACE_IRQS_ON
Martin Schwidefsky21ec7f62010-01-27 10:12:40 +0100574 lm %r2,%r6,SP_R2(%r15) # load svc arguments
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
576 b BASED(sysc_do_svc)
577
Michael Grundy4ba069b2006-09-20 15:58:39 +0200578#
579# per was called from kernel, must be kprobes
580#
581kernel_per:
Martin Schwidefsky59da2132008-11-27 11:05:55 +0100582 mvi SP_SVCNR(%r15),0xff # set trap indication to pgm check
583 mvi SP_SVCNR+1(%r15),0xff
Michael Grundy4ba069b2006-09-20 15:58:39 +0200584 la %r2,SP_PTREGS(%r15) # address of register-save area
585 l %r1,BASED(.Lhandle_per) # load adr. of per handler
Heiko Carstens411788e2007-11-20 11:13:32 +0100586 la %r14,BASED(sysc_restore)# load adr. of system return
Michael Grundy4ba069b2006-09-20 15:58:39 +0200587 br %r1 # branch to do_single_step
588
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589/*
590 * IO interrupt handler routine
591 */
592
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200593 .globl io_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594io_int_handler:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 stck __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100596 stpt __LC_ASYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 SAVE_ALL_BASE __LC_SAVE_AREA+16
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200598 SAVE_ALL_ASYNC __LC_IO_OLD_PSW,__LC_SAVE_AREA+16
Heiko Carstens77fa2242005-06-25 14:55:30 -0700599 CREATE_STACK_FRAME __LC_IO_OLD_PSW,__LC_SAVE_AREA+16
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
601 bz BASED(io_no_vtime)
602 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
603 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
604 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
605io_no_vtime:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
Heiko Carstens1f194a42006-07-03 00:24:46 -0700607 TRACE_IRQS_OFF
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200608 l %r1,BASED(.Ldo_IRQ) # load address of do_IRQ
609 la %r2,SP_PTREGS(%r15) # address of register-save area
610 basr %r14,%r1 # branch to standard irq handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611io_return:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 tm __TI_flags+3(%r9),_TIF_WORK_INT
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200613 bnz BASED(io_work) # there is work to do (signals etc.)
Heiko Carstens411788e2007-11-20 11:13:32 +0100614io_restore:
615#ifdef CONFIG_TRACE_IRQFLAGS
Hendrik Bruecknera8c3cb42009-09-11 10:28:42 +0200616 la %r1,BASED(io_restore_trace_psw_addr)
617 l %r1,0(%r1)
Heiko Carstens411788e2007-11-20 11:13:32 +0100618 lpsw 0(%r1)
619io_restore_trace:
620 TRACE_IRQS_CHECK
Heiko Carstens523b44c2007-10-11 22:11:12 +0200621 LOCKDEP_SYS_EXIT
Heiko Carstens411788e2007-11-20 11:13:32 +0100622#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623io_leave:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200624 RESTORE_ALL __LC_RETURN_PSW,0
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700625io_done:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626
Heiko Carstens411788e2007-11-20 11:13:32 +0100627#ifdef CONFIG_TRACE_IRQFLAGS
Hendrik Bruecknera8c3cb42009-09-11 10:28:42 +0200628io_restore_trace_psw_addr:
629 .long io_restore_trace_psw
630
631 .section .data,"aw",@progbits
Heiko Carstens411788e2007-11-20 11:13:32 +0100632 .align 8
633 .globl io_restore_trace_psw
634io_restore_trace_psw:
635 .long 0, io_restore_trace + 0x80000000
Hendrik Bruecknera8c3cb42009-09-11 10:28:42 +0200636 .previous
Heiko Carstens411788e2007-11-20 11:13:32 +0100637#endif
638
Martin Schwidefsky26889052008-05-07 09:22:52 +0200639#
640# switch to kernel stack, then check the TIF bits
641#
642io_work:
643 tm SP_PSW+1(%r15),0x01 # returning to user ?
644#ifndef CONFIG_PREEMPT
645 bno BASED(io_restore) # no-> skip resched & signal
646#else
647 bnz BASED(io_work_user) # no -> check for preemptive scheduling
648 # check for preemptive scheduling
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649 icm %r0,15,__TI_precount(%r9)
Martin Schwidefsky26889052008-05-07 09:22:52 +0200650 bnz BASED(io_restore) # preemption disabled
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651 l %r1,SP_R15(%r15)
652 s %r1,BASED(.Lc_spsize)
653 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200654 xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1) # clear back chain
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 lr %r15,%r1
656io_resume_loop:
657 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED
Heiko Carstens411788e2007-11-20 11:13:32 +0100658 bno BASED(io_restore)
Heiko Carstensb8e7a542007-11-20 11:13:35 +0100659 l %r1,BASED(.Lpreempt_schedule_irq)
660 la %r14,BASED(io_resume_loop)
661 br %r1 # call schedule
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662#endif
663
Martin Schwidefsky26889052008-05-07 09:22:52 +0200664io_work_user:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 l %r1,__LC_KERNEL_STACK
666 s %r1,BASED(.Lc_spsize)
667 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200668 xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1) # clear back chain
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 lr %r15,%r1
670#
671# One of the work bits is on. Find out which one.
Roland McGrath02a029b2008-04-30 00:53:08 -0700672# Checked are: _TIF_SIGPENDING, _TIF_NEED_RESCHED
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200673# and _TIF_MCCK_PENDING
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674#
675io_work_loop:
Heiko Carstens77fa2242005-06-25 14:55:30 -0700676 tm __TI_flags+3(%r9),_TIF_MCCK_PENDING
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200677 bo BASED(io_mcck_pending)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED
679 bo BASED(io_reschedule)
Roland McGrath02a029b2008-04-30 00:53:08 -0700680 tm __TI_flags+3(%r9),_TIF_SIGPENDING
Heiko Carstens54dfe5d2006-02-01 03:06:38 -0800681 bnz BASED(io_sigpending)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200682 tm __TI_flags+3(%r9),_TIF_NOTIFY_RESUME
683 bnz BASED(io_notify_resume)
Heiko Carstens411788e2007-11-20 11:13:32 +0100684 b BASED(io_restore)
685io_work_done:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686
687#
Heiko Carstens77fa2242005-06-25 14:55:30 -0700688# _TIF_MCCK_PENDING is set, call handler
689#
690io_mcck_pending:
691 l %r1,BASED(.Ls390_handle_mcck)
Heiko Carstensb771aea2007-07-27 12:29:18 +0200692 basr %r14,%r1 # TIF bit will be cleared by handler
Heiko Carstensb771aea2007-07-27 12:29:18 +0200693 b BASED(io_work_loop)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700694
695#
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200697#
698io_reschedule:
Heiko Carstens411788e2007-11-20 11:13:32 +0100699 TRACE_IRQS_ON
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200700 l %r1,BASED(.Lschedule)
701 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
702 basr %r14,%r1 # call scheduler
703 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100704 TRACE_IRQS_OFF
Linus Torvalds1da177e2005-04-16 15:20:36 -0700705 tm __TI_flags+3(%r9),_TIF_WORK_INT
Heiko Carstens411788e2007-11-20 11:13:32 +0100706 bz BASED(io_restore) # there is no work to do
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707 b BASED(io_work_loop)
708
709#
Roland McGrath02a029b2008-04-30 00:53:08 -0700710# _TIF_SIGPENDING is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711#
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200712io_sigpending:
Heiko Carstens411788e2007-11-20 11:13:32 +0100713 TRACE_IRQS_ON
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200714 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
715 la %r2,SP_PTREGS(%r15) # load pt_regs
716 l %r1,BASED(.Ldo_signal)
717 basr %r14,%r1 # call do_signal
718 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100719 TRACE_IRQS_OFF
Heiko Carstense1c3ad92005-11-07 00:59:02 -0800720 b BASED(io_work_loop)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200722#
723# _TIF_SIGPENDING is set, call do_signal
724#
725io_notify_resume:
726 TRACE_IRQS_ON
727 stosm __SF_EMPTY(%r15),0x03 # reenable interrupts
728 la %r2,SP_PTREGS(%r15) # load pt_regs
729 l %r1,BASED(.Ldo_notify_resume)
730 basr %r14,%r1 # call do_signal
731 stnsm __SF_EMPTY(%r15),0xfc # disable I/O and ext. interrupts
732 TRACE_IRQS_OFF
733 b BASED(io_work_loop)
734
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735/*
736 * External interrupt handler routine
737 */
738
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200739 .globl ext_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740ext_int_handler:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 stck __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100742 stpt __LC_ASYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743 SAVE_ALL_BASE __LC_SAVE_AREA+16
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200744 SAVE_ALL_ASYNC __LC_EXT_OLD_PSW,__LC_SAVE_AREA+16
Heiko Carstens77fa2242005-06-25 14:55:30 -0700745 CREATE_STACK_FRAME __LC_EXT_OLD_PSW,__LC_SAVE_AREA+16
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
747 bz BASED(ext_no_vtime)
748 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
749 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
750 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
751ext_no_vtime:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
Heiko Carstens1f194a42006-07-03 00:24:46 -0700753 TRACE_IRQS_OFF
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200754 la %r2,SP_PTREGS(%r15) # address of register-save area
755 lh %r3,__LC_EXT_INT_CODE # get interruption code
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 l %r1,BASED(.Ldo_extint)
757 basr %r14,%r1
758 b BASED(io_return)
759
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700760__critical_end:
761
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762/*
763 * Machine check handler routines
764 */
765
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200766 .globl mcck_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767mcck_int_handler:
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100768 stck __LC_INT_CLOCK
Heiko Carstens77fa2242005-06-25 14:55:30 -0700769 spt __LC_CPU_TIMER_SAVE_AREA # revalidate cpu timer
770 lm %r0,%r15,__LC_GPREGS_SAVE_AREA # revalidate gprs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771 SAVE_ALL_BASE __LC_SAVE_AREA+32
Heiko Carstens77fa2242005-06-25 14:55:30 -0700772 la %r12,__LC_MCK_OLD_PSW
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200773 tm __LC_MCCK_CODE,0x80 # system damage?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700774 bo BASED(mcck_int_main) # yes -> rest of mcck code invalid
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200775 mvc __LC_SAVE_AREA+52(8),__LC_ASYNC_ENTER_TIMER
776 mvc __LC_ASYNC_ENTER_TIMER(8),__LC_CPU_TIMER_SAVE_AREA
777 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
778 bo BASED(1f)
779 la %r14,__LC_SYNC_ENTER_TIMER
780 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
781 bl BASED(0f)
782 la %r14,__LC_ASYNC_ENTER_TIMER
7830: clc 0(8,%r14),__LC_EXIT_TIMER
784 bl BASED(0f)
785 la %r14,__LC_EXIT_TIMER
7860: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
787 bl BASED(0f)
788 la %r14,__LC_LAST_UPDATE_TIMER
7890: spt 0(%r14)
790 mvc __LC_ASYNC_ENTER_TIMER(8),0(%r14)
Martin Schwidefskyc185b782008-12-25 13:39:25 +01007911: tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700792 bno BASED(mcck_int_main) # no -> skip cleanup critical
793 tm __LC_MCK_OLD_PSW+1,0x01 # test problem state bit
794 bnz BASED(mcck_int_main) # from user -> load async stack
795 clc __LC_MCK_OLD_PSW+4(4),BASED(.Lcritical_end)
796 bhe BASED(mcck_int_main)
797 clc __LC_MCK_OLD_PSW+4(4),BASED(.Lcritical_start)
798 bl BASED(mcck_int_main)
799 l %r14,BASED(.Lcleanup_critical)
800 basr %r14,%r14
801mcck_int_main:
802 l %r14,__LC_PANIC_STACK # are we already on the panic stack?
803 slr %r14,%r15
804 sra %r14,PAGE_SHIFT
805 be BASED(0f)
806 l %r15,__LC_PANIC_STACK # load panic stack
8070: CREATE_STACK_FRAME __LC_MCK_OLD_PSW,__LC_SAVE_AREA+32
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200808 tm __LC_MCCK_CODE+2,0x08 # mwp of old psw valid?
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700809 bno BASED(mcck_no_vtime) # no -> skip cleanup critical
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200810 tm SP_PSW+1(%r15),0x01 # interrupting from user ?
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700811 bz BASED(mcck_no_vtime)
812 UPDATE_VTIME __LC_EXIT_TIMER,__LC_ASYNC_ENTER_TIMER,__LC_USER_TIMER
813 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
814 mvc __LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
815mcck_no_vtime:
Heiko Carstens77fa2242005-06-25 14:55:30 -0700816 l %r9,__LC_THREAD_INFO # load pointer to thread_info struct
817 la %r2,SP_PTREGS(%r15) # load pt_regs
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200818 l %r1,BASED(.Ls390_mcck)
819 basr %r14,%r1 # call machine check handler
820 tm SP_PSW+1(%r15),0x01 # returning to user ?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700821 bno BASED(mcck_return)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200822 l %r1,__LC_KERNEL_STACK # switch to kernel stack
Heiko Carstens77fa2242005-06-25 14:55:30 -0700823 s %r1,BASED(.Lc_spsize)
824 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200825 xc __SF_BACKCHAIN(4,%r1),__SF_BACKCHAIN(%r1) # clear back chain
Heiko Carstens77fa2242005-06-25 14:55:30 -0700826 lr %r15,%r1
827 stosm __SF_EMPTY(%r15),0x04 # turn dat on
828 tm __TI_flags+3(%r9),_TIF_MCCK_PENDING
829 bno BASED(mcck_return)
Heiko Carstens1f194a42006-07-03 00:24:46 -0700830 TRACE_IRQS_OFF
Heiko Carstens77fa2242005-06-25 14:55:30 -0700831 l %r1,BASED(.Ls390_handle_mcck)
832 basr %r14,%r1 # call machine check handler
Heiko Carstens1f194a42006-07-03 00:24:46 -0700833 TRACE_IRQS_ON
Linus Torvalds1da177e2005-04-16 15:20:36 -0700834mcck_return:
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200835 mvc __LC_RETURN_MCCK_PSW(8),SP_PSW(%r15) # move return PSW
836 ni __LC_RETURN_MCCK_PSW+1,0xfd # clear wait state bit
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200837 mvc __LC_ASYNC_ENTER_TIMER(8),__LC_SAVE_AREA+52
838 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
839 bno BASED(0f)
840 lm %r0,%r15,SP_R0(%r15) # load gprs 0-15
841 stpt __LC_EXIT_TIMER
842 lpsw __LC_RETURN_MCCK_PSW # back to caller
Martin Schwidefskyc185b782008-12-25 13:39:25 +01008430: lm %r0,%r15,SP_R0(%r15) # load gprs 0-15
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200844 lpsw __LC_RETURN_MCCK_PSW # back to caller
845
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200846 RESTORE_ALL __LC_RETURN_MCCK_PSW,0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848/*
849 * Restart interruption handler, kick starter for additional CPUs
850 */
Heiko Carstens84b36a82007-06-19 13:10:03 +0200851#ifdef CONFIG_SMP
Heiko Carstens2bc89b52008-02-05 16:50:40 +0100852 __CPUINIT
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200853 .globl restart_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700854restart_int_handler:
Martin Schwidefsky5b409ed2009-04-14 15:36:27 +0200855 basr %r1,0
856restart_base:
857 spt restart_vtime-restart_base(%r1)
858 stck __LC_LAST_UPDATE_CLOCK
859 mvc __LC_LAST_UPDATE_TIMER(8),restart_vtime-restart_base(%r1)
860 mvc __LC_EXIT_TIMER(8),restart_vtime-restart_base(%r1)
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200861 l %r15,__LC_SAVE_AREA+60 # load ksp
862 lctl %c0,%c15,__LC_CREGS_SAVE_AREA # get new ctl regs
863 lam %a0,%a15,__LC_AREGS_SAVE_AREA
864 lm %r6,%r15,__SF_GPRS(%r15) # load registers from clone
Martin Schwidefsky5b409ed2009-04-14 15:36:27 +0200865 l %r1,__LC_THREAD_INFO
866 mvc __LC_USER_TIMER(8),__TI_user_timer(%r1)
867 mvc __LC_SYSTEM_TIMER(8),__TI_system_timer(%r1)
868 xc __LC_STEAL_TIMER(8),__LC_STEAL_TIMER
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200869 stosm __SF_EMPTY(%r15),0x04 # now we can turn dat on
870 basr %r14,0
871 l %r14,restart_addr-.(%r14)
872 br %r14 # branch to start_secondary
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873restart_addr:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200874 .long start_secondary
Martin Schwidefsky5b409ed2009-04-14 15:36:27 +0200875 .align 8
876restart_vtime:
877 .long 0x7fffffff,0xffffffff
Heiko Carstens84b36a82007-06-19 13:10:03 +0200878 .previous
Linus Torvalds1da177e2005-04-16 15:20:36 -0700879#else
880/*
881 * If we do not run with SMP enabled, let the new CPU crash ...
882 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200883 .globl restart_int_handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884restart_int_handler:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200885 basr %r1,0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886restart_base:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200887 lpsw restart_crash-restart_base(%r1)
888 .align 8
Linus Torvalds1da177e2005-04-16 15:20:36 -0700889restart_crash:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200890 .long 0x000a0000,0x00000000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700891restart_go:
892#endif
893
894#ifdef CONFIG_CHECK_STACK
895/*
896 * The synchronous or the asynchronous stack overflowed. We are dead.
897 * No need to properly save the registers, we are going to panic anyway.
898 * Setup a pt_regs so that show_trace can provide a good call trace.
899 */
900stack_overflow:
901 l %r15,__LC_PANIC_STACK # change to panic stack
902 sl %r15,BASED(.Lc_spsize)
903 mvc SP_PSW(8,%r15),0(%r12) # move user PSW to stack
904 stm %r0,%r11,SP_R0(%r15) # store gprs %r0-%r11 to kernel stack
905 la %r1,__LC_SAVE_AREA
906 ch %r12,BASED(.L0x020) # old psw addr == __LC_SVC_OLD_PSW ?
907 be BASED(0f)
908 ch %r12,BASED(.L0x028) # old psw addr == __LC_PGM_OLD_PSW ?
909 be BASED(0f)
910 la %r1,__LC_SAVE_AREA+16
9110: mvc SP_R12(16,%r15),0(%r1) # move %r12-%r15 to stack
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200912 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15) # clear back chain
Linus Torvalds1da177e2005-04-16 15:20:36 -0700913 l %r1,BASED(1f) # branch to kernel_stack_overflow
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200914 la %r2,SP_PTREGS(%r15) # load pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915 br %r1
Heiko Carstens25d83cb2006-09-28 16:56:37 +02009161: .long kernel_stack_overflow
Linus Torvalds1da177e2005-04-16 15:20:36 -0700917#endif
918
919cleanup_table_system_call:
920 .long system_call + 0x80000000, sysc_do_svc + 0x80000000
921cleanup_table_sysc_return:
922 .long sysc_return + 0x80000000, sysc_leave + 0x80000000
923cleanup_table_sysc_leave:
Heiko Carstens411788e2007-11-20 11:13:32 +0100924 .long sysc_leave + 0x80000000, sysc_done + 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700925cleanup_table_sysc_work_loop:
Heiko Carstens411788e2007-11-20 11:13:32 +0100926 .long sysc_work_loop + 0x80000000, sysc_work_done + 0x80000000
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200927cleanup_table_io_return:
928 .long io_return + 0x80000000, io_leave + 0x80000000
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700929cleanup_table_io_leave:
930 .long io_leave + 0x80000000, io_done + 0x80000000
931cleanup_table_io_work_loop:
Heiko Carstens411788e2007-11-20 11:13:32 +0100932 .long io_work_loop + 0x80000000, io_work_done + 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700933
934cleanup_critical:
935 clc 4(4,%r12),BASED(cleanup_table_system_call)
936 bl BASED(0f)
937 clc 4(4,%r12),BASED(cleanup_table_system_call+4)
938 bl BASED(cleanup_system_call)
9390:
940 clc 4(4,%r12),BASED(cleanup_table_sysc_return)
941 bl BASED(0f)
942 clc 4(4,%r12),BASED(cleanup_table_sysc_return+4)
943 bl BASED(cleanup_sysc_return)
9440:
945 clc 4(4,%r12),BASED(cleanup_table_sysc_leave)
946 bl BASED(0f)
947 clc 4(4,%r12),BASED(cleanup_table_sysc_leave+4)
948 bl BASED(cleanup_sysc_leave)
9490:
950 clc 4(4,%r12),BASED(cleanup_table_sysc_work_loop)
951 bl BASED(0f)
952 clc 4(4,%r12),BASED(cleanup_table_sysc_work_loop+4)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700953 bl BASED(cleanup_sysc_return)
Linus Torvalds1da177e2005-04-16 15:20:36 -07009540:
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200955 clc 4(4,%r12),BASED(cleanup_table_io_return)
956 bl BASED(0f)
957 clc 4(4,%r12),BASED(cleanup_table_io_return+4)
958 bl BASED(cleanup_io_return)
9590:
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700960 clc 4(4,%r12),BASED(cleanup_table_io_leave)
961 bl BASED(0f)
962 clc 4(4,%r12),BASED(cleanup_table_io_leave+4)
963 bl BASED(cleanup_io_leave)
9640:
965 clc 4(4,%r12),BASED(cleanup_table_io_work_loop)
966 bl BASED(0f)
967 clc 4(4,%r12),BASED(cleanup_table_io_work_loop+4)
968 bl BASED(cleanup_io_return)
9690:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700970 br %r14
971
972cleanup_system_call:
973 mvc __LC_RETURN_PSW(8),0(%r12)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700974 c %r12,BASED(.Lmck_old_psw)
975 be BASED(0f)
976 la %r12,__LC_SAVE_AREA+16
977 b BASED(1f)
9780: la %r12,__LC_SAVE_AREA+32
9791:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700980 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+4)
981 bh BASED(0f)
982 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
9830: clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+8)
984 bhe BASED(cleanup_vtime)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700985 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn)
986 bh BASED(0f)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700987 mvc __LC_SAVE_AREA(16),0(%r12)
9880: st %r13,4(%r12)
989 st %r12,__LC_SAVE_AREA+48 # argh
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200990 SAVE_ALL_SYNC __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Heiko Carstens77fa2242005-06-25 14:55:30 -0700991 CREATE_STACK_FRAME __LC_SVC_OLD_PSW,__LC_SAVE_AREA
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700992 l %r12,__LC_SAVE_AREA+48 # argh
993 st %r15,12(%r12)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700994 lh %r7,0x8a
Linus Torvalds1da177e2005-04-16 15:20:36 -0700995cleanup_vtime:
996 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+12)
997 bhe BASED(cleanup_stime)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700998 UPDATE_VTIME __LC_EXIT_TIMER,__LC_SYNC_ENTER_TIMER,__LC_USER_TIMER
999cleanup_stime:
1000 clc __LC_RETURN_PSW+4(4),BASED(cleanup_system_call_insn+16)
1001 bh BASED(cleanup_update)
1002 UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
1003cleanup_update:
1004 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Linus Torvalds1da177e2005-04-16 15:20:36 -07001005 mvc __LC_RETURN_PSW+4(4),BASED(cleanup_table_system_call+4)
1006 la %r12,__LC_RETURN_PSW
1007 br %r14
1008cleanup_system_call_insn:
1009 .long sysc_saveall + 0x80000000
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001010 .long system_call + 0x80000000
1011 .long sysc_vtime + 0x80000000
1012 .long sysc_stime + 0x80000000
1013 .long sysc_update + 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -07001014
1015cleanup_sysc_return:
1016 mvc __LC_RETURN_PSW(4),0(%r12)
1017 mvc __LC_RETURN_PSW+4(4),BASED(cleanup_table_sysc_return)
1018 la %r12,__LC_RETURN_PSW
1019 br %r14
1020
1021cleanup_sysc_leave:
1022 clc 4(4,%r12),BASED(cleanup_sysc_leave_insn)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001023 be BASED(2f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001024 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
1025 clc 4(4,%r12),BASED(cleanup_sysc_leave_insn+4)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001026 be BASED(2f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001027 mvc __LC_RETURN_PSW(8),SP_PSW(%r15)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001028 c %r12,BASED(.Lmck_old_psw)
1029 bne BASED(0f)
1030 mvc __LC_SAVE_AREA+32(16),SP_R12(%r15)
1031 b BASED(1f)
10320: mvc __LC_SAVE_AREA+16(16),SP_R12(%r15)
10331: lm %r0,%r11,SP_R0(%r15)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001034 l %r15,SP_R15(%r15)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -070010352: la %r12,__LC_RETURN_PSW
Linus Torvalds1da177e2005-04-16 15:20:36 -07001036 br %r14
1037cleanup_sysc_leave_insn:
Heiko Carstens411788e2007-11-20 11:13:32 +01001038 .long sysc_done - 4 + 0x80000000
Heiko Carstens411788e2007-11-20 11:13:32 +01001039 .long sysc_done - 8 + 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -07001040
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001041cleanup_io_return:
1042 mvc __LC_RETURN_PSW(4),0(%r12)
1043 mvc __LC_RETURN_PSW+4(4),BASED(cleanup_table_io_work_loop)
1044 la %r12,__LC_RETURN_PSW
1045 br %r14
1046
1047cleanup_io_leave:
1048 clc 4(4,%r12),BASED(cleanup_io_leave_insn)
1049 be BASED(2f)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001050 mvc __LC_EXIT_TIMER(8),__LC_ASYNC_ENTER_TIMER
1051 clc 4(4,%r12),BASED(cleanup_io_leave_insn+4)
1052 be BASED(2f)
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001053 mvc __LC_RETURN_PSW(8),SP_PSW(%r15)
1054 c %r12,BASED(.Lmck_old_psw)
1055 bne BASED(0f)
1056 mvc __LC_SAVE_AREA+32(16),SP_R12(%r15)
1057 b BASED(1f)
10580: mvc __LC_SAVE_AREA+16(16),SP_R12(%r15)
10591: lm %r0,%r11,SP_R0(%r15)
1060 l %r15,SP_R15(%r15)
10612: la %r12,__LC_RETURN_PSW
1062 br %r14
1063cleanup_io_leave_insn:
Heiko Carstens411788e2007-11-20 11:13:32 +01001064 .long io_done - 4 + 0x80000000
Heiko Carstens411788e2007-11-20 11:13:32 +01001065 .long io_done - 8 + 0x80000000
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -07001066
Linus Torvalds1da177e2005-04-16 15:20:36 -07001067/*
1068 * Integer constants
1069 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001070 .align 4
1071.Lc_spsize: .long SP_SIZE
1072.Lc_overhead: .long STACK_FRAME_OVERHEAD
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001073.Lnr_syscalls: .long NR_syscalls
1074.L0x018: .short 0x018
1075.L0x020: .short 0x020
1076.L0x028: .short 0x028
1077.L0x030: .short 0x030
1078.L0x038: .short 0x038
1079.Lc_1: .long 1
Linus Torvalds1da177e2005-04-16 15:20:36 -07001080
1081/*
1082 * Symbol constants
1083 */
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001084.Ls390_mcck: .long s390_do_machine_check
Heiko Carstens77fa2242005-06-25 14:55:30 -07001085.Ls390_handle_mcck:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001086 .long s390_handle_mcck
1087.Lmck_old_psw: .long __LC_MCK_OLD_PSW
1088.Ldo_IRQ: .long do_IRQ
1089.Ldo_extint: .long do_extint
1090.Ldo_signal: .long do_signal
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +02001091.Ldo_notify_resume:
1092 .long do_notify_resume
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001093.Lhandle_per: .long do_single_step
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +02001094.Ldo_execve: .long do_execve
1095.Lexecve_tail: .long execve_tail
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001096.Ljump_table: .long pgm_check_table
1097.Lschedule: .long schedule
Christian Borntraegerab1809b2007-12-04 16:09:04 +01001098#ifdef CONFIG_PREEMPT
Heiko Carstensb8e7a542007-11-20 11:13:35 +01001099.Lpreempt_schedule_irq:
1100 .long preempt_schedule_irq
Christian Borntraegerab1809b2007-12-04 16:09:04 +01001101#endif
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +02001102.Ltrace_entry: .long do_syscall_trace_enter
1103.Ltrace_exit: .long do_syscall_trace_exit
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001104.Lschedtail: .long schedule_tail
1105.Lsysc_table: .long sys_call_table
Heiko Carstens1f194a42006-07-03 00:24:46 -07001106#ifdef CONFIG_TRACE_IRQFLAGS
Heiko Carstens50bec4c2008-11-14 18:18:05 +01001107.Ltrace_irq_on_caller:
1108 .long trace_hardirqs_on_caller
1109.Ltrace_irq_off_caller:
1110 .long trace_hardirqs_off_caller
Heiko Carstensaf4c68742008-11-14 18:18:03 +01001111#endif
1112#ifdef CONFIG_LOCKDEP
Heiko Carstens523b44c2007-10-11 22:11:12 +02001113.Llockdep_sys_exit:
1114 .long lockdep_sys_exit
Heiko Carstens1f194a42006-07-03 00:24:46 -07001115#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001116.Lcritical_start:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001117 .long __critical_start + 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -07001118.Lcritical_end:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001119 .long __critical_end + 0x80000000
Linus Torvalds1da177e2005-04-16 15:20:36 -07001120.Lcleanup_critical:
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001121 .long cleanup_critical
Linus Torvalds1da177e2005-04-16 15:20:36 -07001122
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001123 .section .rodata, "a"
Linus Torvalds1da177e2005-04-16 15:20:36 -07001124#define SYSCALL(esa,esame,emu) .long esa
Heiko Carstens9bf12262009-06-12 10:26:47 +02001125 .globl sys_call_table
Linus Torvalds1da177e2005-04-16 15:20:36 -07001126sys_call_table:
1127#include "syscalls.S"
1128#undef SYSCALL