^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Linker script variables to be set after section resolution, as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * ld.lld does not like variables assigned before SECTIONS is processed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #ifndef __ARM64_KERNEL_IMAGE_VARS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #define __ARM64_KERNEL_IMAGE_VARS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #ifndef LINKER_SCRIPT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #error This file should only be included in vmlinux.lds.S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #ifdef CONFIG_EFI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) __efistub_kernel_size = _edata - _text;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) __efistub_primary_entry_offset = primary_entry - _text;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * The EFI stub has its own symbol namespace prefixed by __efistub_, to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * isolate it from the kernel proper. The following symbols are legally
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * accessed by the stub, so provide some aliases to make them accessible.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * Only include data symbols here, or text symbols of functions that are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * guaranteed to be safe when executed at another offset than they were
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * linked at. The routines below are all implemented in assembler in a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * position independent manner
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) __efistub_memcmp = __pi_memcmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) __efistub_memchr = __pi_memchr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) __efistub_memcpy = __pi_memcpy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) __efistub_memmove = __pi_memmove;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) __efistub_memset = __pi_memset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) __efistub_strlen = __pi_strlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) __efistub_strnlen = __pi_strnlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) __efistub_strcmp = __pi_strcmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) __efistub_strncmp = __pi_strncmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) __efistub_strrchr = __pi_strrchr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) __efistub___clean_dcache_area_poc = __pi___clean_dcache_area_poc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) __efistub___memcpy = __pi_memcpy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) __efistub___memmove = __pi_memmove;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) __efistub___memset = __pi_memset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) __efistub__text = _text;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) __efistub__end = _end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) __efistub__edata = _edata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) __efistub_screen_info = screen_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) __efistub__ctype = _ctype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #ifdef CONFIG_KVM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * KVM nVHE code has its own symbol namespace prefixed with __kvm_nvhe_, to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * separate it from the kernel proper. The following symbols are legally
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * accessed by it, therefore provide aliases to make them linkable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * Do not include symbols which may not be safely accessed under hypervisor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * memory mappings.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) /* Alternative callbacks for init-time patching of nVHE hyp code. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) KVM_NVHE_ALIAS(kvm_patch_vector_branch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) KVM_NVHE_ALIAS(kvm_update_va_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) KVM_NVHE_ALIAS(kvm_get_kimage_voffset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) KVM_NVHE_ALIAS(kvm_compute_final_ctr_el0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) KVM_NVHE_ALIAS(spectre_bhb_patch_loop_iter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) KVM_NVHE_ALIAS(spectre_bhb_patch_loop_mitigation_enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) KVM_NVHE_ALIAS(spectre_bhb_patch_wa3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) KVM_NVHE_ALIAS(spectre_bhb_patch_clearbhb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /* Global kernel state accessed by nVHE hyp code. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) KVM_NVHE_ALIAS(kvm_vgic_global_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) /* Kernel symbols used to call panic() from nVHE hyp code (via ERET). */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) KVM_NVHE_ALIAS(__hyp_panic_string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) KVM_NVHE_ALIAS(panic);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) /* Vectors installed by hyp-init on reset HVC. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) KVM_NVHE_ALIAS(__hyp_stub_vectors);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) /* Kernel symbol used by icache_is_vpipt(). */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) KVM_NVHE_ALIAS(__icache_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) /* Kernel symbols needed for cpus_have_final/const_caps checks. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) KVM_NVHE_ALIAS(arm64_const_caps_ready);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) KVM_NVHE_ALIAS(cpu_hwcap_keys);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) /* Static keys which are set if a vGIC trap should be handled in hyp. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) KVM_NVHE_ALIAS(vgic_v2_cpuif_trap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) KVM_NVHE_ALIAS(vgic_v3_cpuif_trap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) /* Static key checked in pmr_sync(). */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) #ifdef CONFIG_ARM64_PSEUDO_NMI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) KVM_NVHE_ALIAS(gic_pmr_sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) /* Static key checked in GIC_PRIO_IRQOFF. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) KVM_NVHE_ALIAS(gic_nonsecure_priorities);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) /* EL2 exception handling */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) KVM_NVHE_ALIAS(__start___kvm_ex_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) KVM_NVHE_ALIAS(__stop___kvm_ex_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) /* Array containing bases of nVHE per-CPU memory regions. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) KVM_NVHE_ALIAS(kvm_arm_hyp_percpu_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) /* PMU available static key */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) KVM_NVHE_ALIAS(kvm_arm_pmu_available);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) /* Position-independent library routines */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) KVM_NVHE_ALIAS_HYP(clear_page, __pi_clear_page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) KVM_NVHE_ALIAS_HYP(copy_page, __pi_copy_page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) KVM_NVHE_ALIAS_HYP(memcpy, __pi_memcpy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) KVM_NVHE_ALIAS_HYP(memset, __pi_memset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) #ifdef CONFIG_KASAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) KVM_NVHE_ALIAS_HYP(__memcpy, __pi_memcpy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) KVM_NVHE_ALIAS_HYP(__memset, __pi_memset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) /* Kernel memory sections */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) KVM_NVHE_ALIAS(__start_rodata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) KVM_NVHE_ALIAS(__end_rodata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) KVM_NVHE_ALIAS(__bss_start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) KVM_NVHE_ALIAS(__bss_stop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) /* Hyp memory sections */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) KVM_NVHE_ALIAS(__hyp_idmap_text_start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) KVM_NVHE_ALIAS(__hyp_idmap_text_end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) KVM_NVHE_ALIAS(__hyp_text_start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) KVM_NVHE_ALIAS(__hyp_text_end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) KVM_NVHE_ALIAS(__hyp_bss_start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) KVM_NVHE_ALIAS(__hyp_bss_end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) KVM_NVHE_ALIAS(__hyp_rodata_start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) KVM_NVHE_ALIAS(__hyp_rodata_end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) /* pKVM static key */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) KVM_NVHE_ALIAS(kvm_protected_mode_initialized);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) #endif /* CONFIG_KVM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) #endif /* __ARM64_KERNEL_IMAGE_VARS_H */