Skip to content

Commit 7b2399e

Browse files
David BrazdilMarc Zyngier
authored andcommitted
KVM: arm64: Move __smccc_workaround_1_smc to .rodata
This snippet of assembly is used by cpu_errata.c to overwrite parts of KVM hyp vector. Move it to its own source file and change its ELF section to .rodata. Signed-off-by: David Brazdil <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent b38b298 commit 7b2399e

File tree

3 files changed

+33
-16
lines changed

3 files changed

+33
-16
lines changed

arch/arm64/kvm/hyp/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ ccflags-y += -fno-stack-protector -DDISABLE_BRANCH_PROFILING \
77
$(DISABLE_STACKLEAK_PLUGIN)
88

99
obj-$(CONFIG_KVM) += hyp.o
10+
obj-$(CONFIG_KVM_INDIRECT_VECTORS) += smccc_wa.o
1011

1112
hyp-y := vgic-v3-sr.o timer-sr.o aarch32.o vgic-v2-cpuif-proxy.o sysreg-sr.o \
1213
debug-sr.o entry.o switch.o fpsimd.o tlb.o hyp-entry.o

arch/arm64/kvm/hyp/hyp-entry.S

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -318,20 +318,4 @@ SYM_CODE_START(__bp_harden_hyp_vecs)
318318
1: .org __bp_harden_hyp_vecs + __BP_HARDEN_HYP_VECS_SZ
319319
.org 1b
320320
SYM_CODE_END(__bp_harden_hyp_vecs)
321-
322-
.popsection
323-
324-
SYM_CODE_START(__smccc_workaround_1_smc)
325-
esb
326-
sub sp, sp, #(8 * 4)
327-
stp x2, x3, [sp, #(8 * 0)]
328-
stp x0, x1, [sp, #(8 * 2)]
329-
mov w0, #ARM_SMCCC_ARCH_WORKAROUND_1
330-
smc #0
331-
ldp x2, x3, [sp, #(8 * 0)]
332-
ldp x0, x1, [sp, #(8 * 2)]
333-
add sp, sp, #(8 * 4)
334-
1: .org __smccc_workaround_1_smc + __SMCCC_WORKAROUND_1_SMC_SZ
335-
.org 1b
336-
SYM_CODE_END(__smccc_workaround_1_smc)
337321
#endif

arch/arm64/kvm/hyp/smccc_wa.S

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* Copyright (C) 2015-2018 - ARM Ltd
4+
* Author: Marc Zyngier <[email protected]>
5+
*/
6+
7+
#include <linux/arm-smccc.h>
8+
#include <linux/linkage.h>
9+
10+
#include <asm/kvm_asm.h>
11+
#include <asm/kvm_mmu.h>
12+
13+
/*
14+
* This is not executed directly and is instead copied into the vectors
15+
* by install_bp_hardening_cb().
16+
*/
17+
.data
18+
.pushsection .rodata
19+
.global __smccc_workaround_1_smc
20+
SYM_DATA_START(__smccc_workaround_1_smc)
21+
esb
22+
sub sp, sp, #(8 * 4)
23+
stp x2, x3, [sp, #(8 * 0)]
24+
stp x0, x1, [sp, #(8 * 2)]
25+
mov w0, #ARM_SMCCC_ARCH_WORKAROUND_1
26+
smc #0
27+
ldp x2, x3, [sp, #(8 * 0)]
28+
ldp x0, x1, [sp, #(8 * 2)]
29+
add sp, sp, #(8 * 4)
30+
1: .org __smccc_workaround_1_smc + __SMCCC_WORKAROUND_1_SMC_SZ
31+
.org 1b
32+
SYM_DATA_END(__smccc_workaround_1_smc)

0 commit comments

Comments
 (0)