Skip to content

Commit 4debef5

Browse files
James Morsectmarinas
authored andcommitted
arm64: KVM: Guests can skip __install_bp_hardening_cb()s HYP work
enable_smccc_arch_workaround_1() passes NULL as the hyp_vecs start and end if the HVC conduit is in use, and ARM_SMCCC_ARCH_WORKAROUND_1 is detected. If the guest kernel happened to be built with KVM_INDIRECT_VECTORS, we go on to allocate a slot, memcpy() the empty workaround in and do the appropriate cache maintenance. This works as we always tell memcpy() the range is 0, so it never accesses the NULL src pointer, but we still do the cache maintenance. If hyp_vecs_start is NULL we know we're a guest, just update the fn like the !KVM_INDIRECT_VECTORS version. Reviewed-by: Julien Thierry <julien.thierry@arm.com> Acked-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: James Morse <james.morse@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 4afe8e7 commit 4debef5

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎arch/arm64/kernel/cpu_errata.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,15 @@ static void __install_bp_hardening_cb(bp_hardening_cb_t fn,
138138
static DEFINE_SPINLOCK(bp_lock);
139139
int cpu, slot = -1;
140140

141+
/*
142+
* enable_smccc_arch_workaround_1() passes NULL for the hyp_vecs
143+
* start/end if we're a guest. Skip the hyp-vectors work.
144+
*/
145+
if (!hyp_vecs_start) {
146+
__this_cpu_write(bp_hardening_data.fn, fn);
147+
return;
148+
}
149+
141150
spin_lock(&bp_lock);
142151
for_each_possible_cpu(cpu) {
143152
if (per_cpu(bp_hardening_data.fn, cpu) == fn) {

0 commit comments

Comments
 (0)