Skip to content

Commit 49ce484

Browse files
mrutland-armwilldeacon
authored andcommitted
arm64/fpsimd: ptrace/prctl: Ensure VL changes do not resurrect stale data
The SVE/SME vector lengths can be changed via prctl/ptrace syscalls. Changes to the SVE/SME vector lengths are documented as preserving the lower 128 bits of the Z registers (i.e. the bits shared with the FPSIMD V registers). To ensure this, vec_set_vector_length() explicitly copies register values from a task's saved SVE state to its saved FPSIMD state when dropping the task to FPSIMD-only. The logic for this was not updated when when FPSIMD/SVE state tracking was changed across commits: baa8515 ("arm64/fpsimd: Track the saved FPSIMD state type separately to TIF_SVE") a0136be (arm64/fpsimd: Load FP state based on recorded data type") bbc6172 ("arm64/fpsimd: SME no longer requires SVE register state") 8c845e2 ("arm64/sve: Leave SVE enabled on syscall if we don't context switch") Since the last commit above, a task's FPSIMD/SVE state may be stored in FPSIMD format while TIF_SVE is set, and the stored SVE state is stale. When vec_set_vector_length() encounters this case, it will erroneously clobber the live FPSIMD state with stale SVE state by using sve_to_fpsimd(). Fix this by using fpsimd_sync_from_effective_state() instead. Related issues with streaming mode state will be addressed in subsequent patches. Fixes: 8c845e2 ("arm64/sve: Leave SVE enabled on syscall if we don't context switch") Signed-off-by: Mark Rutland <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: David Spickett <[email protected]> Cc: Luis Machado <[email protected]> Cc: Marc Zyngier <[email protected]> Cc: Mark Brown <[email protected]> Cc: Will Deacon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent cde5c32 commit 49ce484

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/arm64/kernel/fpsimd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ int vec_set_vector_length(struct task_struct *task, enum vec_type type,
852852
fpsimd_flush_task_state(task);
853853
if (test_and_clear_tsk_thread_flag(task, TIF_SVE) ||
854854
thread_sm_enabled(&task->thread)) {
855-
sve_to_fpsimd(task);
855+
fpsimd_sync_from_effective_state(task);
856856
task->thread.fp_type = FP_STATE_FPSIMD;
857857
}
858858

0 commit comments

Comments
 (0)