|
91 | 91 | * Helpers to save/restore callee-saved regs: |
92 | 92 | * used by several macros below |
93 | 93 | *-------------------------------------------------------------*/ |
94 | | -.macro SAVE_R13_TO_R24 |
| 94 | +.macro SAVE_R13_TO_R25 |
95 | 95 | PUSH r13 |
96 | 96 | PUSH r14 |
97 | 97 | PUSH r15 |
|
104 | 104 | PUSH r22 |
105 | 105 | PUSH r23 |
106 | 106 | PUSH r24 |
| 107 | + PUSH r25 |
107 | 108 | .endm |
108 | 109 |
|
109 | | -.macro RESTORE_R24_TO_R13 |
| 110 | +.macro RESTORE_R25_TO_R13 |
| 111 | + POP r25 |
110 | 112 | POP r24 |
111 | 113 | POP r23 |
112 | 114 | POP r22 |
|
121 | 123 | POP r13 |
122 | 124 | .endm |
123 | 125 |
|
124 | | -/*-------------------------------------------------------------- |
125 | | - * Collect User Mode callee regs as struct callee_regs - needed by |
126 | | - * fork/do_signal/unaligned-access-emulation. |
127 | | - * (By default only scratch regs are saved on entry to kernel) |
128 | | - * |
129 | | - * Special handling for r25 if used for caching Task Pointer. |
130 | | - * It would have been saved in task->thread.user_r25 already, but to keep |
131 | | - * the interface same it is copied into regular r25 placeholder in |
132 | | - * struct callee_regs. |
133 | | - *-------------------------------------------------------------*/ |
| 126 | +/* |
| 127 | + * save user mode callee regs as struct callee_regs |
| 128 | + * - needed by fork/do_signal/unaligned-access-emulation. |
| 129 | + */ |
134 | 130 | .macro SAVE_CALLEE_SAVED_USER |
| 131 | + SAVE_R13_TO_R25 |
| 132 | +.endm |
135 | 133 |
|
136 | | - mov r12, sp ; save SP as ref to pt_regs |
137 | | - SAVE_R13_TO_R24 |
138 | | - |
139 | | -#ifdef CONFIG_ARC_CURR_IN_REG |
140 | | - ; Retrieve orig r25 and save it with rest of callee_regs |
141 | | - ld r12, [r12, PT_user_r25] |
142 | | - PUSH r12 |
143 | | -#else |
144 | | - PUSH r25 |
145 | | -#endif |
146 | | - |
| 134 | +/* |
| 135 | + * restore user mode callee regs as struct callee_regs |
| 136 | + * - could have been changed by ptrace tracer or unaligned-access fixup |
| 137 | + */ |
| 138 | +.macro RESTORE_CALLEE_SAVED_USER |
| 139 | + RESTORE_R25_TO_R13 |
147 | 140 | .endm |
148 | 141 |
|
149 | | -/*-------------------------------------------------------------- |
150 | | - * Save kernel Mode callee regs at the time of Contect Switch. |
151 | | - * |
152 | | - * Special handling for r25 if used for caching Task Pointer. |
153 | | - * Kernel simply skips saving it since it will be loaded with |
154 | | - * incoming task pointer anyways |
155 | | - *-------------------------------------------------------------*/ |
| 142 | +/* |
| 143 | + * save/restore kernel mode callee regs at the time of context switch |
| 144 | + */ |
156 | 145 | .macro SAVE_CALLEE_SAVED_KERNEL |
157 | | - |
158 | | - SAVE_R13_TO_R24 |
159 | | - |
160 | | -#ifdef CONFIG_ARC_CURR_IN_REG |
161 | | - sub sp, sp, 4 |
162 | | -#else |
163 | | - PUSH r25 |
164 | | -#endif |
| 146 | + SAVE_R13_TO_R25 |
165 | 147 | .endm |
166 | 148 |
|
167 | | -/*-------------------------------------------------------------- |
168 | | - * Opposite of SAVE_CALLEE_SAVED_KERNEL |
169 | | - *-------------------------------------------------------------*/ |
170 | 149 | .macro RESTORE_CALLEE_SAVED_KERNEL |
171 | | - |
172 | | -#ifdef CONFIG_ARC_CURR_IN_REG |
173 | | - add sp, sp, 4 /* skip usual r25 placeholder */ |
174 | | -#else |
175 | | - POP r25 |
176 | | -#endif |
177 | | - RESTORE_R24_TO_R13 |
178 | | -.endm |
179 | | - |
180 | | -/*-------------------------------------------------------------- |
181 | | - * Opposite of SAVE_CALLEE_SAVED_USER |
182 | | - * |
183 | | - * ptrace tracer or unaligned-access fixup might have changed a user mode |
184 | | - * callee reg which is saved back to usual r25 storage location |
185 | | - *-------------------------------------------------------------*/ |
186 | | -.macro RESTORE_CALLEE_SAVED_USER |
187 | | - |
188 | | -#ifdef CONFIG_ARC_CURR_IN_REG |
189 | | - POP r12 |
190 | | -#else |
191 | | - POP r25 |
192 | | -#endif |
193 | | - RESTORE_R24_TO_R13 |
194 | | - |
195 | | - ; SP is back to start of pt_regs |
196 | | -#ifdef CONFIG_ARC_CURR_IN_REG |
197 | | - st r12, [sp, PT_user_r25] |
198 | | -#endif |
| 150 | + RESTORE_R25_TO_R13 |
199 | 151 | .endm |
200 | 152 |
|
201 | 153 | /*-------------------------------------------------------------- |
|
231 | 183 |
|
232 | 184 | #ifdef CONFIG_SMP |
233 | 185 |
|
234 | | -/*------------------------------------------------- |
| 186 | +/* |
235 | 187 | * Retrieve the current running task on this CPU |
236 | | - * 1. Determine curr CPU id. |
237 | | - * 2. Use it to index into _current_task[ ] |
| 188 | + * - loads it from backing _current_task[] (and can't use the |
| 189 | + * caching reg for current task |
238 | 190 | */ |
239 | 191 | .macro GET_CURR_TASK_ON_CPU reg |
240 | 192 | GET_CPU_ID \reg |
|
256 | 208 | add2 \tmp, @_current_task, \tmp |
257 | 209 | st \tsk, [\tmp] |
258 | 210 | #ifdef CONFIG_ARC_CURR_IN_REG |
259 | | - mov r25, \tsk |
| 211 | + mov gp, \tsk |
260 | 212 | #endif |
261 | 213 |
|
262 | 214 | .endm |
|
271 | 223 | .macro SET_CURR_TASK_ON_CPU tsk, tmp |
272 | 224 | st \tsk, [@_current_task] |
273 | 225 | #ifdef CONFIG_ARC_CURR_IN_REG |
274 | | - mov r25, \tsk |
| 226 | + mov gp, \tsk |
275 | 227 | #endif |
276 | 228 | .endm |
277 | 229 |
|
278 | 230 | #endif /* SMP / UNI */ |
279 | 231 |
|
280 | | -/* ------------------------------------------------------------------ |
| 232 | +/* |
281 | 233 | * Get the ptr to some field of Current Task at @off in task struct |
282 | | - * -Uses r25 for Current task ptr if that is enabled |
| 234 | + * - Uses current task cached in reg if enabled |
283 | 235 | */ |
284 | | - |
285 | 236 | #ifdef CONFIG_ARC_CURR_IN_REG |
286 | 237 |
|
287 | 238 | .macro GET_CURR_TASK_FIELD_PTR off, reg |
288 | | - add \reg, r25, \off |
| 239 | + add \reg, gp, \off |
289 | 240 | .endm |
290 | 241 |
|
291 | 242 | #else |
|
0 commit comments