summaryrefslogtreecommitdiff
path: root/arch/arm/boot/compressed/head.S
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2020-02-17 14:44:37 +0300
committerArd Biesheuvel <ardb@kernel.org>2020-02-23 01:37:37 +0300
commit9f9223778ef385e79dc67f5ee48ee4c1fb757f6b (patch)
tree82aab113bd4467d603dc317435832205ac1e7c74 /arch/arm/boot/compressed/head.S
parente951a1f427f2312e17b4e0f485e60068ca1423bb (diff)
downloadlinux-9f9223778ef385e79dc67f5ee48ee4c1fb757f6b.tar.xz
efi/libstub/arm: Make efi_entry() an ordinary PE/COFF entrypoint
Expose efi_entry() as the PE/COFF entrypoint directly, instead of jumping into a wrapper that fiddles with stack buffers and other stuff that the compiler is much better at. The only reason this code exists is to obtain a pointer to the base of the image, but we can get the same value from the loaded_image protocol, which we already need for other reasons anyway. Update the return type as well, to make it consistent with what is required for a PE/COFF executable entrypoint. Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Diffstat (limited to 'arch/arm/boot/compressed/head.S')
-rw-r--r--arch/arm/boot/compressed/head.S42
1 files changed, 9 insertions, 33 deletions
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index 8487221bedb0..36ffbeecd30b 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -1437,33 +1437,15 @@ __enter_kernel:
reloc_code_end:
#ifdef CONFIG_EFI_STUB
- .align 2
-_start: .long start - .
-
-ENTRY(efi_stub_entry)
- @ allocate space on stack for passing current zImage address
- @ and for the EFI stub to return of new entry point of
- @ zImage, as EFI stub may copy the kernel. Pointer address
- @ is passed in r2. r0 and r1 are passed through from the
- @ EFI firmware to efi_entry
- adr ip, _start
- ldr r3, [ip]
- add r3, r3, ip
- stmfd sp!, {r3, lr}
- mov r2, sp @ pass zImage address in r2
- bl efi_entry
-
- @ Check for error return from EFI stub. r0 has FDT address
- @ or error code.
- cmn r0, #1
- beq efi_load_fail
-
- @ Preserve return value of efi_entry() in r4
- mov r4, r0
- add r1, r4, #SZ_2M @ DT end
+ENTRY(efi_enter_kernel)
+ mov r7, r0 @ preserve image base
+ mov r4, r1 @ preserve DT pointer
+
+ mov r0, r4 @ DT start
+ add r1, r4, r2 @ DT end
bl cache_clean_flush
- ldr r0, [sp] @ relocated zImage
+ mov r0, r7 @ relocated zImage
ldr r1, =_edata @ size of zImage
add r1, r1, r0 @ end of zImage
bl cache_clean_flush
@@ -1473,9 +1455,8 @@ ENTRY(efi_stub_entry)
@ inside the PE/COFF loader allocated region is unsafe. Let's
@ assume our own zImage relocation code did a better job, and
@ jump into its version of this routine before proceeding.
- ldr r0, [sp] @ relocated zImage
ldr r1, .Ljmp
- sub r1, r0, r1
+ sub r1, r7, r1
mov pc, r1 @ no mode switch
0:
bl cache_off
@@ -1487,12 +1468,7 @@ ENTRY(efi_stub_entry)
mov r1, #0xFFFFFFFF
mov r2, r4
b __efi_start
-
-efi_load_fail:
- @ Return EFI_LOAD_ERROR to EFI firmware on error.
- ldr r0, =0x80000001
- ldmfd sp!, {ip, pc}
-ENDPROC(efi_stub_entry)
+ENDPROC(efi_enter_kernel)
.align 2
.Ljmp: .long start - 0b
#endif