Loading...
1/*
2 * Common Low Level Interrupts/Traps/Exceptions(non-TLB) Handling for ARC
3 * (included from entry-<isa>.S
4 *
5 * Copyright (C) 2014-15 Synopsys, Inc. (www.synopsys.com)
6 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13/*------------------------------------------------------------------
14 * Function ABI
15 *------------------------------------------------------------------
16 *
17 * Arguments r0 - r7
18 * Caller Saved Registers r0 - r12
19 * Callee Saved Registers r13- r25
20 * Global Pointer (gp) r26
21 * Frame Pointer (fp) r27
22 * Stack Pointer (sp) r28
23 * Branch link register (blink) r31
24 *------------------------------------------------------------------
25 */
26
27;################### Special Sys Call Wrappers ##########################
28
29ENTRY(sys_clone_wrapper)
30 SAVE_CALLEE_SAVED_USER
31 bl @sys_clone
32 DISCARD_CALLEE_SAVED_USER
33
34 GET_CURR_THR_INFO_FLAGS r10
35 btst r10, TIF_SYSCALL_TRACE
36 bnz tracesys_exit
37
38 b .Lret_from_system_call
39END(sys_clone_wrapper)
40
41ENTRY(ret_from_fork)
42 ; when the forked child comes here from the __switch_to function
43 ; r0 has the last task pointer.
44 ; put last task in scheduler queue
45 jl @schedule_tail
46
47 ld r9, [sp, PT_status32]
48 brne r9, 0, 1f
49
50 jl.d [r14] ; kernel thread entry point
51 mov r0, r13 ; (see PF_KTHREAD block in copy_thread)
52
531:
54 ; Return to user space
55 ; 1. Any forked task (Reach here via BRne above)
56 ; 2. First ever init task (Reach here via return from JL above)
57 ; This is the historic "kernel_execve" use-case, to return to init
58 ; user mode, in a round about way since that is always done from
59 ; a kernel thread which is executed via JL above but always returns
60 ; out whenever kernel_execve (now inline do_fork()) is involved
61 b ret_from_exception
62END(ret_from_fork)
63
64;################### Non TLB Exception Handling #############################
65
66; ---------------------------------------------
67; Instruction Error Exception Handler
68; ---------------------------------------------
69
70ENTRY(instr_service)
71
72 EXCEPTION_PROLOGUE
73
74 lr r0, [efa]
75 mov r1, sp
76
77 FAKE_RET_FROM_EXCPN
78
79 bl do_insterror_or_kprobe
80 b ret_from_exception
81END(instr_service)
82
83; ---------------------------------------------
84; Machine Check Exception Handler
85; ---------------------------------------------
86
87ENTRY(EV_MachineCheck)
88
89 EXCEPTION_PROLOGUE
90
91 lr r2, [ecr]
92 lr r0, [efa]
93 mov r1, sp
94
95 ; hardware auto-disables MMU, re-enable it to allow kernel vaddr
96 ; access for say stack unwinding of modules for crash dumps
97 lr r3, [ARC_REG_PID]
98 or r3, r3, MMU_ENABLE
99 sr r3, [ARC_REG_PID]
100
101 lsr r3, r2, 8
102 bmsk r3, r3, 7
103 brne r3, ECR_C_MCHK_DUP_TLB, 1f
104
105 bl do_tlb_overlap_fault
106 b ret_from_exception
107
1081:
109 ; DEAD END: can't do much, display Regs and HALT
110 SAVE_CALLEE_SAVED_USER
111
112 GET_CURR_TASK_FIELD_PTR TASK_THREAD, r10
113 st sp, [r10, THREAD_CALLEE_REG]
114
115 j do_machine_check_fault
116
117END(EV_MachineCheck)
118
119; ---------------------------------------------
120; Privilege Violation Exception Handler
121; ---------------------------------------------
122ENTRY(EV_PrivilegeV)
123
124 EXCEPTION_PROLOGUE
125
126 lr r0, [efa]
127 mov r1, sp
128
129 FAKE_RET_FROM_EXCPN
130
131 bl do_privilege_fault
132 b ret_from_exception
133END(EV_PrivilegeV)
134
135; ---------------------------------------------
136; Extension Instruction Exception Handler
137; ---------------------------------------------
138ENTRY(EV_Extension)
139
140 EXCEPTION_PROLOGUE
141
142 lr r0, [efa]
143 mov r1, sp
144
145 FAKE_RET_FROM_EXCPN
146
147 bl do_extension_fault
148 b ret_from_exception
149END(EV_Extension)
150
151;################ Trap Handling (Syscall, Breakpoint) ##################
152
153; ---------------------------------------------
154; syscall Tracing
155; ---------------------------------------------
156tracesys:
157 ; save EFA in case tracer wants the PC of traced task
158 ; using ERET won't work since next-PC has already committed
159 lr r12, [efa]
160 GET_CURR_TASK_FIELD_PTR TASK_THREAD, r11
161 st r12, [r11, THREAD_FAULT_ADDR] ; thread.fault_address
162
163 ; PRE Sys Call Ptrace hook
164 mov r0, sp ; pt_regs needed
165 bl @syscall_trace_entry
166
167 ; Tracing code now returns the syscall num (orig or modif)
168 mov r8, r0
169
170 ; Do the Sys Call as we normally would.
171 ; Validate the Sys Call number
172 cmp r8, NR_syscalls
173 mov.hi r0, -ENOSYS
174 bhi tracesys_exit
175
176 ; Restore the sys-call args. Mere invocation of the hook abv could have
177 ; clobbered them (since they are in scratch regs). The tracer could also
178 ; have deliberately changed the syscall args: r0-r7
179 ld r0, [sp, PT_r0]
180 ld r1, [sp, PT_r1]
181 ld r2, [sp, PT_r2]
182 ld r3, [sp, PT_r3]
183 ld r4, [sp, PT_r4]
184 ld r5, [sp, PT_r5]
185 ld r6, [sp, PT_r6]
186 ld r7, [sp, PT_r7]
187 ld.as r9, [sys_call_table, r8]
188 jl [r9] ; Entry into Sys Call Handler
189
190tracesys_exit:
191 st r0, [sp, PT_r0] ; sys call return value in pt_regs
192
193 ;POST Sys Call Ptrace Hook
194 bl @syscall_trace_exit
195 b ret_from_exception ; NOT ret_from_system_call at is saves r0 which
196 ; we'd done before calling post hook above
197
198; ---------------------------------------------
199; Breakpoint TRAP
200; ---------------------------------------------
201trap_with_param:
202
203 ; stop_pc info by gdb needs this info
204 lr r0, [efa]
205 mov r1, sp
206
207 ; Now that we have read EFA, it is safe to do "fake" rtie
208 ; and get out of CPU exception mode
209 FAKE_RET_FROM_EXCPN
210
211 ; Save callee regs in case gdb wants to have a look
212 ; SP will grow up by size of CALLEE Reg-File
213 ; NOTE: clobbers r12
214 SAVE_CALLEE_SAVED_USER
215
216 ; save location of saved Callee Regs @ thread_struct->pc
217 GET_CURR_TASK_FIELD_PTR TASK_THREAD, r10
218 st sp, [r10, THREAD_CALLEE_REG]
219
220 ; Call the trap handler
221 bl do_non_swi_trap
222
223 ; unwind stack to discard Callee saved Regs
224 DISCARD_CALLEE_SAVED_USER
225
226 b ret_from_exception
227
228; ---------------------------------------------
229; syscall TRAP
230; ABI: (r0-r7) upto 8 args, (r8) syscall number
231; ---------------------------------------------
232
233ENTRY(EV_Trap)
234
235 EXCEPTION_PROLOGUE
236
237 ;============ TRAP 1 :breakpoints
238 ; Check ECR for trap with arg (PROLOGUE ensures r9 has ECR)
239 bmsk.f 0, r9, 7
240 bnz trap_with_param
241
242 ;============ TRAP (no param): syscall top level
243
244 ; First return from Exception to pure K mode (Exception/IRQs renabled)
245 FAKE_RET_FROM_EXCPN
246
247 ; If syscall tracing ongoing, invoke pre-post-hooks
248 GET_CURR_THR_INFO_FLAGS r10
249 btst r10, TIF_SYSCALL_TRACE
250 bnz tracesys ; this never comes back
251
252 ;============ Normal syscall case
253
254 ; syscall num shd not exceed the total system calls avail
255 cmp r8, NR_syscalls
256 mov.hi r0, -ENOSYS
257 bhi .Lret_from_system_call
258
259 ; Offset into the syscall_table and call handler
260 ld.as r9,[sys_call_table, r8]
261 jl [r9] ; Entry into Sys Call Handler
262
263.Lret_from_system_call:
264
265 st r0, [sp, PT_r0] ; sys call return value in pt_regs
266
267 ; fall through to ret_from_exception
268END(EV_Trap)
269
270;############# Return from Intr/Excp/Trap (Linux Specifics) ##############
271;
272; If ret to user mode do we need to handle signals, schedule() et al.
273
274ENTRY(ret_from_exception)
275
276 ; Pre-{IRQ,Trap,Exception} K/U mode from pt_regs->status32
277 ld r8, [sp, PT_status32] ; returning to User/Kernel Mode
278
279 bbit0 r8, STATUS_U_BIT, resume_kernel_mode
280
281 ; Before returning to User mode check-for-and-complete any pending work
282 ; such as rescheduling/signal-delivery etc.
283resume_user_mode_begin:
284
285 ; Disable IRQs to ensures that chk for pending work itself is atomic
286 ; (and we don't end up missing a NEED_RESCHED/SIGPENDING due to an
287 ; interim IRQ).
288 IRQ_DISABLE r10
289
290 ; Fast Path return to user mode if no pending work
291 GET_CURR_THR_INFO_FLAGS r9
292 and.f 0, r9, _TIF_WORK_MASK
293 bz .Lrestore_regs
294
295 ; --- (Slow Path #1) task preemption ---
296 bbit0 r9, TIF_NEED_RESCHED, .Lchk_pend_signals
297 mov blink, resume_user_mode_begin ; tail-call to U mode ret chks
298 j @schedule ; BTST+Bnz causes relo error in link
299
300.Lchk_pend_signals:
301 IRQ_ENABLE r10
302
303 ; --- (Slow Path #2) pending signal ---
304 mov r0, sp ; pt_regs for arg to do_signal()/do_notify_resume()
305
306 GET_CURR_THR_INFO_FLAGS r9
307 bbit0 r9, TIF_SIGPENDING, .Lchk_notify_resume
308
309 ; Normal Trap/IRQ entry only saves Scratch (caller-saved) regs
310 ; in pt_reg since the "C" ABI (kernel code) will automatically
311 ; save/restore callee-saved regs.
312 ;
313 ; However, here we need to explicitly save callee regs because
314 ; (i) If this signal causes coredump - full regfile needed
315 ; (ii) If signal is SIGTRAP/SIGSTOP, task is being traced thus
316 ; tracer might call PEEKUSR(CALLEE reg)
317 ;
318 ; NOTE: SP will grow up by size of CALLEE Reg-File
319 SAVE_CALLEE_SAVED_USER ; clobbers r12
320
321 ; save location of saved Callee Regs @ thread_struct->callee
322 GET_CURR_TASK_FIELD_PTR TASK_THREAD, r10
323 st sp, [r10, THREAD_CALLEE_REG]
324
325 bl @do_signal
326
327 ; Ideally we want to discard the Callee reg above, however if this was
328 ; a tracing signal, tracer could have done a POKEUSR(CALLEE reg)
329 RESTORE_CALLEE_SAVED_USER
330
331 b resume_user_mode_begin ; loop back to start of U mode ret
332
333 ; --- (Slow Path #3) notify_resume ---
334.Lchk_notify_resume:
335 btst r9, TIF_NOTIFY_RESUME
336 blnz @do_notify_resume
337 b resume_user_mode_begin ; unconditionally back to U mode ret chks
338 ; for single exit point from this block
339
340resume_kernel_mode:
341
342 ; Disable Interrupts from this point on
343 ; CONFIG_PREEMPT: This is a must for preempt_schedule_irq()
344 ; !CONFIG_PREEMPT: To ensure restore_regs is intr safe
345 IRQ_DISABLE r9
346
347#ifdef CONFIG_PREEMPT
348
349 ; Can't preempt if preemption disabled
350 GET_CURR_THR_INFO_FROM_SP r10
351 ld r8, [r10, THREAD_INFO_PREEMPT_COUNT]
352 brne r8, 0, .Lrestore_regs
353
354 ; check if this task's NEED_RESCHED flag set
355 ld r9, [r10, THREAD_INFO_FLAGS]
356 bbit0 r9, TIF_NEED_RESCHED, .Lrestore_regs
357
358 ; Invoke PREEMPTION
359 jl preempt_schedule_irq
360
361 ; preempt_schedule_irq() always returns with IRQ disabled
362#endif
363
364 b .Lrestore_regs
365
366##### DONT ADD CODE HERE - .Lrestore_regs actually follows in entry-<isa>.S
367
1/*
2 * Common Low Level Interrupts/Traps/Exceptions(non-TLB) Handling for ARC
3 * (included from entry-<isa>.S
4 *
5 * Copyright (C) 2014-15 Synopsys, Inc. (www.synopsys.com)
6 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13/*------------------------------------------------------------------
14 * Function ABI
15 *------------------------------------------------------------------
16 *
17 * Arguments r0 - r7
18 * Caller Saved Registers r0 - r12
19 * Callee Saved Registers r13- r25
20 * Global Pointer (gp) r26
21 * Frame Pointer (fp) r27
22 * Stack Pointer (sp) r28
23 * Branch link register (blink) r31
24 *------------------------------------------------------------------
25 */
26
27;################### Special Sys Call Wrappers ##########################
28
29ENTRY(sys_clone_wrapper)
30 SAVE_CALLEE_SAVED_USER
31 bl @sys_clone
32 DISCARD_CALLEE_SAVED_USER
33
34 GET_CURR_THR_INFO_FLAGS r10
35 btst r10, TIF_SYSCALL_TRACE
36 bnz tracesys_exit
37
38 b .Lret_from_system_call
39END(sys_clone_wrapper)
40
41ENTRY(ret_from_fork)
42 ; when the forked child comes here from the __switch_to function
43 ; r0 has the last task pointer.
44 ; put last task in scheduler queue
45 jl @schedule_tail
46
47 ld r9, [sp, PT_status32]
48 brne r9, 0, 1f
49
50 jl.d [r14] ; kernel thread entry point
51 mov r0, r13 ; (see PF_KTHREAD block in copy_thread)
52
531:
54 ; Return to user space
55 ; 1. Any forked task (Reach here via BRne above)
56 ; 2. First ever init task (Reach here via return from JL above)
57 ; This is the historic "kernel_execve" use-case, to return to init
58 ; user mode, in a round about way since that is always done from
59 ; a kernel thread which is executed via JL above but always returns
60 ; out whenever kernel_execve (now inline do_fork()) is involved
61 b ret_from_exception
62END(ret_from_fork)
63
64;################### Non TLB Exception Handling #############################
65
66; ---------------------------------------------
67; Instruction Error Exception Handler
68; ---------------------------------------------
69
70ENTRY(instr_service)
71
72 EXCEPTION_PROLOGUE
73
74 lr r0, [efa]
75 mov r1, sp
76
77 FAKE_RET_FROM_EXCPN
78
79 bl do_insterror_or_kprobe
80 b ret_from_exception
81END(instr_service)
82
83; ---------------------------------------------
84; Machine Check Exception Handler
85; ---------------------------------------------
86
87ENTRY(EV_MachineCheck)
88
89 EXCEPTION_PROLOGUE
90
91 lr r2, [ecr]
92 lr r0, [efa]
93 mov r1, sp
94
95 lsr r3, r2, 8
96 bmsk r3, r3, 7
97 brne r3, ECR_C_MCHK_DUP_TLB, 1f
98
99 bl do_tlb_overlap_fault
100 b ret_from_exception
101
1021:
103 ; DEAD END: can't do much, display Regs and HALT
104 SAVE_CALLEE_SAVED_USER
105
106 GET_CURR_TASK_FIELD_PTR TASK_THREAD, r10
107 st sp, [r10, THREAD_CALLEE_REG]
108
109 j do_machine_check_fault
110
111END(EV_MachineCheck)
112
113; ---------------------------------------------
114; Privilege Violation Exception Handler
115; ---------------------------------------------
116ENTRY(EV_PrivilegeV)
117
118 EXCEPTION_PROLOGUE
119
120 lr r0, [efa]
121 mov r1, sp
122
123 FAKE_RET_FROM_EXCPN
124
125 bl do_privilege_fault
126 b ret_from_exception
127END(EV_PrivilegeV)
128
129; ---------------------------------------------
130; Extension Instruction Exception Handler
131; ---------------------------------------------
132ENTRY(EV_Extension)
133
134 EXCEPTION_PROLOGUE
135
136 lr r0, [efa]
137 mov r1, sp
138
139 FAKE_RET_FROM_EXCPN
140
141 bl do_extension_fault
142 b ret_from_exception
143END(EV_Extension)
144
145;################ Trap Handling (Syscall, Breakpoint) ##################
146
147; ---------------------------------------------
148; syscall Tracing
149; ---------------------------------------------
150tracesys:
151 ; save EFA in case tracer wants the PC of traced task
152 ; using ERET won't work since next-PC has already committed
153 lr r12, [efa]
154 GET_CURR_TASK_FIELD_PTR TASK_THREAD, r11
155 st r12, [r11, THREAD_FAULT_ADDR] ; thread.fault_address
156
157 ; PRE Sys Call Ptrace hook
158 mov r0, sp ; pt_regs needed
159 bl @syscall_trace_entry
160
161 ; Tracing code now returns the syscall num (orig or modif)
162 mov r8, r0
163
164 ; Do the Sys Call as we normally would.
165 ; Validate the Sys Call number
166 cmp r8, NR_syscalls
167 mov.hi r0, -ENOSYS
168 bhi tracesys_exit
169
170 ; Restore the sys-call args. Mere invocation of the hook abv could have
171 ; clobbered them (since they are in scratch regs). The tracer could also
172 ; have deliberately changed the syscall args: r0-r7
173 ld r0, [sp, PT_r0]
174 ld r1, [sp, PT_r1]
175 ld r2, [sp, PT_r2]
176 ld r3, [sp, PT_r3]
177 ld r4, [sp, PT_r4]
178 ld r5, [sp, PT_r5]
179 ld r6, [sp, PT_r6]
180 ld r7, [sp, PT_r7]
181 ld.as r9, [sys_call_table, r8]
182 jl [r9] ; Entry into Sys Call Handler
183
184tracesys_exit:
185 st r0, [sp, PT_r0] ; sys call return value in pt_regs
186
187 ;POST Sys Call Ptrace Hook
188 bl @syscall_trace_exit
189 b ret_from_exception ; NOT ret_from_system_call at is saves r0 which
190 ; we'd done before calling post hook above
191
192; ---------------------------------------------
193; Breakpoint TRAP
194; ---------------------------------------------
195trap_with_param:
196
197 ; stop_pc info by gdb needs this info
198 lr r0, [efa]
199 mov r1, sp
200
201 ; Now that we have read EFA, it is safe to do "fake" rtie
202 ; and get out of CPU exception mode
203 FAKE_RET_FROM_EXCPN
204
205 ; Save callee regs in case gdb wants to have a look
206 ; SP will grow up by size of CALLEE Reg-File
207 ; NOTE: clobbers r12
208 SAVE_CALLEE_SAVED_USER
209
210 ; save location of saved Callee Regs @ thread_struct->pc
211 GET_CURR_TASK_FIELD_PTR TASK_THREAD, r10
212 st sp, [r10, THREAD_CALLEE_REG]
213
214 ; Call the trap handler
215 bl do_non_swi_trap
216
217 ; unwind stack to discard Callee saved Regs
218 DISCARD_CALLEE_SAVED_USER
219
220 b ret_from_exception
221
222; ---------------------------------------------
223; syscall TRAP
224; ABI: (r0-r7) upto 8 args, (r8) syscall number
225; ---------------------------------------------
226
227ENTRY(EV_Trap)
228
229 EXCEPTION_PROLOGUE
230
231 ;============ TRAP 1 :breakpoints
232 ; Check ECR for trap with arg (PROLOGUE ensures r9 has ECR)
233 bmsk.f 0, r9, 7
234 bnz trap_with_param
235
236 ;============ TRAP (no param): syscall top level
237
238 ; First return from Exception to pure K mode (Exception/IRQs renabled)
239 FAKE_RET_FROM_EXCPN
240
241 ; If syscall tracing ongoing, invoke pre-post-hooks
242 GET_CURR_THR_INFO_FLAGS r10
243 btst r10, TIF_SYSCALL_TRACE
244 bnz tracesys ; this never comes back
245
246 ;============ Normal syscall case
247
248 ; syscall num shd not exceed the total system calls avail
249 cmp r8, NR_syscalls
250 mov.hi r0, -ENOSYS
251 bhi .Lret_from_system_call
252
253 ; Offset into the syscall_table and call handler
254 ld.as r9,[sys_call_table, r8]
255 jl [r9] ; Entry into Sys Call Handler
256
257.Lret_from_system_call:
258
259 st r0, [sp, PT_r0] ; sys call return value in pt_regs
260
261 ; fall through to ret_from_exception
262END(EV_Trap)
263
264;############# Return from Intr/Excp/Trap (Linux Specifics) ##############
265;
266; If ret to user mode do we need to handle signals, schedule() et al.
267
268ENTRY(ret_from_exception)
269
270 ; Pre-{IRQ,Trap,Exception} K/U mode from pt_regs->status32
271 ld r8, [sp, PT_status32] ; returning to User/Kernel Mode
272
273 bbit0 r8, STATUS_U_BIT, resume_kernel_mode
274
275 ; Before returning to User mode check-for-and-complete any pending work
276 ; such as rescheduling/signal-delivery etc.
277resume_user_mode_begin:
278
279 ; Disable IRQs to ensures that chk for pending work itself is atomic
280 ; (and we don't end up missing a NEED_RESCHED/SIGPENDING due to an
281 ; interim IRQ).
282 IRQ_DISABLE r10
283
284 ; Fast Path return to user mode if no pending work
285 GET_CURR_THR_INFO_FLAGS r9
286 and.f 0, r9, _TIF_WORK_MASK
287 bz .Lrestore_regs
288
289 ; --- (Slow Path #1) task preemption ---
290 bbit0 r9, TIF_NEED_RESCHED, .Lchk_pend_signals
291 mov blink, resume_user_mode_begin ; tail-call to U mode ret chks
292 j @schedule ; BTST+Bnz causes relo error in link
293
294.Lchk_pend_signals:
295 IRQ_ENABLE r10
296
297 ; --- (Slow Path #2) pending signal ---
298 mov r0, sp ; pt_regs for arg to do_signal()/do_notify_resume()
299
300 GET_CURR_THR_INFO_FLAGS r9
301 bbit0 r9, TIF_SIGPENDING, .Lchk_notify_resume
302
303 ; Normal Trap/IRQ entry only saves Scratch (caller-saved) regs
304 ; in pt_reg since the "C" ABI (kernel code) will automatically
305 ; save/restore callee-saved regs.
306 ;
307 ; However, here we need to explicitly save callee regs because
308 ; (i) If this signal causes coredump - full regfile needed
309 ; (ii) If signal is SIGTRAP/SIGSTOP, task is being traced thus
310 ; tracer might call PEEKUSR(CALLEE reg)
311 ;
312 ; NOTE: SP will grow up by size of CALLEE Reg-File
313 SAVE_CALLEE_SAVED_USER ; clobbers r12
314
315 ; save location of saved Callee Regs @ thread_struct->callee
316 GET_CURR_TASK_FIELD_PTR TASK_THREAD, r10
317 st sp, [r10, THREAD_CALLEE_REG]
318
319 bl @do_signal
320
321 ; Ideally we want to discard the Callee reg above, however if this was
322 ; a tracing signal, tracer could have done a POKEUSR(CALLEE reg)
323 RESTORE_CALLEE_SAVED_USER
324
325 b resume_user_mode_begin ; loop back to start of U mode ret
326
327 ; --- (Slow Path #3) notify_resume ---
328.Lchk_notify_resume:
329 btst r9, TIF_NOTIFY_RESUME
330 blnz @do_notify_resume
331 b resume_user_mode_begin ; unconditionally back to U mode ret chks
332 ; for single exit point from this block
333
334resume_kernel_mode:
335
336 ; Disable Interrupts from this point on
337 ; CONFIG_PREEMPT: This is a must for preempt_schedule_irq()
338 ; !CONFIG_PREEMPT: To ensure restore_regs is intr safe
339 IRQ_DISABLE r9
340
341#ifdef CONFIG_PREEMPT
342
343 ; Can't preempt if preemption disabled
344 GET_CURR_THR_INFO_FROM_SP r10
345 ld r8, [r10, THREAD_INFO_PREEMPT_COUNT]
346 brne r8, 0, .Lrestore_regs
347
348 ; check if this task's NEED_RESCHED flag set
349 ld r9, [r10, THREAD_INFO_FLAGS]
350 bbit0 r9, TIF_NEED_RESCHED, .Lrestore_regs
351
352 ; Invoke PREEMPTION
353 jl preempt_schedule_irq
354
355 ; preempt_schedule_irq() always returns with IRQ disabled
356#endif
357
358 b .Lrestore_regs
359
360##### DONT ADD CODE HERE - .Lrestore_regs actually follows in entry-<isa>.S
361