@@ -182,36 +182,18 @@ macro_rules! exception_handlers {
182182.endm
183183
184184/**
185- * This is a generic handler for exceptions taken at the current EL while using
186- * SP0. It behaves similarly to the SPx case by first switching to SPx, doing
187- * the work, then switching back to SP0 before returning.
188- *
189- * Switching to SPx and calling the Rust handler takes 17 instructions. To
190- * restore and return we would need need an additional 16 instructions which
191- * would take us over the limit of 32, so we instead jump to a separate function
192- * to do so. This makes the handler 18 instructions.
193- */
194- .macro current_exception_sp0 handler:req el:req
195- msr spsel, #1
196- save_volatile_to_stack \el
197- mov x0, sp
198- bl \handler
199- b restore_volatile_from_stack_sp0_\el
200- .endm
201-
202- /**
203- * This is a generic handler for exceptions taken at the current EL while using
204- * SPx. It saves volatile registers, calls the Rust handler, restores volatile
185+ * This is a generic handler for exceptions taken at the current EL. It saves
186+ * volatile registers to the stack, calls the Rust handler, restores volatile
205187 * registers, then returns.
206188 *
207- * This also works for exceptions taken from EL0 , if we don't care about
189+ * This also works for exceptions taken from lower ELs , if we don't care about
208190 * non-volatile registers.
209191 *
210192 * Saving state and jumping to the Rust handler takes 16 instructions, and
211193 * restoring and returning also takes 15 instructions, so we can fit the whole
212194 * handler in 31 instructions, under the limit of 32.
213195 */
214- .macro current_exception_spx handler:req el:req
196+ .macro current_exception handler:req el:req
215197 save_volatile_to_stack \el
216198 mov x0, sp
217199 bl \handler
@@ -225,91 +207,73 @@ macro_rules! exception_handlers {
225207.balign 0x800
226208vector_table_\el:
227209sync_cur_sp0_\el:
228- current_exception_sp0 {sync_current} \el
210+ current_exception {sync_current} \el
229211
230212.balign 0x80
231213irq_cur_sp0_\el:
232- current_exception_sp0 {irq_current} \el
214+ current_exception {irq_current} \el
233215
234216.balign 0x80
235217fiq_cur_sp0_\el:
236- current_exception_sp0 {fiq_current} \el
218+ current_exception {fiq_current} \el
237219
238220.balign 0x80
239221serr_cur_sp0_\el:
240- current_exception_sp0 {serror_current} \el
222+ current_exception {serror_current} \el
241223
242224.balign 0x80
243225sync_cur_spx_\el:
244- current_exception_spx {sync_current} \el
226+ current_exception {sync_current} \el
245227
246228.balign 0x80
247229irq_cur_spx_\el:
248- current_exception_spx {irq_current} \el
230+ current_exception {irq_current} \el
249231
250232.balign 0x80
251233fiq_cur_spx_\el:
252- current_exception_spx {fiq_current} \el
234+ current_exception {fiq_current} \el
253235
254236.balign 0x80
255237serr_cur_spx_\el:
256- current_exception_spx {serror_current} \el
238+ current_exception {serror_current} \el
257239
258240.balign 0x80
259241sync_lower_64_\el:
260- current_exception_spx {sync_lower} \el
242+ current_exception {sync_lower} \el
261243
262244.balign 0x80
263245irq_lower_64_\el:
264- current_exception_spx {irq_lower} \el
246+ current_exception {irq_lower} \el
265247
266248.balign 0x80
267249fiq_lower_64_\el:
268- current_exception_spx {fiq_lower} \el
250+ current_exception {fiq_lower} \el
269251
270252.balign 0x80
271253serr_lower_64_\el:
272- current_exception_spx {serror_lower} \el
254+ current_exception {serror_lower} \el
273255
274256.balign 0x80
275257sync_lower_32_\el:
276- current_exception_spx {sync_lower} \el
258+ current_exception {sync_lower} \el
277259
278260.balign 0x80
279261irq_lower_32_\el:
280- current_exception_spx {irq_lower} \el
262+ current_exception {irq_lower} \el
281263
282264.balign 0x80
283265fiq_lower_32_\el:
284- current_exception_spx {fiq_lower} \el
266+ current_exception {fiq_lower} \el
285267
286268.balign 0x80
287269serr_lower_32_\el:
288- current_exception_spx {serror_lower} \el
270+ current_exception {serror_lower} \el
289271
290272.endm
291273
292274vector_table el1
293275vector_table el2
294276vector_table el3
295-
296- .section .text.restore_volatile_from_stack_sp0_el1, "ax"
297- restore_volatile_from_stack_sp0_el1:
298- restore_volatile_from_stack el1
299- msr spsel, #0
300- eret
301-
302- .section .text.restore_volatile_from_stack_sp0_el3, "ax"
303- restore_volatile_from_stack_sp0_el2:
304- restore_volatile_from_stack el2
305- msr spsel, #0
306- eret
307-
308- .section .text.restore_volatile_from_stack_sp0_el3, "ax"
309- restore_volatile_from_stack_sp0_el3:
310- restore_volatile_from_stack el3
311- msr spsel, #0
312- eret
313277 "# ,
314278 sync_current = sym <$handlers as $crate:: ExceptionHandlers >:: sync_current,
315279 irq_current = sym <$handlers as $crate:: ExceptionHandlers >:: irq_current,
0 commit comments