Kees Cook | 90776dd | 2019-08-13 16:04:50 -0700 | [diff] [blame] | 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 | #ifdef CONFIG_EFI |
| 14 | |
Ard Biesheuvel | 9f92237 | 2020-02-17 12:44:37 +0100 | [diff] [blame] | 15 | __efistub_kernel_size = _edata - _text; |
Ard Biesheuvel | 348a625 | 2020-03-26 18:14:23 +0100 | [diff] [blame] | 16 | __efistub_primary_entry_offset = primary_entry - _text; |
Ard Biesheuvel | 9f92237 | 2020-02-17 12:44:37 +0100 | [diff] [blame] | 17 | |
Kees Cook | 90776dd | 2019-08-13 16:04:50 -0700 | [diff] [blame] | 18 | |
| 19 | /* |
| 20 | * The EFI stub has its own symbol namespace prefixed by __efistub_, to |
| 21 | * isolate it from the kernel proper. The following symbols are legally |
| 22 | * accessed by the stub, so provide some aliases to make them accessible. |
| 23 | * Only include data symbols here, or text symbols of functions that are |
| 24 | * guaranteed to be safe when executed at another offset than they were |
| 25 | * linked at. The routines below are all implemented in assembler in a |
| 26 | * position independent manner |
| 27 | */ |
| 28 | __efistub_memcmp = __pi_memcmp; |
| 29 | __efistub_memchr = __pi_memchr; |
| 30 | __efistub_memcpy = __pi_memcpy; |
| 31 | __efistub_memmove = __pi_memmove; |
| 32 | __efistub_memset = __pi_memset; |
| 33 | __efistub_strlen = __pi_strlen; |
| 34 | __efistub_strnlen = __pi_strnlen; |
| 35 | __efistub_strcmp = __pi_strcmp; |
| 36 | __efistub_strncmp = __pi_strncmp; |
| 37 | __efistub_strrchr = __pi_strrchr; |
Fuad Tabba | fade9c2 | 2021-05-24 09:30:01 +0100 | [diff] [blame] | 38 | __efistub_dcache_clean_poc = __pi_dcache_clean_poc; |
Kees Cook | 90776dd | 2019-08-13 16:04:50 -0700 | [diff] [blame] | 39 | |
Andrey Konovalov | 0fea6e9 | 2020-12-22 12:02:06 -0800 | [diff] [blame] | 40 | #if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS) |
Kees Cook | 90776dd | 2019-08-13 16:04:50 -0700 | [diff] [blame] | 41 | __efistub___memcpy = __pi_memcpy; |
| 42 | __efistub___memmove = __pi_memmove; |
| 43 | __efistub___memset = __pi_memset; |
| 44 | #endif |
| 45 | |
| 46 | __efistub__text = _text; |
Kees Cook | 90776dd | 2019-08-13 16:04:50 -0700 | [diff] [blame] | 47 | __efistub__end = _end; |
| 48 | __efistub__edata = _edata; |
| 49 | __efistub_screen_info = screen_info; |
Ard Biesheuvel | 91d150c | 2020-02-10 17:02:46 +0100 | [diff] [blame] | 50 | __efistub__ctype = _ctype; |
Kees Cook | 90776dd | 2019-08-13 16:04:50 -0700 | [diff] [blame] | 51 | |
| 52 | #endif |
| 53 | |
David Brazdil | 7621712 | 2020-06-25 14:14:08 +0100 | [diff] [blame] | 54 | #ifdef CONFIG_KVM |
| 55 | |
| 56 | /* |
| 57 | * KVM nVHE code has its own symbol namespace prefixed with __kvm_nvhe_, to |
| 58 | * separate it from the kernel proper. The following symbols are legally |
| 59 | * accessed by it, therefore provide aliases to make them linkable. |
| 60 | * Do not include symbols which may not be safely accessed under hypervisor |
| 61 | * memory mappings. |
| 62 | */ |
| 63 | |
David Brazdil | b877e98 | 2020-06-25 14:14:11 +0100 | [diff] [blame] | 64 | /* Alternative callbacks for init-time patching of nVHE hyp code. */ |
David Brazdil | b877e98 | 2020-06-25 14:14:11 +0100 | [diff] [blame] | 65 | KVM_NVHE_ALIAS(kvm_patch_vector_branch); |
| 66 | KVM_NVHE_ALIAS(kvm_update_va_mask); |
Marc Zyngier | 68b824e | 2020-10-24 16:33:38 +0100 | [diff] [blame] | 67 | KVM_NVHE_ALIAS(kvm_get_kimage_voffset); |
Marc Zyngier | 755db23 | 2021-03-22 12:09:51 +0000 | [diff] [blame] | 68 | KVM_NVHE_ALIAS(kvm_compute_final_ctr_el0); |
David Brazdil | b877e98 | 2020-06-25 14:14:11 +0100 | [diff] [blame] | 69 | |
| 70 | /* Global kernel state accessed by nVHE hyp code. */ |
David Brazdil | 09cf57e | 2020-06-25 14:14:14 +0100 | [diff] [blame] | 71 | KVM_NVHE_ALIAS(kvm_vgic_global_state); |
David Brazdil | b877e98 | 2020-06-25 14:14:11 +0100 | [diff] [blame] | 72 | |
David Brazdil | b877e98 | 2020-06-25 14:14:11 +0100 | [diff] [blame] | 73 | /* Kernel symbols used to call panic() from nVHE hyp code (via ERET). */ |
Andrew Scull | aec0fae | 2021-03-18 14:33:11 +0000 | [diff] [blame] | 74 | KVM_NVHE_ALIAS(nvhe_hyp_panic_handler); |
David Brazdil | b877e98 | 2020-06-25 14:14:11 +0100 | [diff] [blame] | 75 | |
Andrew Scull | 208243c | 2020-06-25 14:14:12 +0100 | [diff] [blame] | 76 | /* Vectors installed by hyp-init on reset HVC. */ |
| 77 | KVM_NVHE_ALIAS(__hyp_stub_vectors); |
| 78 | |
David Brazdil | e03fa29 | 2020-06-25 14:14:13 +0100 | [diff] [blame] | 79 | /* Kernel symbol used by icache_is_vpipt(). */ |
| 80 | KVM_NVHE_ALIAS(__icache_flags); |
| 81 | |
| 82 | /* Kernel symbols needed for cpus_have_final/const_caps checks. */ |
| 83 | KVM_NVHE_ALIAS(arm64_const_caps_ready); |
| 84 | KVM_NVHE_ALIAS(cpu_hwcap_keys); |
David Brazdil | e03fa29 | 2020-06-25 14:14:13 +0100 | [diff] [blame] | 85 | |
David Brazdil | 09cf57e | 2020-06-25 14:14:14 +0100 | [diff] [blame] | 86 | /* Static keys which are set if a vGIC trap should be handled in hyp. */ |
| 87 | KVM_NVHE_ALIAS(vgic_v2_cpuif_trap); |
| 88 | KVM_NVHE_ALIAS(vgic_v3_cpuif_trap); |
| 89 | |
| 90 | /* Static key checked in pmr_sync(). */ |
| 91 | #ifdef CONFIG_ARM64_PSEUDO_NMI |
| 92 | KVM_NVHE_ALIAS(gic_pmr_sync); |
Alexandru Elisei | 3367805 | 2020-09-12 16:37:07 +0100 | [diff] [blame] | 93 | /* Static key checked in GIC_PRIO_IRQOFF. */ |
| 94 | KVM_NVHE_ALIAS(gic_nonsecure_priorities); |
David Brazdil | 09cf57e | 2020-06-25 14:14:14 +0100 | [diff] [blame] | 95 | #endif |
| 96 | |
James Morse | e9ee186 | 2020-08-21 15:07:05 +0100 | [diff] [blame] | 97 | /* EL2 exception handling */ |
| 98 | KVM_NVHE_ALIAS(__start___kvm_ex_table); |
| 99 | KVM_NVHE_ALIAS(__stop___kvm_ex_table); |
| 100 | |
David Brazdil | 687413d | 2020-12-02 18:41:09 +0000 | [diff] [blame] | 101 | /* Array containing bases of nVHE per-CPU memory regions. */ |
| 102 | KVM_NVHE_ALIAS(kvm_arm_hyp_percpu_base); |
| 103 | |
Marc Zyngier | f27647b | 2021-03-05 18:52:51 +0000 | [diff] [blame] | 104 | /* PMU available static key */ |
Sean Christopherson | be399d8 | 2021-11-11 02:07:36 +0000 | [diff] [blame] | 105 | #ifdef CONFIG_HW_PERF_EVENTS |
Marc Zyngier | f27647b | 2021-03-05 18:52:51 +0000 | [diff] [blame] | 106 | KVM_NVHE_ALIAS(kvm_arm_pmu_available); |
Sean Christopherson | be399d8 | 2021-11-11 02:07:36 +0000 | [diff] [blame] | 107 | #endif |
Marc Zyngier | f27647b | 2021-03-05 18:52:51 +0000 | [diff] [blame] | 108 | |
Will Deacon | 7b4a7b5 | 2021-03-19 10:01:10 +0000 | [diff] [blame] | 109 | /* Position-independent library routines */ |
| 110 | KVM_NVHE_ALIAS_HYP(clear_page, __pi_clear_page); |
| 111 | KVM_NVHE_ALIAS_HYP(copy_page, __pi_copy_page); |
| 112 | KVM_NVHE_ALIAS_HYP(memcpy, __pi_memcpy); |
| 113 | KVM_NVHE_ALIAS_HYP(memset, __pi_memset); |
| 114 | |
| 115 | #ifdef CONFIG_KASAN |
| 116 | KVM_NVHE_ALIAS_HYP(__memcpy, __pi_memcpy); |
| 117 | KVM_NVHE_ALIAS_HYP(__memset, __pi_memset); |
| 118 | #endif |
| 119 | |
Quentin Perret | f320bc7 | 2021-03-19 10:01:25 +0000 | [diff] [blame] | 120 | /* Kernel memory sections */ |
| 121 | KVM_NVHE_ALIAS(__start_rodata); |
| 122 | KVM_NVHE_ALIAS(__end_rodata); |
| 123 | KVM_NVHE_ALIAS(__bss_start); |
| 124 | KVM_NVHE_ALIAS(__bss_stop); |
| 125 | |
| 126 | /* Hyp memory sections */ |
| 127 | KVM_NVHE_ALIAS(__hyp_idmap_text_start); |
| 128 | KVM_NVHE_ALIAS(__hyp_idmap_text_end); |
| 129 | KVM_NVHE_ALIAS(__hyp_text_start); |
| 130 | KVM_NVHE_ALIAS(__hyp_text_end); |
| 131 | KVM_NVHE_ALIAS(__hyp_bss_start); |
| 132 | KVM_NVHE_ALIAS(__hyp_bss_end); |
| 133 | KVM_NVHE_ALIAS(__hyp_rodata_start); |
| 134 | KVM_NVHE_ALIAS(__hyp_rodata_end); |
| 135 | |
Quentin Perret | 1025c8c | 2021-03-19 10:01:43 +0000 | [diff] [blame] | 136 | /* pKVM static key */ |
| 137 | KVM_NVHE_ALIAS(kvm_protected_mode_initialized); |
| 138 | |
David Brazdil | 7621712 | 2020-06-25 14:14:08 +0100 | [diff] [blame] | 139 | #endif /* CONFIG_KVM */ |
| 140 | |
Kees Cook | 90776dd | 2019-08-13 16:04:50 -0700 | [diff] [blame] | 141 | #endif /* __ARM64_KERNEL_IMAGE_VARS_H */ |