Skip to content

Commit 62021cc

Browse files
brooniewilldeacon
authored andcommitted
arm64/fpsimd: Stop using TIF_SVE to manage register saving in KVM
Now that we are explicitly telling the host FP code which register state it needs to save we can remove the manipulation of TIF_SVE from the KVM code, simplifying it and allowing us to optimise our handling of normal tasks. Remove the manipulation of TIF_SVE from KVM and instead rely on to_save to ensure we save the correct data for it. There should be no functional or performance impact from this change. Signed-off-by: Mark Brown <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Reviewed-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent deeb8f9 commit 62021cc

File tree

2 files changed

+4
-21
lines changed

2 files changed

+4
-21
lines changed

arch/arm64/kernel/fpsimd.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,8 @@ static void task_fpsimd_load(void)
439439
* last, if KVM is involved this may be the guest VM context rather
440440
* than the host thread for the VM pointed to by current. This means
441441
* that we must always reference the state storage via last rather
442-
* than via current, other than the TIF_ flags which KVM will
443-
* carefully maintain for us.
442+
* than via current, if we are saving KVM state then it will have
443+
* ensured that the type of registers to save is set in last->to_save.
444444
*/
445445
static void fpsimd_save(void)
446446
{
@@ -457,27 +457,13 @@ static void fpsimd_save(void)
457457
if (test_thread_flag(TIF_FOREIGN_FPSTATE))
458458
return;
459459

460-
if (test_thread_flag(TIF_SVE)) {
460+
if ((last->to_save == FP_STATE_CURRENT && test_thread_flag(TIF_SVE)) ||
461+
last->to_save == FP_STATE_SVE) {
461462
save_sve_regs = true;
462463
save_ffr = true;
463464
vl = last->sve_vl;
464465
}
465466

466-
/*
467-
* Validate that an explicitly specified state to save is
468-
* consistent with the task state.
469-
*/
470-
switch (last->to_save) {
471-
case FP_STATE_CURRENT:
472-
break;
473-
case FP_STATE_FPSIMD:
474-
WARN_ON_ONCE(save_sve_regs);
475-
break;
476-
case FP_STATE_SVE:
477-
WARN_ON_ONCE(!save_sve_regs);
478-
break;
479-
}
480-
481467
if (system_supports_sme()) {
482468
u64 *svcr = last->svcr;
483469

arch/arm64/kvm/fpsimd.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ void kvm_arch_vcpu_ctxsync_fp(struct kvm_vcpu *vcpu)
151151
&vcpu->arch.fp_type, fp_type);
152152

153153
clear_thread_flag(TIF_FOREIGN_FPSTATE);
154-
update_thread_flag(TIF_SVE, vcpu_has_sve(vcpu));
155154
}
156155
}
157156

@@ -208,7 +207,5 @@ void kvm_arch_vcpu_put_fp(struct kvm_vcpu *vcpu)
208207
sysreg_clear_set(CPACR_EL1, CPACR_EL1_ZEN_EL0EN, 0);
209208
}
210209

211-
update_thread_flag(TIF_SVE, 0);
212-
213210
local_irq_restore(flags);
214211
}

0 commit comments

Comments
 (0)