From: Sanghoon Lee Date: Thu, 14 Jun 2018 05:36:02 +0000 (+0900) Subject: [COMMON] arm64: fpsimd: Restore FPSIMD state for user thread X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e0e7d6eb3ac43186a6561e64c2adf79e0291405c;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [COMMON] arm64: fpsimd: Restore FPSIMD state for user thread When user thread calls system call to kernel and kernel has overwritten the FPSIMD registers, these registers should be restored for user when kernel completes its job. Change-Id: Ieca1f7baa8a1b245d172bfc750517c70b999ccfa Signed-off-by: Sanghoon Lee --- diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index 805b9c746e55..705ccb03008b 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -279,6 +279,16 @@ void fpsimd_put(void) BUG_ON(atomic_dec_return( ¤t->thread.fpsimd_kernel_state.depth) < 0); + + preempt_disable(); + if (current->mm && test_thread_flag(TIF_FOREIGN_FPSTATE) + && atomic_read(¤t->thread.fpsimd_kernel_state.depth) == 0) { + fpsimd_load_state(¤t->thread.fpsimd_state); + this_cpu_write(fpsimd_last_state, ¤t->thread.fpsimd_state); + current->thread.fpsimd_state.cpu = smp_processor_id(); + clear_thread_flag(TIF_FOREIGN_FPSTATE); + } + preempt_enable(); } #ifdef CONFIG_KERNEL_MODE_NEON