mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
ANDROID: KVM: arm64: Factor out logic for setting SVE vector length at hyp
Factor out the logic for setting the SVE vector length at the hypervisor in pKVM to the maximum hardware supported value when saving and restoring host SVE state. This shares common code, and elides an unused variable warning when SVE is not configured. Change-Id: Ibaa58e5bb44e4f85b9548a6abb498f0a769f6a4b Signed-off-by: Fuad Tabba <tabba@google.com> Bug: 267291591
This commit is contained in:
@@ -152,6 +152,12 @@ static inline bool pkvm_ipa_range_has_pvmfw(struct pkvm_hyp_vm *vm,
|
||||
return ipa_end > pkvm->pvmfw_load_addr && ipa_start < pvmfw_load_end;
|
||||
}
|
||||
|
||||
static inline void pkvm_set_max_sve_vq(void)
|
||||
{
|
||||
sve_cond_update_zcr_vq(sve_vq_from_vl(kvm_host_sve_max_vl) - 1,
|
||||
SYS_ZCR_EL2);
|
||||
}
|
||||
|
||||
int pkvm_load_pvmfw_pages(struct pkvm_hyp_vm *vm, u64 ipa, phys_addr_t phys,
|
||||
u64 size);
|
||||
void pkvm_poison_pvmfw_pages(void);
|
||||
|
||||
@@ -688,10 +688,9 @@ static void fpsimd_host_restore(void)
|
||||
|
||||
if (system_supports_sve()) {
|
||||
struct kvm_host_sve_state *sve_state = get_host_sve_state(vcpu);
|
||||
u64 vq_len = sve_vq_from_vl(kvm_host_sve_max_vl) - 1;
|
||||
|
||||
write_sysreg_el1(sve_state->zcr_el1, SYS_ZCR);
|
||||
sve_cond_update_zcr_vq(vq_len, SYS_ZCR_EL2);
|
||||
pkvm_set_max_sve_vq();
|
||||
__sve_restore_state(sve_state->sve_regs +
|
||||
sve_ffr_offset(kvm_host_sve_max_vl),
|
||||
&sve_state->fpsr);
|
||||
|
||||
@@ -199,10 +199,9 @@ static void kvm_hyp_handle_fpsimd_host(struct kvm_vcpu *vcpu)
|
||||
*/
|
||||
if (unlikely(is_protected_kvm_enabled() && system_supports_sve())) {
|
||||
struct kvm_host_sve_state *sve_state = get_host_sve_state(vcpu);
|
||||
u64 vq_len = sve_vq_from_vl(kvm_host_sve_max_vl) - 1;
|
||||
|
||||
sve_state->zcr_el1 = read_sysreg_el1(SYS_ZCR);
|
||||
sve_cond_update_zcr_vq(vq_len, SYS_ZCR_EL2);
|
||||
pkvm_set_max_sve_vq();
|
||||
__sve_save_state(sve_state->sve_regs +
|
||||
sve_ffr_offset(kvm_host_sve_max_vl),
|
||||
&sve_state->fpsr);
|
||||
|
||||
Reference in New Issue
Block a user