Skip to content

Commit

Permalink
arm64/sve: Preserve SVE registers around kernel-mode NEON use
Browse files Browse the repository at this point in the history
Kernel-mode NEON will corrupt the SVE vector registers, due to the
way they alias the FPSIMD vector registers in the hardware.

This patch ensures that any live SVE register content for the task
is saved by kernel_neon_begin().  The data will be restored in the
usual way on return to userspace.

Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
  • Loading branch information
Dave Martin authored and Will Deacon committed Nov 3, 2017
1 parent 2e0f247 commit 1bd3f93
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions arch/arm64/kernel/fpsimd.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,10 @@ void kernel_neon_begin(void)
__this_cpu_write(kernel_neon_busy, true);

/* Save unsaved task fpsimd state, if any: */
if (current->mm && !test_and_set_thread_flag(TIF_FOREIGN_FPSTATE))
fpsimd_save_state(&current->thread.fpsimd_state);
if (current->mm) {
task_fpsimd_save();
set_thread_flag(TIF_FOREIGN_FPSTATE);
}

/* Invalidate any task state remaining in the fpsimd regs: */
__this_cpu_write(fpsimd_last_state, NULL);
Expand Down

0 comments on commit 1bd3f93

Please sign in to comment.