1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2022 ARM Ltd.
5 #ifndef __ASM_VECTORS_H
6 #define __ASM_VECTORS_H
9 #include <linux/percpu.h>
11 #include <asm/fixmap.h>
14 extern char vectors[];
15 extern char tramp_vectors[];
16 extern char __bp_harden_el1_vectors[];
19 * Note: the order of this enum corresponds to two arrays in entry.S:
20 * tramp_vecs and __bp_harden_el1_vectors. By default the canonical
21 * 'full fat' vectors are used directly.
23 enum arm64_bp_harden_el1_vectors {
24 #ifdef CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY
26 * Perform the BHB loop mitigation, before branching to the canonical
32 * Make the SMC call for firmware mitigation, before branching to the
38 * Use the ClearBHB instruction, before branching to the canonical
41 EL1_VECTOR_BHB_CLEAR_INSN,
42 #endif /* CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY */
45 * Remap the kernel before branching to the canonical vectors.
50 #ifndef CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY
51 #define EL1_VECTOR_BHB_LOOP -1
52 #define EL1_VECTOR_BHB_FW -1
53 #define EL1_VECTOR_BHB_CLEAR_INSN -1
54 #endif /* !CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY */
56 /* The vectors to use on return from EL0. e.g. to remap the kernel */
57 DECLARE_PER_CPU_READ_MOSTLY(const char *, this_cpu_vector);
59 #ifndef CONFIG_UNMAP_KERNEL_AT_EL0
60 #define TRAMP_VALIAS 0
63 static inline const char *
64 arm64_get_bp_hardening_vector(enum arm64_bp_harden_el1_vectors slot)
66 if (arm64_kernel_unmapped_at_el0())
67 return (char *)TRAMP_VALIAS + SZ_2K * slot;
69 WARN_ON_ONCE(slot == EL1_VECTOR_KPTI);
71 return __bp_harden_el1_vectors + SZ_2K * slot;
74 #endif /* __ASM_VECTORS_H */