* [PATCH v2] powerpc: Call restore_sprs() before _switch()
@ 2015-12-10 9:44 Anton Blanchard
2015-12-14 9:47 ` [v2] " Michael Ellerman
0 siblings, 1 reply; 2+ messages in thread
From: Anton Blanchard @ 2015-12-10 9:44 UTC (permalink / raw)
To: mpe, benh, paulus, cyrilbur, scottwood, mikey, linuxppc-dev,
Rashmica
commit 152d523e6307 ("powerpc: Create context switch helpers save_sprs()
and restore_sprs()") moved the restore of SPRs after the call to _switch().
There is an issue with this approach - new tasks do not return through
_switch(), they are set up by copy_thread() to directly return through
ret_from_fork() or ret_from_kernel_thread(). This means restore_sprs() is
not getting called for new tasks.
Fix this by moving restore_sprs() before _switch().
Signed-off-by: Anton Blanchard <anton@samba.org>
Fixes: 152d523e6307 ("powerpc: Create context switch helpers save_sprs() and restore_sprs()")
fold
---
arch/powerpc/kernel/process.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 58194c3..6f5c392 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -964,14 +964,17 @@ struct task_struct *__switch_to(struct task_struct *prev,
tm_recheckpoint_new_task(new);
- last = _switch(old_thread, new_thread);
-
- /* Need to recalculate these after calling _switch() */
- old_thread = &last->thread;
- new_thread = ¤t->thread;
-
+ /*
+ * Call restore_sprs() before calling _switch(). If we move it after
+ * _switch() then we miss out on calling it for new tasks. The reason
+ * for this is we manually create a stack frame for new tasks that
+ * directly returns through ret_from_fork() or
+ * ret_from_kernel_thread(). See copy_thread() for details.
+ */
restore_sprs(old_thread, new_thread);
+ last = _switch(old_thread, new_thread);
+
#ifdef CONFIG_PPC_BOOK3S_64
if (current_thread_info()->local_flags & _TLF_LAZY_MMU) {
current_thread_info()->local_flags &= ~_TLF_LAZY_MMU;
--
2.5.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [v2] powerpc: Call restore_sprs() before _switch()
2015-12-10 9:44 [PATCH v2] powerpc: Call restore_sprs() before _switch() Anton Blanchard
@ 2015-12-14 9:47 ` Michael Ellerman
0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2015-12-14 9:47 UTC (permalink / raw)
To: Anton Blanchard, benh, paulus, cyrilbur, scottwood, mikey,
linuxppc-dev, Rashmica
On Thu, 2015-10-12 at 09:44:39 UTC, Anton Blanchard wrote:
> commit 152d523e6307 ("powerpc: Create context switch helpers save_sprs()
> and restore_sprs()") moved the restore of SPRs after the call to _switch().
>
> There is an issue with this approach - new tasks do not return through
> _switch(), they are set up by copy_thread() to directly return through
> ret_from_fork() or ret_from_kernel_thread(). This means restore_sprs() is
> not getting called for new tasks.
>
> Fix this by moving restore_sprs() before _switch().
>
> Signed-off-by: Anton Blanchard <anton@samba.org>
> Fixes: 152d523e6307 ("powerpc: Create context switch helpers save_sprs() and restore_sprs()")
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/20dbe67062062c2a790832f0
cheers
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-12-14 9:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-10 9:44 [PATCH v2] powerpc: Call restore_sprs() before _switch() Anton Blanchard
2015-12-14 9:47 ` [v2] " Michael Ellerman
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).