@@ -14,30 +14,37 @@ core::arch::global_asm!(
1414 .global _asm_default_data_abort_handler
1515 .type _asm_default_data_abort_handler, %function
1616 _asm_default_data_abort_handler:
17- // Subtract 8 from the stored LR, see p.1214 of the ARMv7-A architecture manual.
18- subs lr, lr, #8
19- // state save from compiled code
20- stmfd sp!, {{ r0 }}
21- mrs r0, spsr
22- stmfd sp!, {{ r0 }}
17+ sub lr, lr, #8 // Subtract 8 from LR, see p.1214 of the ARMv7-A architecture manual.
18+ push {{ r12 }} // Save preserved register R12 - can now use it
19+ mrs r12, spsr // grab SPSR
20+ push {{ r12 }} // save SPSR value
21+ mov r12, sp // align SP down to eight byte boundary using R12
22+ and r12, r12, 7 //
23+ sub sp, r12 // SP now aligned - only push 64-bit values from here
24+ push {{ r0-r4, r12 }} // push alignment amount, and preserved registers - can now use R0-R3 (R4 is just padding)
2325 "# ,
24- crate :: save_context !( ) ,
26+ crate :: save_fpu_context !( ) ,
2527 r#"
26- // Pass the faulting instruction address to the handler.
27- mov r0, lr
28- // call C handler
29- bl _data_abort_handler
30- // if we get back here, assume they returned a new LR in r0
31- mov lr, r0
28+ mov r0, lr // Pass the faulting instruction address to the handler.
29+ bl _data_abort_handler // call C handler
30+ mov lr, r0 // if we get back here, assume they returned a new LR in r0
3231 "# ,
33- crate :: restore_context !( ) ,
32+ crate :: restore_fpu_context !( ) ,
3433 r#"
35- // Return from the asm handler
36- ldmia sp!, {{ r0 }}
37- msr spsr, r0
38- ldmia sp!, {{ r0 }}
39- movs pc, lr
34+ pop {{ r0-r4, r12 }} // restore preserved registers, dummy value, and alignment amount
35+ add sp, r12 // restore SP alignment using R12
36+ pop {{ r12 }} // restore SPSR using R12
37+ msr spsr, r12 //
38+ pop {{ r12 }} // restore R12
39+ movs pc, lr // return from exception
4040 .size _asm_default_data_abort_handler, . - _asm_default_data_abort_handler
41+ "#
42+ ) ;
43+
44+ core:: arch:: global_asm!(
45+ r#"
46+ // Work around https://github.com/rust-lang/rust/issues/127269
47+ .fpu vfp2
4148
4249
4350 // Called from the vector table when we have a prefetch abort.
@@ -48,29 +55,29 @@ core::arch::global_asm!(
4855 .global _asm_default_prefetch_abort_handler
4956 .type _asm_default_prefetch_abort_handler, %function
5057 _asm_default_prefetch_abort_handler:
51- // Subtract 4 from the stored LR, see p.1212 of the ARMv7-A architecture manual.
52- subs lr, lr, #4
53- // state save from compiled code
54- stmfd sp!, {{ r0 }}
55- mrs r0, spsr
56- stmfd sp!, {{ r0 }}
58+ sub lr, lr, #4 // Subtract 4 from LR, see p.1212 of the ARMv7-A architecture manual.
59+ push {{ r12 }} // Save preserved register R12 - can now use it
60+ mrs r12, spsr // grab SPSR
61+ push {{ r12 }} // save SPSR value
62+ mov r12, sp // align SP down to eight byte boundary using R12
63+ and r12, r12, 7 //
64+ sub sp, r12 // SP now aligned - only push 64-bit values from here
65+ push {{ r0-r4, r12 }} // push alignment amount, and preserved registers - can now use R0-R3 (R4 is just padding)
5766 "# ,
58- crate :: save_context !( ) ,
67+ crate :: save_fpu_context !( ) ,
5968 r#"
60- // Pass the faulting instruction address to the handler.
61- mov r0, lr
62- // call C handler
63- bl _prefetch_abort_handler
64- // if we get back here, assume they returned a new LR in r0
65- mov lr, r0
69+ mov r0, lr // Pass the faulting instruction address to the handler.
70+ bl _prefetch_abort_handler // call C handler
71+ mov lr, r0 // if we get back here, assume they returned a new LR in r0
6672 "# ,
67- crate :: restore_context !( ) ,
73+ crate :: restore_fpu_context !( ) ,
6874 r#"
69- // Return from the asm handler
70- ldmia sp!, {{ r0 }}
71- msr spsr, r0
72- ldmia sp!, {{ r0 }}
73- movs pc, lr
75+ pop {{ r0-r4, r12 }} // restore preserved registers, dummy value, and alignment amount
76+ add sp, r12 // restore SP alignment using R12
77+ pop {{ r12 }} // restore SPSR using R12
78+ msr spsr, r12 //
79+ pop {{ r12 }} // restore R12
80+ movs pc, lr // return from exception
7481 .size _asm_default_prefetch_abort_handler, . - _asm_default_prefetch_abort_handler
7582 "# ,
7683) ;
0 commit comments