Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: arm64: Make BP hardening globals static instead

Branch predictor hardening of the hyp vectors is partially driven by a
couple of global variables ('__kvm_bp_vect_base' and
'__kvm_harden_el2_vector_slot'). However, these are only used within a
single compilation unit, so internalise them there instead.

Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Quentin Perret <qperret@google.com>
Link: https://lore.kernel.org/r/20201113113847.21619-5-will@kernel.org

authored by

Will Deacon and committed by
Marc Zyngier
07cf8aa9 042c76a9

+8 -6
-3
arch/arm64/include/asm/kvm_mmu.h
··· 208 208 return ret; 209 209 } 210 210 211 - extern void *__kvm_bp_vect_base; 212 - extern int __kvm_harden_el2_vector_slot; 213 - 214 211 #define kvm_phys_to_vttbr(addr) phys_to_ttbr(addr) 215 212 216 213 static __always_inline u64 kvm_get_vttbr(struct kvm_s2_mmu *mmu)
+8
arch/arm64/kvm/arm.c
··· 51 51 static DEFINE_PER_CPU(unsigned long, kvm_arm_hyp_stack_page); 52 52 unsigned long kvm_arm_hyp_percpu_base[NR_CPUS]; 53 53 54 + /* Hypervisor VA of the indirect vector trampoline page */ 55 + static void *__kvm_bp_vect_base; 56 + /* 57 + * Slot in the hyp vector page for use by the indirect vector trampoline 58 + * when mitigation against Spectre-v2 is not required. 59 + */ 60 + static int __kvm_harden_el2_vector_slot; 61 + 54 62 /* The VMID used in the VTTBR */ 55 63 static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1); 56 64 static u32 kvm_next_vmid;
-3
arch/arm64/kvm/va_layout.c
··· 131 131 } 132 132 } 133 133 134 - void *__kvm_bp_vect_base; 135 - int __kvm_harden_el2_vector_slot; 136 - 137 134 void kvm_patch_vector_branch(struct alt_instr *alt, 138 135 __le32 *origptr, __le32 *updptr, int nr_inst) 139 136 {