linux/arch/arm64/include/asm/hyp_image.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2/*
   3 * Copyright (C) 2020 Google LLC.
   4 * Written by David Brazdil <dbrazdil@google.com>
   5 */
   6
   7#ifndef __ARM64_HYP_IMAGE_H__
   8#define __ARM64_HYP_IMAGE_H__
   9
  10#define __HYP_CONCAT(a, b)      a ## b
  11#define HYP_CONCAT(a, b)        __HYP_CONCAT(a, b)
  12
  13#ifndef __KVM_NVHE_HYPERVISOR__
  14/*
  15 * KVM nVHE code has its own symbol namespace prefixed with __kvm_nvhe_,
  16 * to separate it from the kernel proper.
  17 */
  18#define kvm_nvhe_sym(sym)       __kvm_nvhe_##sym
  19#else
  20#define kvm_nvhe_sym(sym)       sym
  21#endif
  22
  23#ifdef LINKER_SCRIPT
  24
  25/*
  26 * KVM nVHE ELF section names are prefixed with .hyp, to separate them
  27 * from the kernel proper.
  28 */
  29#define HYP_SECTION_NAME(NAME)  .hyp##NAME
  30
  31/* Symbol defined at the beginning of each hyp section. */
  32#define HYP_SECTION_SYMBOL_NAME(NAME) \
  33        HYP_CONCAT(__hyp_section_, HYP_SECTION_NAME(NAME))
  34
  35/*
  36 * Helper to generate linker script statements starting a hyp section.
  37 *
  38 * A symbol with a well-known name is defined at the first byte. This
  39 * is used as a base for hyp relocations (see gen-hyprel.c). It must
  40 * be defined inside the section so the linker of `vmlinux` cannot
  41 * separate it from the section data.
  42 */
  43#define BEGIN_HYP_SECTION(NAME)                         \
  44        HYP_SECTION_NAME(NAME) : {                      \
  45                HYP_SECTION_SYMBOL_NAME(NAME) = .;
  46
  47/* Helper to generate linker script statements ending a hyp section. */
  48#define END_HYP_SECTION                                 \
  49        }
  50
  51/* Defines an ELF hyp section from input section @NAME and its subsections. */
  52#define HYP_SECTION(NAME)                       \
  53        BEGIN_HYP_SECTION(NAME)                 \
  54                *(NAME NAME##.*)                \
  55        END_HYP_SECTION
  56
  57/*
  58 * Defines a linker script alias of a kernel-proper symbol referenced by
  59 * KVM nVHE hyp code.
  60 */
  61#define KVM_NVHE_ALIAS(sym)     kvm_nvhe_sym(sym) = sym;
  62
  63/* Defines a linker script alias for KVM nVHE hyp symbols */
  64#define KVM_NVHE_ALIAS_HYP(first, sec)  kvm_nvhe_sym(first) = kvm_nvhe_sym(sec);
  65
  66#endif /* LINKER_SCRIPT */
  67
  68#endif /* __ARM64_HYP_IMAGE_H__ */
  69