2 * Contains CPU specific branch predictor invalidation sequences
4 * Copyright (C) 2018 ARM Ltd.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include <linux/linkage.h>
20 #include <linux/arm-smccc.h>
22 #include <asm/alternative.h>
31 * The default sequence is to directly branch to the KVM vectors,
32 * using the computed offset. This applies for VHE as well as
33 * !ARM64_HARDEN_EL2_VECTORS.
35 * For ARM64_HARDEN_EL2_VECTORS configurations, this gets replaced
38 * stp x0, x1, [sp, #-16]!
39 * movz x0, #(addr & 0xffff)
40 * movk x0, #((addr >> 16) & 0xffff), lsl #16
41 * movk x0, #((addr >> 32) & 0xffff), lsl #32
44 * Where addr = kern_hyp_va(__kvm_hyp_vector) + vector-offset + 4.
45 * See kvm_patch_vector_branch for details.
47 alternative_cb kvm_patch_vector_branch
48 b __kvm_hyp_vector + (1b - 0b)
56 .macro generate_vectors
61 .org 0b + SZ_2K // Safety measure
66 .pushsection .hyp.text, "ax"
69 ENTRY(__bp_harden_hyp_vecs_start)
70 .rept BP_HARDEN_EL2_SLOTS
73 ENTRY(__bp_harden_hyp_vecs_end)
77 ENTRY(__qcom_hyp_sanitize_link_stack_start)
78 stp x29, x30, [sp, #-16]!
82 ldp x29, x30, [sp], #16
83 ENTRY(__qcom_hyp_sanitize_link_stack_end)
85 .macro smccc_workaround_1 inst
87 stp x2, x3, [sp, #(8 * 0)]
88 stp x0, x1, [sp, #(8 * 2)]
89 mov w0, #ARM_SMCCC_ARCH_WORKAROUND_1
91 ldp x2, x3, [sp, #(8 * 0)]
92 ldp x0, x1, [sp, #(8 * 2)]
96 ENTRY(__smccc_workaround_1_smc_start)
97 smccc_workaround_1 smc
98 ENTRY(__smccc_workaround_1_smc_end)
100 ENTRY(__smccc_workaround_1_hvc_start)
101 smccc_workaround_1 hvc
102 ENTRY(__smccc_workaround_1_hvc_end)