1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2020 Western Digital Corporation or its affiliates.
9 #include <asm/sections.h>
10 #include <asm/unaligned.h>
14 unsigned long stext_offset(void)
17 * When built as part of the kernel, the EFI stub cannot branch to the
18 * kernel proper via the image header, as the PE/COFF header is
19 * strictly not part of the in-memory presentation of the image, only
20 * of the file representation. So instead, we need to jump to the
21 * actual entrypoint in the .text region of the image.
23 return _start_kernel - _start;
26 efi_status_t handle_kernel_image(unsigned long *image_addr,
27 unsigned long *image_size,
28 unsigned long *reserve_addr,
29 unsigned long *reserve_size,
30 efi_loaded_image_t *image,
31 efi_handle_t image_handle)
33 unsigned long kernel_size, kernel_codesize, kernel_memsize;
36 kernel_size = _edata - _start;
37 kernel_codesize = __init_text_end - _start;
38 kernel_memsize = kernel_size + (_end - _edata);
39 *image_addr = (unsigned long)_start;
40 *image_size = kernel_memsize;
41 *reserve_size = *image_size;
43 status = efi_kaslr_relocate_kernel(image_addr,
44 reserve_addr, reserve_size,
45 kernel_size, kernel_codesize, kernel_memsize,
46 efi_kaslr_get_phys_seed(image_handle));
47 if (status != EFI_SUCCESS) {
48 efi_err("Failed to relocate kernel\n");
55 void efi_icache_sync(unsigned long start, unsigned long end)
57 asm volatile ("fence.i" ::: "memory");