xref: /linux/arch/arm64/kernel/image-vars.h (revision 9aebdea494b5d2d5fe0ba54d71e9d6c5acfe76b4)
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 
15 __efistub_kernel_size		= _edata - _text;
16 __efistub_primary_entry_offset	= primary_entry - _text;
17 
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;
38 __efistub___clean_dcache_area_poc = __pi___clean_dcache_area_poc;
39 
40 #ifdef CONFIG_KASAN
41 __efistub___memcpy		= __pi_memcpy;
42 __efistub___memmove		= __pi_memmove;
43 __efistub___memset		= __pi_memset;
44 #endif
45 
46 __efistub__text			= _text;
47 __efistub__end			= _end;
48 __efistub__edata		= _edata;
49 __efistub_screen_info		= screen_info;
50 __efistub__ctype		= _ctype;
51 
52 #endif
53 
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 
64 #define KVM_NVHE_ALIAS(sym) __kvm_nvhe_##sym = sym;
65 
66 /* Symbols defined in aarch32.c (not yet compiled with nVHE build rules). */
67 KVM_NVHE_ALIAS(kvm_skip_instr32);
68 
69 /* Symbols defined in entry.S (not yet compiled with nVHE build rules). */
70 KVM_NVHE_ALIAS(__guest_enter);
71 KVM_NVHE_ALIAS(__guest_exit);
72 KVM_NVHE_ALIAS(abort_guest_exit_end);
73 KVM_NVHE_ALIAS(abort_guest_exit_start);
74 
75 /* Symbols defined in fpsimd.S (not yet compiled with nVHE build rules). */
76 KVM_NVHE_ALIAS(__fpsimd_restore_state);
77 KVM_NVHE_ALIAS(__fpsimd_save_state);
78 
79 /* Symbols defined in vgic-v2-cpuif-proxy.c (not yet compiled with nVHE build rules). */
80 KVM_NVHE_ALIAS(__vgic_v2_perform_cpuif_access);
81 
82 /* Symbols defined in vgic-v3-sr.c (not yet compiled with nVHE build rules). */
83 KVM_NVHE_ALIAS(__vgic_v3_activate_traps);
84 KVM_NVHE_ALIAS(__vgic_v3_deactivate_traps);
85 KVM_NVHE_ALIAS(__vgic_v3_get_ich_vtr_el2);
86 KVM_NVHE_ALIAS(__vgic_v3_init_lrs);
87 KVM_NVHE_ALIAS(__vgic_v3_perform_cpuif_access);
88 KVM_NVHE_ALIAS(__vgic_v3_read_vmcr);
89 KVM_NVHE_ALIAS(__vgic_v3_restore_aprs);
90 KVM_NVHE_ALIAS(__vgic_v3_restore_state);
91 KVM_NVHE_ALIAS(__vgic_v3_save_aprs);
92 KVM_NVHE_ALIAS(__vgic_v3_save_state);
93 KVM_NVHE_ALIAS(__vgic_v3_write_vmcr);
94 
95 /* Alternative callbacks for init-time patching of nVHE hyp code. */
96 KVM_NVHE_ALIAS(arm64_enable_wa2_handling);
97 KVM_NVHE_ALIAS(kvm_patch_vector_branch);
98 KVM_NVHE_ALIAS(kvm_update_va_mask);
99 
100 /* Global kernel state accessed by nVHE hyp code. */
101 KVM_NVHE_ALIAS(arm64_ssbd_callback_required);
102 KVM_NVHE_ALIAS(kvm_host_data);
103 KVM_NVHE_ALIAS(kvm_vgic_global_state);
104 
105 /* Kernel constant needed to compute idmap addresses. */
106 KVM_NVHE_ALIAS(kimage_voffset);
107 
108 /* Kernel symbols used to call panic() from nVHE hyp code (via ERET). */
109 KVM_NVHE_ALIAS(__hyp_panic_string);
110 KVM_NVHE_ALIAS(panic);
111 
112 /* Vectors installed by hyp-init on reset HVC. */
113 KVM_NVHE_ALIAS(__hyp_stub_vectors);
114 
115 /* IDMAP TCR_EL1.T0SZ as computed by the EL1 init code */
116 KVM_NVHE_ALIAS(idmap_t0sz);
117 
118 /* Kernel symbol used by icache_is_vpipt(). */
119 KVM_NVHE_ALIAS(__icache_flags);
120 
121 /* Kernel symbols needed for cpus_have_final/const_caps checks. */
122 KVM_NVHE_ALIAS(arm64_const_caps_ready);
123 KVM_NVHE_ALIAS(cpu_hwcap_keys);
124 KVM_NVHE_ALIAS(cpu_hwcaps);
125 
126 /* Static keys which are set if a vGIC trap should be handled in hyp. */
127 KVM_NVHE_ALIAS(vgic_v2_cpuif_trap);
128 KVM_NVHE_ALIAS(vgic_v3_cpuif_trap);
129 
130 /* Static key checked in pmr_sync(). */
131 #ifdef CONFIG_ARM64_PSEUDO_NMI
132 KVM_NVHE_ALIAS(gic_pmr_sync);
133 #endif
134 
135 #endif /* CONFIG_KVM */
136 
137 #endif /* __ARM64_KERNEL_IMAGE_VARS_H */
138