blob: 6b5ea904e99703d59db7afcec8e2c9e4391f34e3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Heiko Carstens54dfe5d2006-02-01 03:06:38 -08002 * arch/s390/kernel/entry64.S
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * S390 low-level entry points.
4 *
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -04005 * Copyright (C) IBM Corp. 1999,2012
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
Heiko Carstens25d83cb2006-09-28 16:56:37 +02007 * Hartmut Penner (hp@de.ibm.com),
8 * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
Heiko Carstens77fa2242005-06-25 14:55:30 -07009 * Heiko Carstens <heiko.carstens@de.ibm.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 */
11
Heiko Carstens2bc89b52008-02-05 16:50:40 +010012#include <linux/init.h>
Jan Glauber144d6342011-07-24 10:48:19 +020013#include <linux/linkage.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <asm/cache.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <asm/errno.h>
16#include <asm/ptrace.h>
17#include <asm/thread_info.h>
Sam Ravnborg0013a852005-09-09 20:57:26 +020018#include <asm/asm-offsets.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <asm/unistd.h>
20#include <asm/page.h>
21
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 Schwidefsky603d1a52011-07-24 10:48:18 +020084 tm __TI_flags+6(%r12),_TIF_SIE>>8
Martin Schwidefskyc5328902011-12-27 11:27:15 +010085 jz .+42
86 tm __LC_MACHINE_FLAGS+6,0x20 # MACHINE_FLAG_SPP
87 jz .+8
88 .insn s,0xb2800000,BASED(.Lhost_id) # set host id
89 lgr \scratch,%r9
90 slg \scratch,BASED(.Lsie_loop)
91 clg \scratch,BASED(.Lsie_length)
92 jhe .+10
93 lg %r9,BASED(.Lsie_loop)
Carsten Ottecd3b70f2010-05-17 10:00:04 +020094#endif
95 .endm
96
Martin Schwidefskyc5328902011-12-27 11:27:15 +010097 .macro CHECK_STACK stacksize,savearea
Martin Schwidefsky63b12242006-06-29 14:58:05 +020098#ifdef CONFIG_CHECK_STACK
Martin Schwidefskyc5328902011-12-27 11:27:15 +010099 tml %r15,\stacksize - CONFIG_STACK_GUARD
100 lghi %r14,\savearea
101 jz stack_overflow
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200102#endif
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200103 .endm
104
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100105 .macro SWITCH_ASYNC savearea,stack,shift
106 tmhh %r8,0x0001 # interrupting from user ?
107 jnz 1f
108 lgr %r14,%r9
109 slg %r14,BASED(.Lcritical_start)
110 clg %r14,BASED(.Lcritical_length)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 jhe 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100112 lghi %r11,\savearea # inside critical section, do cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 brasl %r14,cleanup_critical
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100114 tmhh %r8,0x0001 # retest problem state after cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 jnz 1f
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001160: lg %r14,\stack # are we already on the target stack?
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 slgr %r14,%r15
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100118 srag %r14,%r14,\shift
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200119 jnz 1f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100120 CHECK_STACK 1<<\shift,\savearea
121 j 2f
1221: lg %r15,\stack # load target stack
1232: aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
124 la %r11,STACK_FRAME_OVERHEAD(%r15)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700125 .endm
126
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100127 .macro UPDATE_VTIME scratch,enter_timer
128 lg \scratch,__LC_EXIT_TIMER
129 slg \scratch,\enter_timer
130 alg \scratch,__LC_USER_TIMER
131 stg \scratch,__LC_USER_TIMER
132 lg \scratch,__LC_LAST_UPDATE_TIMER
133 slg \scratch,__LC_EXIT_TIMER
134 alg \scratch,__LC_SYSTEM_TIMER
135 stg \scratch,__LC_SYSTEM_TIMER
136 mvc __LC_LAST_UPDATE_TIMER(8),\enter_timer
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200137 .endm
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100139 .macro LAST_BREAK scratch
140 srag \scratch,%r10,23
141 jz .+10
142 stg %r10,__TI_last_break(%r12)
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200143 .endm
144
Martin Schwidefsky1e546222010-10-25 16:10:37 +0200145 .macro REENABLE_IRQS
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100146 stg %r8,__LC_RETURN_PSW
147 ni __LC_RETURN_PSW,0xbf
148 ssm __LC_RETURN_PSW
Martin Schwidefsky1e546222010-10-25 16:10:37 +0200149 .endm
150
Martin Schwidefsky860dba42011-01-05 12:47:25 +0100151 .section .kprobes.text, "ax"
152
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153/*
154 * Scheduler resume function, called by switch_to
155 * gpr2 = (task_struct *) prev
156 * gpr3 = (task_struct *) next
157 * Returns:
158 * gpr2 = prev
159 */
Jan Glauber144d6342011-07-24 10:48:19 +0200160ENTRY(__switch_to)
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100161 lg %r4,__THREAD_info(%r2) # get thread_info of prev
162 lg %r5,__THREAD_info(%r3) # get thread_info of next
Heiko Carstens77fa2242005-06-25 14:55:30 -0700163 tm __TI_flags+7(%r4),_TIF_MCCK_PENDING # machine check pending?
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100164 jz 0f
165 ni __TI_flags+7(%r4),255-_TIF_MCCK_PENDING # clear flag in prev
166 oi __TI_flags+7(%r5),_TIF_MCCK_PENDING # set it in next
1670: stmg %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task
168 stg %r15,__THREAD_ksp(%r2) # store kernel stack of prev
169 lg %r15,__THREAD_ksp(%r3) # load kernel stack of next
170 lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4
171 lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task
172 stg %r3,__LC_CURRENT # store task struct of next
Heiko Carstensf2db2e62011-05-23 10:24:34 +0200173 mvc __LC_CURRENT_PID+4(4,%r0),__TASK_pid(%r3) # store pid of next
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100174 stg %r5,__LC_THREAD_INFO # store thread info of next
175 aghi %r5,STACK_SIZE # end of kernel stack of next
176 stg %r5,__LC_KERNEL_STACK # store end of kernel stack
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 br %r14
178
179__critical_start:
180/*
181 * SVC interrupt handler routine. System calls are synchronous events and
182 * are executed with interrupts enabled.
183 */
184
Jan Glauber144d6342011-07-24 10:48:19 +0200185ENTRY(system_call)
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100186 stpt __LC_SYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100187sysc_stmg:
188 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
189 lg %r10,__LC_LAST_BREAK
190 lg %r12,__LC_THREAD_INFO
191 larl %r13,system_call
192sysc_per:
193 lg %r15,__LC_KERNEL_STACK
194 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
195 la %r11,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196sysc_vtime:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100197 UPDATE_VTIME %r13,__LC_SYNC_ENTER_TIMER
198 LAST_BREAK %r13
199 stmg %r0,%r7,__PT_R0(%r11)
200 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
201 mvc __PT_PSW(16,%r11),__LC_SVC_OLD_PSW
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100202 mvc __PT_INT_CODE(4,%r11),__LC_SVC_ILC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203sysc_do_svc:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100204 oi __TI_flags+7(%r12),_TIF_SYSCALL
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100205 llgh %r8,__PT_INT_CODE+2(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100206 slag %r8,%r8,2 # shift and test for svc 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 jnz sysc_nr_ok
208 # svc 0: system call number in %r1
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100209 llgfr %r1,%r1 # clear high word in r1
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200210 cghi %r1,NR_syscalls
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 jnl sysc_nr_ok
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100212 sth %r1,__PT_INT_CODE+2(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100213 slag %r8,%r1,2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214sysc_nr_ok:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100215 larl %r10,sys_call_table # 64 bit system call table
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800216#ifdef CONFIG_COMPAT
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100217 tm __TI_flags+5(%r12),(_TIF_31BIT>>16)
Heiko Carstensc5630772005-09-03 15:58:04 -0700218 jno sysc_noemu
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100219 larl %r10,sys_call_table_emu # 31 bit system call table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220sysc_noemu:
221#endif
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100222 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
223 stg %r2,__PT_ORIG_GPR2(%r11)
224 stg %r7,STACK_FRAME_OVERHEAD(%r15)
225 lgf %r9,0(%r8,%r10) # get system call add.
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100226 tm __TI_flags+6(%r12),_TIF_TRACE >> 8
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200227 jnz sysc_tracesys
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100228 basr %r14,%r9 # call sys_xxxx
229 stg %r2,__PT_R2(%r11) # store return value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230
231sysc_return:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200232 LOCKDEP_SYS_EXIT
233sysc_tif:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100234 tm __PT_PSW+1(%r11),0x01 # returning to user ?
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100235 jno sysc_restore
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200236 tm __TI_flags+7(%r12),_TIF_WORK_SVC
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100237 jnz sysc_work # check for work
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100238 ni __TI_flags+7(%r12),255-_TIF_SYSCALL
Heiko Carstens411788e2007-11-20 11:13:32 +0100239sysc_restore:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100240 lg %r14,__LC_VDSO_PER_CPU
241 lmg %r0,%r10,__PT_R0(%r11)
242 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
243 stpt __LC_EXIT_TIMER
244 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
245 lmg %r11,%r15,__PT_R11(%r11)
246 lpswe __LC_RETURN_PSW
Heiko Carstens411788e2007-11-20 11:13:32 +0100247sysc_done:
248
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249#
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200250# One of the work bits is on. Find out which one.
251#
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100252sysc_work:
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200253 tm __TI_flags+7(%r12),_TIF_MCCK_PENDING
Heiko Carstens77fa2242005-06-25 14:55:30 -0700254 jo sysc_mcck_pending
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200255 tm __TI_flags+7(%r12),_TIF_NEED_RESCHED
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 jo sysc_reschedule
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200257 tm __TI_flags+7(%r12),_TIF_SIGPENDING
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200258 jo sysc_sigpending
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200259 tm __TI_flags+7(%r12),_TIF_NOTIFY_RESUME
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200260 jo sysc_notify_resume
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100261 tm __TI_flags+7(%r12),_TIF_PER_TRAP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 jo sysc_singlestep
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200263 j sysc_return # beware of critical section cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264
265#
266# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200267#
268sysc_reschedule:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200269 larl %r14,sysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100270 jg schedule
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271
272#
Heiko Carstens77fa2242005-06-25 14:55:30 -0700273# _TIF_MCCK_PENDING is set, call handler
274#
275sysc_mcck_pending:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200276 larl %r14,sysc_return
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200277 jg s390_handle_mcck # TIF bit will be cleared by handler
Heiko Carstens77fa2242005-06-25 14:55:30 -0700278
279#
Roland McGrath02a029b2008-04-30 00:53:08 -0700280# _TIF_SIGPENDING is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281#
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200282sysc_sigpending:
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100283 ni __TI_flags+7(%r12),255-_TIF_PER_TRAP # clear TIF_PER_TRAP
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100284 lgr %r2,%r11 # pass pointer to pt_regs
285 brasl %r14,do_signal
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100286 tm __TI_flags+7(%r12),_TIF_SYSCALL
287 jno sysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100288 lmg %r2,%r7,__PT_R2(%r11) # load svc arguments
289 lghi %r8,0 # svc 0 returns -ENOSYS
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100290 lh %r1,__PT_INT_CODE+2(%r11) # load new svc number
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100291 cghi %r1,NR_syscalls
292 jnl sysc_nr_ok # invalid svc number -> do svc 0
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100293 slag %r8,%r1,2
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100294 j sysc_nr_ok # restart svc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295
296#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200297# _TIF_NOTIFY_RESUME is set, call do_notify_resume
298#
299sysc_notify_resume:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100300 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200301 larl %r14,sysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100302 jg do_notify_resume
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200303
304#
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100305# _TIF_PER_TRAP is set, call do_per_trap
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306#
307sysc_singlestep:
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100308 ni __TI_flags+7(%r12),255-(_TIF_SYSCALL | _TIF_PER_TRAP)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100309 lgr %r2,%r11 # pass pointer to pt_regs
310 larl %r14,sysc_return
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100311 jg do_per_trap
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313#
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200314# call tracehook_report_syscall_entry/tracehook_report_syscall_exit before
315# and after the system call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316#
317sysc_tracesys:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100318 lgr %r2,%r11 # pass pointer to pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 la %r3,0
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100320 llgh %r0,__PT_INT_CODE+2(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100321 stg %r0,__PT_R2(%r11)
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200322 brasl %r14,do_syscall_trace_enter
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 lghi %r0,NR_syscalls
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200324 clgr %r0,%r2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 jnh sysc_tracenogo
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100326 sllg %r8,%r2,2
327 lgf %r9,0(%r8,%r10)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328sysc_tracego:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100329 lmg %r3,%r7,__PT_R3(%r11)
330 stg %r7,STACK_FRAME_OVERHEAD(%r15)
331 lg %r2,__PT_ORIG_GPR2(%r11)
332 basr %r14,%r9 # call sys_xxx
333 stg %r2,__PT_R2(%r11) # store return value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334sysc_tracenogo:
Martin Schwidefskyb6ef5bb2011-10-30 15:16:49 +0100335 tm __TI_flags+6(%r12),_TIF_TRACE >> 8
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200336 jz sysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100337 lgr %r2,%r11 # pass pointer to pt_regs
338 larl %r14,sysc_return
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200339 jg do_syscall_trace_exit
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340
341#
342# a new process exits the kernel with ret_from_fork
343#
Jan Glauber144d6342011-07-24 10:48:19 +0200344ENTRY(ret_from_fork)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100345 la %r11,STACK_FRAME_OVERHEAD(%r15)
346 lg %r12,__LC_THREAD_INFO
347 tm __PT_PSW+1(%r11),0x01 # forking a kernel thread ?
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 jo 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100349 stg %r15,__PT_R15(%r11) # store stack pointer for new kthread
Heiko Carstens25d83cb2006-09-28 16:56:37 +02003500: brasl %r14,schedule_tail
Heiko Carstens1f194a42006-07-03 00:24:46 -0700351 TRACE_IRQS_ON
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100352 ssm __LC_SVC_NEW_PSW # reenable interrupts
Al Viro8f2961c2008-12-25 13:37:58 +0100353 j sysc_tracenogo
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354
355#
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200356# kernel_execve function needs to deal with pt_regs that is not
357# at the usual place
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358#
Jan Glauber144d6342011-07-24 10:48:19 +0200359ENTRY(kernel_execve)
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200360 stmg %r12,%r15,96(%r15)
361 lgr %r14,%r15
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100362 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200363 stg %r14,__SF_BACKCHAIN(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100364 la %r12,STACK_FRAME_OVERHEAD(%r15)
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200365 xc 0(__PT_SIZE,%r12),0(%r12)
366 lgr %r5,%r12
367 brasl %r14,do_execve
368 ltgfr %r2,%r2
369 je 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100370 aghi %r15,(STACK_FRAME_OVERHEAD + __PT_SIZE)
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200371 lmg %r12,%r15,96(%r15)
372 br %r14
373 # execve succeeded.
Martin Schwidefskyc5328902011-12-27 11:27:15 +01003740: ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200375 lg %r15,__LC_KERNEL_STACK # load ksp
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100376 aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
377 la %r11,STACK_FRAME_OVERHEAD(%r15)
378 mvc 0(__PT_SIZE,%r11),0(%r12) # copy pt_regs
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200379 lg %r12,__LC_THREAD_INFO
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200380 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100381 ssm __LC_SVC_NEW_PSW # reenable interrupts
Martin Schwidefsky03ff9a22007-04-27 16:01:40 +0200382 brasl %r14,execve_tail
383 j sysc_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384
385/*
386 * Program check handler routine
387 */
388
Jan Glauber144d6342011-07-24 10:48:19 +0200389ENTRY(pgm_check_handler)
Martin Schwidefskyc185b782008-12-25 13:39:25 +0100390 stpt __LC_SYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100391 stmg %r8,%r15,__LC_SAVE_AREA_SYNC
392 lg %r10,__LC_LAST_BREAK
393 lg %r12,__LC_THREAD_INFO
394 larl %r13,system_call
395 lmg %r8,%r9,__LC_PGM_OLD_PSW
396 HANDLE_SIE_INTERCEPT %r14
397 tmhh %r8,0x0001 # test problem state bit
398 jnz 1f # -> fault in user space
399 tmhh %r8,0x4000 # PER bit set in old PSW ?
400 jnz 0f # -> enabled, can't be a double fault
401 tm __LC_PGM_ILC+3,0x80 # check for per exception
402 jnz pgm_svcper # -> single stepped svc
4030: CHECK_STACK STACK_SIZE,__LC_SAVE_AREA_SYNC
404 j 2f
4051: UPDATE_VTIME %r14,__LC_SYNC_ENTER_TIMER
406 LAST_BREAK %r14
407 lg %r15,__LC_KERNEL_STACK
4082: aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
409 la %r11,STACK_FRAME_OVERHEAD(%r15)
410 stmg %r0,%r7,__PT_R0(%r11)
411 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
412 stmg %r8,%r9,__PT_PSW(%r11)
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100413 mvc __PT_INT_CODE(4,%r11),__LC_PGM_ILC
414 mvc __PT_INT_PARM_LONG(8,%r11),__LC_TRANS_EXC_CODE
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100415 stg %r10,__PT_ARGS(%r11)
416 tm __LC_PGM_ILC+3,0x80 # check for per exception
417 jz 0f
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200418 lg %r1,__TI_task(%r12)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100419 tmhh %r8,0x0001 # kernel per event ?
420 jz pgm_kprobe
421 oi __TI_flags+7(%r12),_TIF_PER_TRAP
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100422 mvc __THREAD_per_address(8,%r1),__LC_PER_ADDRESS
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100423 mvc __THREAD_per_cause(2,%r1),__LC_PER_CAUSE
Martin Schwidefsky5e9a2692011-01-05 12:48:10 +0100424 mvc __THREAD_per_paid(1,%r1),__LC_PER_PAID
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +01004250: REENABLE_IRQS
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100426 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200427 larl %r1,pgm_check_table
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100428 llgh %r10,__PT_INT_CODE+2(%r11)
429 nill %r10,0x007f
430 sll %r10,3
431 je sysc_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100432 lg %r1,0(%r10,%r1) # load address of handler routine
433 lgr %r2,%r11 # pass pointer to pt_regs
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200434 basr %r14,%r1 # branch to interrupt-handler
Heiko Carstensf5cdac22010-07-27 19:29:37 +0200435 j sysc_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436
437#
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100438# PER event in supervisor state, must be kprobes
439#
440pgm_kprobe:
441 REENABLE_IRQS
442 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
443 lgr %r2,%r11 # pass pointer to pt_regs
444 brasl %r14,do_per_trap
445 j sysc_return
446
447#
448# single stepped system call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449#
450pgm_svcper:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100451 oi __TI_flags+7(%r12),_TIF_PER_TRAP
452 mvc __LC_RETURN_PSW(8),__LC_SVC_NEW_PSW
453 larl %r14,sysc_per
454 stg %r14,__LC_RETURN_PSW+8
455 lpswe __LC_RETURN_PSW # branch to sysc_per and enable irqs
Michael Grundy4ba069b2006-09-20 15:58:39 +0200456
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457/*
458 * IO interrupt handler routine
459 */
Jan Glauber144d6342011-07-24 10:48:19 +0200460ENTRY(io_int_handler)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461 stck __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100462 stpt __LC_ASYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100463 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
464 lg %r10,__LC_LAST_BREAK
465 lg %r12,__LC_THREAD_INFO
466 larl %r13,system_call
467 lmg %r8,%r9,__LC_IO_OLD_PSW
468 HANDLE_SIE_INTERCEPT %r14
469 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_STACK,STACK_SHIFT
470 tmhh %r8,0x0001 # interrupting from user?
471 jz io_skip
472 UPDATE_VTIME %r14,__LC_ASYNC_ENTER_TIMER
473 LAST_BREAK %r14
474io_skip:
475 stmg %r0,%r7,__PT_R0(%r11)
476 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
477 stmg %r8,%r9,__PT_PSW(%r11)
Heiko Carstens1f194a42006-07-03 00:24:46 -0700478 TRACE_IRQS_OFF
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100479 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
480 lgr %r2,%r11 # pass pointer to pt_regs
481 brasl %r14,do_IRQ
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482io_return:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200483 LOCKDEP_SYS_EXIT
484 TRACE_IRQS_ON
485io_tif:
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200486 tm __TI_flags+7(%r12),_TIF_WORK_INT
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200487 jnz io_work # there is work to do (signals etc.)
Heiko Carstens411788e2007-11-20 11:13:32 +0100488io_restore:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100489 lg %r14,__LC_VDSO_PER_CPU
490 lmg %r0,%r10,__PT_R0(%r11)
491 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100492 stpt __LC_EXIT_TIMER
493 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
494 lmg %r11,%r15,__PT_R11(%r11)
495 lpswe __LC_RETURN_PSW
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700496io_done:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497
Martin Schwidefsky26889052008-05-07 09:22:52 +0200498#
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200499# There is work todo, find out in which context we have been interrupted:
500# 1) if we return to user space we can do all _TIF_WORK_INT work
501# 2) if we return to kernel code and kvm is enabled check if we need to
502# modify the psw to leave SIE
503# 3) if we return to kernel code and preemptive scheduling is enabled check
504# the preemption counter and if it is zero call preempt_schedule_irq
505# Before any work can be done, a switch to the kernel stack is required.
Martin Schwidefsky26889052008-05-07 09:22:52 +0200506#
507io_work:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100508 tm __PT_PSW+1(%r11),0x01 # returning to user ?
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200509 jo io_work_user # yes -> do resched & signal
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200510#ifdef CONFIG_PREEMPT
Martin Schwidefsky26889052008-05-07 09:22:52 +0200511 # check for preemptive scheduling
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200512 icm %r0,15,__TI_precount(%r12)
Martin Schwidefsky26889052008-05-07 09:22:52 +0200513 jnz io_restore # preemption is disabled
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200514 tm __TI_flags+7(%r12),_TIF_NEED_RESCHED
515 jno io_restore
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516 # switch to kernel stack
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100517 lg %r1,__PT_R15(%r11)
518 aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
519 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
520 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
521 la %r11,STACK_FRAME_OVERHEAD(%r1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 lgr %r15,%r1
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200523 # TRACE_IRQS_ON already done at io_return, call
524 # TRACE_IRQS_OFF to keep things symmetrical
525 TRACE_IRQS_OFF
526 brasl %r14,preempt_schedule_irq
527 j io_return
528#else
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200529 j io_restore
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200530#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200532#
533# Need to do work before returning to userspace, switch to kernel stack
534#
Martin Schwidefsky26889052008-05-07 09:22:52 +0200535io_work_user:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 lg %r1,__LC_KERNEL_STACK
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100537 aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
538 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
539 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
540 la %r11,STACK_FRAME_OVERHEAD(%r1)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 lgr %r15,%r1
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200542
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543#
544# One of the work bits is on. Find out which one.
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200545# Checked are: _TIF_SIGPENDING, _TIF_NOTIFY_RESUME, _TIF_NEED_RESCHED
Heiko Carstens54dfe5d2006-02-01 03:06:38 -0800546# and _TIF_MCCK_PENDING
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547#
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200548io_work_tif:
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200549 tm __TI_flags+7(%r12),_TIF_MCCK_PENDING
Heiko Carstens77fa2242005-06-25 14:55:30 -0700550 jo io_mcck_pending
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200551 tm __TI_flags+7(%r12),_TIF_NEED_RESCHED
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 jo io_reschedule
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200553 tm __TI_flags+7(%r12),_TIF_SIGPENDING
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200554 jo io_sigpending
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200555 tm __TI_flags+7(%r12),_TIF_NOTIFY_RESUME
Martin Schwidefsky43d399d2010-05-17 10:00:01 +0200556 jo io_notify_resume
557 j io_return # beware of critical section cleanup
Christian Borntraeger0eaeafa2008-05-07 09:22:53 +0200558
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559#
Heiko Carstens77fa2242005-06-25 14:55:30 -0700560# _TIF_MCCK_PENDING is set, call handler
561#
562io_mcck_pending:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200563 # TRACE_IRQS_ON already done at io_return
Heiko Carstensb771aea2007-07-27 12:29:18 +0200564 brasl %r14,s390_handle_mcck # TIF bit will be cleared by handler
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200565 TRACE_IRQS_OFF
566 j io_return
Heiko Carstens77fa2242005-06-25 14:55:30 -0700567
568#
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569# _TIF_NEED_RESCHED is set, call schedule
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200570#
571io_reschedule:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200572 # TRACE_IRQS_ON already done at io_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100573 ssm __LC_SVC_NEW_PSW # reenable interrupts
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200574 brasl %r14,schedule # call scheduler
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100575 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100576 TRACE_IRQS_OFF
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200577 j io_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578
579#
Roland McGrath02a029b2008-04-30 00:53:08 -0700580# _TIF_SIGPENDING or is set, call do_signal
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581#
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200582io_sigpending:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200583 # TRACE_IRQS_ON already done at io_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100584 ssm __LC_SVC_NEW_PSW # reenable interrupts
585 lgr %r2,%r11 # pass pointer to pt_regs
586 brasl %r14,do_signal
587 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
Heiko Carstens411788e2007-11-20 11:13:32 +0100588 TRACE_IRQS_OFF
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200589 j io_return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200591#
592# _TIF_NOTIFY_RESUME or is set, call do_notify_resume
593#
594io_notify_resume:
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200595 # TRACE_IRQS_ON already done at io_return
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100596 ssm __LC_SVC_NEW_PSW # reenable interrupts
597 lgr %r2,%r11 # pass pointer to pt_regs
598 brasl %r14,do_notify_resume
599 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200600 TRACE_IRQS_OFF
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200601 j io_return
Martin Schwidefsky753c4dd2008-10-10 21:33:20 +0200602
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603/*
604 * External interrupt handler routine
605 */
Jan Glauber144d6342011-07-24 10:48:19 +0200606ENTRY(ext_int_handler)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607 stck __LC_INT_CLOCK
Martin Schwidefsky9cfb9b32008-12-31 15:11:41 +0100608 stpt __LC_ASYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100609 stmg %r8,%r15,__LC_SAVE_AREA_ASYNC
610 lg %r10,__LC_LAST_BREAK
611 lg %r12,__LC_THREAD_INFO
612 larl %r13,system_call
613 lmg %r8,%r9,__LC_EXT_OLD_PSW
614 HANDLE_SIE_INTERCEPT %r14
615 SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_STACK,STACK_SHIFT
616 tmhh %r8,0x0001 # interrupting from user ?
617 jz ext_skip
618 UPDATE_VTIME %r14,__LC_ASYNC_ENTER_TIMER
619 LAST_BREAK %r14
620ext_skip:
621 stmg %r0,%r7,__PT_R0(%r11)
622 mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC
623 stmg %r8,%r9,__PT_PSW(%r11)
Heiko Carstens1f194a42006-07-03 00:24:46 -0700624 TRACE_IRQS_OFF
Michael Holzheu0de9db32012-05-09 16:27:35 +0200625 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
Martin Schwidefskyf6649a72010-10-25 16:10:38 +0200626 lghi %r1,4096
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100627 lgr %r2,%r11 # pass pointer to pt_regs
Martin Schwidefsky7e180bd2012-03-11 11:59:25 -0400628 llgf %r3,__LC_EXT_CPU_ADDR # get cpu address + interruption code
Martin Schwidefskyf6649a72010-10-25 16:10:38 +0200629 llgf %r4,__LC_EXT_PARAMS # get external parameter
630 lg %r5,__LC_EXT_PARAMS2-4096(%r1) # get 64 bit external parameter
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200631 brasl %r14,do_extint
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632 j io_return
633
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400634/*
635 * Load idle PSW. The second "half" of this function is in cleanup_idle.
636 */
637ENTRY(psw_idle)
638 stg %r4,__SF_EMPTY(%r15)
639 larl %r1,psw_idle_lpsw+4
640 stg %r1,__SF_EMPTY+8(%r15)
641 larl %r1,.Lvtimer_max
642 stck __IDLE_ENTER(%r2)
643 ltr %r5,%r5
644 stpt __VQ_IDLE_ENTER(%r3)
645 jz psw_idle_lpsw
646 spt 0(%r1)
647psw_idle_lpsw:
648 lpswe __SF_EMPTY(%r15)
649 br %r14
650psw_idle_end:
651
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700652__critical_end:
653
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654/*
655 * Machine check handler routines
656 */
Jan Glauber144d6342011-07-24 10:48:19 +0200657ENTRY(mcck_int_handler)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200658 stck __LC_MCCK_CLOCK
Heiko Carstens77fa2242005-06-25 14:55:30 -0700659 la %r1,4095 # revalidate r1
660 spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # revalidate cpu timer
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200661 lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# revalidate gprs
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100662 lg %r10,__LC_LAST_BREAK
663 lg %r12,__LC_THREAD_INFO
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200664 larl %r13,system_call
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100665 lmg %r8,%r9,__LC_MCK_OLD_PSW
666 HANDLE_SIE_INTERCEPT %r14
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200667 tm __LC_MCCK_CODE,0x80 # system damage?
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100668 jo mcck_panic # yes -> rest of mcck code invalid
669 lghi %r14,__LC_CPU_TIMER_SAVE_AREA
670 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200671 tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid?
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100672 jo 3f
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200673 la %r14,__LC_SYNC_ENTER_TIMER
674 clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER
675 jl 0f
676 la %r14,__LC_ASYNC_ENTER_TIMER
6770: clc 0(8,%r14),__LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100678 jl 1f
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200679 la %r14,__LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +01006801: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER
681 jl 2f
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200682 la %r14,__LC_LAST_UPDATE_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +01006832: spt 0(%r14)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200684 mvc __LC_MCCK_ENTER_TIMER(8),0(%r14)
Martin Schwidefskyc5328902011-12-27 11:27:15 +01006853: tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid?
686 jno mcck_panic # no -> skip cleanup critical
687 SWITCH_ASYNC __LC_GPREGS_SAVE_AREA+64,__LC_PANIC_STACK,PAGE_SHIFT
688 tm %r8,0x0001 # interrupting from user ?
689 jz mcck_skip
690 UPDATE_VTIME %r14,__LC_MCCK_ENTER_TIMER
691 LAST_BREAK %r14
692mcck_skip:
693 lghi %r14,__LC_GPREGS_SAVE_AREA
694 mvc __PT_R0(128,%r11),0(%r14)
695 stmg %r8,%r9,__PT_PSW(%r11)
696 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
697 lgr %r2,%r11 # pass pointer to pt_regs
Heiko Carstens77fa2242005-06-25 14:55:30 -0700698 brasl %r14,s390_do_machine_check
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100699 tm __PT_PSW+1(%r11),0x01 # returning to user ?
Heiko Carstens77fa2242005-06-25 14:55:30 -0700700 jno mcck_return
701 lg %r1,__LC_KERNEL_STACK # switch to kernel stack
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100702 aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
703 mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11)
704 xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1)
705 la %r11,STACK_FRAME_OVERHEAD(%r1)
Heiko Carstens77fa2242005-06-25 14:55:30 -0700706 lgr %r15,%r1
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100707 ssm __LC_PGM_NEW_PSW # turn dat on, keep irqs off
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200708 tm __TI_flags+7(%r12),_TIF_MCCK_PENDING
Heiko Carstens77fa2242005-06-25 14:55:30 -0700709 jno mcck_return
Heiko Carstens1f194a42006-07-03 00:24:46 -0700710 TRACE_IRQS_OFF
Heiko Carstens77fa2242005-06-25 14:55:30 -0700711 brasl %r14,s390_handle_mcck
Heiko Carstens1f194a42006-07-03 00:24:46 -0700712 TRACE_IRQS_ON
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713mcck_return:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100714 lg %r14,__LC_VDSO_PER_CPU
715 lmg %r0,%r10,__PT_R0(%r11)
716 mvc __LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200717 tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ?
718 jno 0f
719 stpt __LC_EXIT_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100720 mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER
7210: lmg %r11,%r15,__PT_R11(%r11)
722 lpswe __LC_RETURN_MCCK_PSW
723
724mcck_panic:
725 lg %r14,__LC_PANIC_STACK
726 slgr %r14,%r15
727 srag %r14,%r14,PAGE_SHIFT
728 jz 0f
729 lg %r15,__LC_PANIC_STACK
7300: aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE)
731 j mcck_skip
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732
Michael Holzheu7dd6b332011-08-03 16:44:19 +0200733#
734# PSW restart interrupt handler
735#
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400736ENTRY(restart_int_handler)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100737 stg %r15,__LC_SAVE_AREA_RESTART
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400738 lg %r15,__LC_RESTART_STACK
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100739 aghi %r15,-__PT_SIZE # create pt_regs on stack
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400740 xc 0(__PT_SIZE,%r15),0(%r15)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100741 stmg %r0,%r14,__PT_R0(%r15)
742 mvc __PT_R15(8,%r15),__LC_SAVE_AREA_RESTART
743 mvc __PT_PSW(16,%r15),__LC_RST_OLD_PSW # store restart old psw
Martin Schwidefsky8b646bd2012-03-11 11:59:26 -0400744 aghi %r15,-STACK_FRAME_OVERHEAD # create stack frame on stack
745 xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15)
746 lmg %r1,%r3,__LC_RESTART_FN # load fn, parm & source cpu
747 ltgr %r3,%r3 # test source cpu address
748 jm 1f # negative -> skip source stop
7490: sigp %r4,%r3,1 # sigp sense to source cpu
750 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)
7542: sigp %r4,%r3,5 # sigp stop to current cpu
755 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 Schwidefskyc5328902011-12-27 11:27:15 +0100767 lg %r11,__LC_PANIC_STACK # change to panic stack
768 aghi %r11,-__PT_SIZE # create pt_regs
769 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
773 lgr %r15,%r11
774 aghi %r15,-STACK_FRAME_OVERHEAD
775 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
776 lgr %r2,%r11 # pass pointer to pt_regs
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777 jg kernel_stack_overflow
778#endif
779
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100780 .align 8
781cleanup_table:
782 .quad system_call
783 .quad sysc_do_svc
784 .quad sysc_tif
785 .quad sysc_restore
786 .quad sysc_done
787 .quad io_tif
788 .quad io_restore
789 .quad io_done
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400790 .quad psw_idle
791 .quad psw_idle_end
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792
793cleanup_critical:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100794 clg %r9,BASED(cleanup_table) # system_call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795 jl 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100796 clg %r9,BASED(cleanup_table+8) # sysc_do_svc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 jl cleanup_system_call
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100798 clg %r9,BASED(cleanup_table+16) # sysc_tif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799 jl 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100800 clg %r9,BASED(cleanup_table+24) # sysc_restore
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200801 jl cleanup_sysc_tif
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100802 clg %r9,BASED(cleanup_table+32) # sysc_done
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200803 jl cleanup_sysc_restore
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100804 clg %r9,BASED(cleanup_table+40) # io_tif
Martin Schwidefsky63b12242006-06-29 14:58:05 +0200805 jl 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100806 clg %r9,BASED(cleanup_table+48) # io_restore
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200807 jl cleanup_io_tif
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100808 clg %r9,BASED(cleanup_table+56) # io_done
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200809 jl cleanup_io_restore
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400810 clg %r9,BASED(cleanup_table+64) # psw_idle
811 jl 0f
812 clg %r9,BASED(cleanup_table+72) # psw_idle_end
813 jl cleanup_idle
Martin Schwidefskyc5328902011-12-27 11:27:15 +01008140: br %r14
815
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816
817cleanup_system_call:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100818 # check if stpt has been executed
819 clg %r9,BASED(cleanup_system_call_insn)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820 jh 0f
821 mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100822 cghi %r11,__LC_SAVE_AREA_ASYNC
Martin Schwidefsky63779812010-05-17 10:00:03 +0200823 je 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100824 mvc __LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER
8250: # check if stmg has been executed
826 clg %r9,BASED(cleanup_system_call_insn+8)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827 jh 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100828 mvc __LC_SAVE_AREA_SYNC(64),0(%r11)
8290: # check if base register setup + TIF bit load has been done
830 clg %r9,BASED(cleanup_system_call_insn+16)
831 jhe 0f
832 # set up saved registers r10 and r12
833 stg %r10,16(%r11) # r10 last break
834 stg %r12,32(%r11) # r12 thread-info pointer
8350: # check if the user time update has been done
836 clg %r9,BASED(cleanup_system_call_insn+24)
837 jh 0f
838 lg %r15,__LC_EXIT_TIMER
839 slg %r15,__LC_SYNC_ENTER_TIMER
840 alg %r15,__LC_USER_TIMER
841 stg %r15,__LC_USER_TIMER
8420: # check if the system time update has been done
843 clg %r9,BASED(cleanup_system_call_insn+32)
844 jh 0f
845 lg %r15,__LC_LAST_UPDATE_TIMER
846 slg %r15,__LC_EXIT_TIMER
847 alg %r15,__LC_SYSTEM_TIMER
848 stg %r15,__LC_SYSTEM_TIMER
8490: # update accounting time stamp
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850 mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100851 # do LAST_BREAK
852 lg %r9,16(%r11)
853 srag %r9,%r9,23
Martin Schwidefsky86f25522010-05-17 10:00:05 +0200854 jz 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100855 mvc __TI_last_break(8,%r12),16(%r11)
8560: # set up saved register r11
857 lg %r15,__LC_KERNEL_STACK
858 aghi %r15,-__PT_SIZE
859 stg %r15,24(%r11) # r11 pt_regs pointer
860 # fill pt_regs
861 mvc __PT_R8(64,%r15),__LC_SAVE_AREA_SYNC
862 stmg %r0,%r7,__PT_R0(%r15)
863 mvc __PT_PSW(16,%r15),__LC_SVC_OLD_PSW
Martin Schwidefskyaa33c8c2011-12-27 11:27:18 +0100864 mvc __PT_INT_CODE(4,%r15),__LC_SVC_ILC
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100865 # setup saved register r15
866 aghi %r15,-STACK_FRAME_OVERHEAD
867 stg %r15,56(%r11) # r15 stack pointer
868 # set new psw address and exit
869 larl %r9,sysc_do_svc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870 br %r14
871cleanup_system_call_insn:
Heiko Carstens25d83cb2006-09-28 16:56:37 +0200872 .quad system_call
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100873 .quad sysc_stmg
874 .quad sysc_per
875 .quad sysc_vtime+18
876 .quad sysc_vtime+42
Linus Torvalds1da177e2005-04-16 15:20:36 -0700877
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200878cleanup_sysc_tif:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100879 larl %r9,sysc_tif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700880 br %r14
881
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200882cleanup_sysc_restore:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100883 clg %r9,BASED(cleanup_sysc_restore_insn)
Martin Schwidefsky63779812010-05-17 10:00:03 +0200884 je 0f
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100885 lg %r9,24(%r11) # get saved pointer to pt_regs
886 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
887 mvc 0(64,%r11),__PT_R8(%r9)
888 lmg %r0,%r7,__PT_R0(%r9)
8890: lmg %r8,%r9,__LC_RETURN_PSW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700890 br %r14
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200891cleanup_sysc_restore_insn:
Heiko Carstens411788e2007-11-20 11:13:32 +0100892 .quad sysc_done - 4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700893
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200894cleanup_io_tif:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100895 larl %r9,io_tif
Martin Schwidefsky176b1802010-04-09 13:43:00 +0200896 br %r14
897
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200898cleanup_io_restore:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100899 clg %r9,BASED(cleanup_io_restore_insn)
900 je 0f
901 lg %r9,24(%r11) # get saved r11 pointer to pt_regs
902 mvc __LC_RETURN_PSW(16),__PT_PSW(%r9)
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100903 mvc 0(64,%r11),__PT_R8(%r9)
904 lmg %r0,%r7,__PT_R0(%r9)
9050: lmg %r8,%r9,__LC_RETURN_PSW
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700906 br %r14
Martin Schwidefsky6a2df3a2010-05-17 10:00:02 +0200907cleanup_io_restore_insn:
Heiko Carstens411788e2007-11-20 11:13:32 +0100908 .quad io_done - 4
Martin Schwidefskyae6aa2e2005-09-03 15:57:56 -0700909
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400910cleanup_idle:
911 # copy interrupt clock & cpu timer
912 mvc __IDLE_EXIT(8,%r2),__LC_INT_CLOCK
913 mvc __VQ_IDLE_EXIT(8,%r3),__LC_ASYNC_ENTER_TIMER
914 cghi %r11,__LC_SAVE_AREA_ASYNC
915 je 0f
916 mvc __IDLE_EXIT(8,%r2),__LC_MCCK_CLOCK
917 mvc __VQ_IDLE_EXIT(8,%r3),__LC_MCCK_ENTER_TIMER
9180: # check if stck & stpt have been executed
919 clg %r9,BASED(cleanup_idle_insn)
920 jhe 1f
921 mvc __IDLE_ENTER(8,%r2),__IDLE_EXIT(%r2)
922 mvc __VQ_IDLE_ENTER(8,%r3),__VQ_IDLE_EXIT(%r3)
923 j 2f
9241: # check if the cpu timer has been reprogrammed
925 ltr %r5,%r5
926 jz 2f
927 spt __VQ_IDLE_ENTER(%r3)
9282: # account system time going idle
929 lg %r9,__LC_STEAL_TIMER
930 alg %r9,__IDLE_ENTER(%r2)
931 slg %r9,__LC_LAST_UPDATE_CLOCK
932 stg %r9,__LC_STEAL_TIMER
933 mvc __LC_LAST_UPDATE_CLOCK(8),__IDLE_EXIT(%r2)
934 lg %r9,__LC_SYSTEM_TIMER
935 alg %r9,__LC_LAST_UPDATE_TIMER
936 slg %r9,__VQ_IDLE_ENTER(%r3)
937 stg %r9,__LC_SYSTEM_TIMER
938 mvc __LC_LAST_UPDATE_TIMER(8),__VQ_IDLE_EXIT(%r3)
939 # prepare return psw
940 nihh %r8,0xfffd # clear wait state bit
941 lg %r9,48(%r11) # return from psw_idle
942 br %r14
943cleanup_idle_insn:
944 .quad psw_idle_lpsw
945
Linus Torvalds1da177e2005-04-16 15:20:36 -0700946/*
947 * Integer constants
948 */
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100949 .align 8
Linus Torvalds1da177e2005-04-16 15:20:36 -0700950.Lcritical_start:
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100951 .quad __critical_start
952.Lcritical_length:
953 .quad __critical_end - __critical_start
Martin Schwidefsky4c1051e2012-03-11 11:59:27 -0400954.Lvtimer_max:
955 .quad 0x7fffffffffffffff
Martin Schwidefskyc5328902011-12-27 11:27:15 +0100956
Linus Torvalds1da177e2005-04-16 15:20:36 -0700957
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200958#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
959/*
960 * sie64a calling convention:
961 * %r2 pointer to sie control block
962 * %r3 guest register save area
963 */
Jan Glauber144d6342011-07-24 10:48:19 +0200964ENTRY(sie64a)
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200965 stmg %r6,%r14,__SF_GPRS(%r15) # save kernel registers
966 stg %r2,__SF_EMPTY(%r15) # save control block pointer
967 stg %r3,__SF_EMPTY+8(%r15) # save guest register save area
Martin Schwidefskyddd6f952011-12-27 11:27:13 +0100968 xc __SF_EMPTY+16(8,%r15),__SF_EMPTY+16(%r15) # host id == 0
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200969 lmg %r0,%r13,0(%r3) # load guest gprs 0-13
970 lg %r14,__LC_THREAD_INFO # pointer thread_info struct
971 oi __TI_flags+6(%r14),_TIF_SIE>>8
972sie_loop:
973 lg %r14,__LC_THREAD_INFO # pointer thread_info struct
974 tm __TI_flags+7(%r14),_TIF_EXIT_SIE
975 jnz sie_exit
Christian Borntraeger480e5922011-09-20 17:07:28 +0200976 lg %r14,__LC_GMAP # get gmap pointer
977 ltgr %r14,%r14
978 jz sie_gmap
979 lctlg %c1,%c1,__GMAP_ASCE(%r14) # load primary asce
980sie_gmap:
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200981 lg %r14,__SF_EMPTY(%r15) # get control block pointer
982 SPP __SF_EMPTY(%r15) # set guest id
983 sie 0(%r14)
984sie_done:
Martin Schwidefskyddd6f952011-12-27 11:27:13 +0100985 SPP __SF_EMPTY+16(%r15) # set host id
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200986 lg %r14,__LC_THREAD_INFO # pointer thread_info struct
987sie_exit:
Christian Borntraeger480e5922011-09-20 17:07:28 +0200988 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200989 ni __TI_flags+6(%r14),255-(_TIF_SIE>>8)
990 lg %r14,__SF_EMPTY+8(%r15) # load guest register save area
991 stmg %r0,%r13,0(%r14) # save guest gprs 0-13
992 lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers
993 lghi %r2,0
994 br %r14
995sie_fault:
Carsten Otte69ba9742011-10-30 15:16:59 +0100996 lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
Martin Schwidefsky603d1a52011-07-24 10:48:18 +0200997 lg %r14,__LC_THREAD_INFO # pointer thread_info struct
998 ni __TI_flags+6(%r14),255-(_TIF_SIE>>8)
999 lg %r14,__SF_EMPTY+8(%r15) # load guest register save area
1000 stmg %r0,%r13,0(%r14) # save guest gprs 0-13
1001 lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers
1002 lghi %r2,-EFAULT
1003 br %r14
1004
1005 .align 8
1006.Lsie_loop:
1007 .quad sie_loop
Martin Schwidefskyc5328902011-12-27 11:27:15 +01001008.Lsie_length:
1009 .quad sie_done - sie_loop
Martin Schwidefskyddd6f952011-12-27 11:27:13 +01001010.Lhost_id:
1011 .quad 0
Martin Schwidefsky603d1a52011-07-24 10:48:18 +02001012
1013 .section __ex_table,"a"
1014 .quad sie_loop,sie_fault
1015 .previous
1016#endif
1017
Heiko Carstens25d83cb2006-09-28 16:56:37 +02001018 .section .rodata, "a"
Linus Torvalds1da177e2005-04-16 15:20:36 -07001019#define SYSCALL(esa,esame,emu) .long esame
Heiko Carstens9bf12262009-06-12 10:26:47 +02001020 .globl sys_call_table
Linus Torvalds1da177e2005-04-16 15:20:36 -07001021sys_call_table:
1022#include "syscalls.S"
1023#undef SYSCALL
1024
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -08001025#ifdef CONFIG_COMPAT
Linus Torvalds1da177e2005-04-16 15:20:36 -07001026
1027#define SYSCALL(esa,esame,emu) .long emu
Linus Torvalds1da177e2005-04-16 15:20:36 -07001028sys_call_table_emu:
1029#include "syscalls.S"
1030#undef SYSCALL
1031#endif