Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * S390 low-level entry points. |
| 3 | * |
Heiko Carstens | a53c8fa | 2012-07-20 11:15:04 +0200 | [diff] [blame^] | 4 | * Copyright IBM Corp. 1999, 2012 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), |
Heiko Carstens | 25d83cb | 2006-09-28 16:56:37 +0200 | [diff] [blame] | 6 | * Hartmut Penner (hp@de.ibm.com), |
| 7 | * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com), |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 8 | * Heiko Carstens <heiko.carstens@de.ibm.com> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | */ |
| 10 | |
Heiko Carstens | 2bc89b5 | 2008-02-05 16:50:40 +0100 | [diff] [blame] | 11 | #include <linux/init.h> |
Jan Glauber | 144d634 | 2011-07-24 10:48:19 +0200 | [diff] [blame] | 12 | #include <linux/linkage.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <asm/cache.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <asm/errno.h> |
| 15 | #include <asm/ptrace.h> |
| 16 | #include <asm/thread_info.h> |
Sam Ravnborg | 0013a85 | 2005-09-09 20:57:26 +0200 | [diff] [blame] | 17 | #include <asm/asm-offsets.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <asm/unistd.h> |
| 19 | #include <asm/page.h> |
Heiko Carstens | eb54619 | 2012-06-04 15:05:43 +0200 | [diff] [blame] | 20 | #include <asm/sigp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 22 | __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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
| 39 | STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER |
| 40 | STACK_SIZE = 1 << STACK_SHIFT |
| 41 | |
Martin Schwidefsky | 753c4dd | 2008-10-10 21:33:20 +0200 | [diff] [blame] | 42 | _TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \ |
Martin Schwidefsky | b6ef5bb | 2011-10-30 15:16:49 +0100 | [diff] [blame] | 43 | _TIF_MCCK_PENDING | _TIF_PER_TRAP ) |
Martin Schwidefsky | 753c4dd | 2008-10-10 21:33:20 +0200 | [diff] [blame] | 44 | _TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \ |
Heiko Carstens | 54dfe5d | 2006-02-01 03:06:38 -0800 | [diff] [blame] | 45 | _TIF_MCCK_PENDING) |
Martin Schwidefsky | b6ef5bb | 2011-10-30 15:16:49 +0100 | [diff] [blame] | 46 | _TIF_TRACE = (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | \ |
| 47 | _TIF_SYSCALL_TRACEPOINT) |
Martin Schwidefsky | 603d1a5 | 2011-07-24 10:48:18 +0200 | [diff] [blame] | 48 | _TIF_EXIT_SIE = (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_MCCK_PENDING) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | #define BASED(name) name-system_call(%r13) |
| 51 | |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 52 | .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 Schwidefsky | 603d1a5 | 2011-07-24 10:48:18 +0200 | [diff] [blame] | 74 | .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 Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 82 | .macro HANDLE_SIE_INTERCEPT scratch |
Carsten Otte | cd3b70f | 2010-05-17 10:00:04 +0200 | [diff] [blame] | 83 | #if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE) |
Martin Schwidefsky | 6022afc | 2012-05-09 16:27:36 +0200 | [diff] [blame] | 84 | tmhh %r8,0x0001 # interrupting from user ? |
| 85 | jnz .+42 |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 86 | lgr \scratch,%r9 |
| 87 | slg \scratch,BASED(.Lsie_loop) |
| 88 | clg \scratch,BASED(.Lsie_length) |
Martin Schwidefsky | 6022afc | 2012-05-09 16:27:36 +0200 | [diff] [blame] | 89 | jhe .+22 |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 90 | lg %r9,BASED(.Lsie_loop) |
Heiko Carstens | 9ee39e4 | 2012-05-14 10:09:43 +0200 | [diff] [blame] | 91 | SPP BASED(.Lhost_id) # set host id |
Carsten Otte | cd3b70f | 2010-05-17 10:00:04 +0200 | [diff] [blame] | 92 | #endif |
| 93 | .endm |
| 94 | |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 95 | .macro CHECK_STACK stacksize,savearea |
Martin Schwidefsky | 63b1224 | 2006-06-29 14:58:05 +0200 | [diff] [blame] | 96 | #ifdef CONFIG_CHECK_STACK |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 97 | tml %r15,\stacksize - CONFIG_STACK_GUARD |
| 98 | lghi %r14,\savearea |
| 99 | jz stack_overflow |
Martin Schwidefsky | 63b1224 | 2006-06-29 14:58:05 +0200 | [diff] [blame] | 100 | #endif |
Martin Schwidefsky | 63b1224 | 2006-06-29 14:58:05 +0200 | [diff] [blame] | 101 | .endm |
| 102 | |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 103 | .macro SWITCH_ASYNC savearea,stack,shift |
| 104 | tmhh %r8,0x0001 # interrupting from user ? |
| 105 | jnz 1f |
| 106 | lgr %r14,%r9 |
| 107 | slg %r14,BASED(.Lcritical_start) |
| 108 | clg %r14,BASED(.Lcritical_length) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | jhe 0f |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 110 | lghi %r11,\savearea # inside critical section, do cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | brasl %r14,cleanup_critical |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 112 | tmhh %r8,0x0001 # retest problem state after cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | jnz 1f |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 114 | 0: lg %r14,\stack # are we already on the target stack? |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | slgr %r14,%r15 |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 116 | srag %r14,%r14,\shift |
Martin Schwidefsky | 86f2552 | 2010-05-17 10:00:05 +0200 | [diff] [blame] | 117 | jnz 1f |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 118 | CHECK_STACK 1<<\shift,\savearea |
| 119 | j 2f |
| 120 | 1: lg %r15,\stack # load target stack |
| 121 | 2: aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE) |
| 122 | la %r11,STACK_FRAME_OVERHEAD(%r15) |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 123 | .endm |
| 124 | |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 125 | .macro UPDATE_VTIME scratch,enter_timer |
| 126 | lg \scratch,__LC_EXIT_TIMER |
| 127 | slg \scratch,\enter_timer |
| 128 | alg \scratch,__LC_USER_TIMER |
| 129 | stg \scratch,__LC_USER_TIMER |
| 130 | lg \scratch,__LC_LAST_UPDATE_TIMER |
| 131 | slg \scratch,__LC_EXIT_TIMER |
| 132 | alg \scratch,__LC_SYSTEM_TIMER |
| 133 | stg \scratch,__LC_SYSTEM_TIMER |
| 134 | mvc __LC_LAST_UPDATE_TIMER(8),\enter_timer |
Heiko Carstens | 25d83cb | 2006-09-28 16:56:37 +0200 | [diff] [blame] | 135 | .endm |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 137 | .macro LAST_BREAK scratch |
| 138 | srag \scratch,%r10,23 |
| 139 | jz .+10 |
| 140 | stg %r10,__TI_last_break(%r12) |
Martin Schwidefsky | 86f2552 | 2010-05-17 10:00:05 +0200 | [diff] [blame] | 141 | .endm |
| 142 | |
Martin Schwidefsky | 1e54622 | 2010-10-25 16:10:37 +0200 | [diff] [blame] | 143 | .macro REENABLE_IRQS |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 144 | stg %r8,__LC_RETURN_PSW |
| 145 | ni __LC_RETURN_PSW,0xbf |
| 146 | ssm __LC_RETURN_PSW |
Martin Schwidefsky | 1e54622 | 2010-10-25 16:10:37 +0200 | [diff] [blame] | 147 | .endm |
| 148 | |
Heiko Carstens | 473e66b | 2012-05-09 16:27:39 +0200 | [diff] [blame] | 149 | .macro STCK savearea |
Heiko Carstens | d652d59 | 2012-05-14 10:35:22 +0200 | [diff] [blame] | 150 | #ifdef CONFIG_HAVE_MARCH_Z9_109_FEATURES |
Heiko Carstens | 473e66b | 2012-05-09 16:27:39 +0200 | [diff] [blame] | 151 | .insn s,0xb27c0000,\savearea # store clock fast |
| 152 | #else |
| 153 | .insn s,0xb2050000,\savearea # store clock |
| 154 | #endif |
| 155 | .endm |
| 156 | |
Martin Schwidefsky | 860dba4 | 2011-01-05 12:47:25 +0100 | [diff] [blame] | 157 | .section .kprobes.text, "ax" |
| 158 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | /* |
| 160 | * Scheduler resume function, called by switch_to |
| 161 | * gpr2 = (task_struct *) prev |
| 162 | * gpr3 = (task_struct *) next |
| 163 | * Returns: |
| 164 | * gpr2 = prev |
| 165 | */ |
Jan Glauber | 144d634 | 2011-07-24 10:48:19 +0200 | [diff] [blame] | 166 | ENTRY(__switch_to) |
Martin Schwidefsky | eda0c6d | 2012-05-15 09:20:06 +0200 | [diff] [blame] | 167 | stmg %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task |
| 168 | stg %r15,__THREAD_ksp(%r2) # store kernel stack of prev |
Martin Schwidefsky | 5e9a269 | 2011-01-05 12:48:10 +0100 | [diff] [blame] | 169 | lg %r4,__THREAD_info(%r2) # get thread_info of prev |
| 170 | lg %r5,__THREAD_info(%r3) # get thread_info of next |
Martin Schwidefsky | eda0c6d | 2012-05-15 09:20:06 +0200 | [diff] [blame] | 171 | lgr %r15,%r5 |
| 172 | aghi %r15,STACK_SIZE # end of kernel stack of next |
| 173 | stg %r3,__LC_CURRENT # store task struct of next |
| 174 | stg %r5,__LC_THREAD_INFO # store thread info of next |
| 175 | stg %r15,__LC_KERNEL_STACK # store end of kernel stack |
| 176 | lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4 |
| 177 | mvc __LC_CURRENT_PID+4(4,%r0),__TASK_pid(%r3) # store pid of next |
| 178 | lg %r15,__THREAD_ksp(%r3) # load kernel stack of next |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 179 | tm __TI_flags+7(%r4),_TIF_MCCK_PENDING # machine check pending? |
Martin Schwidefsky | 5e9a269 | 2011-01-05 12:48:10 +0100 | [diff] [blame] | 180 | jz 0f |
| 181 | ni __TI_flags+7(%r4),255-_TIF_MCCK_PENDING # clear flag in prev |
| 182 | oi __TI_flags+7(%r5),_TIF_MCCK_PENDING # set it in next |
Martin Schwidefsky | eda0c6d | 2012-05-15 09:20:06 +0200 | [diff] [blame] | 183 | 0: lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | br %r14 |
| 185 | |
| 186 | __critical_start: |
| 187 | /* |
| 188 | * SVC interrupt handler routine. System calls are synchronous events and |
| 189 | * are executed with interrupts enabled. |
| 190 | */ |
| 191 | |
Jan Glauber | 144d634 | 2011-07-24 10:48:19 +0200 | [diff] [blame] | 192 | ENTRY(system_call) |
Martin Schwidefsky | c185b78 | 2008-12-25 13:39:25 +0100 | [diff] [blame] | 193 | stpt __LC_SYNC_ENTER_TIMER |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 194 | sysc_stmg: |
| 195 | stmg %r8,%r15,__LC_SAVE_AREA_SYNC |
| 196 | lg %r10,__LC_LAST_BREAK |
| 197 | lg %r12,__LC_THREAD_INFO |
| 198 | larl %r13,system_call |
| 199 | sysc_per: |
| 200 | lg %r15,__LC_KERNEL_STACK |
| 201 | aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE) |
| 202 | la %r11,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | sysc_vtime: |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 204 | UPDATE_VTIME %r13,__LC_SYNC_ENTER_TIMER |
| 205 | LAST_BREAK %r13 |
| 206 | stmg %r0,%r7,__PT_R0(%r11) |
| 207 | mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC |
| 208 | mvc __PT_PSW(16,%r11),__LC_SVC_OLD_PSW |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 209 | mvc __PT_INT_CODE(4,%r11),__LC_SVC_ILC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | sysc_do_svc: |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 211 | oi __TI_flags+7(%r12),_TIF_SYSCALL |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 212 | llgh %r8,__PT_INT_CODE+2(%r11) |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 213 | slag %r8,%r8,2 # shift and test for svc 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | jnz sysc_nr_ok |
| 215 | # svc 0: system call number in %r1 |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 216 | llgfr %r1,%r1 # clear high word in r1 |
Martin Schwidefsky | 86f2552 | 2010-05-17 10:00:05 +0200 | [diff] [blame] | 217 | cghi %r1,NR_syscalls |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | jnl sysc_nr_ok |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 219 | sth %r1,__PT_INT_CODE+2(%r11) |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 220 | slag %r8,%r1,2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | sysc_nr_ok: |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 222 | larl %r10,sys_call_table # 64 bit system call table |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 223 | #ifdef CONFIG_COMPAT |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 224 | tm __TI_flags+5(%r12),(_TIF_31BIT>>16) |
Heiko Carstens | c563077 | 2005-09-03 15:58:04 -0700 | [diff] [blame] | 225 | jno sysc_noemu |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 226 | larl %r10,sys_call_table_emu # 31 bit system call table |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | sysc_noemu: |
| 228 | #endif |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 229 | xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) |
| 230 | stg %r2,__PT_ORIG_GPR2(%r11) |
| 231 | stg %r7,STACK_FRAME_OVERHEAD(%r15) |
| 232 | lgf %r9,0(%r8,%r10) # get system call add. |
Martin Schwidefsky | b6ef5bb | 2011-10-30 15:16:49 +0100 | [diff] [blame] | 233 | tm __TI_flags+6(%r12),_TIF_TRACE >> 8 |
Heiko Carstens | 25d83cb | 2006-09-28 16:56:37 +0200 | [diff] [blame] | 234 | jnz sysc_tracesys |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 235 | basr %r14,%r9 # call sys_xxxx |
| 236 | stg %r2,__PT_R2(%r11) # store return value |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | |
| 238 | sysc_return: |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 239 | LOCKDEP_SYS_EXIT |
| 240 | sysc_tif: |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 241 | tm __PT_PSW+1(%r11),0x01 # returning to user ? |
Martin Schwidefsky | b6ef5bb | 2011-10-30 15:16:49 +0100 | [diff] [blame] | 242 | jno sysc_restore |
Martin Schwidefsky | 86f2552 | 2010-05-17 10:00:05 +0200 | [diff] [blame] | 243 | tm __TI_flags+7(%r12),_TIF_WORK_SVC |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 244 | jnz sysc_work # check for work |
Martin Schwidefsky | b6ef5bb | 2011-10-30 15:16:49 +0100 | [diff] [blame] | 245 | ni __TI_flags+7(%r12),255-_TIF_SYSCALL |
Heiko Carstens | 411788e | 2007-11-20 11:13:32 +0100 | [diff] [blame] | 246 | sysc_restore: |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 247 | lg %r14,__LC_VDSO_PER_CPU |
| 248 | lmg %r0,%r10,__PT_R0(%r11) |
| 249 | mvc __LC_RETURN_PSW(16),__PT_PSW(%r11) |
| 250 | stpt __LC_EXIT_TIMER |
| 251 | mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER |
| 252 | lmg %r11,%r15,__PT_R11(%r11) |
| 253 | lpswe __LC_RETURN_PSW |
Heiko Carstens | 411788e | 2007-11-20 11:13:32 +0100 | [diff] [blame] | 254 | sysc_done: |
| 255 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | # |
Martin Schwidefsky | 43d399d | 2010-05-17 10:00:01 +0200 | [diff] [blame] | 257 | # One of the work bits is on. Find out which one. |
| 258 | # |
Martin Schwidefsky | b6ef5bb | 2011-10-30 15:16:49 +0100 | [diff] [blame] | 259 | sysc_work: |
Martin Schwidefsky | 86f2552 | 2010-05-17 10:00:05 +0200 | [diff] [blame] | 260 | tm __TI_flags+7(%r12),_TIF_MCCK_PENDING |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 261 | jo sysc_mcck_pending |
Martin Schwidefsky | 86f2552 | 2010-05-17 10:00:05 +0200 | [diff] [blame] | 262 | tm __TI_flags+7(%r12),_TIF_NEED_RESCHED |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | jo sysc_reschedule |
Martin Schwidefsky | 86f2552 | 2010-05-17 10:00:05 +0200 | [diff] [blame] | 264 | tm __TI_flags+7(%r12),_TIF_SIGPENDING |
Martin Schwidefsky | 43d399d | 2010-05-17 10:00:01 +0200 | [diff] [blame] | 265 | jo sysc_sigpending |
Martin Schwidefsky | 86f2552 | 2010-05-17 10:00:05 +0200 | [diff] [blame] | 266 | tm __TI_flags+7(%r12),_TIF_NOTIFY_RESUME |
Martin Schwidefsky | 43d399d | 2010-05-17 10:00:01 +0200 | [diff] [blame] | 267 | jo sysc_notify_resume |
Martin Schwidefsky | 5e9a269 | 2011-01-05 12:48:10 +0100 | [diff] [blame] | 268 | tm __TI_flags+7(%r12),_TIF_PER_TRAP |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | jo sysc_singlestep |
Martin Schwidefsky | 43d399d | 2010-05-17 10:00:01 +0200 | [diff] [blame] | 270 | j sysc_return # beware of critical section cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | |
| 272 | # |
| 273 | # _TIF_NEED_RESCHED is set, call schedule |
Heiko Carstens | 25d83cb | 2006-09-28 16:56:37 +0200 | [diff] [blame] | 274 | # |
| 275 | sysc_reschedule: |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 276 | larl %r14,sysc_return |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 277 | jg schedule |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | |
| 279 | # |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 280 | # _TIF_MCCK_PENDING is set, call handler |
| 281 | # |
| 282 | sysc_mcck_pending: |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 283 | larl %r14,sysc_return |
Heiko Carstens | 25d83cb | 2006-09-28 16:56:37 +0200 | [diff] [blame] | 284 | jg s390_handle_mcck # TIF bit will be cleared by handler |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 285 | |
| 286 | # |
Roland McGrath | 02a029b | 2008-04-30 00:53:08 -0700 | [diff] [blame] | 287 | # _TIF_SIGPENDING is set, call do_signal |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | # |
Heiko Carstens | 25d83cb | 2006-09-28 16:56:37 +0200 | [diff] [blame] | 289 | sysc_sigpending: |
Martin Schwidefsky | 5e9a269 | 2011-01-05 12:48:10 +0100 | [diff] [blame] | 290 | ni __TI_flags+7(%r12),255-_TIF_PER_TRAP # clear TIF_PER_TRAP |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 291 | lgr %r2,%r11 # pass pointer to pt_regs |
| 292 | brasl %r14,do_signal |
Martin Schwidefsky | b6ef5bb | 2011-10-30 15:16:49 +0100 | [diff] [blame] | 293 | tm __TI_flags+7(%r12),_TIF_SYSCALL |
| 294 | jno sysc_return |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 295 | lmg %r2,%r7,__PT_R2(%r11) # load svc arguments |
| 296 | lghi %r8,0 # svc 0 returns -ENOSYS |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 297 | lh %r1,__PT_INT_CODE+2(%r11) # load new svc number |
Martin Schwidefsky | b6ef5bb | 2011-10-30 15:16:49 +0100 | [diff] [blame] | 298 | cghi %r1,NR_syscalls |
| 299 | jnl sysc_nr_ok # invalid svc number -> do svc 0 |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 300 | slag %r8,%r1,2 |
Martin Schwidefsky | b6ef5bb | 2011-10-30 15:16:49 +0100 | [diff] [blame] | 301 | j sysc_nr_ok # restart svc |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | |
| 303 | # |
Martin Schwidefsky | 753c4dd | 2008-10-10 21:33:20 +0200 | [diff] [blame] | 304 | # _TIF_NOTIFY_RESUME is set, call do_notify_resume |
| 305 | # |
| 306 | sysc_notify_resume: |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 307 | lgr %r2,%r11 # pass pointer to pt_regs |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 308 | larl %r14,sysc_return |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 309 | jg do_notify_resume |
Martin Schwidefsky | 753c4dd | 2008-10-10 21:33:20 +0200 | [diff] [blame] | 310 | |
| 311 | # |
Martin Schwidefsky | 5e9a269 | 2011-01-05 12:48:10 +0100 | [diff] [blame] | 312 | # _TIF_PER_TRAP is set, call do_per_trap |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | # |
| 314 | sysc_singlestep: |
Martin Schwidefsky | b6ef5bb | 2011-10-30 15:16:49 +0100 | [diff] [blame] | 315 | ni __TI_flags+7(%r12),255-(_TIF_SYSCALL | _TIF_PER_TRAP) |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 316 | lgr %r2,%r11 # pass pointer to pt_regs |
| 317 | larl %r14,sysc_return |
Martin Schwidefsky | 5e9a269 | 2011-01-05 12:48:10 +0100 | [diff] [blame] | 318 | jg do_per_trap |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | # |
Martin Schwidefsky | 753c4dd | 2008-10-10 21:33:20 +0200 | [diff] [blame] | 321 | # call tracehook_report_syscall_entry/tracehook_report_syscall_exit before |
| 322 | # and after the system call |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | # |
| 324 | sysc_tracesys: |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 325 | lgr %r2,%r11 # pass pointer to pt_regs |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | la %r3,0 |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 327 | llgh %r0,__PT_INT_CODE+2(%r11) |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 328 | stg %r0,__PT_R2(%r11) |
Martin Schwidefsky | 753c4dd | 2008-10-10 21:33:20 +0200 | [diff] [blame] | 329 | brasl %r14,do_syscall_trace_enter |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | lghi %r0,NR_syscalls |
Martin Schwidefsky | 753c4dd | 2008-10-10 21:33:20 +0200 | [diff] [blame] | 331 | clgr %r0,%r2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | jnh sysc_tracenogo |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 333 | sllg %r8,%r2,2 |
| 334 | lgf %r9,0(%r8,%r10) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | sysc_tracego: |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 336 | lmg %r3,%r7,__PT_R3(%r11) |
| 337 | stg %r7,STACK_FRAME_OVERHEAD(%r15) |
| 338 | lg %r2,__PT_ORIG_GPR2(%r11) |
| 339 | basr %r14,%r9 # call sys_xxx |
| 340 | stg %r2,__PT_R2(%r11) # store return value |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | sysc_tracenogo: |
Martin Schwidefsky | b6ef5bb | 2011-10-30 15:16:49 +0100 | [diff] [blame] | 342 | tm __TI_flags+6(%r12),_TIF_TRACE >> 8 |
Heiko Carstens | 25d83cb | 2006-09-28 16:56:37 +0200 | [diff] [blame] | 343 | jz sysc_return |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 344 | lgr %r2,%r11 # pass pointer to pt_regs |
| 345 | larl %r14,sysc_return |
Martin Schwidefsky | 753c4dd | 2008-10-10 21:33:20 +0200 | [diff] [blame] | 346 | jg do_syscall_trace_exit |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | |
| 348 | # |
| 349 | # a new process exits the kernel with ret_from_fork |
| 350 | # |
Jan Glauber | 144d634 | 2011-07-24 10:48:19 +0200 | [diff] [blame] | 351 | ENTRY(ret_from_fork) |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 352 | la %r11,STACK_FRAME_OVERHEAD(%r15) |
| 353 | lg %r12,__LC_THREAD_INFO |
| 354 | tm __PT_PSW+1(%r11),0x01 # forking a kernel thread ? |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | jo 0f |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 356 | stg %r15,__PT_R15(%r11) # store stack pointer for new kthread |
Heiko Carstens | 25d83cb | 2006-09-28 16:56:37 +0200 | [diff] [blame] | 357 | 0: brasl %r14,schedule_tail |
Heiko Carstens | 1f194a4 | 2006-07-03 00:24:46 -0700 | [diff] [blame] | 358 | TRACE_IRQS_ON |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 359 | ssm __LC_SVC_NEW_PSW # reenable interrupts |
Al Viro | 8f2961c | 2008-12-25 13:37:58 +0100 | [diff] [blame] | 360 | j sysc_tracenogo |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | |
| 362 | # |
Martin Schwidefsky | 03ff9a2 | 2007-04-27 16:01:40 +0200 | [diff] [blame] | 363 | # kernel_execve function needs to deal with pt_regs that is not |
| 364 | # at the usual place |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | # |
Jan Glauber | 144d634 | 2011-07-24 10:48:19 +0200 | [diff] [blame] | 366 | ENTRY(kernel_execve) |
Martin Schwidefsky | 03ff9a2 | 2007-04-27 16:01:40 +0200 | [diff] [blame] | 367 | stmg %r12,%r15,96(%r15) |
| 368 | lgr %r14,%r15 |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 369 | aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE) |
Martin Schwidefsky | 03ff9a2 | 2007-04-27 16:01:40 +0200 | [diff] [blame] | 370 | stg %r14,__SF_BACKCHAIN(%r15) |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 371 | la %r12,STACK_FRAME_OVERHEAD(%r15) |
Martin Schwidefsky | 03ff9a2 | 2007-04-27 16:01:40 +0200 | [diff] [blame] | 372 | xc 0(__PT_SIZE,%r12),0(%r12) |
| 373 | lgr %r5,%r12 |
| 374 | brasl %r14,do_execve |
| 375 | ltgfr %r2,%r2 |
| 376 | je 0f |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 377 | aghi %r15,(STACK_FRAME_OVERHEAD + __PT_SIZE) |
Martin Schwidefsky | 03ff9a2 | 2007-04-27 16:01:40 +0200 | [diff] [blame] | 378 | lmg %r12,%r15,96(%r15) |
| 379 | br %r14 |
| 380 | # execve succeeded. |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 381 | 0: ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts |
Martin Schwidefsky | 03ff9a2 | 2007-04-27 16:01:40 +0200 | [diff] [blame] | 382 | lg %r15,__LC_KERNEL_STACK # load ksp |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 383 | aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE) |
| 384 | la %r11,STACK_FRAME_OVERHEAD(%r15) |
| 385 | mvc 0(__PT_SIZE,%r11),0(%r12) # copy pt_regs |
Martin Schwidefsky | 86f2552 | 2010-05-17 10:00:05 +0200 | [diff] [blame] | 386 | lg %r12,__LC_THREAD_INFO |
Martin Schwidefsky | 03ff9a2 | 2007-04-27 16:01:40 +0200 | [diff] [blame] | 387 | xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 388 | ssm __LC_SVC_NEW_PSW # reenable interrupts |
Martin Schwidefsky | 03ff9a2 | 2007-04-27 16:01:40 +0200 | [diff] [blame] | 389 | brasl %r14,execve_tail |
| 390 | j sysc_return |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | |
| 392 | /* |
| 393 | * Program check handler routine |
| 394 | */ |
| 395 | |
Jan Glauber | 144d634 | 2011-07-24 10:48:19 +0200 | [diff] [blame] | 396 | ENTRY(pgm_check_handler) |
Martin Schwidefsky | c185b78 | 2008-12-25 13:39:25 +0100 | [diff] [blame] | 397 | stpt __LC_SYNC_ENTER_TIMER |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 398 | stmg %r8,%r15,__LC_SAVE_AREA_SYNC |
| 399 | lg %r10,__LC_LAST_BREAK |
| 400 | lg %r12,__LC_THREAD_INFO |
| 401 | larl %r13,system_call |
| 402 | lmg %r8,%r9,__LC_PGM_OLD_PSW |
| 403 | HANDLE_SIE_INTERCEPT %r14 |
| 404 | tmhh %r8,0x0001 # test problem state bit |
| 405 | jnz 1f # -> fault in user space |
| 406 | tmhh %r8,0x4000 # PER bit set in old PSW ? |
| 407 | jnz 0f # -> enabled, can't be a double fault |
| 408 | tm __LC_PGM_ILC+3,0x80 # check for per exception |
| 409 | jnz pgm_svcper # -> single stepped svc |
| 410 | 0: CHECK_STACK STACK_SIZE,__LC_SAVE_AREA_SYNC |
| 411 | j 2f |
| 412 | 1: UPDATE_VTIME %r14,__LC_SYNC_ENTER_TIMER |
| 413 | LAST_BREAK %r14 |
| 414 | lg %r15,__LC_KERNEL_STACK |
| 415 | 2: aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE) |
| 416 | la %r11,STACK_FRAME_OVERHEAD(%r15) |
| 417 | stmg %r0,%r7,__PT_R0(%r11) |
| 418 | mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC |
| 419 | stmg %r8,%r9,__PT_PSW(%r11) |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 420 | mvc __PT_INT_CODE(4,%r11),__LC_PGM_ILC |
| 421 | mvc __PT_INT_PARM_LONG(8,%r11),__LC_TRANS_EXC_CODE |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 422 | stg %r10,__PT_ARGS(%r11) |
| 423 | tm __LC_PGM_ILC+3,0x80 # check for per exception |
| 424 | jz 0f |
Martin Schwidefsky | 86f2552 | 2010-05-17 10:00:05 +0200 | [diff] [blame] | 425 | lg %r1,__TI_task(%r12) |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 426 | tmhh %r8,0x0001 # kernel per event ? |
| 427 | jz pgm_kprobe |
| 428 | oi __TI_flags+7(%r12),_TIF_PER_TRAP |
Martin Schwidefsky | 5e9a269 | 2011-01-05 12:48:10 +0100 | [diff] [blame] | 429 | mvc __THREAD_per_address(8,%r1),__LC_PER_ADDRESS |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 430 | mvc __THREAD_per_cause(2,%r1),__LC_PER_CAUSE |
Martin Schwidefsky | 5e9a269 | 2011-01-05 12:48:10 +0100 | [diff] [blame] | 431 | mvc __THREAD_per_paid(1,%r1),__LC_PER_PAID |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 432 | 0: REENABLE_IRQS |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 433 | xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) |
Heiko Carstens | f5cdac2 | 2010-07-27 19:29:37 +0200 | [diff] [blame] | 434 | larl %r1,pgm_check_table |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 435 | llgh %r10,__PT_INT_CODE+2(%r11) |
| 436 | nill %r10,0x007f |
| 437 | sll %r10,3 |
| 438 | je sysc_return |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 439 | lg %r1,0(%r10,%r1) # load address of handler routine |
| 440 | lgr %r2,%r11 # pass pointer to pt_regs |
Heiko Carstens | f5cdac2 | 2010-07-27 19:29:37 +0200 | [diff] [blame] | 441 | basr %r14,%r1 # branch to interrupt-handler |
Heiko Carstens | f5cdac2 | 2010-07-27 19:29:37 +0200 | [diff] [blame] | 442 | j sysc_return |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | |
| 444 | # |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 445 | # PER event in supervisor state, must be kprobes |
| 446 | # |
| 447 | pgm_kprobe: |
| 448 | REENABLE_IRQS |
| 449 | xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) |
| 450 | lgr %r2,%r11 # pass pointer to pt_regs |
| 451 | brasl %r14,do_per_trap |
| 452 | j sysc_return |
| 453 | |
| 454 | # |
| 455 | # single stepped system call |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | # |
| 457 | pgm_svcper: |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 458 | oi __TI_flags+7(%r12),_TIF_PER_TRAP |
| 459 | mvc __LC_RETURN_PSW(8),__LC_SVC_NEW_PSW |
| 460 | larl %r14,sysc_per |
| 461 | stg %r14,__LC_RETURN_PSW+8 |
| 462 | lpswe __LC_RETURN_PSW # branch to sysc_per and enable irqs |
Michael Grundy | 4ba069b | 2006-09-20 15:58:39 +0200 | [diff] [blame] | 463 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | /* |
| 465 | * IO interrupt handler routine |
| 466 | */ |
Jan Glauber | 144d634 | 2011-07-24 10:48:19 +0200 | [diff] [blame] | 467 | ENTRY(io_int_handler) |
Heiko Carstens | 473e66b | 2012-05-09 16:27:39 +0200 | [diff] [blame] | 468 | STCK __LC_INT_CLOCK |
Martin Schwidefsky | 9cfb9b3 | 2008-12-31 15:11:41 +0100 | [diff] [blame] | 469 | stpt __LC_ASYNC_ENTER_TIMER |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 470 | stmg %r8,%r15,__LC_SAVE_AREA_ASYNC |
| 471 | lg %r10,__LC_LAST_BREAK |
| 472 | lg %r12,__LC_THREAD_INFO |
| 473 | larl %r13,system_call |
| 474 | lmg %r8,%r9,__LC_IO_OLD_PSW |
| 475 | HANDLE_SIE_INTERCEPT %r14 |
| 476 | SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_STACK,STACK_SHIFT |
| 477 | tmhh %r8,0x0001 # interrupting from user? |
| 478 | jz io_skip |
| 479 | UPDATE_VTIME %r14,__LC_ASYNC_ENTER_TIMER |
| 480 | LAST_BREAK %r14 |
| 481 | io_skip: |
| 482 | stmg %r0,%r7,__PT_R0(%r11) |
| 483 | mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC |
| 484 | stmg %r8,%r9,__PT_PSW(%r11) |
Heiko Carstens | 1f194a4 | 2006-07-03 00:24:46 -0700 | [diff] [blame] | 485 | TRACE_IRQS_OFF |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 486 | xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) |
| 487 | lgr %r2,%r11 # pass pointer to pt_regs |
| 488 | brasl %r14,do_IRQ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | io_return: |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 490 | LOCKDEP_SYS_EXIT |
| 491 | TRACE_IRQS_ON |
| 492 | io_tif: |
Martin Schwidefsky | 86f2552 | 2010-05-17 10:00:05 +0200 | [diff] [blame] | 493 | tm __TI_flags+7(%r12),_TIF_WORK_INT |
Heiko Carstens | 25d83cb | 2006-09-28 16:56:37 +0200 | [diff] [blame] | 494 | jnz io_work # there is work to do (signals etc.) |
Heiko Carstens | 411788e | 2007-11-20 11:13:32 +0100 | [diff] [blame] | 495 | io_restore: |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 496 | lg %r14,__LC_VDSO_PER_CPU |
| 497 | lmg %r0,%r10,__PT_R0(%r11) |
| 498 | mvc __LC_RETURN_PSW(16),__PT_PSW(%r11) |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 499 | stpt __LC_EXIT_TIMER |
| 500 | mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER |
| 501 | lmg %r11,%r15,__PT_R11(%r11) |
| 502 | lpswe __LC_RETURN_PSW |
Martin Schwidefsky | ae6aa2e | 2005-09-03 15:57:56 -0700 | [diff] [blame] | 503 | io_done: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | |
Martin Schwidefsky | 2688905 | 2008-05-07 09:22:52 +0200 | [diff] [blame] | 505 | # |
Martin Schwidefsky | 43d399d | 2010-05-17 10:00:01 +0200 | [diff] [blame] | 506 | # There is work todo, find out in which context we have been interrupted: |
| 507 | # 1) if we return to user space we can do all _TIF_WORK_INT work |
| 508 | # 2) if we return to kernel code and kvm is enabled check if we need to |
| 509 | # modify the psw to leave SIE |
| 510 | # 3) if we return to kernel code and preemptive scheduling is enabled check |
| 511 | # the preemption counter and if it is zero call preempt_schedule_irq |
| 512 | # Before any work can be done, a switch to the kernel stack is required. |
Martin Schwidefsky | 2688905 | 2008-05-07 09:22:52 +0200 | [diff] [blame] | 513 | # |
| 514 | io_work: |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 515 | tm __PT_PSW+1(%r11),0x01 # returning to user ? |
Martin Schwidefsky | 43d399d | 2010-05-17 10:00:01 +0200 | [diff] [blame] | 516 | jo io_work_user # yes -> do resched & signal |
Martin Schwidefsky | 43d399d | 2010-05-17 10:00:01 +0200 | [diff] [blame] | 517 | #ifdef CONFIG_PREEMPT |
Martin Schwidefsky | 2688905 | 2008-05-07 09:22:52 +0200 | [diff] [blame] | 518 | # check for preemptive scheduling |
Martin Schwidefsky | 86f2552 | 2010-05-17 10:00:05 +0200 | [diff] [blame] | 519 | icm %r0,15,__TI_precount(%r12) |
Martin Schwidefsky | 2688905 | 2008-05-07 09:22:52 +0200 | [diff] [blame] | 520 | jnz io_restore # preemption is disabled |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 521 | tm __TI_flags+7(%r12),_TIF_NEED_RESCHED |
| 522 | jno io_restore |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | # switch to kernel stack |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 524 | lg %r1,__PT_R15(%r11) |
| 525 | aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE) |
| 526 | mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11) |
| 527 | xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) |
| 528 | la %r11,STACK_FRAME_OVERHEAD(%r1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | lgr %r15,%r1 |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 530 | # TRACE_IRQS_ON already done at io_return, call |
| 531 | # TRACE_IRQS_OFF to keep things symmetrical |
| 532 | TRACE_IRQS_OFF |
| 533 | brasl %r14,preempt_schedule_irq |
| 534 | j io_return |
| 535 | #else |
Martin Schwidefsky | 43d399d | 2010-05-17 10:00:01 +0200 | [diff] [blame] | 536 | j io_restore |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 537 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | |
Martin Schwidefsky | 43d399d | 2010-05-17 10:00:01 +0200 | [diff] [blame] | 539 | # |
| 540 | # Need to do work before returning to userspace, switch to kernel stack |
| 541 | # |
Martin Schwidefsky | 2688905 | 2008-05-07 09:22:52 +0200 | [diff] [blame] | 542 | io_work_user: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | lg %r1,__LC_KERNEL_STACK |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 544 | aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE) |
| 545 | mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11) |
| 546 | xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) |
| 547 | la %r11,STACK_FRAME_OVERHEAD(%r1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | lgr %r15,%r1 |
Martin Schwidefsky | 43d399d | 2010-05-17 10:00:01 +0200 | [diff] [blame] | 549 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | # |
| 551 | # One of the work bits is on. Find out which one. |
Martin Schwidefsky | 43d399d | 2010-05-17 10:00:01 +0200 | [diff] [blame] | 552 | # Checked are: _TIF_SIGPENDING, _TIF_NOTIFY_RESUME, _TIF_NEED_RESCHED |
Heiko Carstens | 54dfe5d | 2006-02-01 03:06:38 -0800 | [diff] [blame] | 553 | # and _TIF_MCCK_PENDING |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | # |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 555 | io_work_tif: |
Martin Schwidefsky | 86f2552 | 2010-05-17 10:00:05 +0200 | [diff] [blame] | 556 | tm __TI_flags+7(%r12),_TIF_MCCK_PENDING |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 557 | jo io_mcck_pending |
Martin Schwidefsky | 86f2552 | 2010-05-17 10:00:05 +0200 | [diff] [blame] | 558 | tm __TI_flags+7(%r12),_TIF_NEED_RESCHED |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | jo io_reschedule |
Martin Schwidefsky | 86f2552 | 2010-05-17 10:00:05 +0200 | [diff] [blame] | 560 | tm __TI_flags+7(%r12),_TIF_SIGPENDING |
Martin Schwidefsky | 43d399d | 2010-05-17 10:00:01 +0200 | [diff] [blame] | 561 | jo io_sigpending |
Martin Schwidefsky | 86f2552 | 2010-05-17 10:00:05 +0200 | [diff] [blame] | 562 | tm __TI_flags+7(%r12),_TIF_NOTIFY_RESUME |
Martin Schwidefsky | 43d399d | 2010-05-17 10:00:01 +0200 | [diff] [blame] | 563 | jo io_notify_resume |
| 564 | j io_return # beware of critical section cleanup |
Christian Borntraeger | 0eaeafa | 2008-05-07 09:22:53 +0200 | [diff] [blame] | 565 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | # |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 567 | # _TIF_MCCK_PENDING is set, call handler |
| 568 | # |
| 569 | io_mcck_pending: |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 570 | # TRACE_IRQS_ON already done at io_return |
Heiko Carstens | b771aea | 2007-07-27 12:29:18 +0200 | [diff] [blame] | 571 | brasl %r14,s390_handle_mcck # TIF bit will be cleared by handler |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 572 | TRACE_IRQS_OFF |
| 573 | j io_return |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 574 | |
| 575 | # |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | # _TIF_NEED_RESCHED is set, call schedule |
Heiko Carstens | 25d83cb | 2006-09-28 16:56:37 +0200 | [diff] [blame] | 577 | # |
| 578 | io_reschedule: |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 579 | # TRACE_IRQS_ON already done at io_return |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 580 | ssm __LC_SVC_NEW_PSW # reenable interrupts |
Heiko Carstens | 25d83cb | 2006-09-28 16:56:37 +0200 | [diff] [blame] | 581 | brasl %r14,schedule # call scheduler |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 582 | ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts |
Heiko Carstens | 411788e | 2007-11-20 11:13:32 +0100 | [diff] [blame] | 583 | TRACE_IRQS_OFF |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 584 | j io_return |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | |
| 586 | # |
Roland McGrath | 02a029b | 2008-04-30 00:53:08 -0700 | [diff] [blame] | 587 | # _TIF_SIGPENDING or is set, call do_signal |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | # |
Heiko Carstens | 25d83cb | 2006-09-28 16:56:37 +0200 | [diff] [blame] | 589 | io_sigpending: |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 590 | # TRACE_IRQS_ON already done at io_return |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 591 | ssm __LC_SVC_NEW_PSW # reenable interrupts |
| 592 | lgr %r2,%r11 # pass pointer to pt_regs |
| 593 | brasl %r14,do_signal |
| 594 | ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts |
Heiko Carstens | 411788e | 2007-11-20 11:13:32 +0100 | [diff] [blame] | 595 | TRACE_IRQS_OFF |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 596 | j io_return |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | |
Martin Schwidefsky | 753c4dd | 2008-10-10 21:33:20 +0200 | [diff] [blame] | 598 | # |
| 599 | # _TIF_NOTIFY_RESUME or is set, call do_notify_resume |
| 600 | # |
| 601 | io_notify_resume: |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 602 | # TRACE_IRQS_ON already done at io_return |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 603 | ssm __LC_SVC_NEW_PSW # reenable interrupts |
| 604 | lgr %r2,%r11 # pass pointer to pt_regs |
| 605 | brasl %r14,do_notify_resume |
| 606 | ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts |
Martin Schwidefsky | 753c4dd | 2008-10-10 21:33:20 +0200 | [diff] [blame] | 607 | TRACE_IRQS_OFF |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 608 | j io_return |
Martin Schwidefsky | 753c4dd | 2008-10-10 21:33:20 +0200 | [diff] [blame] | 609 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | /* |
| 611 | * External interrupt handler routine |
| 612 | */ |
Jan Glauber | 144d634 | 2011-07-24 10:48:19 +0200 | [diff] [blame] | 613 | ENTRY(ext_int_handler) |
Heiko Carstens | 473e66b | 2012-05-09 16:27:39 +0200 | [diff] [blame] | 614 | STCK __LC_INT_CLOCK |
Martin Schwidefsky | 9cfb9b3 | 2008-12-31 15:11:41 +0100 | [diff] [blame] | 615 | stpt __LC_ASYNC_ENTER_TIMER |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 616 | stmg %r8,%r15,__LC_SAVE_AREA_ASYNC |
| 617 | lg %r10,__LC_LAST_BREAK |
| 618 | lg %r12,__LC_THREAD_INFO |
| 619 | larl %r13,system_call |
| 620 | lmg %r8,%r9,__LC_EXT_OLD_PSW |
| 621 | HANDLE_SIE_INTERCEPT %r14 |
| 622 | SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_STACK,STACK_SHIFT |
| 623 | tmhh %r8,0x0001 # interrupting from user ? |
| 624 | jz ext_skip |
| 625 | UPDATE_VTIME %r14,__LC_ASYNC_ENTER_TIMER |
| 626 | LAST_BREAK %r14 |
| 627 | ext_skip: |
| 628 | stmg %r0,%r7,__PT_R0(%r11) |
| 629 | mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC |
| 630 | stmg %r8,%r9,__PT_PSW(%r11) |
Heiko Carstens | 1f194a4 | 2006-07-03 00:24:46 -0700 | [diff] [blame] | 631 | TRACE_IRQS_OFF |
Michael Holzheu | 0de9db3 | 2012-05-09 16:27:35 +0200 | [diff] [blame] | 632 | xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) |
Martin Schwidefsky | f6649a7 | 2010-10-25 16:10:38 +0200 | [diff] [blame] | 633 | lghi %r1,4096 |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 634 | lgr %r2,%r11 # pass pointer to pt_regs |
Martin Schwidefsky | 7e180bd | 2012-03-11 11:59:25 -0400 | [diff] [blame] | 635 | llgf %r3,__LC_EXT_CPU_ADDR # get cpu address + interruption code |
Martin Schwidefsky | f6649a7 | 2010-10-25 16:10:38 +0200 | [diff] [blame] | 636 | llgf %r4,__LC_EXT_PARAMS # get external parameter |
| 637 | lg %r5,__LC_EXT_PARAMS2-4096(%r1) # get 64 bit external parameter |
Heiko Carstens | 25d83cb | 2006-09-28 16:56:37 +0200 | [diff] [blame] | 638 | brasl %r14,do_extint |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | j io_return |
| 640 | |
Martin Schwidefsky | 4c1051e | 2012-03-11 11:59:27 -0400 | [diff] [blame] | 641 | /* |
| 642 | * Load idle PSW. The second "half" of this function is in cleanup_idle. |
| 643 | */ |
| 644 | ENTRY(psw_idle) |
| 645 | stg %r4,__SF_EMPTY(%r15) |
| 646 | larl %r1,psw_idle_lpsw+4 |
| 647 | stg %r1,__SF_EMPTY+8(%r15) |
| 648 | larl %r1,.Lvtimer_max |
Heiko Carstens | 473e66b | 2012-05-09 16:27:39 +0200 | [diff] [blame] | 649 | STCK __IDLE_ENTER(%r2) |
Martin Schwidefsky | 4c1051e | 2012-03-11 11:59:27 -0400 | [diff] [blame] | 650 | ltr %r5,%r5 |
| 651 | stpt __VQ_IDLE_ENTER(%r3) |
| 652 | jz psw_idle_lpsw |
| 653 | spt 0(%r1) |
| 654 | psw_idle_lpsw: |
| 655 | lpswe __SF_EMPTY(%r15) |
| 656 | br %r14 |
| 657 | psw_idle_end: |
| 658 | |
Martin Schwidefsky | ae6aa2e | 2005-09-03 15:57:56 -0700 | [diff] [blame] | 659 | __critical_end: |
| 660 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 661 | /* |
| 662 | * Machine check handler routines |
| 663 | */ |
Jan Glauber | 144d634 | 2011-07-24 10:48:19 +0200 | [diff] [blame] | 664 | ENTRY(mcck_int_handler) |
Heiko Carstens | 473e66b | 2012-05-09 16:27:39 +0200 | [diff] [blame] | 665 | STCK __LC_MCCK_CLOCK |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 666 | la %r1,4095 # revalidate r1 |
| 667 | spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # revalidate cpu timer |
Heiko Carstens | 25d83cb | 2006-09-28 16:56:37 +0200 | [diff] [blame] | 668 | lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# revalidate gprs |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 669 | lg %r10,__LC_LAST_BREAK |
| 670 | lg %r12,__LC_THREAD_INFO |
Martin Schwidefsky | 86f2552 | 2010-05-17 10:00:05 +0200 | [diff] [blame] | 671 | larl %r13,system_call |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 672 | lmg %r8,%r9,__LC_MCK_OLD_PSW |
| 673 | HANDLE_SIE_INTERCEPT %r14 |
Heiko Carstens | 25d83cb | 2006-09-28 16:56:37 +0200 | [diff] [blame] | 674 | tm __LC_MCCK_CODE,0x80 # system damage? |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 675 | jo mcck_panic # yes -> rest of mcck code invalid |
| 676 | lghi %r14,__LC_CPU_TIMER_SAVE_AREA |
| 677 | mvc __LC_MCCK_ENTER_TIMER(8),0(%r14) |
Martin Schwidefsky | 63b1224 | 2006-06-29 14:58:05 +0200 | [diff] [blame] | 678 | tm __LC_MCCK_CODE+5,0x02 # stored cpu timer value valid? |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 679 | jo 3f |
Martin Schwidefsky | 63b1224 | 2006-06-29 14:58:05 +0200 | [diff] [blame] | 680 | la %r14,__LC_SYNC_ENTER_TIMER |
| 681 | clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER |
| 682 | jl 0f |
| 683 | la %r14,__LC_ASYNC_ENTER_TIMER |
| 684 | 0: clc 0(8,%r14),__LC_EXIT_TIMER |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 685 | jl 1f |
Martin Schwidefsky | 63b1224 | 2006-06-29 14:58:05 +0200 | [diff] [blame] | 686 | la %r14,__LC_EXIT_TIMER |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 687 | 1: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER |
| 688 | jl 2f |
Martin Schwidefsky | 63b1224 | 2006-06-29 14:58:05 +0200 | [diff] [blame] | 689 | la %r14,__LC_LAST_UPDATE_TIMER |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 690 | 2: spt 0(%r14) |
Martin Schwidefsky | 6377981 | 2010-05-17 10:00:03 +0200 | [diff] [blame] | 691 | mvc __LC_MCCK_ENTER_TIMER(8),0(%r14) |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 692 | 3: tm __LC_MCCK_CODE+2,0x09 # mwp + ia of old psw valid? |
| 693 | jno mcck_panic # no -> skip cleanup critical |
| 694 | SWITCH_ASYNC __LC_GPREGS_SAVE_AREA+64,__LC_PANIC_STACK,PAGE_SHIFT |
| 695 | tm %r8,0x0001 # interrupting from user ? |
| 696 | jz mcck_skip |
| 697 | UPDATE_VTIME %r14,__LC_MCCK_ENTER_TIMER |
| 698 | LAST_BREAK %r14 |
| 699 | mcck_skip: |
| 700 | lghi %r14,__LC_GPREGS_SAVE_AREA |
| 701 | mvc __PT_R0(128,%r11),0(%r14) |
| 702 | stmg %r8,%r9,__PT_PSW(%r11) |
| 703 | xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) |
| 704 | lgr %r2,%r11 # pass pointer to pt_regs |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 705 | brasl %r14,s390_do_machine_check |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 706 | tm __PT_PSW+1(%r11),0x01 # returning to user ? |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 707 | jno mcck_return |
| 708 | lg %r1,__LC_KERNEL_STACK # switch to kernel stack |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 709 | aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE) |
| 710 | mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11) |
| 711 | xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) |
| 712 | la %r11,STACK_FRAME_OVERHEAD(%r1) |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 713 | lgr %r15,%r1 |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 714 | ssm __LC_PGM_NEW_PSW # turn dat on, keep irqs off |
Martin Schwidefsky | 86f2552 | 2010-05-17 10:00:05 +0200 | [diff] [blame] | 715 | tm __TI_flags+7(%r12),_TIF_MCCK_PENDING |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 716 | jno mcck_return |
Heiko Carstens | 1f194a4 | 2006-07-03 00:24:46 -0700 | [diff] [blame] | 717 | TRACE_IRQS_OFF |
Heiko Carstens | 77fa224 | 2005-06-25 14:55:30 -0700 | [diff] [blame] | 718 | brasl %r14,s390_handle_mcck |
Heiko Carstens | 1f194a4 | 2006-07-03 00:24:46 -0700 | [diff] [blame] | 719 | TRACE_IRQS_ON |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | mcck_return: |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 721 | lg %r14,__LC_VDSO_PER_CPU |
| 722 | lmg %r0,%r10,__PT_R0(%r11) |
| 723 | mvc __LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW |
Martin Schwidefsky | 63b1224 | 2006-06-29 14:58:05 +0200 | [diff] [blame] | 724 | tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ? |
| 725 | jno 0f |
| 726 | stpt __LC_EXIT_TIMER |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 727 | mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER |
| 728 | 0: lmg %r11,%r15,__PT_R11(%r11) |
| 729 | lpswe __LC_RETURN_MCCK_PSW |
| 730 | |
| 731 | mcck_panic: |
| 732 | lg %r14,__LC_PANIC_STACK |
| 733 | slgr %r14,%r15 |
| 734 | srag %r14,%r14,PAGE_SHIFT |
| 735 | jz 0f |
| 736 | lg %r15,__LC_PANIC_STACK |
| 737 | 0: aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE) |
| 738 | j mcck_skip |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 739 | |
Michael Holzheu | 7dd6b33 | 2011-08-03 16:44:19 +0200 | [diff] [blame] | 740 | # |
| 741 | # PSW restart interrupt handler |
| 742 | # |
Martin Schwidefsky | 8b646bd | 2012-03-11 11:59:26 -0400 | [diff] [blame] | 743 | ENTRY(restart_int_handler) |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 744 | stg %r15,__LC_SAVE_AREA_RESTART |
Martin Schwidefsky | 8b646bd | 2012-03-11 11:59:26 -0400 | [diff] [blame] | 745 | lg %r15,__LC_RESTART_STACK |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 746 | aghi %r15,-__PT_SIZE # create pt_regs on stack |
Martin Schwidefsky | 8b646bd | 2012-03-11 11:59:26 -0400 | [diff] [blame] | 747 | xc 0(__PT_SIZE,%r15),0(%r15) |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 748 | stmg %r0,%r14,__PT_R0(%r15) |
| 749 | mvc __PT_R15(8,%r15),__LC_SAVE_AREA_RESTART |
| 750 | mvc __PT_PSW(16,%r15),__LC_RST_OLD_PSW # store restart old psw |
Martin Schwidefsky | 8b646bd | 2012-03-11 11:59:26 -0400 | [diff] [blame] | 751 | aghi %r15,-STACK_FRAME_OVERHEAD # create stack frame on stack |
| 752 | xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15) |
Heiko Carstens | fbe7656 | 2012-06-05 09:59:52 +0200 | [diff] [blame] | 753 | lg %r1,__LC_RESTART_FN # load fn, parm & source cpu |
| 754 | lg %r2,__LC_RESTART_DATA |
| 755 | lg %r3,__LC_RESTART_SOURCE |
Martin Schwidefsky | 8b646bd | 2012-03-11 11:59:26 -0400 | [diff] [blame] | 756 | ltgr %r3,%r3 # test source cpu address |
| 757 | jm 1f # negative -> skip source stop |
Heiko Carstens | eb54619 | 2012-06-04 15:05:43 +0200 | [diff] [blame] | 758 | 0: sigp %r4,%r3,SIGP_SENSE # sigp sense to source cpu |
Martin Schwidefsky | 8b646bd | 2012-03-11 11:59:26 -0400 | [diff] [blame] | 759 | brc 10,0b # wait for status stored |
| 760 | 1: basr %r14,%r1 # call function |
| 761 | stap __SF_EMPTY(%r15) # store cpu address |
| 762 | llgh %r3,__SF_EMPTY(%r15) |
Heiko Carstens | eb54619 | 2012-06-04 15:05:43 +0200 | [diff] [blame] | 763 | 2: sigp %r4,%r3,SIGP_STOP # sigp stop to current cpu |
Martin Schwidefsky | 8b646bd | 2012-03-11 11:59:26 -0400 | [diff] [blame] | 764 | brc 2,2b |
| 765 | 3: j 3b |
Michael Holzheu | 7dd6b33 | 2011-08-03 16:44:19 +0200 | [diff] [blame] | 766 | |
Martin Schwidefsky | 860dba4 | 2011-01-05 12:47:25 +0100 | [diff] [blame] | 767 | .section .kprobes.text, "ax" |
| 768 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 769 | #ifdef CONFIG_CHECK_STACK |
| 770 | /* |
| 771 | * The synchronous or the asynchronous stack overflowed. We are dead. |
| 772 | * No need to properly save the registers, we are going to panic anyway. |
| 773 | * Setup a pt_regs so that show_trace can provide a good call trace. |
| 774 | */ |
| 775 | stack_overflow: |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 776 | lg %r11,__LC_PANIC_STACK # change to panic stack |
| 777 | aghi %r11,-__PT_SIZE # create pt_regs |
| 778 | stmg %r0,%r7,__PT_R0(%r11) |
| 779 | stmg %r8,%r9,__PT_PSW(%r11) |
| 780 | mvc __PT_R8(64,%r11),0(%r14) |
| 781 | stg %r10,__PT_ORIG_GPR2(%r11) # store last break to orig_gpr2 |
| 782 | lgr %r15,%r11 |
| 783 | aghi %r15,-STACK_FRAME_OVERHEAD |
| 784 | xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) |
| 785 | lgr %r2,%r11 # pass pointer to pt_regs |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 786 | jg kernel_stack_overflow |
| 787 | #endif |
| 788 | |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 789 | .align 8 |
| 790 | cleanup_table: |
| 791 | .quad system_call |
| 792 | .quad sysc_do_svc |
| 793 | .quad sysc_tif |
| 794 | .quad sysc_restore |
| 795 | .quad sysc_done |
| 796 | .quad io_tif |
| 797 | .quad io_restore |
| 798 | .quad io_done |
Martin Schwidefsky | 4c1051e | 2012-03-11 11:59:27 -0400 | [diff] [blame] | 799 | .quad psw_idle |
| 800 | .quad psw_idle_end |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 801 | |
| 802 | cleanup_critical: |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 803 | clg %r9,BASED(cleanup_table) # system_call |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | jl 0f |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 805 | clg %r9,BASED(cleanup_table+8) # sysc_do_svc |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 806 | jl cleanup_system_call |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 807 | clg %r9,BASED(cleanup_table+16) # sysc_tif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 808 | jl 0f |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 809 | clg %r9,BASED(cleanup_table+24) # sysc_restore |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 810 | jl cleanup_sysc_tif |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 811 | clg %r9,BASED(cleanup_table+32) # sysc_done |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 812 | jl cleanup_sysc_restore |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 813 | clg %r9,BASED(cleanup_table+40) # io_tif |
Martin Schwidefsky | 63b1224 | 2006-06-29 14:58:05 +0200 | [diff] [blame] | 814 | jl 0f |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 815 | clg %r9,BASED(cleanup_table+48) # io_restore |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 816 | jl cleanup_io_tif |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 817 | clg %r9,BASED(cleanup_table+56) # io_done |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 818 | jl cleanup_io_restore |
Martin Schwidefsky | 4c1051e | 2012-03-11 11:59:27 -0400 | [diff] [blame] | 819 | clg %r9,BASED(cleanup_table+64) # psw_idle |
| 820 | jl 0f |
| 821 | clg %r9,BASED(cleanup_table+72) # psw_idle_end |
| 822 | jl cleanup_idle |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 823 | 0: br %r14 |
| 824 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 825 | |
| 826 | cleanup_system_call: |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 827 | # check if stpt has been executed |
| 828 | clg %r9,BASED(cleanup_system_call_insn) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 829 | jh 0f |
| 830 | mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 831 | cghi %r11,__LC_SAVE_AREA_ASYNC |
Martin Schwidefsky | 6377981 | 2010-05-17 10:00:03 +0200 | [diff] [blame] | 832 | je 0f |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 833 | mvc __LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER |
| 834 | 0: # check if stmg has been executed |
| 835 | clg %r9,BASED(cleanup_system_call_insn+8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 836 | jh 0f |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 837 | mvc __LC_SAVE_AREA_SYNC(64),0(%r11) |
| 838 | 0: # check if base register setup + TIF bit load has been done |
| 839 | clg %r9,BASED(cleanup_system_call_insn+16) |
| 840 | jhe 0f |
| 841 | # set up saved registers r10 and r12 |
| 842 | stg %r10,16(%r11) # r10 last break |
| 843 | stg %r12,32(%r11) # r12 thread-info pointer |
| 844 | 0: # check if the user time update has been done |
| 845 | clg %r9,BASED(cleanup_system_call_insn+24) |
| 846 | jh 0f |
| 847 | lg %r15,__LC_EXIT_TIMER |
| 848 | slg %r15,__LC_SYNC_ENTER_TIMER |
| 849 | alg %r15,__LC_USER_TIMER |
| 850 | stg %r15,__LC_USER_TIMER |
| 851 | 0: # check if the system time update has been done |
| 852 | clg %r9,BASED(cleanup_system_call_insn+32) |
| 853 | jh 0f |
| 854 | lg %r15,__LC_LAST_UPDATE_TIMER |
| 855 | slg %r15,__LC_EXIT_TIMER |
| 856 | alg %r15,__LC_SYSTEM_TIMER |
| 857 | stg %r15,__LC_SYSTEM_TIMER |
| 858 | 0: # update accounting time stamp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 859 | mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 860 | # do LAST_BREAK |
| 861 | lg %r9,16(%r11) |
| 862 | srag %r9,%r9,23 |
Martin Schwidefsky | 86f2552 | 2010-05-17 10:00:05 +0200 | [diff] [blame] | 863 | jz 0f |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 864 | mvc __TI_last_break(8,%r12),16(%r11) |
| 865 | 0: # set up saved register r11 |
| 866 | lg %r15,__LC_KERNEL_STACK |
| 867 | aghi %r15,-__PT_SIZE |
| 868 | stg %r15,24(%r11) # r11 pt_regs pointer |
| 869 | # fill pt_regs |
| 870 | mvc __PT_R8(64,%r15),__LC_SAVE_AREA_SYNC |
| 871 | stmg %r0,%r7,__PT_R0(%r15) |
| 872 | mvc __PT_PSW(16,%r15),__LC_SVC_OLD_PSW |
Martin Schwidefsky | aa33c8c | 2011-12-27 11:27:18 +0100 | [diff] [blame] | 873 | mvc __PT_INT_CODE(4,%r15),__LC_SVC_ILC |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 874 | # setup saved register r15 |
| 875 | aghi %r15,-STACK_FRAME_OVERHEAD |
| 876 | stg %r15,56(%r11) # r15 stack pointer |
| 877 | # set new psw address and exit |
| 878 | larl %r9,sysc_do_svc |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 879 | br %r14 |
| 880 | cleanup_system_call_insn: |
Heiko Carstens | 25d83cb | 2006-09-28 16:56:37 +0200 | [diff] [blame] | 881 | .quad system_call |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 882 | .quad sysc_stmg |
| 883 | .quad sysc_per |
| 884 | .quad sysc_vtime+18 |
| 885 | .quad sysc_vtime+42 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 886 | |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 887 | cleanup_sysc_tif: |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 888 | larl %r9,sysc_tif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 889 | br %r14 |
| 890 | |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 891 | cleanup_sysc_restore: |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 892 | clg %r9,BASED(cleanup_sysc_restore_insn) |
Martin Schwidefsky | 6377981 | 2010-05-17 10:00:03 +0200 | [diff] [blame] | 893 | je 0f |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 894 | lg %r9,24(%r11) # get saved pointer to pt_regs |
| 895 | mvc __LC_RETURN_PSW(16),__PT_PSW(%r9) |
| 896 | mvc 0(64,%r11),__PT_R8(%r9) |
| 897 | lmg %r0,%r7,__PT_R0(%r9) |
| 898 | 0: lmg %r8,%r9,__LC_RETURN_PSW |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 899 | br %r14 |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 900 | cleanup_sysc_restore_insn: |
Heiko Carstens | 411788e | 2007-11-20 11:13:32 +0100 | [diff] [blame] | 901 | .quad sysc_done - 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 902 | |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 903 | cleanup_io_tif: |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 904 | larl %r9,io_tif |
Martin Schwidefsky | 176b180 | 2010-04-09 13:43:00 +0200 | [diff] [blame] | 905 | br %r14 |
| 906 | |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 907 | cleanup_io_restore: |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 908 | clg %r9,BASED(cleanup_io_restore_insn) |
| 909 | je 0f |
| 910 | lg %r9,24(%r11) # get saved r11 pointer to pt_regs |
| 911 | mvc __LC_RETURN_PSW(16),__PT_PSW(%r9) |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 912 | mvc 0(64,%r11),__PT_R8(%r9) |
| 913 | lmg %r0,%r7,__PT_R0(%r9) |
| 914 | 0: lmg %r8,%r9,__LC_RETURN_PSW |
Martin Schwidefsky | ae6aa2e | 2005-09-03 15:57:56 -0700 | [diff] [blame] | 915 | br %r14 |
Martin Schwidefsky | 6a2df3a | 2010-05-17 10:00:02 +0200 | [diff] [blame] | 916 | cleanup_io_restore_insn: |
Heiko Carstens | 411788e | 2007-11-20 11:13:32 +0100 | [diff] [blame] | 917 | .quad io_done - 4 |
Martin Schwidefsky | ae6aa2e | 2005-09-03 15:57:56 -0700 | [diff] [blame] | 918 | |
Martin Schwidefsky | 4c1051e | 2012-03-11 11:59:27 -0400 | [diff] [blame] | 919 | cleanup_idle: |
| 920 | # copy interrupt clock & cpu timer |
| 921 | mvc __IDLE_EXIT(8,%r2),__LC_INT_CLOCK |
| 922 | mvc __VQ_IDLE_EXIT(8,%r3),__LC_ASYNC_ENTER_TIMER |
| 923 | cghi %r11,__LC_SAVE_AREA_ASYNC |
| 924 | je 0f |
| 925 | mvc __IDLE_EXIT(8,%r2),__LC_MCCK_CLOCK |
| 926 | mvc __VQ_IDLE_EXIT(8,%r3),__LC_MCCK_ENTER_TIMER |
| 927 | 0: # check if stck & stpt have been executed |
| 928 | clg %r9,BASED(cleanup_idle_insn) |
| 929 | jhe 1f |
| 930 | mvc __IDLE_ENTER(8,%r2),__IDLE_EXIT(%r2) |
| 931 | mvc __VQ_IDLE_ENTER(8,%r3),__VQ_IDLE_EXIT(%r3) |
| 932 | j 2f |
| 933 | 1: # check if the cpu timer has been reprogrammed |
| 934 | ltr %r5,%r5 |
| 935 | jz 2f |
| 936 | spt __VQ_IDLE_ENTER(%r3) |
| 937 | 2: # account system time going idle |
| 938 | lg %r9,__LC_STEAL_TIMER |
| 939 | alg %r9,__IDLE_ENTER(%r2) |
| 940 | slg %r9,__LC_LAST_UPDATE_CLOCK |
| 941 | stg %r9,__LC_STEAL_TIMER |
| 942 | mvc __LC_LAST_UPDATE_CLOCK(8),__IDLE_EXIT(%r2) |
| 943 | lg %r9,__LC_SYSTEM_TIMER |
| 944 | alg %r9,__LC_LAST_UPDATE_TIMER |
| 945 | slg %r9,__VQ_IDLE_ENTER(%r3) |
| 946 | stg %r9,__LC_SYSTEM_TIMER |
| 947 | mvc __LC_LAST_UPDATE_TIMER(8),__VQ_IDLE_EXIT(%r3) |
| 948 | # prepare return psw |
| 949 | nihh %r8,0xfffd # clear wait state bit |
| 950 | lg %r9,48(%r11) # return from psw_idle |
| 951 | br %r14 |
| 952 | cleanup_idle_insn: |
| 953 | .quad psw_idle_lpsw |
| 954 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 955 | /* |
| 956 | * Integer constants |
| 957 | */ |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 958 | .align 8 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 959 | .Lcritical_start: |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 960 | .quad __critical_start |
| 961 | .Lcritical_length: |
| 962 | .quad __critical_end - __critical_start |
Martin Schwidefsky | 4c1051e | 2012-03-11 11:59:27 -0400 | [diff] [blame] | 963 | .Lvtimer_max: |
| 964 | .quad 0x7fffffffffffffff |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 965 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 966 | |
Martin Schwidefsky | 603d1a5 | 2011-07-24 10:48:18 +0200 | [diff] [blame] | 967 | #if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE) |
| 968 | /* |
| 969 | * sie64a calling convention: |
| 970 | * %r2 pointer to sie control block |
| 971 | * %r3 guest register save area |
| 972 | */ |
Jan Glauber | 144d634 | 2011-07-24 10:48:19 +0200 | [diff] [blame] | 973 | ENTRY(sie64a) |
Martin Schwidefsky | 603d1a5 | 2011-07-24 10:48:18 +0200 | [diff] [blame] | 974 | stmg %r6,%r14,__SF_GPRS(%r15) # save kernel registers |
| 975 | stg %r2,__SF_EMPTY(%r15) # save control block pointer |
| 976 | stg %r3,__SF_EMPTY+8(%r15) # save guest register save area |
Martin Schwidefsky | ddd6f95 | 2011-12-27 11:27:13 +0100 | [diff] [blame] | 977 | xc __SF_EMPTY+16(8,%r15),__SF_EMPTY+16(%r15) # host id == 0 |
Martin Schwidefsky | 603d1a5 | 2011-07-24 10:48:18 +0200 | [diff] [blame] | 978 | lmg %r0,%r13,0(%r3) # load guest gprs 0-13 |
Martin Schwidefsky | 603d1a5 | 2011-07-24 10:48:18 +0200 | [diff] [blame] | 979 | sie_loop: |
| 980 | lg %r14,__LC_THREAD_INFO # pointer thread_info struct |
| 981 | tm __TI_flags+7(%r14),_TIF_EXIT_SIE |
| 982 | jnz sie_exit |
Christian Borntraeger | 480e592 | 2011-09-20 17:07:28 +0200 | [diff] [blame] | 983 | lg %r14,__LC_GMAP # get gmap pointer |
| 984 | ltgr %r14,%r14 |
| 985 | jz sie_gmap |
| 986 | lctlg %c1,%c1,__GMAP_ASCE(%r14) # load primary asce |
| 987 | sie_gmap: |
Martin Schwidefsky | 603d1a5 | 2011-07-24 10:48:18 +0200 | [diff] [blame] | 988 | lg %r14,__SF_EMPTY(%r15) # get control block pointer |
| 989 | SPP __SF_EMPTY(%r15) # set guest id |
| 990 | sie 0(%r14) |
| 991 | sie_done: |
Martin Schwidefsky | ddd6f95 | 2011-12-27 11:27:13 +0100 | [diff] [blame] | 992 | SPP __SF_EMPTY+16(%r15) # set host id |
Martin Schwidefsky | 603d1a5 | 2011-07-24 10:48:18 +0200 | [diff] [blame] | 993 | lg %r14,__LC_THREAD_INFO # pointer thread_info struct |
| 994 | sie_exit: |
Christian Borntraeger | 480e592 | 2011-09-20 17:07:28 +0200 | [diff] [blame] | 995 | lctlg %c1,%c1,__LC_USER_ASCE # load primary asce |
Martin Schwidefsky | 603d1a5 | 2011-07-24 10:48:18 +0200 | [diff] [blame] | 996 | lg %r14,__SF_EMPTY+8(%r15) # load guest register save area |
| 997 | stmg %r0,%r13,0(%r14) # save guest gprs 0-13 |
| 998 | lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers |
| 999 | lghi %r2,0 |
| 1000 | br %r14 |
| 1001 | sie_fault: |
Carsten Otte | 69ba974 | 2011-10-30 15:16:59 +0100 | [diff] [blame] | 1002 | lctlg %c1,%c1,__LC_USER_ASCE # load primary asce |
Martin Schwidefsky | 603d1a5 | 2011-07-24 10:48:18 +0200 | [diff] [blame] | 1003 | lg %r14,__LC_THREAD_INFO # pointer thread_info struct |
Martin Schwidefsky | 603d1a5 | 2011-07-24 10:48:18 +0200 | [diff] [blame] | 1004 | lg %r14,__SF_EMPTY+8(%r15) # load guest register save area |
| 1005 | stmg %r0,%r13,0(%r14) # save guest gprs 0-13 |
| 1006 | lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers |
| 1007 | lghi %r2,-EFAULT |
| 1008 | br %r14 |
| 1009 | |
| 1010 | .align 8 |
| 1011 | .Lsie_loop: |
| 1012 | .quad sie_loop |
Martin Schwidefsky | c532890 | 2011-12-27 11:27:15 +0100 | [diff] [blame] | 1013 | .Lsie_length: |
| 1014 | .quad sie_done - sie_loop |
Martin Schwidefsky | ddd6f95 | 2011-12-27 11:27:13 +0100 | [diff] [blame] | 1015 | .Lhost_id: |
| 1016 | .quad 0 |
Martin Schwidefsky | 603d1a5 | 2011-07-24 10:48:18 +0200 | [diff] [blame] | 1017 | |
| 1018 | .section __ex_table,"a" |
| 1019 | .quad sie_loop,sie_fault |
| 1020 | .previous |
| 1021 | #endif |
| 1022 | |
Heiko Carstens | 25d83cb | 2006-09-28 16:56:37 +0200 | [diff] [blame] | 1023 | .section .rodata, "a" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1024 | #define SYSCALL(esa,esame,emu) .long esame |
Heiko Carstens | 9bf1226 | 2009-06-12 10:26:47 +0200 | [diff] [blame] | 1025 | .globl sys_call_table |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1026 | sys_call_table: |
| 1027 | #include "syscalls.S" |
| 1028 | #undef SYSCALL |
| 1029 | |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 1030 | #ifdef CONFIG_COMPAT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1031 | |
| 1032 | #define SYSCALL(esa,esame,emu) .long emu |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1033 | sys_call_table_emu: |
| 1034 | #include "syscalls.S" |
| 1035 | #undef SYSCALL |
| 1036 | #endif |