ANDROID: KVM: arm64: Move __deactivate_fpsimd_traps() to switch.h
Move __deactivate_fpsimd_traps() to the shared switch header, instead of having separate implementations in the vhe/nvhe switch.c files. Subsequent patches will remove all specific implementations from switch.c and include switch.h in other files. Bug: 411040189 Change-Id: I42c545e939b230366fbd9ad8e41a614193169bce Signed-off-by: Fuad Tabba <tabba@google.com>
This commit is contained in:
@@ -329,7 +329,26 @@ static void kvm_hyp_handle_fpsimd_host(struct kvm_vcpu *vcpu)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __deactivate_fpsimd_traps(struct kvm_vcpu *vcpu);
|
static void __deactivate_fpsimd_traps(struct kvm_vcpu *vcpu)
|
||||||
|
{
|
||||||
|
u64 reg;
|
||||||
|
bool trap_sve = vcpu_has_sve(vcpu) ||
|
||||||
|
(is_protected_kvm_enabled() && system_supports_sve());
|
||||||
|
|
||||||
|
if (has_vhe() || has_hvhe()) {
|
||||||
|
reg = CPACR_EL1_FPEN_EL0EN | CPACR_EL1_FPEN_EL1EN;
|
||||||
|
if (trap_sve)
|
||||||
|
reg |= CPACR_EL1_ZEN_EL0EN | CPACR_EL1_ZEN_EL1EN;
|
||||||
|
|
||||||
|
sysreg_clear_set(cpacr_el1, 0, reg);
|
||||||
|
} else {
|
||||||
|
reg = CPTR_EL2_TFP;
|
||||||
|
if (trap_sve)
|
||||||
|
reg |= CPTR_EL2_TZ;
|
||||||
|
|
||||||
|
sysreg_clear_set(cptr_el2, reg, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We trap the first access to the FP/SIMD to save the host context and
|
* We trap the first access to the FP/SIMD to save the host context and
|
||||||
|
@@ -171,27 +171,6 @@ static void __deactivate_traps(struct kvm_vcpu *vcpu)
|
|||||||
write_sysreg(__kvm_hyp_host_vector, vbar_el2);
|
write_sysreg(__kvm_hyp_host_vector, vbar_el2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __deactivate_fpsimd_traps(struct kvm_vcpu *vcpu)
|
|
||||||
{
|
|
||||||
u64 reg;
|
|
||||||
bool trap_sve = vcpu_has_sve(vcpu) ||
|
|
||||||
(is_protected_kvm_enabled() && system_supports_sve());
|
|
||||||
|
|
||||||
if (has_hvhe()) {
|
|
||||||
reg = CPACR_EL1_FPEN_EL0EN | CPACR_EL1_FPEN_EL1EN;
|
|
||||||
if (trap_sve)
|
|
||||||
reg |= CPACR_EL1_ZEN_EL0EN | CPACR_EL1_ZEN_EL1EN;
|
|
||||||
|
|
||||||
sysreg_clear_set(cpacr_el1, 0, reg);
|
|
||||||
} else {
|
|
||||||
reg = CPTR_EL2_TFP;
|
|
||||||
if (trap_sve)
|
|
||||||
reg |= CPTR_EL2_TZ;
|
|
||||||
|
|
||||||
sysreg_clear_set(cptr_el2, reg, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Save VGICv3 state on non-VHE systems */
|
/* Save VGICv3 state on non-VHE systems */
|
||||||
static void __hyp_vgic_save_state(struct kvm_vcpu *vcpu)
|
static void __hyp_vgic_save_state(struct kvm_vcpu *vcpu)
|
||||||
{
|
{
|
||||||
|
@@ -163,16 +163,6 @@ void deactivate_traps_vhe_put(struct kvm_vcpu *vcpu)
|
|||||||
local_irq_restore(flags);
|
local_irq_restore(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __deactivate_fpsimd_traps(struct kvm_vcpu *vcpu)
|
|
||||||
{
|
|
||||||
u64 reg = CPACR_EL1_FPEN_EL0EN | CPACR_EL1_FPEN_EL1EN;
|
|
||||||
|
|
||||||
if (vcpu_has_sve(vcpu))
|
|
||||||
reg |= CPACR_EL1_ZEN_EL0EN | CPACR_EL1_ZEN_EL1EN;
|
|
||||||
|
|
||||||
sysreg_clear_set(cpacr_el1, 0, reg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const exit_handler_fn hyp_exit_handlers[] = {
|
static const exit_handler_fn hyp_exit_handlers[] = {
|
||||||
[0 ... ESR_ELx_EC_MAX] = NULL,
|
[0 ... ESR_ELx_EC_MAX] = NULL,
|
||||||
[ESR_ELx_EC_CP15_32] = kvm_hyp_handle_cp15_32,
|
[ESR_ELx_EC_CP15_32] = kvm_hyp_handle_cp15_32,
|
||||||
|
Reference in New Issue
Block a user