blob: 1983c22a8a99a164f93612b04bdb31612a81cbfa [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * S390 low-level entry points.
3 *
Heiko Carstensa53c8fa2012-07-20 11:15:04 +02004 * Copyright IBM Corp. 1999, 2012
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
Heiko Carstens25d83cb2006-09-28 16:56:37 +02006 * Hartmut Penner (hp@de.ibm.com),
7 * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
Heiko Carstens77fa2242005-06-25 14:55:30 -07008 * Heiko Carstens <heiko.carstens@de.ibm.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 */
10
Heiko Carstens2bc89b52008-02-05 16:50:40 +010011#include <linux/init.h>
Jan Glauber144d6342011-07-24 10:48:19 +020012#include <linux/linkage.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <asm/cache.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <asm/errno.h>
15#include <asm/ptrace.h>
16#include <asm/thread_info.h>
Sam Ravnborg0013a852005-09-09 20:57:26 +020017#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <asm/unistd.h>
19#include <asm/page.h>
Heiko Carstenseb546192012-06-04 15:05:43 +020020#include <asm/sigp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
Martin Schwidefskyc5328902011-12-27 11:27:15 +010022__PT_R0 = __PT_GPRS
23__PT_R1 = __PT_GPRS + 8
24__PT_R2 = __PT_GPRS + 16
25__PT_R3 = __PT_GPRS + 24
26__PT_R4 = __PT_GPRS + 32
27__PT_R5 = __PT_GPRS + 40
28__PT_R6 = __PT_GPRS + 48
29__PT_R7 = __PT_GPRS + 56
30__PT_R8 = __PT_GPRS + 64
31__PT_R9 = __PT_GPRS + 72
32__PT_R10 = __PT_GPRS + 80
33__PT_R11 = __PT_GPRS + 88
34__PT_R12 = __PT_GPRS + 96
35__PT_R13 = __PT_GPRS + 104
36__PT_R14 = __PT_GPRS + 112
37__PT_R15 = __PT_GPRS + 120
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
40STACK_SIZE = 1 << STACK_SHIFT
41
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +020042_TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +010043 _TIF_MCCK_PENDING | _TIF_PER_TRAP )
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +020044_TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
Heiko Carstens54dfe5d2006-02-01 03:06:38 -080045 _TIF_MCCK_PENDING)
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +010046_TIF_TRACE = (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | \
47 _TIF_SYSCALL_TRACEPOINT)
Martin Schwidefsky603d1a52011-07-24 10:48:18 +020048_TIF_EXIT_SIE = (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_MCCK_PENDING)
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50#define BASED(name) name-system_call(%r13)
51
Martin Schwidefskyc5328902011-12-27 11:27:15 +010052 .macro TRACE_IRQS_ON
53#ifdef CONFIG_TRACE_IRQFLAGS
54 basr %r2,%r0
55 brasl %r14,trace_hardirqs_on_caller
56#endif
57 .endm
58
59 .macro TRACE_IRQS_OFF
60#ifdef CONFIG_TRACE_IRQFLAGS
61 basr %r2,%r0
62 brasl %r14,trace_hardirqs_off_caller
63#endif
64 .endm
65
66 .macro LOCKDEP_SYS_EXIT
67#ifdef CONFIG_LOCKDEP
68 tm __PT_PSW+1(%r11),0x01 # returning to user ?
69 jz .+10
70 brasl %r14,lockdep_sys_exit
71#endif
72 .endm
73
Martin Schwidefsky603d1a52011-07-24 10:48:18 +020074 .macro SPP newpp
75#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
76 tm __LC_MACHINE_FLAGS+6,0x20 # MACHINE_FLAG_SPP
77 jz .+8
78 .insn s,0xb2800000,\newpp
79#endif
80 .endm
81
Martin Schwidefskyc5328902011-12-27 11:27:15 +010082 .macro HANDLE_SIE_INTERCEPT scratch
Carsten Ottecd3b70f2010-05-17 10:00:04 +020083#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
Martin Schwidefsky6022afc2012-05-09 16:27:36 +020084 tmhh %r8,0x0001 # interrupting from user ?
85 jnz .+42
Martin Schwidefskyc5328902011-12-27 11:27:15 +010086 lgr \scratch,%r9
87 slg \scratch,BASED(.Lsie_loop)
88 clg \scratch,BASED(.Lsie_length)
Martin Schwidefsky6022afc2012-05-09 16:27:36 +020089 jhe .+22
Martin Schwidefskyc5328902011-12-27 11:27:15 +010090 lg %r9,BASED(.Lsie_loop)
Heiko Carstens9ee39e42012-05-14 10:09:43 +020091 SPP BASED(.Lhost_id) # set host id
Carsten Ottecd3b70f2010-05-17 10:00:04 +020092#endif
93 .endm
94
Martin Schwidefskyc5328902011-12-27 11:27:15 +010095 .macro CHECK_STACK stacksize,savearea
Martin Schwidefsky63b12242006-06-29 14:58:05 +020096#ifdef CONFIG_CHECK_STACK
Martin Schwidefskyc5328902011-12-27 11:27:15 +010097 tml %r15,\stacksize - CONFIG_STACK_GUARD
98 lghi %r14,\savearea
99 jz stack_overflow
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200100#endif
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200101 .endm
102
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100103 .macro SWITCH_ASYNC savearea,stack,shift
104 tmhh %r8,0x0001 # interrupting from user ?
105 jnz 1f
106 lgr %r14,%r9
107 slg %r14,BASED(.Lcritical_start)
108 clg %r14,BASED(.Lcritical_length)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 jhe 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100110 lghi %r11,\savearea # inside critical section, do cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 brasl %r14,cleanup_critical
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100112 tmhh %r8,0x0001 # retest problem state after cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 jnz 1f
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001140: lg %r14,\stack # are we already on the target stack?
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 slgr %r14,%r15
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100116 srag %r14,%r14,\shift
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200117 jnz 1f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100118 CHECK_STACK 1<<\shift,\savearea
119 j 2f
1201: lg %r15,\stack # load target stack
1212: aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
122 la %r11,STACK_FRAME_OVERHEAD(%r15)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700123 .endm
124
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100125 .macro UPDATE_VTIME scratch,enter_timer
126 lg \scratch,__LC_EXIT_TIMER
127 slg \scratch,\enter_timer
128 alg \scratch,__LC_USER_TIMER
129 stg \scratch,__LC_USER_TIMER
130 lg \scratch,__LC_LAST_UPDATE_TIMER
131 slg \scratch,__LC_EXIT_TIMER
132 alg \scratch,__LC_SYSTEM_TIMER
133 stg \scratch,__LC_SYSTEM_TIMER
134 mvc __LC_LAST_UPDATE_TIMER(8),\enter_timer
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200135 .endm
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100137 .macro LAST_BREAK scratch
138 srag \scratch,%r10,23
139 jz .+10
140 stg %r10,__TI_last_break(%r12)
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200141 .endm
142
Martin Schwidefsky1e546222010-10-25 16:10:37 +0200143 .macro REENABLE_IRQS
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100144 stg %r8,__LC_RETURN_PSW
145 ni __LC_RETURN_PSW,0xbf
146 ssm __LC_RETURN_PSW
Martin Schwidefsky1e546222010-10-25 16:10:37 +0200147 .endm
148
Heiko Carstens473e66b2012-05-09 16:27:39 +0200149 .macro STCK savearea
Heiko Carstensd652d592012-05-14 10:35:22 +0200150#ifdef CONFIG_HAVE_MARCH_Z9_109_FEATURES
Heiko Carstens473e66b2012-05-09 16:27:39 +0200151 .insn s,0xb27c0000,\savearea # store clock fast
152#else
153 .insn s,0xb2050000,\savearea # store clock
154#endif
155 .endm
156
Martin Schwidefsky860dba42011-01-05 12:47:25 +0100157 .section .kprobes.text, "ax"
158
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159/*
160 * Scheduler resume function, called by switch_to
161 * gpr2 = (task_struct *) prev
162 * gpr3 = (task_struct *) next
163 * Returns:
164 * gpr2 = prev
165 */
Jan Glauber144d6342011-07-24 10:48:19 +0200166ENTRY(__switch_to)
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +0200167 stmg %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task
168 stg %r15,__THREAD_ksp(%r2) # store kernel stack of prev
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100169 lg %r4,__THREAD_info(%r2) # get thread_info of prev
170 lg %r5,__THREAD_info(%r3) # get thread_info of next
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +0200171 lgr %r15,%r5
172 aghi %r15,STACK_SIZE # end of kernel stack of next
173 stg %r3,__LC_CURRENT # store task struct of next
174 stg %r5,__LC_THREAD_INFO # store thread info of next
175 stg %r15,__LC_KERNEL_STACK # store end of kernel stack
176 lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4
177 mvc __LC_CURRENT_PID+4(4,%r0),__TASK_pid(%r3) # store pid of next
178 lg %r15,__THREAD_ksp(%r3) # load kernel stack of next
Heiko Carstens77fa2242005-06-25 14:55:30 -0700179 tm __TI_flags+7(%r4),_TIF_MCCK_PENDING # machine check pending?
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100180 jz 0f
181 ni __TI_flags+7(%r4),255-_TIF_MCCK_PENDING # clear flag in prev
182 oi __TI_flags+7(%r5),_TIF_MCCK_PENDING # set it in next
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +02001830: lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 br %r14
185
186__critical_start:
187/*
188 * SVC interrupt handler routine. System calls are synchronous events and
189 * are executed with interrupts enabled.
190 */
191
Jan Glauber144d6342011-07-24 10:48:19 +0200192ENTRY(system_call)
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100193 stpt __LC_SYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100194sysc_stmg:
195 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
196 lg %r10,__LC_LAST_BREAK
197 lg %r12,__LC_THREAD_INFO
198 larl %r13,system_call
199sysc_per:
200 lg %r15,__LC_KERNEL_STACK
201 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
202 la %r11,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203sysc_vtime:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100204 UPDATE_VTIME %r13,__LC_SYNC_ENTER_TIMER
205 LAST_BREAK %r13
206 stmg %r0,%r7,__PT_R0(%r11)
207 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
208 mvc __PT_PSW(16,%r11),__LC_SVC_OLD_PSW
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100209 mvc __PT_INT_CODE(4,%r11),__LC_SVC_ILC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210sysc_do_svc:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100211 oi __TI_flags+7(%r12),_TIF_SYSCALL
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100212 llgh %r8,__PT_INT_CODE+2(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100213 slag %r8,%r8,2 # shift and test for svc 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 jnz sysc_nr_ok
215 # svc 0: system call number in %r1
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100216 llgfr %r1,%r1 # clear high word in r1
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200217 cghi %r1,NR_syscalls
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 jnl sysc_nr_ok
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100219 sth %r1,__PT_INT_CODE+2(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100220 slag %r8,%r1,2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221sysc_nr_ok:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100222 larl %r10,sys_call_table # 64 bit system call table
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800223#ifdef CONFIG_COMPAT
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100224 tm __TI_flags+5(%r12),(_TIF_31BIT>>16)
Heiko Carstensc5630772005-09-03 15:58:04 -0700225 jno sysc_noemu
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100226 larl %r10,sys_call_table_emu # 31 bit system call table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227sysc_noemu:
228#endif
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100229 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
230 stg %r2,__PT_ORIG_GPR2(%r11)
231 stg %r7,STACK_FRAME_OVERHEAD(%r15)
232 lgf %r9,0(%r8,%r10) # get system call add.
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100233 tm __TI_flags+6(%r12),_TIF_TRACE >> 8
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200234 jnz sysc_tracesys
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100235 basr %r14,%r9 # call sys_xxxx
236 stg %r2,__PT_R2(%r11) # store return value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237
238sysc_return:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200239 LOCKDEP_SYS_EXIT
240sysc_tif:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100241 tm __PT_PSW+1(%r11),0x01 # returning to user ?
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100242 jno sysc_restore
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200243 tm __TI_flags+7(%r12),_TIF_WORK_SVC
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100244 jnz sysc_work # check for work
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100245 ni __TI_flags+7(%r12),255-_TIF_SYSCALL
Heiko Carstens411788e2007-11-20 11:13:32 +0100246sysc_restore:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100247 lg %r14,__LC_VDSO_PER_CPU
248 lmg %r0,%r10,__PT_R0(%r11)
249 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
250 stpt __LC_EXIT_TIMER
251 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
252 lmg %r11,%r15,__PT_R11(%r11)
253 lpswe __LC_RETURN_PSW
Heiko Carstens411788e2007-11-20 11:13:32 +0100254sysc_done:
255
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256#
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200257# One of the work bits is on. Find out which one.
258#
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100259sysc_work:
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200260 tm __TI_flags+7(%r12),_TIF_MCCK_PENDING
Heiko Carstens77fa2242005-06-25 14:55:30 -0700261 jo sysc_mcck_pending
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200262 tm __TI_flags+7(%r12),_TIF_NEED_RESCHED
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 jo sysc_reschedule
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200264 tm __TI_flags+7(%r12),_TIF_SIGPENDING
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200265 jo sysc_sigpending
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200266 tm __TI_flags+7(%r12),_TIF_NOTIFY_RESUME
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200267 jo sysc_notify_resume
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100268 tm __TI_flags+7(%r12),_TIF_PER_TRAP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 jo sysc_singlestep
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200270 j sysc_return # beware of critical section cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271
272#
273# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200274#
275sysc_reschedule:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200276 larl %r14,sysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100277 jg schedule
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278
279#
Heiko Carstens77fa2242005-06-25 14:55:30 -0700280# _TIF_MCCK_PENDING is set, call handler
281#
282sysc_mcck_pending:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200283 larl %r14,sysc_return
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200284 jg s390_handle_mcck # TIF bit will be cleared by handler
Heiko Carstens77fa2242005-06-25 14:55:30 -0700285
286#
Roland McGrath02a029b2008-04-30 00:53:08 -0700287# _TIF_SIGPENDING is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288#
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200289sysc_sigpending:
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100290 ni __TI_flags+7(%r12),255-_TIF_PER_TRAP # clear TIF_PER_TRAP
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100291 lgr %r2,%r11 # pass pointer to pt_regs
292 brasl %r14,do_signal
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100293 tm __TI_flags+7(%r12),_TIF_SYSCALL
294 jno sysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100295 lmg %r2,%r7,__PT_R2(%r11) # load svc arguments
296 lghi %r8,0 # svc 0 returns -ENOSYS
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100297 lh %r1,__PT_INT_CODE+2(%r11) # load new svc number
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100298 cghi %r1,NR_syscalls
299 jnl sysc_nr_ok # invalid svc number -> do svc 0
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100300 slag %r8,%r1,2
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100301 j sysc_nr_ok # restart svc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302
303#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200304# _TIF_NOTIFY_RESUME is set, call do_notify_resume
305#
306sysc_notify_resume:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100307 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200308 larl %r14,sysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100309 jg do_notify_resume
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200310
311#
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100312# _TIF_PER_TRAP is set, call do_per_trap
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313#
314sysc_singlestep:
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100315 ni __TI_flags+7(%r12),255-(_TIF_SYSCALL | _TIF_PER_TRAP)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100316 lgr %r2,%r11 # pass pointer to pt_regs
317 larl %r14,sysc_return
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100318 jg do_per_trap
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200321# call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
322# and after the system call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323#
324sysc_tracesys:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100325 lgr %r2,%r11 # pass pointer to pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 la %r3,0
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100327 llgh %r0,__PT_INT_CODE+2(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100328 stg %r0,__PT_R2(%r11)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200329 brasl %r14,do_syscall_trace_enter
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 lghi %r0,NR_syscalls
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200331 clgr %r0,%r2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332 jnh sysc_tracenogo
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100333 sllg %r8,%r2,2
334 lgf %r9,0(%r8,%r10)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335sysc_tracego:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100336 lmg %r3,%r7,__PT_R3(%r11)
337 stg %r7,STACK_FRAME_OVERHEAD(%r15)
338 lg %r2,__PT_ORIG_GPR2(%r11)
339 basr %r14,%r9 # call sys_xxx
340 stg %r2,__PT_R2(%r11) # store return value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341sysc_tracenogo:
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100342 tm __TI_flags+6(%r12),_TIF_TRACE >> 8
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200343 jz sysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100344 lgr %r2,%r11 # pass pointer to pt_regs
345 larl %r14,sysc_return
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200346 jg do_syscall_trace_exit
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347
348#
349# a new process exits the kernel with ret_from_fork
350#
Jan Glauber144d6342011-07-24 10:48:19 +0200351ENTRY(ret_from_fork)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100352 la %r11,STACK_FRAME_OVERHEAD(%r15)
353 lg %r12,__LC_THREAD_INFO
354 tm __PT_PSW+1(%r11),0x01 # forking a kernel thread ?
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 jo 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100356 stg %r15,__PT_R15(%r11) # store stack pointer for new kthread
Heiko Carstens25d83cb2006-09-28 16:56:37 +02003570: brasl %r14,schedule_tail
Heiko Carstens1f194a42006-07-03 00:24:46 -0700358 TRACE_IRQS_ON
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100359 ssm __LC_SVC_NEW_PSW # reenable interrupts
Al Viro8f2961c2008-12-25 13:37:58 +0100360 j sysc_tracenogo
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361
362#
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200363# kernel_execve function needs to deal with pt_regs that is not
364# at the usual place
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365#
Jan Glauber144d6342011-07-24 10:48:19 +0200366ENTRY(kernel_execve)
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200367 stmg %r12,%r15,96(%r15)
368 lgr %r14,%r15
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100369 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200370 stg %r14,__SF_BACKCHAIN(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100371 la %r12,STACK_FRAME_OVERHEAD(%r15)
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200372 xc 0(__PT_SIZE,%r12),0(%r12)
373 lgr %r5,%r12
374 brasl %r14,do_execve
375 ltgfr %r2,%r2
376 je 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100377 aghi %r15,(STACK_FRAME_OVERHEAD + __PT_SIZE)
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200378 lmg %r12,%r15,96(%r15)
379 br %r14
380 # execve succeeded.
Martin Schwidefskyc5328902011-12-27 11:27:15 +01003810: ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200382 lg %r15,__LC_KERNEL_STACK # load ksp
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100383 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
384 la %r11,STACK_FRAME_OVERHEAD(%r15)
385 mvc 0(__PT_SIZE,%r11),0(%r12) # copy pt_regs
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200386 lg %r12,__LC_THREAD_INFO
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200387 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100388 ssm __LC_SVC_NEW_PSW # reenable interrupts
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200389 brasl %r14,execve_tail
390 j sysc_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391
392/*
393 * Program check handler routine
394 */
395
Jan Glauber144d6342011-07-24 10:48:19 +0200396ENTRY(pgm_check_handler)
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100397 stpt __LC_SYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100398 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
399 lg %r10,__LC_LAST_BREAK
400 lg %r12,__LC_THREAD_INFO
401 larl %r13,system_call
402 lmg %r8,%r9,__LC_PGM_OLD_PSW
403 HANDLE_SIE_INTERCEPT %r14
404 tmhh %r8,0x0001 # test problem state bit
405 jnz 1f # -> fault in user space
406 tmhh %r8,0x4000 # PER bit set in old PSW ?
407 jnz 0f # -> enabled, can't be a double fault
408 tm __LC_PGM_ILC+3,0x80 # check for per exception
409 jnz pgm_svcper # -> single stepped svc
4100: CHECK_STACK STACK_SIZE,__LC_SAVE_AREA_SYNC
411 j 2f
4121: UPDATE_VTIME %r14,__LC_SYNC_ENTER_TIMER
413 LAST_BREAK %r14
414 lg %r15,__LC_KERNEL_STACK
4152: aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
416 la %r11,STACK_FRAME_OVERHEAD(%r15)
417 stmg %r0,%r7,__PT_R0(%r11)
418 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
419 stmg %r8,%r9,__PT_PSW(%r11)
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100420 mvc __PT_INT_CODE(4,%r11),__LC_PGM_ILC
421 mvc __PT_INT_PARM_LONG(8,%r11),__LC_TRANS_EXC_CODE
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100422 stg %r10,__PT_ARGS(%r11)
423 tm __LC_PGM_ILC+3,0x80 # check for per exception
424 jz 0f
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200425 lg %r1,__TI_task(%r12)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100426 tmhh %r8,0x0001 # kernel per event ?
427 jz pgm_kprobe
428 oi __TI_flags+7(%r12),_TIF_PER_TRAP
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100429 mvc __THREAD_per_address(8,%r1),__LC_PER_ADDRESS
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100430 mvc __THREAD_per_cause(2,%r1),__LC_PER_CAUSE
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100431 mvc __THREAD_per_paid(1,%r1),__LC_PER_PAID
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +01004320: REENABLE_IRQS
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100433 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200434 larl %r1,pgm_check_table
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100435 llgh %r10,__PT_INT_CODE+2(%r11)
436 nill %r10,0x007f
437 sll %r10,3
438 je sysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100439 lg %r1,0(%r10,%r1) # load address of handler routine
440 lgr %r2,%r11 # pass pointer to pt_regs
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200441 basr %r14,%r1 # branch to interrupt-handler
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200442 j sysc_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443
444#
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100445# PER event in supervisor state, must be kprobes
446#
447pgm_kprobe:
448 REENABLE_IRQS
449 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
450 lgr %r2,%r11 # pass pointer to pt_regs
451 brasl %r14,do_per_trap
452 j sysc_return
453
454#
455# single stepped system call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456#
457pgm_svcper:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100458 oi __TI_flags+7(%r12),_TIF_PER_TRAP
459 mvc __LC_RETURN_PSW(8),__LC_SVC_NEW_PSW
460 larl %r14,sysc_per
461 stg %r14,__LC_RETURN_PSW+8
462 lpswe __LC_RETURN_PSW # branch to sysc_per and enable irqs
Michael Grundy4ba069b2006-09-20 15:58:39 +0200463
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464/*
465 * IO interrupt handler routine
466 */
Jan Glauber144d6342011-07-24 10:48:19 +0200467ENTRY(io_int_handler)
Heiko Carstens473e66b2012-05-09 16:27:39 +0200468 STCK __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100469 stpt __LC_ASYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100470 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
471 lg %r10,__LC_LAST_BREAK
472 lg %r12,__LC_THREAD_INFO
473 larl %r13,system_call
474 lmg %r8,%r9,__LC_IO_OLD_PSW
475 HANDLE_SIE_INTERCEPT %r14
476 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_STACK,STACK_SHIFT
477 tmhh %r8,0x0001 # interrupting from user?
478 jz io_skip
479 UPDATE_VTIME %r14,__LC_ASYNC_ENTER_TIMER
480 LAST_BREAK %r14
481io_skip:
482 stmg %r0,%r7,__PT_R0(%r11)
483 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
484 stmg %r8,%r9,__PT_PSW(%r11)
Heiko Carstens1f194a42006-07-03 00:24:46 -0700485 TRACE_IRQS_OFF
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100486 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
487 lgr %r2,%r11 # pass pointer to pt_regs
488 brasl %r14,do_IRQ
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489io_return:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200490 LOCKDEP_SYS_EXIT
491 TRACE_IRQS_ON
492io_tif:
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200493 tm __TI_flags+7(%r12),_TIF_WORK_INT
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200494 jnz io_work # there is work to do (signals etc.)
Heiko Carstens411788e2007-11-20 11:13:32 +0100495io_restore:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100496 lg %r14,__LC_VDSO_PER_CPU
497 lmg %r0,%r10,__PT_R0(%r11)
498 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100499 stpt __LC_EXIT_TIMER
500 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
501 lmg %r11,%r15,__PT_R11(%r11)
502 lpswe __LC_RETURN_PSW
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700503io_done:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504
Martin Schwidefsky26889052008-05-07 09:22:52 +0200505#
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200506# There is work todo, find out in which context we have been interrupted:
507# 1) if we return to user space we can do all _TIF_WORK_INT work
508# 2) if we return to kernel code and kvm is enabled check if we need to
509# modify the psw to leave SIE
510# 3) if we return to kernel code and preemptive scheduling is enabled check
511# the preemption counter and if it is zero call preempt_schedule_irq
512# Before any work can be done, a switch to the kernel stack is required.
Martin Schwidefsky26889052008-05-07 09:22:52 +0200513#
514io_work:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100515 tm __PT_PSW+1(%r11),0x01 # returning to user ?
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200516 jo io_work_user # yes -> do resched & signal
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200517#ifdef CONFIG_PREEMPT
Martin Schwidefsky26889052008-05-07 09:22:52 +0200518 # check for preemptive scheduling
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200519 icm %r0,15,__TI_precount(%r12)
Martin Schwidefsky26889052008-05-07 09:22:52 +0200520 jnz io_restore # preemption is disabled
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200521 tm __TI_flags+7(%r12),_TIF_NEED_RESCHED
522 jno io_restore
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 # switch to kernel stack
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100524 lg %r1,__PT_R15(%r11)
525 aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
526 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
527 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
528 la %r11,STACK_FRAME_OVERHEAD(%r1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 lgr %r15,%r1
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200530 # TRACE_IRQS_ON already done at io_return, call
531 # TRACE_IRQS_OFF to keep things symmetrical
532 TRACE_IRQS_OFF
533 brasl %r14,preempt_schedule_irq
534 j io_return
535#else
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200536 j io_restore
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200537#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200539#
540# Need to do work before returning to userspace, switch to kernel stack
541#
Martin Schwidefsky26889052008-05-07 09:22:52 +0200542io_work_user:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 lg %r1,__LC_KERNEL_STACK
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100544 aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
545 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
546 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
547 la %r11,STACK_FRAME_OVERHEAD(%r1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 lgr %r15,%r1
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200549
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550#
551# One of the work bits is on. Find out which one.
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200552# Checked are: _TIF_SIGPENDING, _TIF_NOTIFY_RESUME, _TIF_NEED_RESCHED
Heiko Carstens54dfe5d2006-02-01 03:06:38 -0800553# and _TIF_MCCK_PENDING
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554#
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200555io_work_tif:
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200556 tm __TI_flags+7(%r12),_TIF_MCCK_PENDING
Heiko Carstens77fa2242005-06-25 14:55:30 -0700557 jo io_mcck_pending
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200558 tm __TI_flags+7(%r12),_TIF_NEED_RESCHED
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 jo io_reschedule
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200560 tm __TI_flags+7(%r12),_TIF_SIGPENDING
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200561 jo io_sigpending
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200562 tm __TI_flags+7(%r12),_TIF_NOTIFY_RESUME
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200563 jo io_notify_resume
564 j io_return # beware of critical section cleanup
Christian Borntraeger0eaeafa2008-05-07 09:22:53 +0200565
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566#
Heiko Carstens77fa2242005-06-25 14:55:30 -0700567# _TIF_MCCK_PENDING is set, call handler
568#
569io_mcck_pending:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200570 # TRACE_IRQS_ON already done at io_return
Heiko Carstensb771aea2007-07-27 12:29:18 +0200571 brasl %r14,s390_handle_mcck # TIF bit will be cleared by handler
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200572 TRACE_IRQS_OFF
573 j io_return
Heiko Carstens77fa2242005-06-25 14:55:30 -0700574
575#
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200577#
578io_reschedule:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200579 # TRACE_IRQS_ON already done at io_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100580 ssm __LC_SVC_NEW_PSW # reenable interrupts
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200581 brasl %r14,schedule # call scheduler
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100582 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100583 TRACE_IRQS_OFF
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200584 j io_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585
586#
Roland McGrath02a029b2008-04-30 00:53:08 -0700587# _TIF_SIGPENDING or is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588#
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200589io_sigpending:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200590 # TRACE_IRQS_ON already done at io_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100591 ssm __LC_SVC_NEW_PSW # reenable interrupts
592 lgr %r2,%r11 # pass pointer to pt_regs
593 brasl %r14,do_signal
594 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100595 TRACE_IRQS_OFF
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200596 j io_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200598#
599# _TIF_NOTIFY_RESUME or is set, call do_notify_resume
600#
601io_notify_resume:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200602 # TRACE_IRQS_ON already done at io_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100603 ssm __LC_SVC_NEW_PSW # reenable interrupts
604 lgr %r2,%r11 # pass pointer to pt_regs
605 brasl %r14,do_notify_resume
606 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200607 TRACE_IRQS_OFF
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200608 j io_return
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200609
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610/*
611 * External interrupt handler routine
612 */
Jan Glauber144d6342011-07-24 10:48:19 +0200613ENTRY(ext_int_handler)
Heiko Carstens473e66b2012-05-09 16:27:39 +0200614 STCK __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100615 stpt __LC_ASYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100616 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
617 lg %r10,__LC_LAST_BREAK
618 lg %r12,__LC_THREAD_INFO
619 larl %r13,system_call
620 lmg %r8,%r9,__LC_EXT_OLD_PSW
621 HANDLE_SIE_INTERCEPT %r14
622 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_STACK,STACK_SHIFT
623 tmhh %r8,0x0001 # interrupting from user ?
624 jz ext_skip
625 UPDATE_VTIME %r14,__LC_ASYNC_ENTER_TIMER
626 LAST_BREAK %r14
627ext_skip:
628 stmg %r0,%r7,__PT_R0(%r11)
629 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
630 stmg %r8,%r9,__PT_PSW(%r11)
Heiko Carstens1f194a42006-07-03 00:24:46 -0700631 TRACE_IRQS_OFF
Michael Holzheu0de9db32012-05-09 16:27:35 +0200632 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Martin Schwidefskyf6649a72010-10-25 16:10:38 +0200633 lghi %r1,4096
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100634 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky7e180bd2012-03-11 11:59:25 -0400635 llgf %r3,__LC_EXT_CPU_ADDR # get cpu address + interruption code
Martin Schwidefskyf6649a72010-10-25 16:10:38 +0200636 llgf %r4,__LC_EXT_PARAMS # get external parameter
637 lg %r5,__LC_EXT_PARAMS2-4096(%r1) # get 64 bit external parameter
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200638 brasl %r14,do_extint
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 j io_return
640
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400641/*
642 * Load idle PSW. The second "half" of this function is in cleanup_idle.
643 */
644ENTRY(psw_idle)
645 stg %r4,__SF_EMPTY(%r15)
646 larl %r1,psw_idle_lpsw+4
647 stg %r1,__SF_EMPTY+8(%r15)
648 larl %r1,.Lvtimer_max
Heiko Carstens473e66b2012-05-09 16:27:39 +0200649 STCK __IDLE_ENTER(%r2)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400650 ltr %r5,%r5
651 stpt __VQ_IDLE_ENTER(%r3)
652 jz psw_idle_lpsw
653 spt 0(%r1)
654psw_idle_lpsw:
655 lpswe __SF_EMPTY(%r15)
656 br %r14
657psw_idle_end:
658
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700659__critical_end:
660
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661/*
662 * Machine check handler routines
663 */
Jan Glauber144d6342011-07-24 10:48:19 +0200664ENTRY(mcck_int_handler)
Heiko Carstens473e66b2012-05-09 16:27:39 +0200665 STCK __LC_MCCK_CLOCK
Heiko Carstens77fa2242005-06-25 14:55:30 -0700666 la %r1,4095 # revalidate r1
667 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # revalidate cpu timer
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200668 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# revalidate gprs
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100669 lg %r10,__LC_LAST_BREAK
670 lg %r12,__LC_THREAD_INFO
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200671 larl %r13,system_call
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100672 lmg %r8,%r9,__LC_MCK_OLD_PSW
673 HANDLE_SIE_INTERCEPT %r14
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200674 tm __LC_MCCK_CODE,0x80 # system damage?
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100675 jo mcck_panic # yes -> rest of mcck code invalid
676 lghi %r14,__LC_CPU_TIMER_SAVE_AREA
677 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200678 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100679 jo 3f
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200680 la %r14,__LC_SYNC_ENTER_TIMER
681 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
682 jl 0f
683 la %r14,__LC_ASYNC_ENTER_TIMER
6840: clc 0(8,%r14),__LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100685 jl 1f
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200686 la %r14,__LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +01006871: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
688 jl 2f
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200689 la %r14,__LC_LAST_UPDATE_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +01006902: spt 0(%r14)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200691 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
Martin Schwidefskyc5328902011-12-27 11:27:15 +01006923: tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid?
693 jno mcck_panic # no -> skip cleanup critical
694 SWITCH_ASYNC __LC_GPREGS_SAVE_AREA+64,__LC_PANIC_STACK,PAGE_SHIFT
695 tm %r8,0x0001 # interrupting from user ?
696 jz mcck_skip
697 UPDATE_VTIME %r14,__LC_MCCK_ENTER_TIMER
698 LAST_BREAK %r14
699mcck_skip:
700 lghi %r14,__LC_GPREGS_SAVE_AREA
701 mvc __PT_R0(128,%r11),0(%r14)
702 stmg %r8,%r9,__PT_PSW(%r11)
703 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
704 lgr %r2,%r11 # pass pointer to pt_regs
Heiko Carstens77fa2242005-06-25 14:55:30 -0700705 brasl %r14,s390_do_machine_check
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100706 tm __PT_PSW+1(%r11),0x01 # returning to user ?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700707 jno mcck_return
708 lg %r1,__LC_KERNEL_STACK # switch to kernel stack
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100709 aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
710 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
711 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
712 la %r11,STACK_FRAME_OVERHEAD(%r1)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700713 lgr %r15,%r1
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100714 ssm __LC_PGM_NEW_PSW # turn dat on, keep irqs off
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200715 tm __TI_flags+7(%r12),_TIF_MCCK_PENDING
Heiko Carstens77fa2242005-06-25 14:55:30 -0700716 jno mcck_return
Heiko Carstens1f194a42006-07-03 00:24:46 -0700717 TRACE_IRQS_OFF
Heiko Carstens77fa2242005-06-25 14:55:30 -0700718 brasl %r14,s390_handle_mcck
Heiko Carstens1f194a42006-07-03 00:24:46 -0700719 TRACE_IRQS_ON
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720mcck_return:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100721 lg %r14,__LC_VDSO_PER_CPU
722 lmg %r0,%r10,__PT_R0(%r11)
723 mvc __LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200724 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
725 jno 0f
726 stpt __LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100727 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
7280: lmg %r11,%r15,__PT_R11(%r11)
729 lpswe __LC_RETURN_MCCK_PSW
730
731mcck_panic:
732 lg %r14,__LC_PANIC_STACK
733 slgr %r14,%r15
734 srag %r14,%r14,PAGE_SHIFT
735 jz 0f
736 lg %r15,__LC_PANIC_STACK
7370: aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
738 j mcck_skip
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739
Michael Holzheu7dd6b332011-08-03 16:44:19 +0200740#
741# PSW restart interrupt handler
742#
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400743ENTRY(restart_int_handler)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100744 stg %r15,__LC_SAVE_AREA_RESTART
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400745 lg %r15,__LC_RESTART_STACK
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100746 aghi %r15,-__PT_SIZE # create pt_regs on stack
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400747 xc 0(__PT_SIZE,%r15),0(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100748 stmg %r0,%r14,__PT_R0(%r15)
749 mvc __PT_R15(8,%r15),__LC_SAVE_AREA_RESTART
750 mvc __PT_PSW(16,%r15),__LC_RST_OLD_PSW # store restart old psw
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400751 aghi %r15,-STACK_FRAME_OVERHEAD # create stack frame on stack
752 xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15)
Heiko Carstensfbe76562012-06-05 09:59:52 +0200753 lg %r1,__LC_RESTART_FN # load fn, parm & source cpu
754 lg %r2,__LC_RESTART_DATA
755 lg %r3,__LC_RESTART_SOURCE
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400756 ltgr %r3,%r3 # test source cpu address
757 jm 1f # negative -> skip source stop
Heiko Carstenseb546192012-06-04 15:05:43 +02007580: sigp %r4,%r3,SIGP_SENSE # sigp sense to source cpu
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400759 brc 10,0b # wait for status stored
7601: basr %r14,%r1 # call function
761 stap __SF_EMPTY(%r15) # store cpu address
762 llgh %r3,__SF_EMPTY(%r15)
Heiko Carstenseb546192012-06-04 15:05:43 +02007632: sigp %r4,%r3,SIGP_STOP # sigp stop to current cpu
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400764 brc 2,2b
7653: j 3b
Michael Holzheu7dd6b332011-08-03 16:44:19 +0200766
Martin Schwidefsky860dba42011-01-05 12:47:25 +0100767 .section .kprobes.text, "ax"
768
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769#ifdef CONFIG_CHECK_STACK
770/*
771 * The synchronous or the asynchronous stack overflowed. We are dead.
772 * No need to properly save the registers, we are going to panic anyway.
773 * Setup a pt_regs so that show_trace can provide a good call trace.
774 */
775stack_overflow:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100776 lg %r11,__LC_PANIC_STACK # change to panic stack
777 aghi %r11,-__PT_SIZE # create pt_regs
778 stmg %r0,%r7,__PT_R0(%r11)
779 stmg %r8,%r9,__PT_PSW(%r11)
780 mvc __PT_R8(64,%r11),0(%r14)
781 stg %r10,__PT_ORIG_GPR2(%r11) # store last break to orig_gpr2
782 lgr %r15,%r11
783 aghi %r15,-STACK_FRAME_OVERHEAD
784 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
785 lgr %r2,%r11 # pass pointer to pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786 jg kernel_stack_overflow
787#endif
788
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100789 .align 8
790cleanup_table:
791 .quad system_call
792 .quad sysc_do_svc
793 .quad sysc_tif
794 .quad sysc_restore
795 .quad sysc_done
796 .quad io_tif
797 .quad io_restore
798 .quad io_done
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400799 .quad psw_idle
800 .quad psw_idle_end
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801
802cleanup_critical:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100803 clg %r9,BASED(cleanup_table) # system_call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700804 jl 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100805 clg %r9,BASED(cleanup_table+8) # sysc_do_svc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806 jl cleanup_system_call
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100807 clg %r9,BASED(cleanup_table+16) # sysc_tif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808 jl 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100809 clg %r9,BASED(cleanup_table+24) # sysc_restore
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200810 jl cleanup_sysc_tif
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100811 clg %r9,BASED(cleanup_table+32) # sysc_done
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200812 jl cleanup_sysc_restore
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100813 clg %r9,BASED(cleanup_table+40) # io_tif
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200814 jl 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100815 clg %r9,BASED(cleanup_table+48) # io_restore
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200816 jl cleanup_io_tif
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100817 clg %r9,BASED(cleanup_table+56) # io_done
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200818 jl cleanup_io_restore
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400819 clg %r9,BASED(cleanup_table+64) # psw_idle
820 jl 0f
821 clg %r9,BASED(cleanup_table+72) # psw_idle_end
822 jl cleanup_idle
Martin Schwidefskyc5328902011-12-27 11:27:15 +01008230: br %r14
824
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825
826cleanup_system_call:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100827 # check if stpt has been executed
828 clg %r9,BASED(cleanup_system_call_insn)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700829 jh 0f
830 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100831 cghi %r11,__LC_SAVE_AREA_ASYNC
Martin Schwidefsky63779812010-05-17 10:00:03 +0200832 je 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100833 mvc __LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER
8340: # check if stmg has been executed
835 clg %r9,BASED(cleanup_system_call_insn+8)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836 jh 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100837 mvc __LC_SAVE_AREA_SYNC(64),0(%r11)
8380: # check if base register setup + TIF bit load has been done
839 clg %r9,BASED(cleanup_system_call_insn+16)
840 jhe 0f
841 # set up saved registers r10 and r12
842 stg %r10,16(%r11) # r10 last break
843 stg %r12,32(%r11) # r12 thread-info pointer
8440: # check if the user time update has been done
845 clg %r9,BASED(cleanup_system_call_insn+24)
846 jh 0f
847 lg %r15,__LC_EXIT_TIMER
848 slg %r15,__LC_SYNC_ENTER_TIMER
849 alg %r15,__LC_USER_TIMER
850 stg %r15,__LC_USER_TIMER
8510: # check if the system time update has been done
852 clg %r9,BASED(cleanup_system_call_insn+32)
853 jh 0f
854 lg %r15,__LC_LAST_UPDATE_TIMER
855 slg %r15,__LC_EXIT_TIMER
856 alg %r15,__LC_SYSTEM_TIMER
857 stg %r15,__LC_SYSTEM_TIMER
8580: # update accounting time stamp
Linus Torvalds1da177e2005-04-16 15:20:36 -0700859 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100860 # do LAST_BREAK
861 lg %r9,16(%r11)
862 srag %r9,%r9,23
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200863 jz 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100864 mvc __TI_last_break(8,%r12),16(%r11)
8650: # set up saved register r11
866 lg %r15,__LC_KERNEL_STACK
867 aghi %r15,-__PT_SIZE
868 stg %r15,24(%r11) # r11 pt_regs pointer
869 # fill pt_regs
870 mvc __PT_R8(64,%r15),__LC_SAVE_AREA_SYNC
871 stmg %r0,%r7,__PT_R0(%r15)
872 mvc __PT_PSW(16,%r15),__LC_SVC_OLD_PSW
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100873 mvc __PT_INT_CODE(4,%r15),__LC_SVC_ILC
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100874 # setup saved register r15
875 aghi %r15,-STACK_FRAME_OVERHEAD
876 stg %r15,56(%r11) # r15 stack pointer
877 # set new psw address and exit
878 larl %r9,sysc_do_svc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700879 br %r14
880cleanup_system_call_insn:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200881 .quad system_call
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100882 .quad sysc_stmg
883 .quad sysc_per
884 .quad sysc_vtime+18
885 .quad sysc_vtime+42
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200887cleanup_sysc_tif:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100888 larl %r9,sysc_tif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700889 br %r14
890
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200891cleanup_sysc_restore:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100892 clg %r9,BASED(cleanup_sysc_restore_insn)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200893 je 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100894 lg %r9,24(%r11) # get saved pointer to pt_regs
895 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
896 mvc 0(64,%r11),__PT_R8(%r9)
897 lmg %r0,%r7,__PT_R0(%r9)
8980: lmg %r8,%r9,__LC_RETURN_PSW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700899 br %r14
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200900cleanup_sysc_restore_insn:
Heiko Carstens411788e2007-11-20 11:13:32 +0100901 .quad sysc_done - 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700902
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200903cleanup_io_tif:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100904 larl %r9,io_tif
Martin Schwidefsky176b1802010-04-09 13:43:00 +0200905 br %r14
906
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200907cleanup_io_restore:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100908 clg %r9,BASED(cleanup_io_restore_insn)
909 je 0f
910 lg %r9,24(%r11) # get saved r11 pointer to pt_regs
911 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100912 mvc 0(64,%r11),__PT_R8(%r9)
913 lmg %r0,%r7,__PT_R0(%r9)
9140: lmg %r8,%r9,__LC_RETURN_PSW
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700915 br %r14
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200916cleanup_io_restore_insn:
Heiko Carstens411788e2007-11-20 11:13:32 +0100917 .quad io_done - 4
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700918
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400919cleanup_idle:
920 # copy interrupt clock & cpu timer
921 mvc __IDLE_EXIT(8,%r2),__LC_INT_CLOCK
922 mvc __VQ_IDLE_EXIT(8,%r3),__LC_ASYNC_ENTER_TIMER
923 cghi %r11,__LC_SAVE_AREA_ASYNC
924 je 0f
925 mvc __IDLE_EXIT(8,%r2),__LC_MCCK_CLOCK
926 mvc __VQ_IDLE_EXIT(8,%r3),__LC_MCCK_ENTER_TIMER
9270: # check if stck & stpt have been executed
928 clg %r9,BASED(cleanup_idle_insn)
929 jhe 1f
930 mvc __IDLE_ENTER(8,%r2),__IDLE_EXIT(%r2)
931 mvc __VQ_IDLE_ENTER(8,%r3),__VQ_IDLE_EXIT(%r3)
932 j 2f
9331: # check if the cpu timer has been reprogrammed
934 ltr %r5,%r5
935 jz 2f
936 spt __VQ_IDLE_ENTER(%r3)
9372: # account system time going idle
938 lg %r9,__LC_STEAL_TIMER
939 alg %r9,__IDLE_ENTER(%r2)
940 slg %r9,__LC_LAST_UPDATE_CLOCK
941 stg %r9,__LC_STEAL_TIMER
942 mvc __LC_LAST_UPDATE_CLOCK(8),__IDLE_EXIT(%r2)
943 lg %r9,__LC_SYSTEM_TIMER
944 alg %r9,__LC_LAST_UPDATE_TIMER
945 slg %r9,__VQ_IDLE_ENTER(%r3)
946 stg %r9,__LC_SYSTEM_TIMER
947 mvc __LC_LAST_UPDATE_TIMER(8),__VQ_IDLE_EXIT(%r3)
948 # prepare return psw
949 nihh %r8,0xfffd # clear wait state bit
950 lg %r9,48(%r11) # return from psw_idle
951 br %r14
952cleanup_idle_insn:
953 .quad psw_idle_lpsw
954
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955/*
956 * Integer constants
957 */
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100958 .align 8
Linus Torvalds1da177e2005-04-16 15:20:36 -0700959.Lcritical_start:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100960 .quad __critical_start
961.Lcritical_length:
962 .quad __critical_end - __critical_start
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400963.Lvtimer_max:
964 .quad 0x7fffffffffffffff
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100965
Linus Torvalds1da177e2005-04-16 15:20:36 -0700966
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200967#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
968/*
969 * sie64a calling convention:
970 * %r2 pointer to sie control block
971 * %r3 guest register save area
972 */
Jan Glauber144d6342011-07-24 10:48:19 +0200973ENTRY(sie64a)
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200974 stmg %r6,%r14,__SF_GPRS(%r15) # save kernel registers
975 stg %r2,__SF_EMPTY(%r15) # save control block pointer
976 stg %r3,__SF_EMPTY+8(%r15) # save guest register save area
Martin Schwidefskyddd6f952011-12-27 11:27:13 +0100977 xc __SF_EMPTY+16(8,%r15),__SF_EMPTY+16(%r15) # host id == 0
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200978 lmg %r0,%r13,0(%r3) # load guest gprs 0-13
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200979sie_loop:
980 lg %r14,__LC_THREAD_INFO # pointer thread_info struct
981 tm __TI_flags+7(%r14),_TIF_EXIT_SIE
982 jnz sie_exit
Christian Borntraeger480e5922011-09-20 17:07:28 +0200983 lg %r14,__LC_GMAP # get gmap pointer
984 ltgr %r14,%r14
985 jz sie_gmap
986 lctlg %c1,%c1,__GMAP_ASCE(%r14) # load primary asce
987sie_gmap:
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200988 lg %r14,__SF_EMPTY(%r15) # get control block pointer
989 SPP __SF_EMPTY(%r15) # set guest id
990 sie 0(%r14)
991sie_done:
Martin Schwidefskyddd6f952011-12-27 11:27:13 +0100992 SPP __SF_EMPTY+16(%r15) # set host id
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200993 lg %r14,__LC_THREAD_INFO # pointer thread_info struct
994sie_exit:
Christian Borntraeger480e5922011-09-20 17:07:28 +0200995 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200996 lg %r14,__SF_EMPTY+8(%r15) # load guest register save area
997 stmg %r0,%r13,0(%r14) # save guest gprs 0-13
998 lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers
999 lghi %r2,0
1000 br %r14
1001sie_fault:
Carsten Otte69ba9742011-10-30 15:16:59 +01001002 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
Martin Schwidefsky603d1a52011-07-24 10:48:18 +02001003 lg %r14,__LC_THREAD_INFO # pointer thread_info struct
Martin Schwidefsky603d1a52011-07-24 10:48:18 +02001004 lg %r14,__SF_EMPTY+8(%r15) # load guest register save area
1005 stmg %r0,%r13,0(%r14) # save guest gprs 0-13
1006 lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers
1007 lghi %r2,-EFAULT
1008 br %r14
1009
1010 .align 8
1011.Lsie_loop:
1012 .quad sie_loop
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001013.Lsie_length:
1014 .quad sie_done - sie_loop
Martin Schwidefskyddd6f952011-12-27 11:27:13 +01001015.Lhost_id:
1016 .quad 0
Martin Schwidefsky603d1a52011-07-24 10:48:18 +02001017
1018 .section __ex_table,"a"
1019 .quad sie_loop,sie_fault
1020 .previous
1021#endif
1022
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001023 .section .rodata, "a"
Linus Torvalds1da177e2005-04-16 15:20:36 -07001024#define SYSCALL(esa,esame,emu) .long esame
Heiko Carstens9bf12262009-06-12 10:26:47 +02001025 .globl sys_call_table
Linus Torvalds1da177e2005-04-16 15:20:36 -07001026sys_call_table:
1027#include "syscalls.S"
1028#undef SYSCALL
1029
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -08001030#ifdef CONFIG_COMPAT
Linus Torvalds1da177e2005-04-16 15:20:36 -07001031
1032#define SYSCALL(esa,esame,emu) .long emu
Linus Torvalds1da177e2005-04-16 15:20:36 -07001033sys_call_table_emu:
1034#include "syscalls.S"
1035#undef SYSCALL
1036#endif