Skip to content

Commit 0698fac

Browse files
ardbiesheuvelIngo Molnar
authored andcommitted
efi/arm: Clean EFI stub exit code from cache instead of avoiding it
The following commit: c722549 ("efi/arm: Work around missing cache maintenance in decompressor handover") modified the EFI handover code written in assembler to work around the missing cache maintenance of the piece of code that is executed after the MMU and caches are turned off. Due to the fact that this sequence incorporates a subroutine call, cleaning that code from the cache is not a matter of simply passing the start and end of the currently running subroutine into cache_clean_flush(), which is why instead, the code jumps across into the cleaned copy of the 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 cache_clean_flush() call to cover the remaining code in the subroutine, and any code it may execute in the context of cache_off(). Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: [email protected] Cc: Ingo Molnar <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Heinrich Schuchardt <[email protected]> Cc: Tom Lendacky <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 9864936 commit 0698fac

File tree

1 file changed

+8
-10
lines changed
  • arch/arm/boot/compressed

1 file changed

+8
-10
lines changed

arch/arm/boot/compressed/head.S

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,13 +1452,11 @@ ENTRY(efi_enter_kernel)
14521452

14531453
@ The PE/COFF loader might not have cleaned the code we are
14541454
@ running beyond the PoU, and so calling cache_off below from
1455-
@ inside the PE/COFF loader allocated region is unsafe. Let's
1456-
@ assume our own zImage relocation code did a better job, and
1457-
@ jump into its version of this routine before proceeding.
1458-
ldr r1, .Ljmp
1459-
sub r1, r7, r1
1460-
mov pc, r1 @ no mode switch
1461-
0:
1455+
@ inside the PE/COFF loader allocated region is unsafe unless
1456+
@ we explicitly clean it to the PoC.
1457+
adr r0, call_cache_fn @ region of code we will
1458+
adr r1, 0f @ run with MMU off
1459+
bl cache_clean_flush
14621460
bl cache_off
14631461

14641462
@ Set parameters for booting zImage according to boot protocol
@@ -1467,10 +1465,10 @@ ENTRY(efi_enter_kernel)
14671465
mov r0, #0
14681466
mov r1, #0xFFFFFFFF
14691467
mov r2, r4
1470-
b __efi_start
1468+
add r7, r7, #(__efi_start - start)
1469+
mov pc, r7 @ no mode switch
14711470
ENDPROC(efi_enter_kernel)
1472-
.align 2
1473-
.Ljmp: .long start - 0b
1471+
0:
14741472
#endif
14751473

14761474
.align

0 commit comments

Comments
 (0)