blob: cace76d17535b620ba87dfa7dd184f13903eda04 [file] [log] [blame]
Catalin Marinas60ffc302012-03-05 11:49:27 +00001/*
2 * Low-level exception handling code
3 *
4 * Copyright (C) 2012 ARM Ltd.
5 * Authors: Catalin Marinas <catalin.marinas@arm.com>
6 * Will Deacon <will.deacon@arm.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 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <linux/init.h>
22#include <linux/linkage.h>
23
Marc Zyngier8d883b22015-06-01 10:47:41 +010024#include <asm/alternative.h>
Catalin Marinas60ffc302012-03-05 11:49:27 +000025#include <asm/assembler.h>
26#include <asm/asm-offsets.h>
Will Deacon905e8c52015-03-23 19:07:02 +000027#include <asm/cpufeature.h>
Catalin Marinas60ffc302012-03-05 11:49:27 +000028#include <asm/errno.h>
Marc Zyngier5c1ce6f2013-04-08 17:17:03 +010029#include <asm/esr.h>
James Morse8e23dac2015-12-04 11:02:27 +000030#include <asm/irq.h>
James Morsee19a6ee2016-06-20 18:28:01 +010031#include <asm/memory.h>
Catalin Marinas39bc88e2016-09-02 14:54:03 +010032#include <asm/ptrace.h>
Catalin Marinas60ffc302012-03-05 11:49:27 +000033#include <asm/thread_info.h>
Al Virob4b86642016-12-26 04:10:19 -050034#include <asm/asm-uaccess.h>
Catalin Marinas60ffc302012-03-05 11:49:27 +000035#include <asm/unistd.h>
36
37/*
Larry Bassel6c81fe72014-05-30 12:34:15 -070038 * Context tracking subsystem. Used to instrument transitions
39 * between user and kernel mode.
40 */
41 .macro ct_user_exit, syscall = 0
42#ifdef CONFIG_CONTEXT_TRACKING
43 bl context_tracking_user_exit
44 .if \syscall == 1
45 /*
46 * Save/restore needed during syscalls. Restore syscall arguments from
47 * the values already saved on stack during kernel_entry.
48 */
49 ldp x0, x1, [sp]
50 ldp x2, x3, [sp, #S_X2]
51 ldp x4, x5, [sp, #S_X4]
52 ldp x6, x7, [sp, #S_X6]
53 .endif
54#endif
55 .endm
56
57 .macro ct_user_enter
58#ifdef CONFIG_CONTEXT_TRACKING
59 bl context_tracking_user_enter
60#endif
61 .endm
62
63/*
Catalin Marinas60ffc302012-03-05 11:49:27 +000064 * Bad Abort numbers
65 *-----------------
66 */
67#define BAD_SYNC 0
68#define BAD_IRQ 1
69#define BAD_FIQ 2
70#define BAD_ERROR 3
71
72 .macro kernel_entry, el, regsize = 64
Will Deacon63648dd2014-09-29 12:26:41 +010073 sub sp, sp, #S_FRAME_SIZE
Catalin Marinas60ffc302012-03-05 11:49:27 +000074 .if \regsize == 32
75 mov w0, w0 // zero upper 32 bits of x0
76 .endif
Will Deacon63648dd2014-09-29 12:26:41 +010077 stp x0, x1, [sp, #16 * 0]
78 stp x2, x3, [sp, #16 * 1]
79 stp x4, x5, [sp, #16 * 2]
80 stp x6, x7, [sp, #16 * 3]
81 stp x8, x9, [sp, #16 * 4]
82 stp x10, x11, [sp, #16 * 5]
83 stp x12, x13, [sp, #16 * 6]
84 stp x14, x15, [sp, #16 * 7]
85 stp x16, x17, [sp, #16 * 8]
86 stp x18, x19, [sp, #16 * 9]
87 stp x20, x21, [sp, #16 * 10]
88 stp x22, x23, [sp, #16 * 11]
89 stp x24, x25, [sp, #16 * 12]
90 stp x26, x27, [sp, #16 * 13]
91 stp x28, x29, [sp, #16 * 14]
92
Catalin Marinas60ffc302012-03-05 11:49:27 +000093 .if \el == 0
94 mrs x21, sp_el0
Mark Rutlandc02433d2016-11-03 20:23:13 +000095 ldr_this_cpu tsk, __entry_task, x20 // Ensure MDSCR_EL1.SS is clear,
96 ldr x19, [tsk, #TSK_TI_FLAGS] // since we can unmask debug
Will Deacon2a283072014-04-29 19:04:06 +010097 disable_step_tsk x19, x20 // exceptions when scheduling.
James Morse49003a82015-12-10 10:22:41 +000098
99 mov x29, xzr // fp pointed to user-space
Catalin Marinas60ffc302012-03-05 11:49:27 +0000100 .else
101 add x21, sp, #S_FRAME_SIZE
James Morsee19a6ee2016-06-20 18:28:01 +0100102 get_thread_info tsk
103 /* Save the task's original addr_limit and set USER_DS (TASK_SIZE_64) */
Mark Rutlandc02433d2016-11-03 20:23:13 +0000104 ldr x20, [tsk, #TSK_TI_ADDR_LIMIT]
James Morsee19a6ee2016-06-20 18:28:01 +0100105 str x20, [sp, #S_ORIG_ADDR_LIMIT]
106 mov x20, #TASK_SIZE_64
Mark Rutlandc02433d2016-11-03 20:23:13 +0000107 str x20, [tsk, #TSK_TI_ADDR_LIMIT]
Vladimir Murzin563cada2016-09-01 14:35:59 +0100108 /* No need to reset PSTATE.UAO, hardware's already set it to 0 for us */
James Morsee19a6ee2016-06-20 18:28:01 +0100109 .endif /* \el == 0 */
Catalin Marinas60ffc302012-03-05 11:49:27 +0000110 mrs x22, elr_el1
111 mrs x23, spsr_el1
112 stp lr, x21, [sp, #S_LR]
Catalin Marinas39bc88e2016-09-02 14:54:03 +0100113
114#ifdef CONFIG_ARM64_SW_TTBR0_PAN
115 /*
116 * Set the TTBR0 PAN bit in SPSR. When the exception is taken from
117 * EL0, there is no need to check the state of TTBR0_EL1 since
118 * accesses are always enabled.
119 * Note that the meaning of this bit differs from the ARMv8.1 PAN
120 * feature as all TTBR0_EL1 accesses are disabled, not just those to
121 * user mappings.
122 */
123alternative_if ARM64_HAS_PAN
124 b 1f // skip TTBR0 PAN
125alternative_else_nop_endif
126
127 .if \el != 0
128 mrs x21, ttbr0_el1
129 tst x21, #0xffff << 48 // Check for the reserved ASID
130 orr x23, x23, #PSR_PAN_BIT // Set the emulated PAN in the saved SPSR
131 b.eq 1f // TTBR0 access already disabled
132 and x23, x23, #~PSR_PAN_BIT // Clear the emulated PAN in the saved SPSR
133 .endif
134
135 __uaccess_ttbr0_disable x21
1361:
137#endif
138
Catalin Marinas60ffc302012-03-05 11:49:27 +0000139 stp x22, x23, [sp, #S_PC]
140
Dave Martin17c28952017-08-01 15:35:54 +0100141 /* Not in a syscall by default (el0_svc overwrites for real syscall) */
Catalin Marinas60ffc302012-03-05 11:49:27 +0000142 .if \el == 0
Dave Martin17c28952017-08-01 15:35:54 +0100143 mov w21, #NO_SYSCALL
Dave Martin35d0e6f2017-08-01 15:35:53 +0100144 str w21, [sp, #S_SYSCALLNO]
Catalin Marinas60ffc302012-03-05 11:49:27 +0000145 .endif
146
147 /*
Jungseok Lee6cdf9c72015-12-04 11:02:25 +0000148 * Set sp_el0 to current thread_info.
149 */
150 .if \el == 0
151 msr sp_el0, tsk
152 .endif
153
154 /*
Catalin Marinas60ffc302012-03-05 11:49:27 +0000155 * Registers that may be useful after this macro is invoked:
156 *
157 * x21 - aborted SP
158 * x22 - aborted PC
159 * x23 - aborted PSTATE
160 */
161 .endm
162
Will Deacon412fcb62015-08-19 15:57:09 +0100163 .macro kernel_exit, el
James Morsee19a6ee2016-06-20 18:28:01 +0100164 .if \el != 0
165 /* Restore the task's original addr_limit. */
166 ldr x20, [sp, #S_ORIG_ADDR_LIMIT]
Mark Rutlandc02433d2016-11-03 20:23:13 +0000167 str x20, [tsk, #TSK_TI_ADDR_LIMIT]
James Morsee19a6ee2016-06-20 18:28:01 +0100168
169 /* No need to restore UAO, it will be restored from SPSR_EL1 */
170 .endif
171
Catalin Marinas60ffc302012-03-05 11:49:27 +0000172 ldp x21, x22, [sp, #S_PC] // load ELR, SPSR
173 .if \el == 0
Larry Bassel6c81fe72014-05-30 12:34:15 -0700174 ct_user_enter
Catalin Marinas39bc88e2016-09-02 14:54:03 +0100175 .endif
176
177#ifdef CONFIG_ARM64_SW_TTBR0_PAN
178 /*
179 * Restore access to TTBR0_EL1. If returning to EL0, no need for SPSR
180 * PAN bit checking.
181 */
182alternative_if ARM64_HAS_PAN
183 b 2f // skip TTBR0 PAN
184alternative_else_nop_endif
185
186 .if \el != 0
187 tbnz x22, #22, 1f // Skip re-enabling TTBR0 access if the PSR_PAN_BIT is set
188 .endif
189
190 __uaccess_ttbr0_enable x0
191
192 .if \el == 0
193 /*
194 * Enable errata workarounds only if returning to user. The only
195 * workaround currently required for TTBR0_EL1 changes are for the
196 * Cavium erratum 27456 (broadcast TLBI instructions may cause I-cache
197 * corruption).
198 */
199 post_ttbr0_update_workaround
200 .endif
2011:
202 .if \el != 0
203 and x22, x22, #~PSR_PAN_BIT // ARMv8.0 CPUs do not understand this bit
204 .endif
2052:
206#endif
207
208 .if \el == 0
Catalin Marinas60ffc302012-03-05 11:49:27 +0000209 ldr x23, [sp, #S_SP] // load return stack pointer
Catalin Marinas60ffc302012-03-05 11:49:27 +0000210 msr sp_el0, x23
Will Deacon905e8c52015-03-23 19:07:02 +0000211#ifdef CONFIG_ARM64_ERRATUM_845719
Mark Rutland6ba3b552016-09-07 11:07:09 +0100212alternative_if ARM64_WORKAROUND_845719
Daniel Thompsone28cabf2015-07-22 12:21:03 +0100213 tbz x22, #4, 1f
214#ifdef CONFIG_PID_IN_CONTEXTIDR
215 mrs x29, contextidr_el1
216 msr contextidr_el1, x29
217#else
218 msr contextidr_el1, xzr
219#endif
2201:
Mark Rutland6ba3b552016-09-07 11:07:09 +0100221alternative_else_nop_endif
Will Deacon905e8c52015-03-23 19:07:02 +0000222#endif
Catalin Marinas60ffc302012-03-05 11:49:27 +0000223 .endif
Catalin Marinas39bc88e2016-09-02 14:54:03 +0100224
Will Deacon63648dd2014-09-29 12:26:41 +0100225 msr elr_el1, x21 // set up the return data
226 msr spsr_el1, x22
Will Deacon63648dd2014-09-29 12:26:41 +0100227 ldp x0, x1, [sp, #16 * 0]
Will Deacon63648dd2014-09-29 12:26:41 +0100228 ldp x2, x3, [sp, #16 * 1]
229 ldp x4, x5, [sp, #16 * 2]
230 ldp x6, x7, [sp, #16 * 3]
231 ldp x8, x9, [sp, #16 * 4]
232 ldp x10, x11, [sp, #16 * 5]
233 ldp x12, x13, [sp, #16 * 6]
234 ldp x14, x15, [sp, #16 * 7]
235 ldp x16, x17, [sp, #16 * 8]
236 ldp x18, x19, [sp, #16 * 9]
237 ldp x20, x21, [sp, #16 * 10]
238 ldp x22, x23, [sp, #16 * 11]
239 ldp x24, x25, [sp, #16 * 12]
240 ldp x26, x27, [sp, #16 * 13]
241 ldp x28, x29, [sp, #16 * 14]
242 ldr lr, [sp, #S_LR]
243 add sp, sp, #S_FRAME_SIZE // restore sp
Catalin Marinas60ffc302012-03-05 11:49:27 +0000244 eret // return to kernel
245 .endm
246
James Morse971c67c2015-12-15 11:21:25 +0000247 .macro irq_stack_entry
James Morse8e23dac2015-12-04 11:02:27 +0000248 mov x19, sp // preserve the original sp
249
James Morse8e23dac2015-12-04 11:02:27 +0000250 /*
Mark Rutlandc02433d2016-11-03 20:23:13 +0000251 * Compare sp with the base of the task stack.
252 * If the top ~(THREAD_SIZE - 1) bits match, we are on a task stack,
253 * and should switch to the irq stack.
James Morse8e23dac2015-12-04 11:02:27 +0000254 */
Mark Rutlandc02433d2016-11-03 20:23:13 +0000255 ldr x25, [tsk, TSK_STACK]
256 eor x25, x25, x19
257 and x25, x25, #~(THREAD_SIZE - 1)
258 cbnz x25, 9998f
James Morse8e23dac2015-12-04 11:02:27 +0000259
Mark Rutland1b7e2292016-11-03 20:23:12 +0000260 adr_this_cpu x25, irq_stack, x26
James Morse8e23dac2015-12-04 11:02:27 +0000261 mov x26, #IRQ_STACK_START_SP
262 add x26, x25, x26
James Morsed224a692015-12-18 16:01:47 +0000263
264 /* switch to the irq stack */
James Morse8e23dac2015-12-04 11:02:27 +0000265 mov sp, x26
266
James Morse971c67c2015-12-15 11:21:25 +0000267 /*
268 * Add a dummy stack frame, this non-standard format is fixed up
269 * by unwind_frame()
270 */
271 stp x29, x19, [sp, #-16]!
James Morse8e23dac2015-12-04 11:02:27 +0000272 mov x29, sp
James Morse8e23dac2015-12-04 11:02:27 +0000273
2749998:
275 .endm
276
277 /*
278 * x19 should be preserved between irq_stack_entry and
279 * irq_stack_exit.
280 */
281 .macro irq_stack_exit
282 mov sp, x19
283 .endm
284
Catalin Marinas60ffc302012-03-05 11:49:27 +0000285/*
286 * These are the registers used in the syscall handler, and allow us to
287 * have in theory up to 7 arguments to a function - x0 to x6.
288 *
289 * x7 is reserved for the system call number in 32-bit mode.
290 */
Dave Martin35d0e6f2017-08-01 15:35:53 +0100291wsc_nr .req w25 // number of system calls
292wscno .req w26 // syscall number
293xscno .req x26 // syscall number (zero-extended)
Catalin Marinas60ffc302012-03-05 11:49:27 +0000294stbl .req x27 // syscall table pointer
295tsk .req x28 // current thread_info
296
297/*
298 * Interrupt handling.
299 */
300 .macro irq_handler
James Morse8e23dac2015-12-04 11:02:27 +0000301 ldr_l x1, handle_arch_irq
Catalin Marinas60ffc302012-03-05 11:49:27 +0000302 mov x0, sp
James Morse971c67c2015-12-15 11:21:25 +0000303 irq_stack_entry
Catalin Marinas60ffc302012-03-05 11:49:27 +0000304 blr x1
James Morse8e23dac2015-12-04 11:02:27 +0000305 irq_stack_exit
Catalin Marinas60ffc302012-03-05 11:49:27 +0000306 .endm
307
308 .text
309
310/*
311 * Exception vectors.
312 */
Pratyush Anand888b3c82016-07-08 12:35:50 -0400313 .pushsection ".entry.text", "ax"
Catalin Marinas60ffc302012-03-05 11:49:27 +0000314
315 .align 11
316ENTRY(vectors)
317 ventry el1_sync_invalid // Synchronous EL1t
318 ventry el1_irq_invalid // IRQ EL1t
319 ventry el1_fiq_invalid // FIQ EL1t
320 ventry el1_error_invalid // Error EL1t
321
322 ventry el1_sync // Synchronous EL1h
323 ventry el1_irq // IRQ EL1h
324 ventry el1_fiq_invalid // FIQ EL1h
325 ventry el1_error_invalid // Error EL1h
326
327 ventry el0_sync // Synchronous 64-bit EL0
328 ventry el0_irq // IRQ 64-bit EL0
329 ventry el0_fiq_invalid // FIQ 64-bit EL0
330 ventry el0_error_invalid // Error 64-bit EL0
331
332#ifdef CONFIG_COMPAT
333 ventry el0_sync_compat // Synchronous 32-bit EL0
334 ventry el0_irq_compat // IRQ 32-bit EL0
335 ventry el0_fiq_invalid_compat // FIQ 32-bit EL0
336 ventry el0_error_invalid_compat // Error 32-bit EL0
337#else
338 ventry el0_sync_invalid // Synchronous 32-bit EL0
339 ventry el0_irq_invalid // IRQ 32-bit EL0
340 ventry el0_fiq_invalid // FIQ 32-bit EL0
341 ventry el0_error_invalid // Error 32-bit EL0
342#endif
343END(vectors)
344
345/*
346 * Invalid mode handlers
347 */
348 .macro inv_entry, el, reason, regsize = 64
Ard Biesheuvelb6609502016-03-18 10:58:09 +0100349 kernel_entry \el, \regsize
Catalin Marinas60ffc302012-03-05 11:49:27 +0000350 mov x0, sp
351 mov x1, #\reason
352 mrs x2, esr_el1
353 b bad_mode
354 .endm
355
356el0_sync_invalid:
357 inv_entry 0, BAD_SYNC
358ENDPROC(el0_sync_invalid)
359
360el0_irq_invalid:
361 inv_entry 0, BAD_IRQ
362ENDPROC(el0_irq_invalid)
363
364el0_fiq_invalid:
365 inv_entry 0, BAD_FIQ
366ENDPROC(el0_fiq_invalid)
367
368el0_error_invalid:
369 inv_entry 0, BAD_ERROR
370ENDPROC(el0_error_invalid)
371
372#ifdef CONFIG_COMPAT
373el0_fiq_invalid_compat:
374 inv_entry 0, BAD_FIQ, 32
375ENDPROC(el0_fiq_invalid_compat)
376
377el0_error_invalid_compat:
378 inv_entry 0, BAD_ERROR, 32
379ENDPROC(el0_error_invalid_compat)
380#endif
381
382el1_sync_invalid:
383 inv_entry 1, BAD_SYNC
384ENDPROC(el1_sync_invalid)
385
386el1_irq_invalid:
387 inv_entry 1, BAD_IRQ
388ENDPROC(el1_irq_invalid)
389
390el1_fiq_invalid:
391 inv_entry 1, BAD_FIQ
392ENDPROC(el1_fiq_invalid)
393
394el1_error_invalid:
395 inv_entry 1, BAD_ERROR
396ENDPROC(el1_error_invalid)
397
398/*
399 * EL1 mode handlers.
400 */
401 .align 6
402el1_sync:
403 kernel_entry 1
404 mrs x1, esr_el1 // read the syndrome register
Mark Rutlandaed40e02014-11-24 12:31:40 +0000405 lsr x24, x1, #ESR_ELx_EC_SHIFT // exception class
406 cmp x24, #ESR_ELx_EC_DABT_CUR // data abort in EL1
Catalin Marinas60ffc302012-03-05 11:49:27 +0000407 b.eq el1_da
Laura Abbott9adeb8e2016-08-09 18:25:26 -0700408 cmp x24, #ESR_ELx_EC_IABT_CUR // instruction abort in EL1
409 b.eq el1_ia
Mark Rutlandaed40e02014-11-24 12:31:40 +0000410 cmp x24, #ESR_ELx_EC_SYS64 // configurable trap
Catalin Marinas60ffc302012-03-05 11:49:27 +0000411 b.eq el1_undef
Mark Rutlandaed40e02014-11-24 12:31:40 +0000412 cmp x24, #ESR_ELx_EC_SP_ALIGN // stack alignment exception
Catalin Marinas60ffc302012-03-05 11:49:27 +0000413 b.eq el1_sp_pc
Mark Rutlandaed40e02014-11-24 12:31:40 +0000414 cmp x24, #ESR_ELx_EC_PC_ALIGN // pc alignment exception
Catalin Marinas60ffc302012-03-05 11:49:27 +0000415 b.eq el1_sp_pc
Mark Rutlandaed40e02014-11-24 12:31:40 +0000416 cmp x24, #ESR_ELx_EC_UNKNOWN // unknown exception in EL1
Catalin Marinas60ffc302012-03-05 11:49:27 +0000417 b.eq el1_undef
Mark Rutlandaed40e02014-11-24 12:31:40 +0000418 cmp x24, #ESR_ELx_EC_BREAKPT_CUR // debug exception in EL1
Catalin Marinas60ffc302012-03-05 11:49:27 +0000419 b.ge el1_dbg
420 b el1_inv
Laura Abbott9adeb8e2016-08-09 18:25:26 -0700421
422el1_ia:
423 /*
424 * Fall through to the Data abort case
425 */
Catalin Marinas60ffc302012-03-05 11:49:27 +0000426el1_da:
427 /*
428 * Data abort handling
429 */
Kristina Martsenko276e9322017-05-03 16:37:47 +0100430 mrs x3, far_el1
Will Deacon2a283072014-04-29 19:04:06 +0100431 enable_dbg
Catalin Marinas60ffc302012-03-05 11:49:27 +0000432 // re-enable interrupts if they were enabled in the aborted context
433 tbnz x23, #7, 1f // PSR_I_BIT
434 enable_irq
4351:
Kristina Martsenko276e9322017-05-03 16:37:47 +0100436 clear_address_tag x0, x3
Catalin Marinas60ffc302012-03-05 11:49:27 +0000437 mov x2, sp // struct pt_regs
438 bl do_mem_abort
439
440 // disable interrupts before pulling preserved data off the stack
441 disable_irq
442 kernel_exit 1
443el1_sp_pc:
444 /*
445 * Stack or PC alignment exception handling
446 */
447 mrs x0, far_el1
Will Deacon2a283072014-04-29 19:04:06 +0100448 enable_dbg
Catalin Marinas60ffc302012-03-05 11:49:27 +0000449 mov x2, sp
450 b do_sp_pc_abort
451el1_undef:
452 /*
453 * Undefined instruction
454 */
Will Deacon2a283072014-04-29 19:04:06 +0100455 enable_dbg
Catalin Marinas60ffc302012-03-05 11:49:27 +0000456 mov x0, sp
457 b do_undefinstr
458el1_dbg:
459 /*
460 * Debug exception handling
461 */
Mark Rutlandaed40e02014-11-24 12:31:40 +0000462 cmp x24, #ESR_ELx_EC_BRK64 // if BRK64
Sandeepa Prabhuee6214c2013-12-04 05:50:20 +0000463 cinc x24, x24, eq // set bit '0'
Catalin Marinas60ffc302012-03-05 11:49:27 +0000464 tbz x24, #0, el1_inv // EL1 only
465 mrs x0, far_el1
466 mov x2, sp // struct pt_regs
467 bl do_debug_exception
Catalin Marinas60ffc302012-03-05 11:49:27 +0000468 kernel_exit 1
469el1_inv:
470 // TODO: add support for undefined instructions in kernel mode
Will Deacon2a283072014-04-29 19:04:06 +0100471 enable_dbg
Catalin Marinas60ffc302012-03-05 11:49:27 +0000472 mov x0, sp
Mark Rutland1b428042015-07-07 18:00:49 +0100473 mov x2, x1
Catalin Marinas60ffc302012-03-05 11:49:27 +0000474 mov x1, #BAD_SYNC
Catalin Marinas60ffc302012-03-05 11:49:27 +0000475 b bad_mode
476ENDPROC(el1_sync)
477
478 .align 6
479el1_irq:
480 kernel_entry 1
Will Deacon2a283072014-04-29 19:04:06 +0100481 enable_dbg
Catalin Marinas60ffc302012-03-05 11:49:27 +0000482#ifdef CONFIG_TRACE_IRQFLAGS
483 bl trace_hardirqs_off
484#endif
Marc Zyngier64681782013-11-12 17:11:53 +0000485
486 irq_handler
487
Catalin Marinas60ffc302012-03-05 11:49:27 +0000488#ifdef CONFIG_PREEMPT
Mark Rutlandc02433d2016-11-03 20:23:13 +0000489 ldr w24, [tsk, #TSK_TI_PREEMPT] // get preempt count
Marc Zyngier717321f2013-11-04 20:14:58 +0000490 cbnz w24, 1f // preempt count != 0
Mark Rutlandc02433d2016-11-03 20:23:13 +0000491 ldr x0, [tsk, #TSK_TI_FLAGS] // get flags
Catalin Marinas60ffc302012-03-05 11:49:27 +0000492 tbz x0, #TIF_NEED_RESCHED, 1f // needs rescheduling?
493 bl el1_preempt
4941:
495#endif
496#ifdef CONFIG_TRACE_IRQFLAGS
497 bl trace_hardirqs_on
498#endif
499 kernel_exit 1
500ENDPROC(el1_irq)
501
502#ifdef CONFIG_PREEMPT
503el1_preempt:
504 mov x24, lr
Will Deacon2a283072014-04-29 19:04:06 +01005051: bl preempt_schedule_irq // irq en/disable is done inside
Mark Rutlandc02433d2016-11-03 20:23:13 +0000506 ldr x0, [tsk, #TSK_TI_FLAGS] // get new tasks TI_FLAGS
Catalin Marinas60ffc302012-03-05 11:49:27 +0000507 tbnz x0, #TIF_NEED_RESCHED, 1b // needs rescheduling?
508 ret x24
509#endif
510
511/*
512 * EL0 mode handlers.
513 */
514 .align 6
515el0_sync:
516 kernel_entry 0
517 mrs x25, esr_el1 // read the syndrome register
Mark Rutlandaed40e02014-11-24 12:31:40 +0000518 lsr x24, x25, #ESR_ELx_EC_SHIFT // exception class
519 cmp x24, #ESR_ELx_EC_SVC64 // SVC in 64-bit state
Catalin Marinas60ffc302012-03-05 11:49:27 +0000520 b.eq el0_svc
Mark Rutlandaed40e02014-11-24 12:31:40 +0000521 cmp x24, #ESR_ELx_EC_DABT_LOW // data abort in EL0
Catalin Marinas60ffc302012-03-05 11:49:27 +0000522 b.eq el0_da
Mark Rutlandaed40e02014-11-24 12:31:40 +0000523 cmp x24, #ESR_ELx_EC_IABT_LOW // instruction abort in EL0
Catalin Marinas60ffc302012-03-05 11:49:27 +0000524 b.eq el0_ia
Mark Rutlandaed40e02014-11-24 12:31:40 +0000525 cmp x24, #ESR_ELx_EC_FP_ASIMD // FP/ASIMD access
Catalin Marinas60ffc302012-03-05 11:49:27 +0000526 b.eq el0_fpsimd_acc
Mark Rutlandaed40e02014-11-24 12:31:40 +0000527 cmp x24, #ESR_ELx_EC_FP_EXC64 // FP/ASIMD exception
Catalin Marinas60ffc302012-03-05 11:49:27 +0000528 b.eq el0_fpsimd_exc
Mark Rutlandaed40e02014-11-24 12:31:40 +0000529 cmp x24, #ESR_ELx_EC_SYS64 // configurable trap
Andre Przywara7dd01ae2016-06-28 18:07:32 +0100530 b.eq el0_sys
Mark Rutlandaed40e02014-11-24 12:31:40 +0000531 cmp x24, #ESR_ELx_EC_SP_ALIGN // stack alignment exception
Catalin Marinas60ffc302012-03-05 11:49:27 +0000532 b.eq el0_sp_pc
Mark Rutlandaed40e02014-11-24 12:31:40 +0000533 cmp x24, #ESR_ELx_EC_PC_ALIGN // pc alignment exception
Catalin Marinas60ffc302012-03-05 11:49:27 +0000534 b.eq el0_sp_pc
Mark Rutlandaed40e02014-11-24 12:31:40 +0000535 cmp x24, #ESR_ELx_EC_UNKNOWN // unknown exception in EL0
Catalin Marinas60ffc302012-03-05 11:49:27 +0000536 b.eq el0_undef
Mark Rutlandaed40e02014-11-24 12:31:40 +0000537 cmp x24, #ESR_ELx_EC_BREAKPT_LOW // debug exception in EL0
Catalin Marinas60ffc302012-03-05 11:49:27 +0000538 b.ge el0_dbg
539 b el0_inv
540
541#ifdef CONFIG_COMPAT
542 .align 6
543el0_sync_compat:
544 kernel_entry 0, 32
545 mrs x25, esr_el1 // read the syndrome register
Mark Rutlandaed40e02014-11-24 12:31:40 +0000546 lsr x24, x25, #ESR_ELx_EC_SHIFT // exception class
547 cmp x24, #ESR_ELx_EC_SVC32 // SVC in 32-bit state
Catalin Marinas60ffc302012-03-05 11:49:27 +0000548 b.eq el0_svc_compat
Mark Rutlandaed40e02014-11-24 12:31:40 +0000549 cmp x24, #ESR_ELx_EC_DABT_LOW // data abort in EL0
Catalin Marinas60ffc302012-03-05 11:49:27 +0000550 b.eq el0_da
Mark Rutlandaed40e02014-11-24 12:31:40 +0000551 cmp x24, #ESR_ELx_EC_IABT_LOW // instruction abort in EL0
Catalin Marinas60ffc302012-03-05 11:49:27 +0000552 b.eq el0_ia
Mark Rutlandaed40e02014-11-24 12:31:40 +0000553 cmp x24, #ESR_ELx_EC_FP_ASIMD // FP/ASIMD access
Catalin Marinas60ffc302012-03-05 11:49:27 +0000554 b.eq el0_fpsimd_acc
Mark Rutlandaed40e02014-11-24 12:31:40 +0000555 cmp x24, #ESR_ELx_EC_FP_EXC32 // FP/ASIMD exception
Catalin Marinas60ffc302012-03-05 11:49:27 +0000556 b.eq el0_fpsimd_exc
Mark Salyzyn77f3228f2015-10-13 14:30:51 -0700557 cmp x24, #ESR_ELx_EC_PC_ALIGN // pc alignment exception
558 b.eq el0_sp_pc
Mark Rutlandaed40e02014-11-24 12:31:40 +0000559 cmp x24, #ESR_ELx_EC_UNKNOWN // unknown exception in EL0
Catalin Marinas60ffc302012-03-05 11:49:27 +0000560 b.eq el0_undef
Mark Rutlandaed40e02014-11-24 12:31:40 +0000561 cmp x24, #ESR_ELx_EC_CP15_32 // CP15 MRC/MCR trap
Mark Rutland381cc2b2013-05-24 12:02:35 +0100562 b.eq el0_undef
Mark Rutlandaed40e02014-11-24 12:31:40 +0000563 cmp x24, #ESR_ELx_EC_CP15_64 // CP15 MRRC/MCRR trap
Mark Rutland381cc2b2013-05-24 12:02:35 +0100564 b.eq el0_undef
Mark Rutlandaed40e02014-11-24 12:31:40 +0000565 cmp x24, #ESR_ELx_EC_CP14_MR // CP14 MRC/MCR trap
Mark Rutland381cc2b2013-05-24 12:02:35 +0100566 b.eq el0_undef
Mark Rutlandaed40e02014-11-24 12:31:40 +0000567 cmp x24, #ESR_ELx_EC_CP14_LS // CP14 LDC/STC trap
Mark Rutland381cc2b2013-05-24 12:02:35 +0100568 b.eq el0_undef
Mark Rutlandaed40e02014-11-24 12:31:40 +0000569 cmp x24, #ESR_ELx_EC_CP14_64 // CP14 MRRC/MCRR trap
Mark Rutland381cc2b2013-05-24 12:02:35 +0100570 b.eq el0_undef
Mark Rutlandaed40e02014-11-24 12:31:40 +0000571 cmp x24, #ESR_ELx_EC_BREAKPT_LOW // debug exception in EL0
Catalin Marinas60ffc302012-03-05 11:49:27 +0000572 b.ge el0_dbg
573 b el0_inv
574el0_svc_compat:
575 /*
576 * AArch32 syscall handling
577 */
Catalin Marinas01564112015-01-06 16:42:32 +0000578 adrp stbl, compat_sys_call_table // load compat syscall table pointer
Dave Martin35d0e6f2017-08-01 15:35:53 +0100579 mov wscno, w7 // syscall number in w7 (r7)
580 mov wsc_nr, #__NR_compat_syscalls
Catalin Marinas60ffc302012-03-05 11:49:27 +0000581 b el0_svc_naked
582
583 .align 6
584el0_irq_compat:
585 kernel_entry 0, 32
586 b el0_irq_naked
587#endif
588
589el0_da:
590 /*
591 * Data abort handling
592 */
Larry Bassel6ab64632014-05-30 20:34:14 +0100593 mrs x26, far_el1
Catalin Marinas60ffc302012-03-05 11:49:27 +0000594 // enable interrupts before calling the main handler
Will Deacon2a283072014-04-29 19:04:06 +0100595 enable_dbg_and_irq
Larry Bassel6c81fe72014-05-30 12:34:15 -0700596 ct_user_exit
Kristina Martsenko276e9322017-05-03 16:37:47 +0100597 clear_address_tag x0, x26
Catalin Marinas60ffc302012-03-05 11:49:27 +0000598 mov x1, x25
599 mov x2, sp
Will Deacond54e81f2014-09-29 11:44:01 +0100600 bl do_mem_abort
601 b ret_to_user
Catalin Marinas60ffc302012-03-05 11:49:27 +0000602el0_ia:
603 /*
604 * Instruction abort handling
605 */
Larry Bassel6ab64632014-05-30 20:34:14 +0100606 mrs x26, far_el1
Catalin Marinas60ffc302012-03-05 11:49:27 +0000607 // enable interrupts before calling the main handler
Will Deacon2a283072014-04-29 19:04:06 +0100608 enable_dbg_and_irq
Larry Bassel6c81fe72014-05-30 12:34:15 -0700609 ct_user_exit
Larry Bassel6ab64632014-05-30 20:34:14 +0100610 mov x0, x26
Mark Rutland541ec872016-05-31 12:33:03 +0100611 mov x1, x25
Catalin Marinas60ffc302012-03-05 11:49:27 +0000612 mov x2, sp
Will Deacond54e81f2014-09-29 11:44:01 +0100613 bl do_mem_abort
614 b ret_to_user
Catalin Marinas60ffc302012-03-05 11:49:27 +0000615el0_fpsimd_acc:
616 /*
617 * Floating Point or Advanced SIMD access
618 */
Will Deacon2a283072014-04-29 19:04:06 +0100619 enable_dbg
Larry Bassel6c81fe72014-05-30 12:34:15 -0700620 ct_user_exit
Catalin Marinas60ffc302012-03-05 11:49:27 +0000621 mov x0, x25
622 mov x1, sp
Will Deacond54e81f2014-09-29 11:44:01 +0100623 bl do_fpsimd_acc
624 b ret_to_user
Catalin Marinas60ffc302012-03-05 11:49:27 +0000625el0_fpsimd_exc:
626 /*
627 * Floating Point or Advanced SIMD exception
628 */
Will Deacon2a283072014-04-29 19:04:06 +0100629 enable_dbg
Larry Bassel6c81fe72014-05-30 12:34:15 -0700630 ct_user_exit
Catalin Marinas60ffc302012-03-05 11:49:27 +0000631 mov x0, x25
632 mov x1, sp
Will Deacond54e81f2014-09-29 11:44:01 +0100633 bl do_fpsimd_exc
634 b ret_to_user
Catalin Marinas60ffc302012-03-05 11:49:27 +0000635el0_sp_pc:
636 /*
637 * Stack or PC alignment exception handling
638 */
Larry Bassel6ab64632014-05-30 20:34:14 +0100639 mrs x26, far_el1
Catalin Marinas60ffc302012-03-05 11:49:27 +0000640 // enable interrupts before calling the main handler
Will Deacon2a283072014-04-29 19:04:06 +0100641 enable_dbg_and_irq
Mark Rutland46b05672015-06-15 16:40:27 +0100642 ct_user_exit
Larry Bassel6ab64632014-05-30 20:34:14 +0100643 mov x0, x26
Catalin Marinas60ffc302012-03-05 11:49:27 +0000644 mov x1, x25
645 mov x2, sp
Will Deacond54e81f2014-09-29 11:44:01 +0100646 bl do_sp_pc_abort
647 b ret_to_user
Catalin Marinas60ffc302012-03-05 11:49:27 +0000648el0_undef:
649 /*
650 * Undefined instruction
651 */
Catalin Marinas2600e132013-08-22 11:47:37 +0100652 // enable interrupts before calling the main handler
Will Deacon2a283072014-04-29 19:04:06 +0100653 enable_dbg_and_irq
Larry Bassel6c81fe72014-05-30 12:34:15 -0700654 ct_user_exit
Will Deacon2a283072014-04-29 19:04:06 +0100655 mov x0, sp
Will Deacond54e81f2014-09-29 11:44:01 +0100656 bl do_undefinstr
657 b ret_to_user
Andre Przywara7dd01ae2016-06-28 18:07:32 +0100658el0_sys:
659 /*
660 * System instructions, for trapped cache maintenance instructions
661 */
662 enable_dbg_and_irq
663 ct_user_exit
664 mov x0, x25
665 mov x1, sp
666 bl do_sysinstr
667 b ret_to_user
Catalin Marinas60ffc302012-03-05 11:49:27 +0000668el0_dbg:
669 /*
670 * Debug exception handling
671 */
672 tbnz x24, #0, el0_inv // EL0 only
673 mrs x0, far_el1
Catalin Marinas60ffc302012-03-05 11:49:27 +0000674 mov x1, x25
675 mov x2, sp
Will Deacon2a283072014-04-29 19:04:06 +0100676 bl do_debug_exception
677 enable_dbg
Larry Bassel6c81fe72014-05-30 12:34:15 -0700678 ct_user_exit
Will Deacon2a283072014-04-29 19:04:06 +0100679 b ret_to_user
Catalin Marinas60ffc302012-03-05 11:49:27 +0000680el0_inv:
Will Deacon2a283072014-04-29 19:04:06 +0100681 enable_dbg
Larry Bassel6c81fe72014-05-30 12:34:15 -0700682 ct_user_exit
Catalin Marinas60ffc302012-03-05 11:49:27 +0000683 mov x0, sp
684 mov x1, #BAD_SYNC
Mark Rutland1b428042015-07-07 18:00:49 +0100685 mov x2, x25
Mark Rutland7d9e8f72017-01-18 17:23:41 +0000686 bl bad_el0_sync
Will Deacond54e81f2014-09-29 11:44:01 +0100687 b ret_to_user
Catalin Marinas60ffc302012-03-05 11:49:27 +0000688ENDPROC(el0_sync)
689
690 .align 6
691el0_irq:
692 kernel_entry 0
693el0_irq_naked:
Catalin Marinas60ffc302012-03-05 11:49:27 +0000694 enable_dbg
695#ifdef CONFIG_TRACE_IRQFLAGS
696 bl trace_hardirqs_off
697#endif
Marc Zyngier64681782013-11-12 17:11:53 +0000698
Larry Bassel6c81fe72014-05-30 12:34:15 -0700699 ct_user_exit
Catalin Marinas60ffc302012-03-05 11:49:27 +0000700 irq_handler
Marc Zyngier64681782013-11-12 17:11:53 +0000701
Catalin Marinas60ffc302012-03-05 11:49:27 +0000702#ifdef CONFIG_TRACE_IRQFLAGS
703 bl trace_hardirqs_on
704#endif
705 b ret_to_user
706ENDPROC(el0_irq)
707
708/*
Catalin Marinas60ffc302012-03-05 11:49:27 +0000709 * Register switch for AArch64. The callee-saved registers need to be saved
710 * and restored. On entry:
711 * x0 = previous task_struct (must be preserved across the switch)
712 * x1 = next task_struct
713 * Previous and next are guaranteed not to be the same.
714 *
715 */
716ENTRY(cpu_switch_to)
Will Deaconc0d3fce2015-07-20 15:14:53 +0100717 mov x10, #THREAD_CPU_CONTEXT
718 add x8, x0, x10
Catalin Marinas60ffc302012-03-05 11:49:27 +0000719 mov x9, sp
720 stp x19, x20, [x8], #16 // store callee-saved registers
721 stp x21, x22, [x8], #16
722 stp x23, x24, [x8], #16
723 stp x25, x26, [x8], #16
724 stp x27, x28, [x8], #16
725 stp x29, x9, [x8], #16
726 str lr, [x8]
Will Deaconc0d3fce2015-07-20 15:14:53 +0100727 add x8, x1, x10
Catalin Marinas60ffc302012-03-05 11:49:27 +0000728 ldp x19, x20, [x8], #16 // restore callee-saved registers
729 ldp x21, x22, [x8], #16
730 ldp x23, x24, [x8], #16
731 ldp x25, x26, [x8], #16
732 ldp x27, x28, [x8], #16
733 ldp x29, x9, [x8], #16
734 ldr lr, [x8]
735 mov sp, x9
Mark Rutlandc02433d2016-11-03 20:23:13 +0000736 msr sp_el0, x1
Catalin Marinas60ffc302012-03-05 11:49:27 +0000737 ret
738ENDPROC(cpu_switch_to)
739
740/*
741 * This is the fast syscall return path. We do as little as possible here,
742 * and this includes saving x0 back into the kernel stack.
743 */
744ret_fast_syscall:
745 disable_irq // disable interrupts
Will Deacon412fcb62015-08-19 15:57:09 +0100746 str x0, [sp, #S_X0] // returned x0
Mark Rutlandc02433d2016-11-03 20:23:13 +0000747 ldr x1, [tsk, #TSK_TI_FLAGS] // re-check for syscall tracing
Josh Stone04d7e092015-06-05 14:28:03 -0700748 and x2, x1, #_TIF_SYSCALL_WORK
749 cbnz x2, ret_fast_syscall_trace
Catalin Marinas60ffc302012-03-05 11:49:27 +0000750 and x2, x1, #_TIF_WORK_MASK
Will Deacon412fcb62015-08-19 15:57:09 +0100751 cbnz x2, work_pending
Will Deacon2a283072014-04-29 19:04:06 +0100752 enable_step_tsk x1, x2
Will Deacon412fcb62015-08-19 15:57:09 +0100753 kernel_exit 0
Josh Stone04d7e092015-06-05 14:28:03 -0700754ret_fast_syscall_trace:
755 enable_irq // enable interrupts
Will Deacon412fcb62015-08-19 15:57:09 +0100756 b __sys_trace_return_skipped // we already saved x0
Catalin Marinas60ffc302012-03-05 11:49:27 +0000757
758/*
759 * Ok, we need to do extra processing, enter the slow path.
760 */
Catalin Marinas60ffc302012-03-05 11:49:27 +0000761work_pending:
Catalin Marinas60ffc302012-03-05 11:49:27 +0000762 mov x0, sp // 'regs'
Catalin Marinas60ffc302012-03-05 11:49:27 +0000763 bl do_notify_resume
Catalin Marinasdb3899a2015-12-04 12:42:29 +0000764#ifdef CONFIG_TRACE_IRQFLAGS
Chris Metcalf421dd6f2016-07-14 16:48:14 -0400765 bl trace_hardirqs_on // enabled while in userspace
Catalin Marinasdb3899a2015-12-04 12:42:29 +0000766#endif
Mark Rutlandc02433d2016-11-03 20:23:13 +0000767 ldr x1, [tsk, #TSK_TI_FLAGS] // re-check for single-step
Chris Metcalf421dd6f2016-07-14 16:48:14 -0400768 b finish_ret_to_user
Catalin Marinas60ffc302012-03-05 11:49:27 +0000769/*
770 * "slow" syscall return path.
771 */
Catalin Marinas59dc67b2012-09-10 16:11:46 +0100772ret_to_user:
Catalin Marinas60ffc302012-03-05 11:49:27 +0000773 disable_irq // disable interrupts
Mark Rutlandc02433d2016-11-03 20:23:13 +0000774 ldr x1, [tsk, #TSK_TI_FLAGS]
Catalin Marinas60ffc302012-03-05 11:49:27 +0000775 and x2, x1, #_TIF_WORK_MASK
776 cbnz x2, work_pending
Chris Metcalf421dd6f2016-07-14 16:48:14 -0400777finish_ret_to_user:
Will Deacon2a283072014-04-29 19:04:06 +0100778 enable_step_tsk x1, x2
Will Deacon412fcb62015-08-19 15:57:09 +0100779 kernel_exit 0
Catalin Marinas60ffc302012-03-05 11:49:27 +0000780ENDPROC(ret_to_user)
781
782/*
783 * This is how we return from a fork.
784 */
785ENTRY(ret_from_fork)
786 bl schedule_tail
Catalin Marinasc34501d2012-10-05 12:31:20 +0100787 cbz x19, 1f // not a kernel thread
788 mov x0, x20
789 blr x19
7901: get_thread_info tsk
Catalin Marinas60ffc302012-03-05 11:49:27 +0000791 b ret_to_user
792ENDPROC(ret_from_fork)
793
794/*
795 * SVC handler.
796 */
797 .align 6
798el0_svc:
799 adrp stbl, sys_call_table // load syscall table pointer
Dave Martin35d0e6f2017-08-01 15:35:53 +0100800 mov wscno, w8 // syscall number in w8
801 mov wsc_nr, #__NR_syscalls
Catalin Marinas60ffc302012-03-05 11:49:27 +0000802el0_svc_naked: // compat entry point
Dave Martin35d0e6f2017-08-01 15:35:53 +0100803 stp x0, xscno, [sp, #S_ORIG_X0] // save the original x0 and syscall number
Will Deacon2a283072014-04-29 19:04:06 +0100804 enable_dbg_and_irq
Larry Bassel6c81fe72014-05-30 12:34:15 -0700805 ct_user_exit 1
Catalin Marinas60ffc302012-03-05 11:49:27 +0000806
Mark Rutlandc02433d2016-11-03 20:23:13 +0000807 ldr x16, [tsk, #TSK_TI_FLAGS] // check for syscall hooks
AKASHI Takahiro449f81a2014-04-30 10:51:29 +0100808 tst x16, #_TIF_SYSCALL_WORK
809 b.ne __sys_trace
Dave Martin35d0e6f2017-08-01 15:35:53 +0100810 cmp wscno, wsc_nr // check upper syscall limit
Catalin Marinas60ffc302012-03-05 11:49:27 +0000811 b.hs ni_sys
Dave Martin35d0e6f2017-08-01 15:35:53 +0100812 ldr x16, [stbl, xscno, lsl #3] // address in the syscall table
Will Deacond54e81f2014-09-29 11:44:01 +0100813 blr x16 // call sys_* routine
814 b ret_fast_syscall
Catalin Marinas60ffc302012-03-05 11:49:27 +0000815ni_sys:
816 mov x0, sp
Will Deacond54e81f2014-09-29 11:44:01 +0100817 bl do_ni_syscall
818 b ret_fast_syscall
Catalin Marinas60ffc302012-03-05 11:49:27 +0000819ENDPROC(el0_svc)
820
821 /*
822 * This is the really slow path. We're going to be doing context
823 * switches, and waiting for our parent to respond.
824 */
825__sys_trace:
Dave Martin17c28952017-08-01 15:35:54 +0100826 cmp wscno, #NO_SYSCALL // user-issued syscall(-1)?
AKASHI Takahiro1014c812014-11-28 05:26:35 +0000827 b.ne 1f
Dave Martin35d0e6f2017-08-01 15:35:53 +0100828 mov x0, #-ENOSYS // set default errno if so
AKASHI Takahiro1014c812014-11-28 05:26:35 +0000829 str x0, [sp, #S_X0]
8301: mov x0, sp
AKASHI Takahiro3157858f2014-04-30 10:51:30 +0100831 bl syscall_trace_enter
Dave Martin17c28952017-08-01 15:35:54 +0100832 cmp w0, #NO_SYSCALL // skip the syscall?
AKASHI Takahiro1014c812014-11-28 05:26:35 +0000833 b.eq __sys_trace_return_skipped
Dave Martin35d0e6f2017-08-01 15:35:53 +0100834 mov wscno, w0 // syscall number (possibly new)
Catalin Marinas60ffc302012-03-05 11:49:27 +0000835 mov x1, sp // pointer to regs
Dave Martin35d0e6f2017-08-01 15:35:53 +0100836 cmp wscno, wsc_nr // check upper syscall limit
Will Deacond54e81f2014-09-29 11:44:01 +0100837 b.hs __ni_sys_trace
Catalin Marinas60ffc302012-03-05 11:49:27 +0000838 ldp x0, x1, [sp] // restore the syscall args
839 ldp x2, x3, [sp, #S_X2]
840 ldp x4, x5, [sp, #S_X4]
841 ldp x6, x7, [sp, #S_X6]
Dave Martin35d0e6f2017-08-01 15:35:53 +0100842 ldr x16, [stbl, xscno, lsl #3] // address in the syscall table
Will Deacond54e81f2014-09-29 11:44:01 +0100843 blr x16 // call sys_* routine
Catalin Marinas60ffc302012-03-05 11:49:27 +0000844
845__sys_trace_return:
AKASHI Takahiro1014c812014-11-28 05:26:35 +0000846 str x0, [sp, #S_X0] // save returned x0
847__sys_trace_return_skipped:
AKASHI Takahiro3157858f2014-04-30 10:51:30 +0100848 mov x0, sp
849 bl syscall_trace_exit
Catalin Marinas60ffc302012-03-05 11:49:27 +0000850 b ret_to_user
851
Will Deacond54e81f2014-09-29 11:44:01 +0100852__ni_sys_trace:
853 mov x0, sp
854 bl do_ni_syscall
855 b __sys_trace_return
856
Pratyush Anand888b3c82016-07-08 12:35:50 -0400857 .popsection // .entry.text
858
Catalin Marinas60ffc302012-03-05 11:49:27 +0000859/*
860 * Special system call wrappers.
861 */
Catalin Marinas60ffc302012-03-05 11:49:27 +0000862ENTRY(sys_rt_sigreturn_wrapper)
863 mov x0, sp
864 b sys_rt_sigreturn
865ENDPROC(sys_rt_sigreturn_wrapper)