blob: 63186c91b614f8fdd58cc17e90c25218e857d79f [file] [log] [blame]
Kees Cook90776dd2019-08-13 16:04:50 -07001/* 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 Biesheuvel9f922372020-02-17 12:44:37 +010015__efistub_kernel_size = _edata - _text;
Ard Biesheuvel348a6252020-03-26 18:14:23 +010016__efistub_primary_entry_offset = primary_entry - _text;
Ard Biesheuvel9f922372020-02-17 12:44:37 +010017
Kees Cook90776dd2019-08-13 16:04:50 -070018
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;
Ard Biesheuvelb9676962020-02-28 13:14:07 +010038__efistub___clean_dcache_area_poc = __pi___clean_dcache_area_poc;
Kees Cook90776dd2019-08-13 16:04:50 -070039
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;
Kees Cook90776dd2019-08-13 16:04:50 -070047__efistub__end = _end;
48__efistub__edata = _edata;
49__efistub_screen_info = screen_info;
Ard Biesheuvel91d150c2020-02-10 17:02:46 +010050__efistub__ctype = _ctype;
Kees Cook90776dd2019-08-13 16:04:50 -070051
52#endif
53
David Brazdil76217122020-06-25 14:14:08 +010054#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
Andrew Scullf50b6f6a2020-06-25 14:14:10 +010066/* Symbols defined in debug-sr.c (not yet compiled with nVHE build rules). */
67KVM_NVHE_ALIAS(__kvm_get_mdcr_el2);
68
David Brazdilb877e982020-06-25 14:14:11 +010069/* Symbols defined in entry.S (not yet compiled with nVHE build rules). */
70KVM_NVHE_ALIAS(__guest_exit);
71KVM_NVHE_ALIAS(abort_guest_exit_end);
72KVM_NVHE_ALIAS(abort_guest_exit_start);
73
Andrew Scullf50b6f6a2020-06-25 14:14:10 +010074/* Symbols defined in switch.c (not yet compiled with nVHE build rules). */
75KVM_NVHE_ALIAS(__kvm_vcpu_run_nvhe);
David Brazdilb877e982020-06-25 14:14:11 +010076KVM_NVHE_ALIAS(hyp_panic);
Andrew Scullf50b6f6a2020-06-25 14:14:10 +010077
78/* Symbols defined in sysreg-sr.c (not yet compiled with nVHE build rules). */
79KVM_NVHE_ALIAS(__kvm_enable_ssbs);
80
81/* Symbols defined in timer-sr.c (not yet compiled with nVHE build rules). */
82KVM_NVHE_ALIAS(__kvm_timer_set_cntvoff);
83
84/* Symbols defined in tlb.c (not yet compiled with nVHE build rules). */
85KVM_NVHE_ALIAS(__kvm_flush_vm_context);
86KVM_NVHE_ALIAS(__kvm_tlb_flush_local_vmid);
87KVM_NVHE_ALIAS(__kvm_tlb_flush_vmid);
88KVM_NVHE_ALIAS(__kvm_tlb_flush_vmid_ipa);
89
90/* Symbols defined in vgic-v3-sr.c (not yet compiled with nVHE build rules). */
91KVM_NVHE_ALIAS(__vgic_v3_get_ich_vtr_el2);
92KVM_NVHE_ALIAS(__vgic_v3_init_lrs);
93KVM_NVHE_ALIAS(__vgic_v3_read_vmcr);
94KVM_NVHE_ALIAS(__vgic_v3_restore_aprs);
95KVM_NVHE_ALIAS(__vgic_v3_save_aprs);
96KVM_NVHE_ALIAS(__vgic_v3_write_vmcr);
97
David Brazdilb877e982020-06-25 14:14:11 +010098/* Alternative callbacks for init-time patching of nVHE hyp code. */
99KVM_NVHE_ALIAS(arm64_enable_wa2_handling);
100KVM_NVHE_ALIAS(kvm_patch_vector_branch);
101KVM_NVHE_ALIAS(kvm_update_va_mask);
102
103/* Global kernel state accessed by nVHE hyp code. */
104KVM_NVHE_ALIAS(arm64_ssbd_callback_required);
105KVM_NVHE_ALIAS(kvm_host_data);
106
107/* Kernel constant needed to compute idmap addresses. */
108KVM_NVHE_ALIAS(kimage_voffset);
109
110/* Kernel symbols used to call panic() from nVHE hyp code (via ERET). */
111KVM_NVHE_ALIAS(panic);
112
Andrew Scull208243c2020-06-25 14:14:12 +0100113/* Vectors installed by hyp-init on reset HVC. */
114KVM_NVHE_ALIAS(__hyp_stub_vectors);
115
116/* IDMAP TCR_EL1.T0SZ as computed by the EL1 init code */
117KVM_NVHE_ALIAS(idmap_t0sz);
118
David Brazdil76217122020-06-25 14:14:08 +0100119#endif /* CONFIG_KVM */
120
Kees Cook90776dd2019-08-13 16:04:50 -0700121#endif /* __ARM64_KERNEL_IMAGE_VARS_H */