[ Sasha's backport helper bot ]
Hi,
✅ All tests passed successfully. No issues detected. No action required from the submitter.
The upstream commit SHA1 provided is correct: 62021cc36add7b2c015b837f7893f2fb4b8c2586
Status in newer kernel trees: 6.13.y | Present (exact SHA1) 6.12.y | Present (exact SHA1) 6.6.y | Present (exact SHA1) 6.1.y | Not found
Note: The patch differs from the upstream commit: --- 1: 62021cc36add7 ! 1: 45bec98f19f58 arm64/fpsimd: Stop using TIF_SVE to manage register saving in KVM @@ Metadata ## Commit message ## arm64/fpsimd: Stop using TIF_SVE to manage register saving in KVM
+ [ Upstream commit 62021cc36add7b2c015b837f7893f2fb4b8c2586 ] + 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 @@ Commit message Reviewed-by: Marc Zyngier maz@kernel.org Link: https://lore.kernel.org/r/20221115094640.112848-5-broonie@kernel.org Signed-off-by: Will Deacon will@kernel.org + [ Mark: trivial backport ] + Signed-off-by: Mark Rutland mark.rutland@arm.com + Signed-off-by: Mark Brown broonie@kernel.org
## arch/arm64/kernel/fpsimd.c ## @@ arch/arm64/kernel/fpsimd.c: static void task_fpsimd_load(void) - * last, if KVM is involved this may be the guest VM context rather - * than the host thread for the VM pointed to by current. This means - * that we must always reference the state storage via last rather -- * than via current, other than the TIF_ flags which KVM will -- * carefully maintain for us. + + /* + * Ensure FPSIMD/SVE storage in memory for the loaded context is up to +- * date with respect to the CPU registers. ++ * date with respect to the CPU registers. Note carefully that the ++ * current context is the context last bound to the CPU stored in ++ * last, if KVM is involved this may be the guest VM context rather ++ * than the host thread for the VM pointed to by current. This means ++ * that we must always reference the state storage via last rather + * than via current, if we are saving KVM state then it will have + * ensured that the type of registers to save is set in last->to_save. */ @@ arch/arm64/kernel/fpsimd.c: static void fpsimd_save(void) if (test_thread_flag(TIF_FOREIGN_FPSTATE)) return;
-- if (test_thread_flag(TIF_SVE)) { +- if (IS_ENABLED(CONFIG_ARM64_SVE) && +- test_thread_flag(TIF_SVE)) { +- if (WARN_ON(sve_get_vl() != last->sve_vl)) { + if ((last->to_save == FP_STATE_CURRENT && test_thread_flag(TIF_SVE)) || + last->to_save == FP_STATE_SVE) { - save_sve_regs = true; - save_ffr = true; - vl = last->sve_vl; ++ save_sve_regs = true; ++ vl = last->sve_vl; ++ } ++ ++ if (IS_ENABLED(CONFIG_ARM64_SVE) && save_sve_regs) { ++ /* Get the configured VL from RDVL, will account for SM */ ++ if (WARN_ON(sve_get_vl() != vl)) { + /* + * Can't save the user regs, so current would + * re-enter user with corrupt state. +@@ arch/arm64/kernel/fpsimd.c: static void fpsimd_save(void) + } }
+- if (test_thread_flag(TIF_SVE)) { +- save_sve_regs = true; +- vl = last->sve_vl; +- } +- - /* - * Validate that an explicitly specified state to save is - * consistent with the task state. @@ arch/arm64/kernel/fpsimd.c: static void fpsimd_save(void) - break; - } - - if (system_supports_sme()) { - u64 *svcr = last->svcr; - + if (IS_ENABLED(CONFIG_ARM64_SVE) && save_sve_regs) { + sve_save_state((char *)last->sve_state + + sve_ffr_offset(last->sve_vl),
## arch/arm64/kvm/fpsimd.c ## @@ arch/arm64/kvm/fpsimd.c: void kvm_arch_vcpu_ctxsync_fp(struct kvm_vcpu *vcpu) ---
Results of testing on various branches:
| Branch | Patch Apply | Build Test | |---------------------------|-------------|------------| | stable/linux-6.1.y | Success | Success |