Skip to content

Commit

Permalink
elfloader: arm: do not save FP and LR on stack
Browse files Browse the repository at this point in the history
Since we do not have to branch to another label, there is no need to
follow the ABI here. This removes 2 memory access before and after
changing the state of the MMU, which should overall reduce the chance of
any speculative fetches going wrong.

Signed-off-by: Andy Bui <[email protected]>
  • Loading branch information
Andy Bui committed Feb 25, 2024
1 parent 0cdf9c2 commit 0108b77
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 10 deletions.
5 changes: 0 additions & 5 deletions elfloader-tool/src/arch-arm/armv/armv8-a/64/mmu-hyp.S
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ clean_dcache_by_range_loop:
END_FUNC(clean_dcache_by_range)

BEGIN_FUNC(leave_hyp)
/* We call nested functions, follow the ABI. */
stp x29, x30, [sp, #-16]!
mov x29, sp

/* Ensure I-cache, D-cache and mmu are disabled for EL1/Stage2 */
mov x9, #(1 << 31)
msr hcr_el2, x9
Expand All @@ -74,7 +70,6 @@ BEGIN_FUNC(leave_hyp)
msr spsr_el2, x9

/* Let's the caller use our stack, in case it needs to pop something */
ldp x29, x30, [sp], #16
mov x10, sp
msr sp_el1, x10
msr elr_el2, x30
Expand Down
5 changes: 0 additions & 5 deletions elfloader-tool/src/arch-arm/armv/armv8-a/64/mmu.S
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ BEGIN_FUNC(flush_dcache)
END_FUNC(flush_dcache)

BEGIN_FUNC(arm_enable_mmu)
/* We call nested functions, follow the ABI. */
stp x29, x30, [sp, #-16]!
mov x29, sp

/*
* DEVICE_nGnRnE 000 00000000
* DEVICE_nGnRE 001 00000100
Expand Down Expand Up @@ -81,6 +77,5 @@ BEGIN_FUNC(arm_enable_mmu)
adrp x8, arm_vector_table
msr vbar_el1, x8

ldp x29, x30, [sp], #16
ret
END_FUNC(arm_enable_mmu)

0 comments on commit 0108b77

Please sign in to comment.