KVM: arm64: Allow indirect vectors to be used without SPECTRE_V3A
CPUs vulnerable to Spectre-BHB either need to make an SMC-CC firmware call from the vectors, or run a sequence of branches. This gets added to the hyp vectors. If there is no support for arch-workaround-1 in firmware, the indirect vector will be used. kvm_init_vector_slots() only initialises the two indirect slots if the platform is vulnerable to Spectre-v3a. pKVM's hyp_map_vectors() only initialises __hyp_bp_vect_base if the platform is vulnerable to Spectre-v3a. As there are about to more users of the indirect vectors, ensure their entries in hyp_spectre_vector_selector[] are always initialised, and __hyp_bp_vect_base defaults to the regular VA mapping. The Spectre-v3a check is moved to a helper kvm_system_needs_idmapped_vectors(), and merged with the code that creates the hyp mappings. Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: James Morse <james.morse@arm.com>
This commit is contained in:
Родитель
1b33d4860d
Коммит
5bdf343760
|
@ -714,6 +714,11 @@ static inline void kvm_init_host_cpu_context(struct kvm_cpu_context *cpu_ctxt)
|
||||||
ctxt_sys_reg(cpu_ctxt, MPIDR_EL1) = read_cpuid_mpidr();
|
ctxt_sys_reg(cpu_ctxt, MPIDR_EL1) = read_cpuid_mpidr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool kvm_system_needs_idmapped_vectors(void)
|
||||||
|
{
|
||||||
|
return cpus_have_const_cap(ARM64_SPECTRE_V3A);
|
||||||
|
}
|
||||||
|
|
||||||
void kvm_arm_vcpu_ptrauth_trap(struct kvm_vcpu *vcpu);
|
void kvm_arm_vcpu_ptrauth_trap(struct kvm_vcpu *vcpu);
|
||||||
|
|
||||||
static inline void kvm_arch_hardware_unsetup(void) {}
|
static inline void kvm_arch_hardware_unsetup(void) {}
|
||||||
|
|
|
@ -1491,10 +1491,7 @@ static int kvm_init_vector_slots(void)
|
||||||
base = kern_hyp_va(kvm_ksym_ref(__bp_harden_hyp_vecs));
|
base = kern_hyp_va(kvm_ksym_ref(__bp_harden_hyp_vecs));
|
||||||
kvm_init_vector_slot(base, HYP_VECTOR_SPECTRE_DIRECT);
|
kvm_init_vector_slot(base, HYP_VECTOR_SPECTRE_DIRECT);
|
||||||
|
|
||||||
if (!cpus_have_const_cap(ARM64_SPECTRE_V3A))
|
if (kvm_system_needs_idmapped_vectors() && !has_vhe()) {
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (!has_vhe()) {
|
|
||||||
err = create_hyp_exec_mappings(__pa_symbol(__bp_harden_hyp_vecs),
|
err = create_hyp_exec_mappings(__pa_symbol(__bp_harden_hyp_vecs),
|
||||||
__BP_HARDEN_HYP_VECS_SZ, &base);
|
__BP_HARDEN_HYP_VECS_SZ, &base);
|
||||||
if (err)
|
if (err)
|
||||||
|
|
|
@ -148,8 +148,10 @@ int hyp_map_vectors(void)
|
||||||
phys_addr_t phys;
|
phys_addr_t phys;
|
||||||
void *bp_base;
|
void *bp_base;
|
||||||
|
|
||||||
if (!cpus_have_const_cap(ARM64_SPECTRE_V3A))
|
if (!kvm_system_needs_idmapped_vectors()) {
|
||||||
|
__hyp_bp_vect_base = __bp_harden_hyp_vecs;
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
phys = __hyp_pa(__bp_harden_hyp_vecs);
|
phys = __hyp_pa(__bp_harden_hyp_vecs);
|
||||||
bp_base = (void *)__pkvm_create_private_mapping(phys,
|
bp_base = (void *)__pkvm_create_private_mapping(phys,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче