Skip to contentSkip to conversation

Patch "powerpc/kernel: Fix FP and vector register restoration" has been added to the 4.9-stable tree

PATCH [email protected] 1 participant 1 message Jun 12, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

powerpc/kernel: Fix FP and vector register restoration

to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
powerpc-kernel-fix-fp-and-vector-register-restoration.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 1195892c091a15cc862f4e202482a36adc924e12 Mon Sep 17 00:00:00 2001

From: Breno Leitao <[email protected]>
Date: Fri, 2 Jun 2017 18:43:30 -0300
Subject: powerpc/kernel: Fix FP and vector register restoration

From: Breno Leitao <[email protected]>

commit 1195892c091a15cc862f4e202482a36adc924e12 upstream.

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")
---
 arch/powerpc/kernel/process.c |    2 ++
 1 file changed, 2 insertions(+)
arch/powerpc/kernel/process.c +2 -0
@@ -1659,6 +1659,7 @@ void start_thread(struct pt_regs *regs,
 #ifdef CONFIG_VSX
 	current->thread.used_vsr = 0;
 #endif
+	current->thread.load_fp = 0;
 	memset(&current->thread.fp_state, 0, sizeof(current->thread.fp_state));
 	current->thread.fp_save_area = NULL;
 #ifdef CONFIG_ALTIVEC
@@ -1667,6 +1668,7 @@ void start_thread(struct pt_regs *regs,
 	current->thread.vr_save_area = NULL;
 	current->thread.vrsave = 0;
 	current->thread.used_vr = 0;
+	current->thread.load_vec = 0;
 #endif /* CONFIG_ALTIVEC */
 #ifdef CONFIG_SPE
 	memset(current->thread.evr, 0, sizeof(current->thread.evr));

Patches currently in stable-queue which might be from [email protected] are

queue-4.9/powerpc-kernel-fix-fp-and-vector-register-restoration.patch queue-4.9/powerpc-kernel-initialize-load_tm-on-task-creation.patch