mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-23 11:04:44 +08:00
c82ceb440b
The stub is used in different execution environments, but on arm64, RISC-V and LoongArch, we still use the core kernel's implementation of memcpy and memset, as they are just a branch instruction away, and can generally be reused even from code such as the EFI stub that runs in a completely different address space. KAsan complicates this slightly, resulting in the need for some hacks to expose the uninstrumented, __ prefixed versions as the normal ones, as the latter are instrumented to include the KAsan checks, which only work in the core kernel. Unfortunately, #define'ing memcpy to __memcpy when building C code does not guarantee that no explicit memcpy() calls will be emitted. And with the upcoming zboot support, which consists of a separate binary which therefore needs its own implementation of memcpy/memset anyway, it's better to provide one explicitly instead of linking to the existing one. Given that EFI exposes implementations of memmove() and memset() via the boot services table, let's wire those up in the appropriate way, and drop the references to the core kernel ones. Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
43 lines
1.3 KiB
C
43 lines
1.3 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (C) 2020 Western Digital Corporation or its affiliates.
|
|
* Linker script variables to be set after section resolution, as
|
|
* ld.lld does not like variables assigned before SECTIONS is processed.
|
|
* Based on arch/arm64/kernel/image-vars.h
|
|
*/
|
|
#ifndef __RISCV_KERNEL_IMAGE_VARS_H
|
|
#define __RISCV_KERNEL_IMAGE_VARS_H
|
|
|
|
#ifndef LINKER_SCRIPT
|
|
#error This file should only be included in vmlinux.lds.S
|
|
#endif
|
|
|
|
#ifdef CONFIG_EFI
|
|
|
|
/*
|
|
* The EFI stub has its own symbol namespace prefixed by __efistub_, to
|
|
* isolate it from the kernel proper. The following symbols are legally
|
|
* accessed by the stub, so provide some aliases to make them accessible.
|
|
* Only include data symbols here, or text symbols of functions that are
|
|
* guaranteed to be safe when executed at another offset than they were
|
|
* linked at. The routines below are all implemented in assembler in a
|
|
* position independent manner
|
|
*/
|
|
__efistub_memcmp = memcmp;
|
|
__efistub_memchr = memchr;
|
|
__efistub_strlen = strlen;
|
|
__efistub_strnlen = strnlen;
|
|
__efistub_strcmp = strcmp;
|
|
__efistub_strncmp = strncmp;
|
|
__efistub_strrchr = strrchr;
|
|
|
|
__efistub__start = _start;
|
|
__efistub__start_kernel = _start_kernel;
|
|
__efistub__end = _end;
|
|
__efistub__edata = _edata;
|
|
__efistub_screen_info = screen_info;
|
|
|
|
#endif
|
|
|
|
#endif /* __RISCV_KERNEL_IMAGE_VARS_H */
|