@@ -160,8 +160,13 @@ Anticipated changes to this document include:
160160 [ Arguments on the stack and floating point handling] ( #arguments-on-the-stack-and-floating-point-handling ) .
161161* Removed incorrect information about the floating-point ABI used in
162162 [ Arguments on the stack and floating point handling] ( #arguments-on-the-stack-and-floating-point-handling ) .
163+ * Replaced a conditional clearing of floating-point registers by the ` VSCCLRM `
164+ instruction in the example in
165+ [ Arguments on the stack and floating point handling] ( #arguments-on-the-stack-and-floating-point-handling ) .
163166* Corrected description and example in section
164167 [ Non-secure function pointers] ( #non-secure-function-pointer ) .
168+ * Corrected examples to save and restore ` FPCXT ` in Security state transitions.
169+ * Replaced sequences of ` mov rX, #0 ` by the ` CLRM ` instruction in examples.
165170
166171## References
167172
@@ -1592,20 +1597,23 @@ bar:
15921597 @ protect the FP context if used by secure state
15931598 sub sp, sp, #0x88
15941599 vlstm sp
1600+ @ save FPCXTS. LR is stacked only for alignment purposes
1601+ vmrs r2, fpcxts
1602+ push {r2, lr}
15951603 @ save callee-saved integer registers
15961604 push {r4-r12, lr}
15971605 @ clear all integer registers (except for function pointer and arguments)
1598- mov r2, #0
1599- mov r3, #0
1600- …
1601- mov r12, #0
1606+ clrm {r2-r12}
16021607 @ clear the integer status flags
16031608 msr APSR_nzcvqg, r2
16041609 @ perform the call to the non-secure function
16051610 bic r1, r1, #1
16061611 blxns r1
16071612 @ restore the callee-saved registers
16081613 pop {r4-r12, lr}
1614+ @ restore FPCXTS
1615+ pop {r2, lr}
1616+ vmsr fpcxts, r2
16091617 @ unprotect the FP context and restore it if it was pushed
16101618 vlldm sp
16111619 add sp, sp, #0x88
@@ -1642,10 +1650,7 @@ bar:
16421650 @ setup floating point arguments of the call
16431651 vmov s0, r1
16441652 @ clear all integer registers (except for function pointer and arguments)
1645- mov r2, #0
1646- mov r3, #0
1647- …
1648- mov r12, #0
1653+ clrm {r2-r12}
16491654 @ clear the integer status flags
16501655 msr APSR_nzcvqg, r2
16511656 @ perform the call to the non-secure function
@@ -1723,10 +1728,7 @@ bar:
17231728 @ load the function pointer
17241729 ldr r4, =foo
17251730 @ clear all integer registers (except for function pointer and arguments)
1726- mov r6, #0
1727- mov r7, #0
1728- …
1729- mov r12, #0
1731+ clrm {r6-r12}
17301732 @ clear the integer status flags
17311733 msr APSR_nzcvqg, r6
17321734 @ perform the call to the non-secure function
@@ -1808,12 +1810,14 @@ foo:
18081810__acle_se_foo:
18091811 @ 1: if called from non-secure reserve secure stack space for the arguments
18101812 tst lr, #1
1811- it eq
1813+ ittt eq
18121814 subeq sp, sp, #8
1815+ @ 3: save FPCXTNS if called from non-secure. LR is stacked only for alignment purposes
1816+ vmrseq r12, fpcxtns
1817+ pusheq {r12, lr}
18131818 @ 2: push used callee-saved register onto the stack
18141819 push {r4-r6, lr}
18151820 @ 3: if called from secure the arguments are already in the correct place
1816- tst lr, #1
18171821 bne .LdoneARGS
18181822 @ 4: get the non-secure stack pointer
18191823 mrs r4, SP_NS
@@ -1842,29 +1846,20 @@ __acle_se_foo:
18421846 bl bar
18431847 @11: restore used callee-saved registers
18441848 pop {r4-r6, lr}
1845- @12: if called from secure, we are done
1849+ @12: restore FPCXTNS if called from non- secure
18461850 tst lr, #1
1847- it ne
1851+ itte eq
1852+ popeq {r12, lr}
1853+ vmsreq fpcxtns, r12
1854+ @12: if called from secure, we are done
18481855 bxne lr
18491856 @13: pop secure stack space
18501857 add sp, sp, #8
1851- @14: check SFPA bit to see if FP is used
1852- mrs r1, control
1853- tst r1, #8
1854- bne .LdoneFP
1855- @15: clear floating point caller-saved registers
1856- mov r1, #0
1857- vmov s0, s1, r1, r1
1858- vmov s2, s3, r1, r1
1859- ...
1860- vmov s30, s31, r1, r1
1861- @16: clear floating point flags
1862- vmsr fpscr, r1
1858+ @14: clear floating point caller-saved registers if a FP context is active
1859+ vscclrm {s0-s31}
18631860.LdoneFP:
1864- @17: clear integer caller-saved registers except for return value
1865- mov r1, #0
1866- mov r2, #0
1867- mov r3, #0
1861+ @15: clear integer caller-saved registers except for return value
1862+ clrm {r1-r3}
18681863 @18: clear other registers and the integer status flags
18691864 mov r12, #0
18701865 msr APSR_nzcvqg, r3
0 commit comments