1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2020 Google LLC.
4 * Written by David Brazdil <dbrazdil@google.com>
7 #ifndef __ARM64_HYP_IMAGE_H__
8 #define __ARM64_HYP_IMAGE_H__
10 #define __HYP_CONCAT(a, b) a ## b
11 #define HYP_CONCAT(a, b) __HYP_CONCAT(a, b)
14 * KVM nVHE code has its own symbol namespace prefixed with __kvm_nvhe_,
15 * to separate it from the kernel proper.
17 #define kvm_nvhe_sym(sym) __kvm_nvhe_##sym
22 * KVM nVHE ELF section names are prefixed with .hyp, to separate them
23 * from the kernel proper.
25 #define HYP_SECTION_NAME(NAME) .hyp##NAME
27 /* Symbol defined at the beginning of each hyp section. */
28 #define HYP_SECTION_SYMBOL_NAME(NAME) \
29 HYP_CONCAT(__hyp_section_, HYP_SECTION_NAME(NAME))
32 * Helper to generate linker script statements starting a hyp section.
34 * A symbol with a well-known name is defined at the first byte. This
35 * is used as a base for hyp relocations (see gen-hyprel.c). It must
36 * be defined inside the section so the linker of `vmlinux` cannot
37 * separate it from the section data.
39 #define BEGIN_HYP_SECTION(NAME) \
40 HYP_SECTION_NAME(NAME) : { \
41 HYP_SECTION_SYMBOL_NAME(NAME) = .;
43 /* Helper to generate linker script statements ending a hyp section. */
44 #define END_HYP_SECTION \
47 /* Defines an ELF hyp section from input section @NAME and its subsections. */
48 #define HYP_SECTION(NAME) \
49 BEGIN_HYP_SECTION(NAME) \
54 * Defines a linker script alias of a kernel-proper symbol referenced by
57 #define KVM_NVHE_ALIAS(sym) kvm_nvhe_sym(sym) = sym;
59 #endif /* LINKER_SCRIPT */
61 #endif /* __ARM64_HYP_IMAGE_H__ */