From 0108b774b0511bc81e4ccb86aae69aba36468aea Mon Sep 17 00:00:00 2001 From: Andy Bui Date: Thu, 16 Nov 2023 15:19:52 +1100 Subject: [PATCH] elfloader: arm: do not save FP and LR on stack 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 --- elfloader-tool/src/arch-arm/armv/armv8-a/64/mmu-hyp.S | 5 ----- elfloader-tool/src/arch-arm/armv/armv8-a/64/mmu.S | 5 ----- 2 files changed, 10 deletions(-) diff --git a/elfloader-tool/src/arch-arm/armv/armv8-a/64/mmu-hyp.S b/elfloader-tool/src/arch-arm/armv/armv8-a/64/mmu-hyp.S index 55a15de7..8b9fd216 100644 --- a/elfloader-tool/src/arch-arm/armv/armv8-a/64/mmu-hyp.S +++ b/elfloader-tool/src/arch-arm/armv/armv8-a/64/mmu-hyp.S @@ -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 @@ -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 diff --git a/elfloader-tool/src/arch-arm/armv/armv8-a/64/mmu.S b/elfloader-tool/src/arch-arm/armv/armv8-a/64/mmu.S index bbb80fa7..705c5671 100644 --- a/elfloader-tool/src/arch-arm/armv/armv8-a/64/mmu.S +++ b/elfloader-tool/src/arch-arm/armv/armv8-a/64/mmu.S @@ -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 @@ -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)