mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-05 02:19:51 +00:00
efi/arm64: Clean EFI stub exit code from cache instead of avoiding it
Commit 9f9223778
("efi/libstub/arm: Make efi_entry() an ordinary PE/COFF
entrypoint") modified the handover code written in assembler, and for
maintainability, aligned the logic with the logic used in the 32-bit ARM
version, which is to avoid cache maintenance on the remaining instructions
in the subroutine that will be executed with the MMU and caches off, and
instead, branch into the relocated copy of the kernel image.
However, this assumes that this copy is executable, and this means we
expect EFI_LOADER_DATA regions to be executable as well, which is not
a reasonable assumption to make, even if this is true for most UEFI
implementations today.
So change this back, and add a __clean_dcache_area_poc() call to cover
the remaining code in the subroutine. While at it, switch the other
call site over to __clean_dcache_area_poc() as well, and clean up the
terminology in comments to avoid using 'flush' in the context of cache
maintenance. Also, let's switch to the new style asm annotations.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: linux-efi@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: David Hildenbrand <david@redhat.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Link: https://lore.kernel.org/r/20200228121408.9075-6-ardb@kernel.org
This commit is contained in:
parent
0698fac4ac
commit
b9676962cd
2 changed files with 15 additions and 15 deletions
|
@ -12,32 +12,32 @@
|
||||||
|
|
||||||
__INIT
|
__INIT
|
||||||
|
|
||||||
ENTRY(efi_enter_kernel)
|
SYM_CODE_START(efi_enter_kernel)
|
||||||
/*
|
/*
|
||||||
* efi_entry() will have copied the kernel image if necessary and we
|
* efi_entry() will have copied the kernel image if necessary and we
|
||||||
* end up here with device tree address in x1 and the kernel entry
|
* end up here with device tree address in x1 and the kernel entry
|
||||||
* point stored in x0. Save those values in registers which are
|
* point stored in x0. Save those values in registers which are
|
||||||
* callee preserved.
|
* callee preserved.
|
||||||
*/
|
*/
|
||||||
mov x19, x0 // relocated Image address
|
ldr w2, =stext_offset
|
||||||
|
add x19, x0, x2 // relocated Image entrypoint
|
||||||
mov x20, x1 // DTB address
|
mov x20, x1 // DTB address
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Flush the copied Image to the PoC, and ensure it is not shadowed by
|
* Clean the copied Image to the PoC, and ensure it is not shadowed by
|
||||||
* stale icache entries from before relocation.
|
* stale icache entries from before relocation.
|
||||||
*/
|
*/
|
||||||
ldr w1, =kernel_size
|
ldr w1, =kernel_size
|
||||||
bl __flush_dcache_area
|
bl __clean_dcache_area_poc
|
||||||
ic ialluis
|
ic ialluis
|
||||||
dsb sy
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Jump across, into the copy of the image that we just cleaned
|
* Clean the remainder of this routine to the PoC
|
||||||
* to the PoC, so that we can safely disable the MMU and caches.
|
* so that we can safely disable the MMU and caches.
|
||||||
*/
|
*/
|
||||||
ldr w0, .Ljmp
|
adr x0, 0f
|
||||||
sub x0, x19, w0, sxtw
|
ldr w1, 3f
|
||||||
br x0
|
bl __clean_dcache_area_poc
|
||||||
0:
|
0:
|
||||||
/* Turn off Dcache and MMU */
|
/* Turn off Dcache and MMU */
|
||||||
mrs x0, CurrentEL
|
mrs x0, CurrentEL
|
||||||
|
@ -63,6 +63,6 @@ ENTRY(efi_enter_kernel)
|
||||||
mov x1, xzr
|
mov x1, xzr
|
||||||
mov x2, xzr
|
mov x2, xzr
|
||||||
mov x3, xzr
|
mov x3, xzr
|
||||||
b stext
|
br x19
|
||||||
ENDPROC(efi_enter_kernel)
|
SYM_CODE_END(efi_enter_kernel)
|
||||||
.Ljmp: .long _text - 0b
|
3: .long . - 0b
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#ifdef CONFIG_EFI
|
#ifdef CONFIG_EFI
|
||||||
|
|
||||||
__efistub_kernel_size = _edata - _text;
|
__efistub_kernel_size = _edata - _text;
|
||||||
|
__efistub_stext_offset = stext - _text;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -34,7 +35,7 @@ __efistub_strnlen = __pi_strnlen;
|
||||||
__efistub_strcmp = __pi_strcmp;
|
__efistub_strcmp = __pi_strcmp;
|
||||||
__efistub_strncmp = __pi_strncmp;
|
__efistub_strncmp = __pi_strncmp;
|
||||||
__efistub_strrchr = __pi_strrchr;
|
__efistub_strrchr = __pi_strrchr;
|
||||||
__efistub___flush_dcache_area = __pi___flush_dcache_area;
|
__efistub___clean_dcache_area_poc = __pi___clean_dcache_area_poc;
|
||||||
|
|
||||||
#ifdef CONFIG_KASAN
|
#ifdef CONFIG_KASAN
|
||||||
__efistub___memcpy = __pi_memcpy;
|
__efistub___memcpy = __pi_memcpy;
|
||||||
|
@ -43,7 +44,6 @@ __efistub___memset = __pi_memset;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__efistub__text = _text;
|
__efistub__text = _text;
|
||||||
__efistub_stext = stext;
|
|
||||||
__efistub__end = _end;
|
__efistub__end = _end;
|
||||||
__efistub__edata = _edata;
|
__efistub__edata = _edata;
|
||||||
__efistub_screen_info = screen_info;
|
__efistub_screen_info = screen_info;
|
||||||
|
|
Loading…
Reference in a new issue