| 1 |
/* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 |
/* |
| 3 |
* Linker script variables to be set after section resolution, as |
| 4 |
* ld.lld does not like variables assigned before SECTIONS is processed. |
| 5 |
*/ |
| 6 |
#ifndef __ARM64_KERNEL_IMAGE_VARS_H |
| 7 |
#define __ARM64_KERNEL_IMAGE_VARS_H |
| 8 |
|
| 9 |
#ifndef LINKER_SCRIPT |
| 10 |
#error This file should only be included in vmlinux.lds.S |
| 11 |
#endif |
| 12 |
|
| 13 |
#if defined(CONFIG_LD_IS_LLD) && CONFIG_LLD_VERSION < 210000 |
| 14 |
#define ASSERT(...) |
| 15 |
#endif |
| 16 |
|
| 17 |
#define PI_EXPORT_SYM(sym) \ |
| 18 |
__PI_EXPORT_SYM(sym, __pi_ ## sym, Cannot export BSS symbol sym to startup code) |
| 19 |
#define __PI_EXPORT_SYM(sym, pisym, msg)\ |
| 20 |
PROVIDE(pisym = sym); \ |
| 21 |
ASSERT((sym - KIMAGE_VADDR) < (__bss_start - KIMAGE_VADDR), #msg) |
| 22 |
|
| 23 |
PROVIDE(__efistub_primary_entry = primary_entry); |
| 24 |
|
| 25 |
/* |
| 26 |
* The EFI stub has its own symbol namespace prefixed by __efistub_, to |
| 27 |
* isolate it from the kernel proper. The following symbols are legally |
| 28 |
* accessed by the stub, so provide some aliases to make them accessible. |
| 29 |
* Only include data symbols here, or text symbols of functions that are |
| 30 |
* guaranteed to be safe when executed at another offset than they were |
| 31 |
* linked at. The routines below are all implemented in assembler in a |
| 32 |
* position independent manner |
| 33 |
*/ |
| 34 |
PROVIDE(__efistub_caches_clean_inval_pou = __pi_caches_clean_inval_pou); |
| 35 |
|
| 36 |
PROVIDE(__efistub__text = _text); |
| 37 |
PROVIDE(__efistub__end = _end); |
| 38 |
PROVIDE(__efistub___inittext_end = __inittext_end); |
| 39 |
PROVIDE(__efistub__edata = _edata); |
| 40 |
#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB) |
| 41 |
PROVIDE(__efistub_sysfb_primary_display = sysfb_primary_display); |
| 42 |
#endif |
| 43 |
PROVIDE(__efistub__ctype = _ctype); |
| 44 |
|
| 45 |
PROVIDE(__pi___memcpy = __pi_memcpy); |
| 46 |
PROVIDE(__pi___memmove = __pi_memmove); |
| 47 |
PROVIDE(__pi___memset = __pi_memset); |
| 48 |
|
| 49 |
PI_EXPORT_SYM(id_aa64isar1_override); |
| 50 |
PI_EXPORT_SYM(id_aa64isar2_override); |
| 51 |
PI_EXPORT_SYM(id_aa64mmfr0_override); |
| 52 |
PI_EXPORT_SYM(id_aa64mmfr1_override); |
| 53 |
PI_EXPORT_SYM(id_aa64mmfr2_override); |
| 54 |
PI_EXPORT_SYM(id_aa64pfr0_override); |
| 55 |
PI_EXPORT_SYM(id_aa64pfr1_override); |
| 56 |
PI_EXPORT_SYM(id_aa64smfr0_override); |
| 57 |
PI_EXPORT_SYM(id_aa64zfr0_override); |
| 58 |
PI_EXPORT_SYM(arm64_sw_feature_override); |
| 59 |
PI_EXPORT_SYM(arm64_use_ng_mappings); |
| 60 |
PI_EXPORT_SYM(_ctype); |
| 61 |
|
| 62 |
PI_EXPORT_SYM(swapper_pg_dir); |
| 63 |
|
| 64 |
PI_EXPORT_SYM(_text); |
| 65 |
PI_EXPORT_SYM(_stext); |
| 66 |
PI_EXPORT_SYM(_etext); |
| 67 |
PI_EXPORT_SYM(__start_rodata); |
| 68 |
PI_EXPORT_SYM(__inittext_begin); |
| 69 |
PI_EXPORT_SYM(__inittext_end); |
| 70 |
PI_EXPORT_SYM(__initdata_begin); |
| 71 |
PI_EXPORT_SYM(__initdata_end); |
| 72 |
PI_EXPORT_SYM(_data); |
| 73 |
|
| 74 |
#ifdef CONFIG_KVM |
| 75 |
|
| 76 |
/* |
| 77 |
* KVM nVHE code has its own symbol namespace prefixed with __kvm_nvhe_, to |
| 78 |
* separate it from the kernel proper. The following symbols are legally |
| 79 |
* accessed by it, therefore provide aliases to make them linkable. |
| 80 |
* Do not include symbols which may not be safely accessed under hypervisor |
| 81 |
* memory mappings. |
| 82 |
*/ |
| 83 |
|
| 84 |
/* Alternative callbacks for init-time patching of nVHE hyp code. */ |
| 85 |
KVM_NVHE_ALIAS(kvm_patch_vector_branch); |
| 86 |
KVM_NVHE_ALIAS(kvm_update_va_mask); |
| 87 |
KVM_NVHE_ALIAS(kvm_get_kimage_voffset); |
| 88 |
KVM_NVHE_ALIAS(kvm_compute_final_ctr_el0); |
| 89 |
KVM_NVHE_ALIAS(spectre_bhb_patch_loop_iter); |
| 90 |
KVM_NVHE_ALIAS(spectre_bhb_patch_loop_mitigation_enable); |
| 91 |
KVM_NVHE_ALIAS(spectre_bhb_patch_wa3); |
| 92 |
KVM_NVHE_ALIAS(spectre_bhb_patch_clearbhb); |
| 93 |
KVM_NVHE_ALIAS(alt_cb_patch_nops); |
| 94 |
KVM_NVHE_ALIAS(kvm_compute_ich_hcr_trap_bits); |
| 95 |
|
| 96 |
/* Global kernel state accessed by nVHE hyp code. */ |
| 97 |
KVM_NVHE_ALIAS(kvm_vgic_global_state); |
| 98 |
|
| 99 |
/* Kernel symbols used to call panic() from nVHE hyp code (via ERET). */ |
| 100 |
KVM_NVHE_ALIAS(nvhe_hyp_panic_handler); |
| 101 |
|
| 102 |
/* Vectors installed by hyp-init on reset HVC. */ |
| 103 |
KVM_NVHE_ALIAS(__hyp_stub_vectors); |
| 104 |
|
| 105 |
/* Static keys which are set if a vGIC trap should be handled in hyp. */ |
| 106 |
KVM_NVHE_ALIAS(vgic_v2_cpuif_trap); |
| 107 |
KVM_NVHE_ALIAS(vgic_v3_cpuif_trap); |
| 108 |
|
| 109 |
/* Static key indicating whether GICv3 has GICv2 compatibility */ |
| 110 |
KVM_NVHE_ALIAS(vgic_v3_has_v2_compat); |
| 111 |
|
| 112 |
/* Static key which is set if CNTVOFF_EL2 is unusable */ |
| 113 |
KVM_NVHE_ALIAS(broken_cntvoff_key); |
| 114 |
|
| 115 |
/* EL2 exception handling */ |
| 116 |
KVM_NVHE_ALIAS(__start___kvm_ex_table); |
| 117 |
KVM_NVHE_ALIAS(__stop___kvm_ex_table); |
| 118 |
|
| 119 |
/* Position-independent library routines */ |
| 120 |
KVM_NVHE_ALIAS_HYP(clear_page, __pi_clear_page); |
| 121 |
KVM_NVHE_ALIAS_HYP(copy_page, __pi_copy_page); |
| 122 |
KVM_NVHE_ALIAS_HYP(memcpy, __pi_memcpy); |
| 123 |
KVM_NVHE_ALIAS_HYP(memset, __pi_memset); |
| 124 |
|
| 125 |
#ifdef CONFIG_KASAN |
| 126 |
KVM_NVHE_ALIAS_HYP(__memcpy, __pi_memcpy); |
| 127 |
KVM_NVHE_ALIAS_HYP(__memset, __pi_memset); |
| 128 |
#endif |
| 129 |
|
| 130 |
/* Hyp memory sections */ |
| 131 |
KVM_NVHE_ALIAS(__hyp_idmap_text_start); |
| 132 |
KVM_NVHE_ALIAS(__hyp_idmap_text_end); |
| 133 |
KVM_NVHE_ALIAS(__hyp_text_start); |
| 134 |
KVM_NVHE_ALIAS(__hyp_text_end); |
| 135 |
KVM_NVHE_ALIAS(__hyp_bss_start); |
| 136 |
KVM_NVHE_ALIAS(__hyp_bss_end); |
| 137 |
KVM_NVHE_ALIAS(__hyp_data_start); |
| 138 |
KVM_NVHE_ALIAS(__hyp_data_end); |
| 139 |
KVM_NVHE_ALIAS(__hyp_rodata_start); |
| 140 |
KVM_NVHE_ALIAS(__hyp_rodata_end); |
| 141 |
|
| 142 |
/* pKVM static key */ |
| 143 |
KVM_NVHE_ALIAS(kvm_protected_mode_initialized); |
| 144 |
|
| 145 |
#endif /* CONFIG_KVM */ |
| 146 |
|
| 147 |
#ifdef CONFIG_EFI_ZBOOT |
| 148 |
_kernel_codesize = ABSOLUTE(__inittext_end - _text); |
| 149 |
#endif |
| 150 |
|
| 151 |
/* |
| 152 |
* LLD will occasionally error out with a '__init_end does not converge' error |
| 153 |
* if INIT_IDMAP_DIR_SIZE is defined in terms of _end, as this results in a |
| 154 |
* circular dependency. Counter this by dimensioning the initial IDMAP page |
| 155 |
* tables based on kimage_limit, which is defined such that its value should |
| 156 |
* not change as a result of the initdata segment being pushed over a 64k |
| 157 |
* segment boundary due to changes in INIT_IDMAP_DIR_SIZE, provided that its |
| 158 |
* value doesn't change by more than 2M between linker passes. |
| 159 |
*/ |
| 160 |
kimage_limit = ALIGN(ABSOLUTE(_end + SZ_64K), SZ_2M); |
| 161 |
|
| 162 |
#undef ASSERT |
| 163 |
|
| 164 |
#endif /* __ARM64_KERNEL_IMAGE_VARS_H */ |