arm64: efi: Move dcache cleaning of loaded image out of efi_enter_kernel()
authorArd Biesheuvel <ardb@kernel.org>
Mon, 17 Oct 2022 14:06:39 +0000 (16:06 +0200)
committerArd Biesheuvel <ardb@kernel.org>
Wed, 9 Nov 2022 11:42:01 +0000 (12:42 +0100)
The efi_enter_kernel() routine will be shared between the existing EFI
stub and the zboot decompressor, and the version of
dcache_clean_to_poc() that the core kernel exports to the stub will not
be available in the latter case.

So move the handling into the .c file which will remain part of the stub
build that integrates directly with the kernel proper.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/kernel/efi-entry.S
arch/arm64/kernel/image-vars.h
drivers/firmware/efi/libstub/arm64-stub.c

index 61a87fa1c3055e26252c2b5e029359aceb4d0574..1c1be004a271f142fd328a810ab16aa17cf417ac 100644 (file)
@@ -23,15 +23,6 @@ SYM_CODE_START(efi_enter_kernel)
        add     x19, x0, x2             // relocated Image entrypoint
        mov     x20, x1                 // DTB address
 
-       /*
-        * Clean the copied Image to the PoC, and ensure it is not shadowed by
-        * stale icache entries from before relocation.
-        */
-       ldr     w1, =kernel_size
-       add     x1, x0, x1
-       bl      dcache_clean_poc
-       ic      ialluis
-
        /*
         * Clean the remainder of this routine to the PoC
         * so that we can safely disable the MMU and caches.
index 8151412653de209cc9006881d2e496b132cbd72e..74d20835cf912f68f0b6a24c2869e02a4afa288a 100644 (file)
@@ -10,7 +10,6 @@
 #error This file should only be included in vmlinux.lds.S
 #endif
 
-PROVIDE(__efistub_kernel_size          = _edata - _text);
 PROVIDE(__efistub_primary_entry_offset = primary_entry - _text);
 
 /*
index 259e4b852d63276d7732f462c54984ad155ab84a..bcb21afd8aeb61b703ee6da2c12794152021843d 100644 (file)
@@ -156,7 +156,7 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
                         */
                        *image_addr = (u64)_text;
                        *reserve_size = 0;
-                       return EFI_SUCCESS;
+                       goto clean_image_to_poc;
                }
 
                status = efi_allocate_pages_aligned(*reserve_size, reserve_addr,
@@ -172,5 +172,13 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
        *image_addr = *reserve_addr;
        memcpy((void *)*image_addr, _text, kernel_size);
 
+clean_image_to_poc:
+       /*
+        * Clean the copied Image to the PoC, and ensure it is not shadowed by
+        * stale icache entries from before relocation.
+        */
+       dcache_clean_poc(*image_addr, *image_addr + kernel_size);
+       asm("ic ialluis");
+
        return EFI_SUCCESS;
 }