linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] arm64: fix bug for reloading FPSIMD state after cpu power off
@ 2014-09-01  3:09 Leo Yan
  2014-09-01  6:32 ` Ard Biesheuvel
  2014-09-01  9:34 ` Catalin Marinas
  0 siblings, 2 replies; 4+ messages in thread
From: Leo Yan @ 2014-09-01  3:09 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, catalin.marinas, ard.biesheuvel; +Cc: 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.

Signed-off-by: Leo Yan <leoy@marvell.com>
---
 arch/arm64/kernel/fpsimd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
index ad8aebb..3dca156 100644
--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] arm64: fix bug for reloading FPSIMD state after cpu power off
  2014-09-01  3:09 [PATCH v2] arm64: fix bug for reloading FPSIMD state after cpu power off Leo Yan
@ 2014-09-01  6:32 ` Ard Biesheuvel
  2014-09-01  9:34 ` Catalin Marinas
  1 sibling, 0 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2014-09-01  6:32 UTC (permalink / raw)
  To: Leo Yan; +Cc: linux-arm-kernel, linux-kernel, Catalin Marinas

On 1 September 2014 05:09, Leo Yan <leoy@marvell.com> wrote:
> 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.
>
> Signed-off-by: Leo Yan <leoy@marvell.com>

Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---
>  arch/arm64/kernel/fpsimd.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
> index ad8aebb..3dca156 100644
> --- a/arch/arm64/kernel/fpsimd.c
> +++ b/arch/arm64/kernel/fpsimd.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] arm64: fix bug for reloading FPSIMD state after cpu power off
  2014-09-01  3:09 [PATCH v2] arm64: fix bug for reloading FPSIMD state after cpu power off Leo Yan
  2014-09-01  6:32 ` Ard Biesheuvel
@ 2014-09-01  9:34 ` Catalin Marinas
  2014-09-01 11:56   ` Will Deacon
  1 sibling, 1 reply; 4+ messages in thread
From: Catalin Marinas @ 2014-09-01  9:34 UTC (permalink / raw)
  To: Leo Yan; +Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, Will Deacon

On Mon, Sep 01, 2014 at 04:09:51AM +0100, Leo Yan wrote:
> 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.
> 
> Signed-off-by: Leo Yan <leoy@marvell.com>

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>

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

Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] arm64: fix bug for reloading FPSIMD state after cpu power off
  2014-09-01  9:34 ` Catalin Marinas
@ 2014-09-01 11:56   ` Will Deacon
  0 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2014-09-01 11:56 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: Leo Yan, linux-arm-kernel, linux-kernel, ard.biesheuvel

On Mon, Sep 01, 2014 at 10:34:28AM +0100, Catalin Marinas wrote:
> On Mon, Sep 01, 2014 at 04:09:51AM +0100, Leo Yan wrote:
> > 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.
> > 
> > Signed-off-by: Leo Yan <leoy@marvell.com>
> 
> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
> 
> (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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-09-01 11:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-01  3:09 [PATCH v2] arm64: fix bug for reloading FPSIMD state after cpu power off Leo Yan
2014-09-01  6:32 ` Ard Biesheuvel
2014-09-01  9:34 ` Catalin Marinas
2014-09-01 11:56   ` Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).