arm64/fpsimd: Clear SME state in the target task when setting the VL
authorMark Brown <broonie@kernel.org>
Wed, 2 Aug 2023 23:46:39 +0000 (00:46 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Thu, 3 Aug 2023 14:41:03 +0000 (15:41 +0100)
When setting SME vector lengths we clear TIF_SME to reenable SME traps,
doing a reallocation of the backing storage on next use. We do this using
clear_thread_flag() which operates on the current thread, meaning that when
setting the vector length via ptrace we may both not force traps for the
target task and force a spurious flush of any SME state that the tracing
task may have.

Clear the flag in the target task.

Fixes: e12310a0d30f ("arm64/sme: Implement ptrace support for streaming mode SVE registers")
Reported-by: David Spickett <David.Spickett@arm.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20230803-arm64-fix-ptrace-tif-sme-v1-1-88312fd6fbfd@kernel.org
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/kernel/fpsimd.c

index 520b681..a61a1fd 100644 (file)
@@ -909,7 +909,7 @@ int vec_set_vector_length(struct task_struct *task, enum vec_type type,
                         */
                        task->thread.svcr &= ~(SVCR_SM_MASK |
                                               SVCR_ZA_MASK);
-                       clear_thread_flag(TIF_SME);
+                       clear_tsk_thread_flag(task, TIF_SME);
                        free_sme = true;
                }
        }