18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) 2020 Google LLC.
48c2ecf20Sopenharmony_ci * Written by David Brazdil <dbrazdil@google.com>
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef __ARM64_HYP_IMAGE_H__
88c2ecf20Sopenharmony_ci#define __ARM64_HYP_IMAGE_H__
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci/*
118c2ecf20Sopenharmony_ci * KVM nVHE code has its own symbol namespace prefixed with __kvm_nvhe_,
128c2ecf20Sopenharmony_ci * to separate it from the kernel proper.
138c2ecf20Sopenharmony_ci */
148c2ecf20Sopenharmony_ci#define kvm_nvhe_sym(sym)	__kvm_nvhe_##sym
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#ifdef LINKER_SCRIPT
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci/*
198c2ecf20Sopenharmony_ci * KVM nVHE ELF section names are prefixed with .hyp, to separate them
208c2ecf20Sopenharmony_ci * from the kernel proper.
218c2ecf20Sopenharmony_ci */
228c2ecf20Sopenharmony_ci#define HYP_SECTION_NAME(NAME)	.hyp##NAME
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci/* Defines an ELF hyp section from input section @NAME and its subsections. */
258c2ecf20Sopenharmony_ci#define HYP_SECTION(NAME) \
268c2ecf20Sopenharmony_ci	HYP_SECTION_NAME(NAME) : { *(NAME NAME##.*) }
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci/*
298c2ecf20Sopenharmony_ci * Defines a linker script alias of a kernel-proper symbol referenced by
308c2ecf20Sopenharmony_ci * KVM nVHE hyp code.
318c2ecf20Sopenharmony_ci */
328c2ecf20Sopenharmony_ci#define KVM_NVHE_ALIAS(sym)	kvm_nvhe_sym(sym) = sym;
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci/* Defines a linker script alias for KVM nVHE hyp symbols */
358c2ecf20Sopenharmony_ci#define KVM_NVHE_ALIAS_HYP(first, sec)	kvm_nvhe_sym(first) = kvm_nvhe_sym(sec);
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#endif /* LINKER_SCRIPT */
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#endif /* __ARM64_HYP_IMAGE_H__ */
40