Skip to contentSkip to conversation

arm64: fix bug for reloading FPSIMD state after cpu power off

PATCH In review Leo Yan 4 participants 4 messages Sep 1, 2014 arm64

lore
Share & tools
lore

Leo Yan

author
#0 lore raw

PATCH v2 1/1 arm64: fix bug for reloading FPSIMD state after cpu power off

Now arm64 defers reloading FPSIMD state, but this optimization also introduces the bug after cpu resume back from low power mode.

The reason is after the cpu has been powered off, s/w need set the cpu's fpsimd_last_state to NULL so that it will force to reload FPSIMD state for the thread, otherwise there has the chance to meet the condition for both the task's fpsimd_state.cpu field contains the id of the current cpu, and the cpu's fpsimd_last_state per-cpu variable points to the task's fpsimd_state, so finally kernel will skip to reload the context during it return back to userland.

---
 arch/arm64/kernel/fpsimd.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/kernel/fpsimd.c +1 -0
index ad8aebb..3dca156 100644
@@ -270,6 +270,7 @@ static int fpsimd_cpu_pm_notifier(struct notifier_block *self,
 	case CPU_PM_ENTER:
 		if (current->mm && !test_thread_flag(TIF_FOREIGN_FPSTATE))
 			fpsimd_save_state(&current->thread.fpsimd_state);
+		this_cpu_write(fpsimd_last_state, NULL);
 		break;
 	case CPU_PM_EXIT:
 		if (current->mm)
Signature · 1 line
1.9.1
Acked-by on v2 1/1
#1 lore raw
Quoted 11 lines · Leo Yan

Now arm64 defers reloading FPSIMD state, but this optimization also introduces the bug after cpu resume back from low power mode.

The reason is after the cpu has been powered off, s/w need set the cpu's fpsimd_last_state to NULL so that it will force to reload FPSIMD state for the thread, otherwise there has the chance to meet the condition for both the task's fpsimd_state.cpu field contains the id of the current cpu, and the cpu's fpsimd_last_state per-cpu variable points to the task's fpsimd_state, so finally kernel will skip to reload the context during it return back to userland.

Quoted 1 line
Quoted 19 lines
---
 arch/arm64/kernel/fpsimd.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/kernel/fpsimd.c +1 -1
index ad8aebb..3dca156 100644
@@ -270,6 +270,7 @@ static int fpsimd_cpu_pm_notifier(struct notifier_block *self,
        case CPU_PM_ENTER:
                if (current->mm && !test_thread_flag(TIF_FOREIGN_FPSTATE))
                        fpsimd_save_state(&current->thread.fpsimd_state);
+               this_cpu_write(fpsimd_last_state, NULL);
                break;
        case CPU_PM_EXIT:
                if (current->mm)
--

1.9.1

maintainer Reviewed-by on v2 1/1
#2 lore raw
In reply to Leo Yan
Quoted 11 lines · Leo Yan

Now arm64 defers reloading FPSIMD state, but this optimization also introduces the bug after cpu resume back from low power mode.

The reason is after the cpu has been powered off, s/w need set the cpu's fpsimd_last_state to NULL so that it will force to reload FPSIMD state for the thread, otherwise there has the chance to meet the condition for both the task's fpsimd_state.cpu field contains the id of the current cpu, and the cpu's fpsimd_last_state per-cpu variable points to the task's fpsimd_state, so finally kernel will skip to reload the context during it return back to userland.

Quoted 1 line

(and cc'ing Will to pick it up since he's handling the 3.17 release)

Thanks.

#3 lore raw
Quoted 12 lines · Catalin Marinas
Quoted 11 lines · Leo Yan

Now arm64 defers reloading FPSIMD state, but this optimization also introduces the bug after cpu resume back from low power mode.

The reason is after the cpu has been powered off, s/w need set the cpu's fpsimd_last_state to NULL so that it will force to reload FPSIMD state for the thread, otherwise there has the chance to meet the condition for both the task's fpsimd_state.cpu field contains the id of the current cpu, and the cpu's fpsimd_last_state per-cpu variable points to the task's fpsimd_state, so finally kernel will skip to reload the context during it return back to userland.

Quoted 5 lines
Quoted 1 line

(and cc'ing Will to pick it up since he's handling the 3.17 release)

Cheers for the CC; applied to fixes/core (I'll push out once I've run the regression tests).

I aim to tag that branch tonight if we don't get any more fixes today.

Will