linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 2/2] powerpc/hibernate: PPC64 fix user threads access to kernel space
@ 2013-06-09  5:22 Wang Dongsheng
  2013-06-09  6:43 ` Benjamin Herrenschmidt
  2013-06-09 11:31 ` Wang Dongsheng-B40534
  0 siblings, 2 replies; 6+ messages in thread
From: Wang Dongsheng @ 2013-06-09  5:22 UTC (permalink / raw)
  To: benh, johannes, anton; +Cc: scottwood, linuxppc-dev, Wang Dongsheng

If PID is used in the TLB, after hibernation resume, the user
threads will access to kernel space.

We must restore PID register, because TLB will use PID. The
hibernation suspend flow is trapped from user space to kernel
space, the PID register is user thread pid.

The hibernation resume is begin in kernel start flow, the PID
alway 0. After the kernel thread back to user thread, there is
not have context switch and the pid can not update, because the
kernel thread is trapped form user space. So if we did't restore
PID the user space of thread will be addressing in the kernel
space.

There are two ways to restore PID:
1/ In swsusp_arch_suspend/swsusp_arch_resume, save/resotre PID register.
2/ Form restore_processor_state to restore. this function will
   do context switch.
   switch_mmu_context(current->active_mm, current->active_mm)

PPC32 Using the second method. For consistency reason, PPC64 using
the same way.

Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com>
---
 arch/powerpc/kernel/swsusp.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/powerpc/kernel/swsusp.c b/arch/powerpc/kernel/swsusp.c
index eae33e1..1930e44 100644
--- a/arch/powerpc/kernel/swsusp.c
+++ b/arch/powerpc/kernel/swsusp.c
@@ -32,7 +32,5 @@ void save_processor_state(void)
 
 void restore_processor_state(void)
 {
-#ifdef CONFIG_PPC32
 	switch_mmu_context(current->active_mm, current->active_mm);
-#endif
 }
-- 
1.8.0

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

end of thread, other threads:[~2013-06-09 11:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-09  5:22 [PATCH v2 2/2] powerpc/hibernate: PPC64 fix user threads access to kernel space Wang Dongsheng
2013-06-09  6:43 ` Benjamin Herrenschmidt
2013-06-09  7:44   ` Wang Dongsheng-B40534
2013-06-09  7:45     ` Benjamin Herrenschmidt
2013-06-09  7:57       ` Wang Dongsheng-B40534
2013-06-09 11:31 ` Wang Dongsheng-B40534

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).