xref: /openbmc/linux/arch/arm64/kernel/image-vars.h (revision bbb774d9)
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 PROVIDE(__efistub_kernel_size		= _edata - _text);
14 PROVIDE(__efistub_primary_entry_offset	= primary_entry - _text);
15 
16 /*
17  * The EFI stub has its own symbol namespace prefixed by __efistub_, to
18  * isolate it from the kernel proper. The following symbols are legally
19  * accessed by the stub, so provide some aliases to make them accessible.
20  * Only include data symbols here, or text symbols of functions that are
21  * guaranteed to be safe when executed at another offset than they were
22  * linked at. The routines below are all implemented in assembler in a
23  * position independent manner
24  */
25 PROVIDE(__efistub_memcmp		= __pi_memcmp);
26 PROVIDE(__efistub_memchr		= __pi_memchr);
27 PROVIDE(__efistub_memcpy		= __pi_memcpy);
28 PROVIDE(__efistub_memmove		= __pi_memmove);
29 PROVIDE(__efistub_memset		= __pi_memset);
30 PROVIDE(__efistub_strlen		= __pi_strlen);
31 PROVIDE(__efistub_strnlen		= __pi_strnlen);
32 PROVIDE(__efistub_strcmp		= __pi_strcmp);
33 PROVIDE(__efistub_strncmp		= __pi_strncmp);
34 PROVIDE(__efistub_strrchr		= __pi_strrchr);
35 PROVIDE(__efistub_dcache_clean_poc	= __pi_dcache_clean_poc);
36 
37 PROVIDE(__efistub__text			= _text);
38 PROVIDE(__efistub__end			= _end);
39 PROVIDE(__efistub__edata		= _edata);
40 PROVIDE(__efistub_screen_info		= screen_info);
41 PROVIDE(__efistub__ctype		= _ctype);
42 
43 /*
44  * The __ prefixed memcpy/memset/memmove symbols are provided by KASAN, which
45  * instruments the conventional ones. Therefore, any references from the EFI
46  * stub or other position independent, low level C code should be redirected to
47  * the non-instrumented versions as well.
48  */
49 PROVIDE(__efistub___memcpy		= __pi_memcpy);
50 PROVIDE(__efistub___memmove		= __pi_memmove);
51 PROVIDE(__efistub___memset		= __pi_memset);
52 
53 PROVIDE(__pi___memcpy			= __pi_memcpy);
54 PROVIDE(__pi___memmove			= __pi_memmove);
55 PROVIDE(__pi___memset			= __pi_memset);
56 
57 #ifdef CONFIG_KVM
58 
59 /*
60  * KVM nVHE code has its own symbol namespace prefixed with __kvm_nvhe_, to
61  * separate it from the kernel proper. The following symbols are legally
62  * accessed by it, therefore provide aliases to make them linkable.
63  * Do not include symbols which may not be safely accessed under hypervisor
64  * memory mappings.
65  */
66 
67 /* Alternative callbacks for init-time patching of nVHE hyp code. */
68 KVM_NVHE_ALIAS(kvm_patch_vector_branch);
69 KVM_NVHE_ALIAS(kvm_update_va_mask);
70 KVM_NVHE_ALIAS(kvm_get_kimage_voffset);
71 KVM_NVHE_ALIAS(kvm_compute_final_ctr_el0);
72 KVM_NVHE_ALIAS(spectre_bhb_patch_loop_iter);
73 KVM_NVHE_ALIAS(spectre_bhb_patch_loop_mitigation_enable);
74 KVM_NVHE_ALIAS(spectre_bhb_patch_wa3);
75 KVM_NVHE_ALIAS(spectre_bhb_patch_clearbhb);
76 
77 /* Global kernel state accessed by nVHE hyp code. */
78 KVM_NVHE_ALIAS(kvm_vgic_global_state);
79 
80 /* Kernel symbols used to call panic() from nVHE hyp code (via ERET). */
81 KVM_NVHE_ALIAS(nvhe_hyp_panic_handler);
82 
83 /* Vectors installed by hyp-init on reset HVC. */
84 KVM_NVHE_ALIAS(__hyp_stub_vectors);
85 
86 /* Kernel symbol used by icache_is_vpipt(). */
87 KVM_NVHE_ALIAS(__icache_flags);
88 
89 /* VMID bits set by the KVM VMID allocator */
90 KVM_NVHE_ALIAS(kvm_arm_vmid_bits);
91 
92 /* Kernel symbols needed for cpus_have_final/const_caps checks. */
93 KVM_NVHE_ALIAS(arm64_const_caps_ready);
94 KVM_NVHE_ALIAS(cpu_hwcap_keys);
95 
96 /* Static keys which are set if a vGIC trap should be handled in hyp. */
97 KVM_NVHE_ALIAS(vgic_v2_cpuif_trap);
98 KVM_NVHE_ALIAS(vgic_v3_cpuif_trap);
99 
100 /* Static key checked in pmr_sync(). */
101 #ifdef CONFIG_ARM64_PSEUDO_NMI
102 KVM_NVHE_ALIAS(gic_pmr_sync);
103 /* Static key checked in GIC_PRIO_IRQOFF. */
104 KVM_NVHE_ALIAS(gic_nonsecure_priorities);
105 #endif
106 
107 /* EL2 exception handling */
108 KVM_NVHE_ALIAS(__start___kvm_ex_table);
109 KVM_NVHE_ALIAS(__stop___kvm_ex_table);
110 
111 /* Array containing bases of nVHE per-CPU memory regions. */
112 KVM_NVHE_ALIAS(kvm_arm_hyp_percpu_base);
113 
114 /* PMU available static key */
115 #ifdef CONFIG_HW_PERF_EVENTS
116 KVM_NVHE_ALIAS(kvm_arm_pmu_available);
117 #endif
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 /* Kernel memory sections */
131 KVM_NVHE_ALIAS(__start_rodata);
132 KVM_NVHE_ALIAS(__end_rodata);
133 KVM_NVHE_ALIAS(__bss_start);
134 KVM_NVHE_ALIAS(__bss_stop);
135 
136 /* Hyp memory sections */
137 KVM_NVHE_ALIAS(__hyp_idmap_text_start);
138 KVM_NVHE_ALIAS(__hyp_idmap_text_end);
139 KVM_NVHE_ALIAS(__hyp_text_start);
140 KVM_NVHE_ALIAS(__hyp_text_end);
141 KVM_NVHE_ALIAS(__hyp_bss_start);
142 KVM_NVHE_ALIAS(__hyp_bss_end);
143 KVM_NVHE_ALIAS(__hyp_rodata_start);
144 KVM_NVHE_ALIAS(__hyp_rodata_end);
145 
146 /* pKVM static key */
147 KVM_NVHE_ALIAS(kvm_protected_mode_initialized);
148 
149 #endif /* CONFIG_KVM */
150 
151 #endif /* __ARM64_KERNEL_IMAGE_VARS_H */
152