Skip to content

Commit e511e08

Browse files
Fuad TabbaMarc Zyngier
authored andcommitted
KVM: arm64: Specialize handling of host fpsimd state on trap
In subsequent patches, n/vhe will diverge on saving the host fpsimd/sve state when taking a guest fpsimd/sve trap. Add a specialized helper to handle it. No functional change intended. Reviewed-by: Mark Brown <[email protected]> Reviewed-by: Oliver Upton <[email protected]> Signed-off-by: Fuad Tabba <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent 6d8fb3c commit e511e08

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

arch/arm64/kvm/hyp/include/hyp/switch.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ static inline void __hyp_sve_restore_guest(struct kvm_vcpu *vcpu)
321321
write_sysreg_el1(__vcpu_sys_reg(vcpu, ZCR_EL1), SYS_ZCR);
322322
}
323323

324+
static void kvm_hyp_save_fpsimd_host(struct kvm_vcpu *vcpu);
325+
324326
/*
325327
* We trap the first access to the FP/SIMD to save the host context and
326328
* restore the guest context lazily.
@@ -361,7 +363,7 @@ static bool kvm_hyp_handle_fpsimd(struct kvm_vcpu *vcpu, u64 *exit_code)
361363

362364
/* Write out the host state if it's in the registers */
363365
if (host_owns_fp_regs())
364-
__fpsimd_save_state(*host_data_ptr(fpsimd_state));
366+
kvm_hyp_save_fpsimd_host(vcpu);
365367

366368
/* Restore the guest state */
367369
if (sve_guest)

arch/arm64/kvm/hyp/nvhe/switch.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ static bool kvm_handle_pvm_sys64(struct kvm_vcpu *vcpu, u64 *exit_code)
182182
kvm_handle_pvm_sysreg(vcpu, exit_code));
183183
}
184184

185+
static void kvm_hyp_save_fpsimd_host(struct kvm_vcpu *vcpu)
186+
{
187+
__fpsimd_save_state(*host_data_ptr(fpsimd_state));
188+
}
189+
185190
static const exit_handler_fn hyp_exit_handlers[] = {
186191
[0 ... ESR_ELx_EC_MAX] = NULL,
187192
[ESR_ELx_EC_CP15_32] = kvm_hyp_handle_cp15_32,

arch/arm64/kvm/hyp/vhe/switch.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,11 @@ static bool kvm_hyp_handle_eret(struct kvm_vcpu *vcpu, u64 *exit_code)
262262
return true;
263263
}
264264

265+
static void kvm_hyp_save_fpsimd_host(struct kvm_vcpu *vcpu)
266+
{
267+
__fpsimd_save_state(*host_data_ptr(fpsimd_state));
268+
}
269+
265270
static const exit_handler_fn hyp_exit_handlers[] = {
266271
[0 ... ESR_ELx_EC_MAX] = NULL,
267272
[ESR_ELx_EC_CP15_32] = kvm_hyp_handle_cp15_32,

0 commit comments

Comments
 (0)