blob: 980c7aa1cc5ca2bee34c9af1f977f9e39783c31a [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>
Heiko Carstenseb608fb2012-09-05 13:26:11 +020013#include <asm/processor.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <asm/cache.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <asm/errno.h>
16#include <asm/ptrace.h>
17#include <asm/thread_info.h>
Sam Ravnborg0013a852005-09-09 20:57:26 +020018#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <asm/unistd.h>
20#include <asm/page.h>
Heiko Carstenseb546192012-06-04 15:05:43 +020021#include <asm/sigp.h>
Martin Schwidefsky1f44a2252013-06-27 09:01:09 +020022#include <asm/irq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
Martin Schwidefskyc5328902011-12-27 11:27:15 +010024__PT_R0 = __PT_GPRS
25__PT_R1 = __PT_GPRS + 8
26__PT_R2 = __PT_GPRS + 16
27__PT_R3 = __PT_GPRS + 24
28__PT_R4 = __PT_GPRS + 32
29__PT_R5 = __PT_GPRS + 40
30__PT_R6 = __PT_GPRS + 48
31__PT_R7 = __PT_GPRS + 56
32__PT_R8 = __PT_GPRS + 64
33__PT_R9 = __PT_GPRS + 72
34__PT_R10 = __PT_GPRS + 80
35__PT_R11 = __PT_GPRS + 88
36__PT_R12 = __PT_GPRS + 96
37__PT_R13 = __PT_GPRS + 104
38__PT_R14 = __PT_GPRS + 112
39__PT_R15 = __PT_GPRS + 120
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
42STACK_SIZE = 1 << STACK_SHIFT
Martin Schwidefskydc7ee002013-04-24 10:20:43 +020043STACK_INIT = STACK_SIZE - STACK_FRAME_OVERHEAD - __PT_SIZE
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +020045_TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +010046 _TIF_MCCK_PENDING | _TIF_PER_TRAP )
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +020047_TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \
Heiko Carstens54dfe5d2006-02-01 03:06:38 -080048 _TIF_MCCK_PENDING)
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +010049_TIF_TRACE = (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | \
50 _TIF_SYSCALL_TRACEPOINT)
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52#define BASED(name) name-system_call(%r13)
53
Martin Schwidefskyc5328902011-12-27 11:27:15 +010054 .macro TRACE_IRQS_ON
55#ifdef CONFIG_TRACE_IRQFLAGS
56 basr %r2,%r0
57 brasl %r14,trace_hardirqs_on_caller
58#endif
59 .endm
60
61 .macro TRACE_IRQS_OFF
62#ifdef CONFIG_TRACE_IRQFLAGS
63 basr %r2,%r0
64 brasl %r14,trace_hardirqs_off_caller
65#endif
66 .endm
67
68 .macro LOCKDEP_SYS_EXIT
69#ifdef CONFIG_LOCKDEP
70 tm __PT_PSW+1(%r11),0x01 # returning to user ?
71 jz .+10
72 brasl %r14,lockdep_sys_exit
73#endif
74 .endm
75
Hendrik Brueckner23d18e82013-02-11 18:11:09 +010076 .macro LPP newpp
Martin Schwidefsky603d1a52011-07-24 10:48:18 +020077#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
Hendrik Brueckner23d18e82013-02-11 18:11:09 +010078 tm __LC_MACHINE_FLAGS+6,0x20 # MACHINE_FLAG_LPP
Martin Schwidefsky603d1a52011-07-24 10:48:18 +020079 jz .+8
80 .insn s,0xb2800000,\newpp
81#endif
82 .endm
83
Martin Schwidefsky7c470532013-05-17 14:41:37 +020084 .macro HANDLE_SIE_INTERCEPT scratch,reason
Carsten Ottecd3b70f2010-05-17 10:00:04 +020085#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
Martin Schwidefsky6022afc2012-05-09 16:27:36 +020086 tmhh %r8,0x0001 # interrupting from user ?
Martin Schwidefsky7c470532013-05-17 14:41:37 +020087 jnz .+62
Martin Schwidefskyc5328902011-12-27 11:27:15 +010088 lgr \scratch,%r9
Martin Schwidefsky7c470532013-05-17 14:41:37 +020089 slg \scratch,BASED(.Lsie_critical)
90 clg \scratch,BASED(.Lsie_critical_length)
91 .if \reason==1
Christian Borntraegerce6a04a2012-11-15 09:35:16 +010092 # Some program interrupts are suppressing (e.g. protection).
93 # We must also check the instruction after SIE in that case.
94 # do_protection_exception will rewind to rewind_pad
Martin Schwidefsky7c470532013-05-17 14:41:37 +020095 jh .+42
Christian Borntraegerce6a04a2012-11-15 09:35:16 +010096 .else
Martin Schwidefsky7c470532013-05-17 14:41:37 +020097 jhe .+42
Christian Borntraegerce6a04a2012-11-15 09:35:16 +010098 .endif
Martin Schwidefsky7c470532013-05-17 14:41:37 +020099 lg %r14,__SF_EMPTY(%r15) # get control block pointer
100 LPP __SF_EMPTY+16(%r15) # set host id
Christian Borntraeger95d38fd2013-05-17 14:41:34 +0200101 ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE
Martin Schwidefsky7c470532013-05-17 14:41:37 +0200102 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
103 larl %r9,sie_exit # skip forward to sie_exit
104 mvi __SF_EMPTY+31(%r15),\reason # set exit reason
Carsten Ottecd3b70f2010-05-17 10:00:04 +0200105#endif
106 .endm
107
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100108 .macro CHECK_STACK stacksize,savearea
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200109#ifdef CONFIG_CHECK_STACK
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100110 tml %r15,\stacksize - CONFIG_STACK_GUARD
111 lghi %r14,\savearea
112 jz stack_overflow
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200113#endif
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200114 .endm
115
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100116 .macro SWITCH_ASYNC savearea,stack,shift
117 tmhh %r8,0x0001 # interrupting from user ?
118 jnz 1f
119 lgr %r14,%r9
120 slg %r14,BASED(.Lcritical_start)
121 clg %r14,BASED(.Lcritical_length)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 jhe 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100123 lghi %r11,\savearea # inside critical section, do cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 brasl %r14,cleanup_critical
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100125 tmhh %r8,0x0001 # retest problem state after cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 jnz 1f
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001270: lg %r14,\stack # are we already on the target stack?
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 slgr %r14,%r15
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100129 srag %r14,%r14,\shift
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200130 jnz 1f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100131 CHECK_STACK 1<<\shift,\savearea
Martin Schwidefskydc7ee002013-04-24 10:20:43 +0200132 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100133 j 2f
1341: lg %r15,\stack # load target stack
Martin Schwidefskydc7ee002013-04-24 10:20:43 +02001352: la %r11,STACK_FRAME_OVERHEAD(%r15)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700136 .endm
137
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100138 .macro UPDATE_VTIME scratch,enter_timer
139 lg \scratch,__LC_EXIT_TIMER
140 slg \scratch,\enter_timer
141 alg \scratch,__LC_USER_TIMER
142 stg \scratch,__LC_USER_TIMER
143 lg \scratch,__LC_LAST_UPDATE_TIMER
144 slg \scratch,__LC_EXIT_TIMER
145 alg \scratch,__LC_SYSTEM_TIMER
146 stg \scratch,__LC_SYSTEM_TIMER
147 mvc __LC_LAST_UPDATE_TIMER(8),\enter_timer
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200148 .endm
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100150 .macro LAST_BREAK scratch
151 srag \scratch,%r10,23
152 jz .+10
153 stg %r10,__TI_last_break(%r12)
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200154 .endm
155
Martin Schwidefsky1e546222010-10-25 16:10:37 +0200156 .macro REENABLE_IRQS
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100157 stg %r8,__LC_RETURN_PSW
158 ni __LC_RETURN_PSW,0xbf
159 ssm __LC_RETURN_PSW
Martin Schwidefsky1e546222010-10-25 16:10:37 +0200160 .endm
161
Heiko Carstens473e66b2012-05-09 16:27:39 +0200162 .macro STCK savearea
Heiko Carstensd652d592012-05-14 10:35:22 +0200163#ifdef CONFIG_HAVE_MARCH_Z9_109_FEATURES
Heiko Carstens473e66b2012-05-09 16:27:39 +0200164 .insn s,0xb27c0000,\savearea # store clock fast
165#else
166 .insn s,0xb2050000,\savearea # store clock
167#endif
168 .endm
169
Martin Schwidefsky860dba42011-01-05 12:47:25 +0100170 .section .kprobes.text, "ax"
171
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172/*
173 * Scheduler resume function, called by switch_to
174 * gpr2 = (task_struct *) prev
175 * gpr3 = (task_struct *) next
176 * Returns:
177 * gpr2 = prev
178 */
Jan Glauber144d6342011-07-24 10:48:19 +0200179ENTRY(__switch_to)
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +0200180 stmg %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task
181 stg %r15,__THREAD_ksp(%r2) # store kernel stack of prev
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100182 lg %r4,__THREAD_info(%r2) # get thread_info of prev
183 lg %r5,__THREAD_info(%r3) # get thread_info of next
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +0200184 lgr %r15,%r5
Martin Schwidefskydc7ee002013-04-24 10:20:43 +0200185 aghi %r15,STACK_INIT # end of kernel stack of next
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +0200186 stg %r3,__LC_CURRENT # store task struct of next
187 stg %r5,__LC_THREAD_INFO # store thread info of next
188 stg %r15,__LC_KERNEL_STACK # store end of kernel stack
189 lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4
190 mvc __LC_CURRENT_PID+4(4,%r0),__TASK_pid(%r3) # store pid of next
191 lg %r15,__THREAD_ksp(%r3) # load kernel stack of next
Heiko Carstens77fa2242005-06-25 14:55:30 -0700192 tm __TI_flags+7(%r4),_TIF_MCCK_PENDING # machine check pending?
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100193 jz 0f
194 ni __TI_flags+7(%r4),255-_TIF_MCCK_PENDING # clear flag in prev
195 oi __TI_flags+7(%r5),_TIF_MCCK_PENDING # set it in next
Martin Schwidefskyeda0c6d2012-05-15 09:20:06 +02001960: lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 br %r14
198
199__critical_start:
200/*
201 * SVC interrupt handler routine. System calls are synchronous events and
202 * are executed with interrupts enabled.
203 */
204
Jan Glauber144d6342011-07-24 10:48:19 +0200205ENTRY(system_call)
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100206 stpt __LC_SYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100207sysc_stmg:
208 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
209 lg %r10,__LC_LAST_BREAK
210 lg %r12,__LC_THREAD_INFO
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100211sysc_per:
212 lg %r15,__LC_KERNEL_STACK
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100213 la %r11,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214sysc_vtime:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100215 UPDATE_VTIME %r13,__LC_SYNC_ENTER_TIMER
216 LAST_BREAK %r13
217 stmg %r0,%r7,__PT_R0(%r11)
218 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
219 mvc __PT_PSW(16,%r11),__LC_SVC_OLD_PSW
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100220 mvc __PT_INT_CODE(4,%r11),__LC_SVC_ILC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221sysc_do_svc:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100222 oi __TI_flags+7(%r12),_TIF_SYSCALL
Martin Schwidefsky61649882013-04-24 12:58:39 +0200223 lg %r10,__TI_sysc_table(%r12) # address of system call table
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100224 llgh %r8,__PT_INT_CODE+2(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100225 slag %r8,%r8,2 # shift and test for svc 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 jnz sysc_nr_ok
227 # svc 0: system call number in %r1
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100228 llgfr %r1,%r1 # clear high word in r1
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200229 cghi %r1,NR_syscalls
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 jnl sysc_nr_ok
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100231 sth %r1,__PT_INT_CODE+2(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100232 slag %r8,%r1,2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233sysc_nr_ok:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100234 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
235 stg %r2,__PT_ORIG_GPR2(%r11)
236 stg %r7,STACK_FRAME_OVERHEAD(%r15)
237 lgf %r9,0(%r8,%r10) # get system call add.
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100238 tm __TI_flags+6(%r12),_TIF_TRACE >> 8
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200239 jnz sysc_tracesys
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100240 basr %r14,%r9 # call sys_xxxx
241 stg %r2,__PT_R2(%r11) # store return value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242
243sysc_return:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200244 LOCKDEP_SYS_EXIT
245sysc_tif:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100246 tm __PT_PSW+1(%r11),0x01 # returning to user ?
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100247 jno sysc_restore
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200248 tm __TI_flags+7(%r12),_TIF_WORK_SVC
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100249 jnz sysc_work # check for work
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100250 ni __TI_flags+7(%r12),255-_TIF_SYSCALL
Heiko Carstens411788e2007-11-20 11:13:32 +0100251sysc_restore:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100252 lg %r14,__LC_VDSO_PER_CPU
253 lmg %r0,%r10,__PT_R0(%r11)
254 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
255 stpt __LC_EXIT_TIMER
256 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
257 lmg %r11,%r15,__PT_R11(%r11)
258 lpswe __LC_RETURN_PSW
Heiko Carstens411788e2007-11-20 11:13:32 +0100259sysc_done:
260
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261#
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200262# One of the work bits is on. Find out which one.
263#
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100264sysc_work:
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200265 tm __TI_flags+7(%r12),_TIF_MCCK_PENDING
Heiko Carstens77fa2242005-06-25 14:55:30 -0700266 jo sysc_mcck_pending
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200267 tm __TI_flags+7(%r12),_TIF_NEED_RESCHED
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 jo sysc_reschedule
Martin Schwidefsky39efd4e2012-11-21 16:36:27 +0100269 tm __TI_flags+7(%r12),_TIF_PER_TRAP
270 jo sysc_singlestep
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200271 tm __TI_flags+7(%r12),_TIF_SIGPENDING
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200272 jo sysc_sigpending
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200273 tm __TI_flags+7(%r12),_TIF_NOTIFY_RESUME
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200274 jo sysc_notify_resume
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200275 j sysc_return # beware of critical section cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276
277#
278# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200279#
280sysc_reschedule:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200281 larl %r14,sysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100282 jg schedule
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283
284#
Heiko Carstens77fa2242005-06-25 14:55:30 -0700285# _TIF_MCCK_PENDING is set, call handler
286#
287sysc_mcck_pending:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200288 larl %r14,sysc_return
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200289 jg s390_handle_mcck # TIF bit will be cleared by handler
Heiko Carstens77fa2242005-06-25 14:55:30 -0700290
291#
Roland McGrath02a029b2008-04-30 00:53:08 -0700292# _TIF_SIGPENDING is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293#
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200294sysc_sigpending:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100295 lgr %r2,%r11 # pass pointer to pt_regs
296 brasl %r14,do_signal
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100297 tm __TI_flags+7(%r12),_TIF_SYSCALL
298 jno sysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100299 lmg %r2,%r7,__PT_R2(%r11) # load svc arguments
300 lghi %r8,0 # svc 0 returns -ENOSYS
Martin Schwidefsky450e47d2012-10-09 13:33:53 +0200301 llgh %r1,__PT_INT_CODE+2(%r11) # load new svc number
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100302 cghi %r1,NR_syscalls
303 jnl sysc_nr_ok # invalid svc number -> do svc 0
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100304 slag %r8,%r1,2
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100305 j sysc_nr_ok # restart svc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306
307#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200308# _TIF_NOTIFY_RESUME is set, call do_notify_resume
309#
310sysc_notify_resume:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100311 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200312 larl %r14,sysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100313 jg do_notify_resume
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200314
315#
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100316# _TIF_PER_TRAP is set, call do_per_trap
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317#
318sysc_singlestep:
Martin Schwidefsky39efd4e2012-11-21 16:36:27 +0100319 ni __TI_flags+7(%r12),255-_TIF_PER_TRAP
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100320 lgr %r2,%r11 # pass pointer to pt_regs
321 larl %r14,sysc_return
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100322 jg do_per_trap
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200325# call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
326# and after the system call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327#
328sysc_tracesys:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100329 lgr %r2,%r11 # pass pointer to pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 la %r3,0
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100331 llgh %r0,__PT_INT_CODE+2(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100332 stg %r0,__PT_R2(%r11)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200333 brasl %r14,do_syscall_trace_enter
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 lghi %r0,NR_syscalls
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200335 clgr %r0,%r2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336 jnh sysc_tracenogo
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100337 sllg %r8,%r2,2
338 lgf %r9,0(%r8,%r10)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339sysc_tracego:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100340 lmg %r3,%r7,__PT_R3(%r11)
341 stg %r7,STACK_FRAME_OVERHEAD(%r15)
342 lg %r2,__PT_ORIG_GPR2(%r11)
343 basr %r14,%r9 # call sys_xxx
344 stg %r2,__PT_R2(%r11) # store return value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345sysc_tracenogo:
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100346 tm __TI_flags+6(%r12),_TIF_TRACE >> 8
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200347 jz sysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100348 lgr %r2,%r11 # pass pointer to pt_regs
349 larl %r14,sysc_return
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200350 jg do_syscall_trace_exit
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351
352#
353# a new process exits the kernel with ret_from_fork
354#
Jan Glauber144d6342011-07-24 10:48:19 +0200355ENTRY(ret_from_fork)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100356 la %r11,STACK_FRAME_OVERHEAD(%r15)
357 lg %r12,__LC_THREAD_INFO
Al Viro30dcb092012-10-11 15:30:14 -0400358 brasl %r14,schedule_tail
359 TRACE_IRQS_ON
360 ssm __LC_SVC_NEW_PSW # reenable interrupts
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100361 tm __PT_PSW+1(%r11),0x01 # forking a kernel thread ?
Al Viro30dcb092012-10-11 15:30:14 -0400362 jne sysc_tracenogo
363 # it's a kernel thread
364 lmg %r9,%r10,__PT_R9(%r11) # load gprs
Al Viro37fe5d42012-09-10 18:03:41 -0400365ENTRY(kernel_thread_starter)
366 la %r2,0(%r10)
367 basr %r14,%r9
Al Viro30dcb092012-10-11 15:30:14 -0400368 j sysc_tracenogo
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369
370/*
371 * Program check handler routine
372 */
373
Jan Glauber144d6342011-07-24 10:48:19 +0200374ENTRY(pgm_check_handler)
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100375 stpt __LC_SYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100376 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
377 lg %r10,__LC_LAST_BREAK
378 lg %r12,__LC_THREAD_INFO
379 larl %r13,system_call
380 lmg %r8,%r9,__LC_PGM_OLD_PSW
Christian Borntraegerce6a04a2012-11-15 09:35:16 +0100381 HANDLE_SIE_INTERCEPT %r14,1
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100382 tmhh %r8,0x0001 # test problem state bit
383 jnz 1f # -> fault in user space
384 tmhh %r8,0x4000 # PER bit set in old PSW ?
385 jnz 0f # -> enabled, can't be a double fault
386 tm __LC_PGM_ILC+3,0x80 # check for per exception
387 jnz pgm_svcper # -> single stepped svc
3880: CHECK_STACK STACK_SIZE,__LC_SAVE_AREA_SYNC
Martin Schwidefskydc7ee002013-04-24 10:20:43 +0200389 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100390 j 2f
3911: UPDATE_VTIME %r14,__LC_SYNC_ENTER_TIMER
392 LAST_BREAK %r14
393 lg %r15,__LC_KERNEL_STACK
Martin Schwidefskyd35339a2012-07-31 11:03:04 +0200394 lg %r14,__TI_task(%r12)
395 lghi %r13,__LC_PGM_TDB
396 tm __LC_PGM_ILC+2,0x02 # check for transaction abort
397 jz 2f
398 mvc __THREAD_trap_tdb(256,%r14),0(%r13)
Martin Schwidefskydc7ee002013-04-24 10:20:43 +02003992: la %r11,STACK_FRAME_OVERHEAD(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100400 stmg %r0,%r7,__PT_R0(%r11)
401 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
402 stmg %r8,%r9,__PT_PSW(%r11)
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100403 mvc __PT_INT_CODE(4,%r11),__LC_PGM_ILC
404 mvc __PT_INT_PARM_LONG(8,%r11),__LC_TRANS_EXC_CODE
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100405 stg %r10,__PT_ARGS(%r11)
406 tm __LC_PGM_ILC+3,0x80 # check for per exception
407 jz 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100408 tmhh %r8,0x0001 # kernel per event ?
409 jz pgm_kprobe
410 oi __TI_flags+7(%r12),_TIF_PER_TRAP
Martin Schwidefskyd35339a2012-07-31 11:03:04 +0200411 mvc __THREAD_per_address(8,%r14),__LC_PER_ADDRESS
412 mvc __THREAD_per_cause(2,%r14),__LC_PER_CAUSE
413 mvc __THREAD_per_paid(1,%r14),__LC_PER_PAID
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +01004140: REENABLE_IRQS
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100415 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200416 larl %r1,pgm_check_table
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100417 llgh %r10,__PT_INT_CODE+2(%r11)
418 nill %r10,0x007f
Heiko Carstensb01a37a2012-10-18 18:10:06 +0200419 sll %r10,2
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100420 je sysc_return
Heiko Carstensb01a37a2012-10-18 18:10:06 +0200421 lgf %r1,0(%r10,%r1) # load address of handler routine
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100422 lgr %r2,%r11 # pass pointer to pt_regs
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200423 basr %r14,%r1 # branch to interrupt-handler
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200424 j sysc_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425
426#
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100427# PER event in supervisor state, must be kprobes
428#
429pgm_kprobe:
430 REENABLE_IRQS
431 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
432 lgr %r2,%r11 # pass pointer to pt_regs
433 brasl %r14,do_per_trap
434 j sysc_return
435
436#
437# single stepped system call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438#
439pgm_svcper:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100440 oi __TI_flags+7(%r12),_TIF_PER_TRAP
441 mvc __LC_RETURN_PSW(8),__LC_SVC_NEW_PSW
442 larl %r14,sysc_per
443 stg %r14,__LC_RETURN_PSW+8
444 lpswe __LC_RETURN_PSW # branch to sysc_per and enable irqs
Michael Grundy4ba069b2006-09-20 15:58:39 +0200445
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446/*
447 * IO interrupt handler routine
448 */
Jan Glauber144d6342011-07-24 10:48:19 +0200449ENTRY(io_int_handler)
Heiko Carstens473e66b2012-05-09 16:27:39 +0200450 STCK __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100451 stpt __LC_ASYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100452 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
453 lg %r10,__LC_LAST_BREAK
454 lg %r12,__LC_THREAD_INFO
455 larl %r13,system_call
456 lmg %r8,%r9,__LC_IO_OLD_PSW
Martin Schwidefsky7c470532013-05-17 14:41:37 +0200457 HANDLE_SIE_INTERCEPT %r14,2
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100458 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_STACK,STACK_SHIFT
459 tmhh %r8,0x0001 # interrupting from user?
460 jz io_skip
461 UPDATE_VTIME %r14,__LC_ASYNC_ENTER_TIMER
462 LAST_BREAK %r14
463io_skip:
464 stmg %r0,%r7,__PT_R0(%r11)
465 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
466 stmg %r8,%r9,__PT_PSW(%r11)
Martin Schwidefsky48f6b002013-06-17 14:54:02 +0200467 mvc __PT_INT_CODE(12,%r11),__LC_SUBCHANNEL_ID
Heiko Carstens1f194a42006-07-03 00:24:46 -0700468 TRACE_IRQS_OFF
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100469 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Martin Schwidefsky48f6b002013-06-17 14:54:02 +0200470io_loop:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100471 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky1f44a2252013-06-27 09:01:09 +0200472 lghi %r3,IO_INTERRUPT
473 tm __PT_INT_CODE+8(%r11),0x80 # adapter interrupt ?
474 jz io_call
475 lghi %r3,THIN_INTERRUPT
476io_call:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100477 brasl %r14,do_IRQ
Martin Schwidefsky48f6b002013-06-17 14:54:02 +0200478 tm __LC_MACHINE_FLAGS+6,0x10 # MACHINE_FLAG_LPAR
479 jz io_return
480 tpi 0
481 jz io_return
482 mvc __PT_INT_CODE(12,%r11),__LC_SUBCHANNEL_ID
483 j io_loop
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484io_return:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200485 LOCKDEP_SYS_EXIT
486 TRACE_IRQS_ON
487io_tif:
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200488 tm __TI_flags+7(%r12),_TIF_WORK_INT
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200489 jnz io_work # there is work to do (signals etc.)
Heiko Carstens411788e2007-11-20 11:13:32 +0100490io_restore:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100491 lg %r14,__LC_VDSO_PER_CPU
492 lmg %r0,%r10,__PT_R0(%r11)
493 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100494 stpt __LC_EXIT_TIMER
495 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
496 lmg %r11,%r15,__PT_R11(%r11)
497 lpswe __LC_RETURN_PSW
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700498io_done:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499
Martin Schwidefsky26889052008-05-07 09:22:52 +0200500#
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200501# There is work todo, find out in which context we have been interrupted:
502# 1) if we return to user space we can do all _TIF_WORK_INT work
503# 2) if we return to kernel code and kvm is enabled check if we need to
504# modify the psw to leave SIE
505# 3) if we return to kernel code and preemptive scheduling is enabled check
506# the preemption counter and if it is zero call preempt_schedule_irq
507# Before any work can be done, a switch to the kernel stack is required.
Martin Schwidefsky26889052008-05-07 09:22:52 +0200508#
509io_work:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100510 tm __PT_PSW+1(%r11),0x01 # returning to user ?
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200511 jo io_work_user # yes -> do resched & signal
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200512#ifdef CONFIG_PREEMPT
Martin Schwidefsky26889052008-05-07 09:22:52 +0200513 # check for preemptive scheduling
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200514 icm %r0,15,__TI_precount(%r12)
Martin Schwidefsky26889052008-05-07 09:22:52 +0200515 jnz io_restore # preemption is disabled
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200516 tm __TI_flags+7(%r12),_TIF_NEED_RESCHED
517 jno io_restore
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 # switch to kernel stack
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100519 lg %r1,__PT_R15(%r11)
520 aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
521 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
522 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
523 la %r11,STACK_FRAME_OVERHEAD(%r1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524 lgr %r15,%r1
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200525 # TRACE_IRQS_ON already done at io_return, call
526 # TRACE_IRQS_OFF to keep things symmetrical
527 TRACE_IRQS_OFF
528 brasl %r14,preempt_schedule_irq
529 j io_return
530#else
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200531 j io_restore
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200532#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200534#
535# Need to do work before returning to userspace, switch to kernel stack
536#
Martin Schwidefsky26889052008-05-07 09:22:52 +0200537io_work_user:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 lg %r1,__LC_KERNEL_STACK
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100539 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
540 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
541 la %r11,STACK_FRAME_OVERHEAD(%r1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 lgr %r15,%r1
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200543
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544#
545# One of the work bits is on. Find out which one.
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200546# Checked are: _TIF_SIGPENDING, _TIF_NOTIFY_RESUME, _TIF_NEED_RESCHED
Heiko Carstens54dfe5d2006-02-01 03:06:38 -0800547# and _TIF_MCCK_PENDING
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548#
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200549io_work_tif:
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200550 tm __TI_flags+7(%r12),_TIF_MCCK_PENDING
Heiko Carstens77fa2242005-06-25 14:55:30 -0700551 jo io_mcck_pending
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200552 tm __TI_flags+7(%r12),_TIF_NEED_RESCHED
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 jo io_reschedule
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200554 tm __TI_flags+7(%r12),_TIF_SIGPENDING
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200555 jo io_sigpending
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200556 tm __TI_flags+7(%r12),_TIF_NOTIFY_RESUME
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200557 jo io_notify_resume
558 j io_return # beware of critical section cleanup
Christian Borntraeger0eaeafa2008-05-07 09:22:53 +0200559
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560#
Heiko Carstens77fa2242005-06-25 14:55:30 -0700561# _TIF_MCCK_PENDING is set, call handler
562#
563io_mcck_pending:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200564 # TRACE_IRQS_ON already done at io_return
Heiko Carstensb771aea2007-07-27 12:29:18 +0200565 brasl %r14,s390_handle_mcck # TIF bit will be cleared by handler
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200566 TRACE_IRQS_OFF
567 j io_return
Heiko Carstens77fa2242005-06-25 14:55:30 -0700568
569#
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200571#
572io_reschedule:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200573 # TRACE_IRQS_ON already done at io_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100574 ssm __LC_SVC_NEW_PSW # reenable interrupts
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200575 brasl %r14,schedule # call scheduler
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100576 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100577 TRACE_IRQS_OFF
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200578 j io_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579
580#
Roland McGrath02a029b2008-04-30 00:53:08 -0700581# _TIF_SIGPENDING or is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582#
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200583io_sigpending:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200584 # TRACE_IRQS_ON already done at io_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100585 ssm __LC_SVC_NEW_PSW # reenable interrupts
586 lgr %r2,%r11 # pass pointer to pt_regs
587 brasl %r14,do_signal
588 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100589 TRACE_IRQS_OFF
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200590 j io_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200592#
593# _TIF_NOTIFY_RESUME or is set, call do_notify_resume
594#
595io_notify_resume:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200596 # TRACE_IRQS_ON already done at io_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100597 ssm __LC_SVC_NEW_PSW # reenable interrupts
598 lgr %r2,%r11 # pass pointer to pt_regs
599 brasl %r14,do_notify_resume
600 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200601 TRACE_IRQS_OFF
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200602 j io_return
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200603
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604/*
605 * External interrupt handler routine
606 */
Jan Glauber144d6342011-07-24 10:48:19 +0200607ENTRY(ext_int_handler)
Heiko Carstens473e66b2012-05-09 16:27:39 +0200608 STCK __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100609 stpt __LC_ASYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100610 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
611 lg %r10,__LC_LAST_BREAK
612 lg %r12,__LC_THREAD_INFO
613 larl %r13,system_call
614 lmg %r8,%r9,__LC_EXT_OLD_PSW
Martin Schwidefsky7c470532013-05-17 14:41:37 +0200615 HANDLE_SIE_INTERCEPT %r14,3
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100616 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_STACK,STACK_SHIFT
617 tmhh %r8,0x0001 # interrupting from user ?
618 jz ext_skip
619 UPDATE_VTIME %r14,__LC_ASYNC_ENTER_TIMER
620 LAST_BREAK %r14
621ext_skip:
622 stmg %r0,%r7,__PT_R0(%r11)
623 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
624 stmg %r8,%r9,__PT_PSW(%r11)
Martin Schwidefsky48f6b002013-06-17 14:54:02 +0200625 lghi %r1,__LC_EXT_PARAMS2
626 mvc __PT_INT_CODE(4,%r11),__LC_EXT_CPU_ADDR
627 mvc __PT_INT_PARM(4,%r11),__LC_EXT_PARAMS
628 mvc __PT_INT_PARM_LONG(8,%r11),0(%r1)
Heiko Carstens1f194a42006-07-03 00:24:46 -0700629 TRACE_IRQS_OFF
Michael Holzheu0de9db32012-05-09 16:27:35 +0200630 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100631 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky1f44a2252013-06-27 09:01:09 +0200632 lghi %r3,EXT_INTERRUPT
633 brasl %r14,do_IRQ
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 j io_return
635
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400636/*
637 * Load idle PSW. The second "half" of this function is in cleanup_idle.
638 */
639ENTRY(psw_idle)
Martin Schwidefsky27f6b412012-07-20 11:15:08 +0200640 stg %r3,__SF_EMPTY(%r15)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400641 larl %r1,psw_idle_lpsw+4
642 stg %r1,__SF_EMPTY+8(%r15)
Martin Schwidefsky27f6b412012-07-20 11:15:08 +0200643 STCK __CLOCK_IDLE_ENTER(%r2)
644 stpt __TIMER_IDLE_ENTER(%r2)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400645psw_idle_lpsw:
646 lpswe __SF_EMPTY(%r15)
647 br %r14
648psw_idle_end:
649
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700650__critical_end:
651
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652/*
653 * Machine check handler routines
654 */
Jan Glauber144d6342011-07-24 10:48:19 +0200655ENTRY(mcck_int_handler)
Heiko Carstens473e66b2012-05-09 16:27:39 +0200656 STCK __LC_MCCK_CLOCK
Heiko Carstens77fa2242005-06-25 14:55:30 -0700657 la %r1,4095 # revalidate r1
658 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # revalidate cpu timer
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200659 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# revalidate gprs
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100660 lg %r10,__LC_LAST_BREAK
661 lg %r12,__LC_THREAD_INFO
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200662 larl %r13,system_call
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100663 lmg %r8,%r9,__LC_MCK_OLD_PSW
Martin Schwidefsky7c470532013-05-17 14:41:37 +0200664 HANDLE_SIE_INTERCEPT %r14,4
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200665 tm __LC_MCCK_CODE,0x80 # system damage?
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100666 jo mcck_panic # yes -> rest of mcck code invalid
667 lghi %r14,__LC_CPU_TIMER_SAVE_AREA
668 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200669 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100670 jo 3f
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200671 la %r14,__LC_SYNC_ENTER_TIMER
672 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
673 jl 0f
674 la %r14,__LC_ASYNC_ENTER_TIMER
6750: clc 0(8,%r14),__LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100676 jl 1f
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200677 la %r14,__LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +01006781: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
679 jl 2f
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200680 la %r14,__LC_LAST_UPDATE_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +01006812: spt 0(%r14)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200682 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
Martin Schwidefskyc5328902011-12-27 11:27:15 +01006833: tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid?
684 jno mcck_panic # no -> skip cleanup critical
685 SWITCH_ASYNC __LC_GPREGS_SAVE_AREA+64,__LC_PANIC_STACK,PAGE_SHIFT
686 tm %r8,0x0001 # interrupting from user ?
687 jz mcck_skip
688 UPDATE_VTIME %r14,__LC_MCCK_ENTER_TIMER
689 LAST_BREAK %r14
690mcck_skip:
Martin Schwidefsky6551fbd2013-02-28 16:28:41 +0100691 lghi %r14,__LC_GPREGS_SAVE_AREA+64
692 stmg %r0,%r7,__PT_R0(%r11)
693 mvc __PT_R8(64,%r11),0(%r14)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100694 stmg %r8,%r9,__PT_PSW(%r11)
695 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
696 lgr %r2,%r11 # pass pointer to pt_regs
Heiko Carstens77fa2242005-06-25 14:55:30 -0700697 brasl %r14,s390_do_machine_check
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100698 tm __PT_PSW+1(%r11),0x01 # returning to user ?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700699 jno mcck_return
700 lg %r1,__LC_KERNEL_STACK # switch to kernel stack
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100701 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
702 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
703 la %r11,STACK_FRAME_OVERHEAD(%r1)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700704 lgr %r15,%r1
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100705 ssm __LC_PGM_NEW_PSW # turn dat on, keep irqs off
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200706 tm __TI_flags+7(%r12),_TIF_MCCK_PENDING
Heiko Carstens77fa2242005-06-25 14:55:30 -0700707 jno mcck_return
Heiko Carstens1f194a42006-07-03 00:24:46 -0700708 TRACE_IRQS_OFF
Heiko Carstens77fa2242005-06-25 14:55:30 -0700709 brasl %r14,s390_handle_mcck
Heiko Carstens1f194a42006-07-03 00:24:46 -0700710 TRACE_IRQS_ON
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711mcck_return:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100712 lg %r14,__LC_VDSO_PER_CPU
713 lmg %r0,%r10,__PT_R0(%r11)
714 mvc __LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200715 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
716 jno 0f
717 stpt __LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100718 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
7190: lmg %r11,%r15,__PT_R11(%r11)
720 lpswe __LC_RETURN_MCCK_PSW
721
722mcck_panic:
723 lg %r14,__LC_PANIC_STACK
724 slgr %r14,%r15
725 srag %r14,%r14,PAGE_SHIFT
726 jz 0f
727 lg %r15,__LC_PANIC_STACK
7280: aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
729 j mcck_skip
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730
Michael Holzheu7dd6b332011-08-03 16:44:19 +0200731#
732# PSW restart interrupt handler
733#
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400734ENTRY(restart_int_handler)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100735 stg %r15,__LC_SAVE_AREA_RESTART
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400736 lg %r15,__LC_RESTART_STACK
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100737 aghi %r15,-__PT_SIZE # create pt_regs on stack
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400738 xc 0(__PT_SIZE,%r15),0(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100739 stmg %r0,%r14,__PT_R0(%r15)
740 mvc __PT_R15(8,%r15),__LC_SAVE_AREA_RESTART
741 mvc __PT_PSW(16,%r15),__LC_RST_OLD_PSW # store restart old psw
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400742 aghi %r15,-STACK_FRAME_OVERHEAD # create stack frame on stack
743 xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15)
Heiko Carstensfbe76562012-06-05 09:59:52 +0200744 lg %r1,__LC_RESTART_FN # load fn, parm & source cpu
745 lg %r2,__LC_RESTART_DATA
746 lg %r3,__LC_RESTART_SOURCE
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400747 ltgr %r3,%r3 # test source cpu address
748 jm 1f # negative -> skip source stop
Heiko Carstenseb546192012-06-04 15:05:43 +02007490: sigp %r4,%r3,SIGP_SENSE # sigp sense to source cpu
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400750 brc 10,0b # wait for status stored
7511: basr %r14,%r1 # call function
752 stap __SF_EMPTY(%r15) # store cpu address
753 llgh %r3,__SF_EMPTY(%r15)
Heiko Carstenseb546192012-06-04 15:05:43 +02007542: sigp %r4,%r3,SIGP_STOP # sigp stop to current cpu
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400755 brc 2,2b
7563: j 3b
Michael Holzheu7dd6b332011-08-03 16:44:19 +0200757
Martin Schwidefsky860dba42011-01-05 12:47:25 +0100758 .section .kprobes.text, "ax"
759
Linus Torvalds1da177e2005-04-16 15:20:36 -0700760#ifdef CONFIG_CHECK_STACK
761/*
762 * The synchronous or the asynchronous stack overflowed. We are dead.
763 * No need to properly save the registers, we are going to panic anyway.
764 * Setup a pt_regs so that show_trace can provide a good call trace.
765 */
766stack_overflow:
Martin Schwidefskydc7ee002013-04-24 10:20:43 +0200767 lg %r15,__LC_PANIC_STACK # change to panic stack
768 la %r11,STACK_FRAME_OVERHEAD(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100769 stmg %r0,%r7,__PT_R0(%r11)
770 stmg %r8,%r9,__PT_PSW(%r11)
771 mvc __PT_R8(64,%r11),0(%r14)
772 stg %r10,__PT_ORIG_GPR2(%r11) # store last break to orig_gpr2
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100773 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
774 lgr %r2,%r11 # pass pointer to pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 jg kernel_stack_overflow
776#endif
777
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100778 .align 8
779cleanup_table:
780 .quad system_call
781 .quad sysc_do_svc
782 .quad sysc_tif
783 .quad sysc_restore
784 .quad sysc_done
785 .quad io_tif
786 .quad io_restore
787 .quad io_done
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400788 .quad psw_idle
789 .quad psw_idle_end
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790
791cleanup_critical:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100792 clg %r9,BASED(cleanup_table) # system_call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 jl 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100794 clg %r9,BASED(cleanup_table+8) # sysc_do_svc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795 jl cleanup_system_call
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100796 clg %r9,BASED(cleanup_table+16) # sysc_tif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 jl 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100798 clg %r9,BASED(cleanup_table+24) # sysc_restore
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200799 jl cleanup_sysc_tif
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100800 clg %r9,BASED(cleanup_table+32) # sysc_done
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200801 jl cleanup_sysc_restore
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100802 clg %r9,BASED(cleanup_table+40) # io_tif
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200803 jl 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100804 clg %r9,BASED(cleanup_table+48) # io_restore
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200805 jl cleanup_io_tif
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100806 clg %r9,BASED(cleanup_table+56) # io_done
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200807 jl cleanup_io_restore
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400808 clg %r9,BASED(cleanup_table+64) # psw_idle
809 jl 0f
810 clg %r9,BASED(cleanup_table+72) # psw_idle_end
811 jl cleanup_idle
Martin Schwidefskyc5328902011-12-27 11:27:15 +01008120: br %r14
813
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814
815cleanup_system_call:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100816 # check if stpt has been executed
817 clg %r9,BASED(cleanup_system_call_insn)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818 jh 0f
819 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100820 cghi %r11,__LC_SAVE_AREA_ASYNC
Martin Schwidefsky63779812010-05-17 10:00:03 +0200821 je 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100822 mvc __LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER
8230: # check if stmg has been executed
824 clg %r9,BASED(cleanup_system_call_insn+8)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825 jh 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100826 mvc __LC_SAVE_AREA_SYNC(64),0(%r11)
8270: # check if base register setup + TIF bit load has been done
828 clg %r9,BASED(cleanup_system_call_insn+16)
829 jhe 0f
830 # set up saved registers r10 and r12
831 stg %r10,16(%r11) # r10 last break
832 stg %r12,32(%r11) # r12 thread-info pointer
8330: # check if the user time update has been done
834 clg %r9,BASED(cleanup_system_call_insn+24)
835 jh 0f
836 lg %r15,__LC_EXIT_TIMER
837 slg %r15,__LC_SYNC_ENTER_TIMER
838 alg %r15,__LC_USER_TIMER
839 stg %r15,__LC_USER_TIMER
8400: # check if the system time update has been done
841 clg %r9,BASED(cleanup_system_call_insn+32)
842 jh 0f
843 lg %r15,__LC_LAST_UPDATE_TIMER
844 slg %r15,__LC_EXIT_TIMER
845 alg %r15,__LC_SYSTEM_TIMER
846 stg %r15,__LC_SYSTEM_TIMER
8470: # update accounting time stamp
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100849 # do LAST_BREAK
850 lg %r9,16(%r11)
851 srag %r9,%r9,23
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200852 jz 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100853 mvc __TI_last_break(8,%r12),16(%r11)
8540: # set up saved register r11
855 lg %r15,__LC_KERNEL_STACK
Martin Schwidefskydc7ee002013-04-24 10:20:43 +0200856 la %r9,STACK_FRAME_OVERHEAD(%r15)
857 stg %r9,24(%r11) # r11 pt_regs pointer
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100858 # fill pt_regs
Martin Schwidefskydc7ee002013-04-24 10:20:43 +0200859 mvc __PT_R8(64,%r9),__LC_SAVE_AREA_SYNC
860 stmg %r0,%r7,__PT_R0(%r9)
861 mvc __PT_PSW(16,%r9),__LC_SVC_OLD_PSW
862 mvc __PT_INT_CODE(4,%r9),__LC_SVC_ILC
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100863 # setup saved register r15
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100864 stg %r15,56(%r11) # r15 stack pointer
865 # set new psw address and exit
866 larl %r9,sysc_do_svc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700867 br %r14
868cleanup_system_call_insn:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200869 .quad system_call
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100870 .quad sysc_stmg
871 .quad sysc_per
872 .quad sysc_vtime+18
873 .quad sysc_vtime+42
Linus Torvalds1da177e2005-04-16 15:20:36 -0700874
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200875cleanup_sysc_tif:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100876 larl %r9,sysc_tif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700877 br %r14
878
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200879cleanup_sysc_restore:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100880 clg %r9,BASED(cleanup_sysc_restore_insn)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200881 je 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100882 lg %r9,24(%r11) # get saved pointer to pt_regs
883 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
884 mvc 0(64,%r11),__PT_R8(%r9)
885 lmg %r0,%r7,__PT_R0(%r9)
8860: lmg %r8,%r9,__LC_RETURN_PSW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700887 br %r14
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200888cleanup_sysc_restore_insn:
Heiko Carstens411788e2007-11-20 11:13:32 +0100889 .quad sysc_done - 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700890
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200891cleanup_io_tif:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100892 larl %r9,io_tif
Martin Schwidefsky176b1802010-04-09 13:43:00 +0200893 br %r14
894
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200895cleanup_io_restore:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100896 clg %r9,BASED(cleanup_io_restore_insn)
897 je 0f
898 lg %r9,24(%r11) # get saved r11 pointer to pt_regs
899 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100900 mvc 0(64,%r11),__PT_R8(%r9)
901 lmg %r0,%r7,__PT_R0(%r9)
9020: lmg %r8,%r9,__LC_RETURN_PSW
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700903 br %r14
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200904cleanup_io_restore_insn:
Heiko Carstens411788e2007-11-20 11:13:32 +0100905 .quad io_done - 4
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700906
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400907cleanup_idle:
908 # copy interrupt clock & cpu timer
Martin Schwidefsky27f6b412012-07-20 11:15:08 +0200909 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_INT_CLOCK
910 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_ASYNC_ENTER_TIMER
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400911 cghi %r11,__LC_SAVE_AREA_ASYNC
912 je 0f
Martin Schwidefsky27f6b412012-07-20 11:15:08 +0200913 mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_MCCK_CLOCK
914 mvc __TIMER_IDLE_EXIT(8,%r2),__LC_MCCK_ENTER_TIMER
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -04009150: # check if stck & stpt have been executed
916 clg %r9,BASED(cleanup_idle_insn)
917 jhe 1f
Martin Schwidefsky27f6b412012-07-20 11:15:08 +0200918 mvc __CLOCK_IDLE_ENTER(8,%r2),__CLOCK_IDLE_EXIT(%r2)
919 mvc __TIMER_IDLE_ENTER(8,%r2),__TIMER_IDLE_EXIT(%r2)
9201: # account system time going idle
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400921 lg %r9,__LC_STEAL_TIMER
Martin Schwidefsky27f6b412012-07-20 11:15:08 +0200922 alg %r9,__CLOCK_IDLE_ENTER(%r2)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400923 slg %r9,__LC_LAST_UPDATE_CLOCK
924 stg %r9,__LC_STEAL_TIMER
Martin Schwidefsky27f6b412012-07-20 11:15:08 +0200925 mvc __LC_LAST_UPDATE_CLOCK(8),__CLOCK_IDLE_EXIT(%r2)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400926 lg %r9,__LC_SYSTEM_TIMER
927 alg %r9,__LC_LAST_UPDATE_TIMER
Martin Schwidefsky27f6b412012-07-20 11:15:08 +0200928 slg %r9,__TIMER_IDLE_ENTER(%r2)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400929 stg %r9,__LC_SYSTEM_TIMER
Martin Schwidefsky27f6b412012-07-20 11:15:08 +0200930 mvc __LC_LAST_UPDATE_TIMER(8),__TIMER_IDLE_EXIT(%r2)
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400931 # prepare return psw
932 nihh %r8,0xfffd # clear wait state bit
933 lg %r9,48(%r11) # return from psw_idle
934 br %r14
935cleanup_idle_insn:
936 .quad psw_idle_lpsw
937
Linus Torvalds1da177e2005-04-16 15:20:36 -0700938/*
939 * Integer constants
940 */
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100941 .align 8
Linus Torvalds1da177e2005-04-16 15:20:36 -0700942.Lcritical_start:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100943 .quad __critical_start
944.Lcritical_length:
945 .quad __critical_end - __critical_start
946
Linus Torvalds1da177e2005-04-16 15:20:36 -0700947
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200948#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
949/*
950 * sie64a calling convention:
951 * %r2 pointer to sie control block
952 * %r3 guest register save area
953 */
Jan Glauber144d6342011-07-24 10:48:19 +0200954ENTRY(sie64a)
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200955 stmg %r6,%r14,__SF_GPRS(%r15) # save kernel registers
956 stg %r2,__SF_EMPTY(%r15) # save control block pointer
957 stg %r3,__SF_EMPTY+8(%r15) # save guest register save area
Martin Schwidefsky7c470532013-05-17 14:41:37 +0200958 xc __SF_EMPTY+16(16,%r15),__SF_EMPTY+16(%r15) # host id & reason
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200959 lmg %r0,%r13,0(%r3) # load guest gprs 0-13
Christian Borntraeger480e5922011-09-20 17:07:28 +0200960 lg %r14,__LC_GMAP # get gmap pointer
961 ltgr %r14,%r14
962 jz sie_gmap
963 lctlg %c1,%c1,__GMAP_ASCE(%r14) # load primary asce
964sie_gmap:
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200965 lg %r14,__SF_EMPTY(%r15) # get control block pointer
Christian Borntraeger49b99e12013-05-17 14:41:35 +0200966 oi __SIE_PROG0C+3(%r14),1 # we are going into SIE now
967 tm __SIE_PROG20+3(%r14),1 # last exit...
968 jnz sie_done
Hendrik Brueckner23d18e82013-02-11 18:11:09 +0100969 LPP __SF_EMPTY(%r15) # set guest id
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200970 sie 0(%r14)
971sie_done:
Hendrik Brueckner23d18e82013-02-11 18:11:09 +0100972 LPP __SF_EMPTY+16(%r15) # set host id
Christian Borntraeger95d38fd2013-05-17 14:41:34 +0200973 ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE
Christian Borntraeger480e5922011-09-20 17:07:28 +0200974 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
Martin Schwidefsky7c470532013-05-17 14:41:37 +0200975# some program checks are suppressing. C code (e.g. do_protection_exception)
976# will rewind the PSW by the ILC, which is 4 bytes in case of SIE. Other
977# instructions beween sie64a and sie_done should not cause program
978# interrupts. So lets use a nop (47 00 00 00) as a landing pad.
979# See also HANDLE_SIE_INTERCEPT
980rewind_pad:
981 nop 0
Heinz Graalfsb764bb12013-06-12 13:54:56 +0200982 .globl sie_exit
Martin Schwidefsky7c470532013-05-17 14:41:37 +0200983sie_exit:
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200984 lg %r14,__SF_EMPTY+8(%r15) # load guest register save area
985 stmg %r0,%r13,0(%r14) # save guest gprs 0-13
986 lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers
Martin Schwidefsky7c470532013-05-17 14:41:37 +0200987 lg %r2,__SF_EMPTY+24(%r15) # return exit reason code
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200988 br %r14
989sie_fault:
Martin Schwidefsky7c470532013-05-17 14:41:37 +0200990 lghi %r14,-EFAULT
991 stg %r14,__SF_EMPTY+24(%r15) # set exit reason code
992 j sie_exit
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200993
994 .align 8
Martin Schwidefsky7c470532013-05-17 14:41:37 +0200995.Lsie_critical:
996 .quad sie_gmap
997.Lsie_critical_length:
998 .quad sie_done - sie_gmap
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200999
Christian Borntraegerce6a04a2012-11-15 09:35:16 +01001000 EX_TABLE(rewind_pad,sie_fault)
Martin Schwidefsky7c470532013-05-17 14:41:37 +02001001 EX_TABLE(sie_exit,sie_fault)
Martin Schwidefsky603d1a52011-07-24 10:48:18 +02001002#endif
1003
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001004 .section .rodata, "a"
Linus Torvalds1da177e2005-04-16 15:20:36 -07001005#define SYSCALL(esa,esame,emu) .long esame
Heiko Carstens9bf12262009-06-12 10:26:47 +02001006 .globl sys_call_table
Linus Torvalds1da177e2005-04-16 15:20:36 -07001007sys_call_table:
1008#include "syscalls.S"
1009#undef SYSCALL
1010
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -08001011#ifdef CONFIG_COMPAT
Linus Torvalds1da177e2005-04-16 15:20:36 -07001012
1013#define SYSCALL(esa,esame,emu) .long emu
Martin Schwidefsky61649882013-04-24 12:58:39 +02001014 .globl sys_call_table_emu
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015sys_call_table_emu:
1016#include "syscalls.S"
1017#undef SYSCALL
1018#endif