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