[PATCH v2 2/2] powerpc/hibernate: PPC64 fix user threads access to kernel space
Wang Dongsheng-B40534
B40534 at freescale.com
Sun Jun 9 17:44:15 EST 2013
> -----Original Message-----
> From: Benjamin Herrenschmidt [mailto:benh at kernel.crashing.org]
> Sent: Sunday, June 09, 2013 2:44 PM
> To: Wang Dongsheng-B40534
> Cc: johannes at sipsolutions.net; anton at enomsg.org; Wood Scott-B07421;
> galak at kernel.crashing.org; linuxppc-dev at lists.ozlabs.org
> Subject: Re: [PATCH v2 2/2] powerpc/hibernate: PPC64 fix user threads
> access to kernel space
>
> On Sun, 2013-06-09 at 13:22 +0800, Wang Dongsheng wrote:
> > If PID is used in the TLB, after hibernation resume, the user threads
> > will access to kernel space.
>
> .../...
>
> I think the explanation is way more convoluted and confusing here than
> anything else.
>
> Simply say that upon resume from hibernation, the MMU context needs to be
> restored (this includes the PID register today it might include more if
> we decided to pre-set some MAS for example
> etc...) and be done with it.
>
> Note that switch_mmu_context() used the way you do is quite "full on", it
> will do a whole pile of stuff that are probably completely unnecessary,
> and in addition might still miss the need to completely flush the TLB
> anyway.
>
> I would suggest that instead, somebody adds the necessary routine to
> tlb_nohash.c, something like restore_mmu_context() which will do that.
>
Thanks ben, This is a good idea.
We do not need to decide the current thread has a context in restore_mmu_context().
Because the current has already get a context in hibernation suspend flow.
So we just need set set_context() in restore_mmu_context().
void restore_mmu_context(struct mm_struct *next) {
set_context(next->context.id, next->pgd);
}
-dongsheng
> Cheers,
> Ben.
>
> > Signed-off-by: Wang Dongsheng <dongsheng.wang at 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
> > }
>
>
More information about the Linuxppc-dev
mailing list