OSDN Git Service

powerpc/kernel: Fix FP and vector register restoration
authorBreno Leitao <leitao@debian.org>
Fri, 2 Jun 2017 21:43:30 +0000 (18:43 -0300)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 5 Jun 2017 05:55:30 +0000 (15:55 +1000)
commit1195892c091a15cc862f4e202482a36adc924e12
treee78149a873212fd4409b4dcdb1e3b770965c123e
parent0e5e7f5e9700661c3ddd95501743fb52fec1ab07
powerpc/kernel: Fix FP and vector register restoration

Currently tsk->thread->load_vec and load_fp are not initialized during
task creation, which can lead to garbage values in these variables (non-zero
values).

These variables will be checked later in restore_math() to validate if the
FP and vector registers are being utilized. Since these values might be
non-zero, the restore_math() will continue to save the FP and vectors even if
they were never utilized by the userspace application. load_fp and load_vec
counters will then overflow (they wrap at 255) and the FP and Altivec will be
finally disabled, but before that condition is reached (counter overflow)
several context switches will have restored FP and vector registers without
need, causing a performance degradation.

Fixes: 70fe3d980f5f ("powerpc: Restore FPU/VEC/VSX if previously used")
Cc: stable@vger.kernel.org # v4.6+
Signed-off-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Gustavo Romero <gusbromero@gmail.com>
Acked-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/process.c