From patchwork Sun Jun 9 05:22:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongsheng Wang X-Patchwork-Id: 250007 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id DC21C2C0490 for ; Sun, 9 Jun 2013 16:09:08 +1000 (EST) Received: from co9outboundpool.messaging.microsoft.com (co9ehsobe002.messaging.microsoft.com [207.46.163.25]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client CN "mail.global.frontbridge.com", Issuer "MSIT Machine Auth CA 2" (not verified)) by ozlabs.org (Postfix) with ESMTPS id C4CB22C0096 for ; Sun, 9 Jun 2013 16:08:45 +1000 (EST) Received: from mail201-co9-R.bigfish.com (10.236.132.233) by CO9EHSOBE019.bigfish.com (10.236.130.82) with Microsoft SMTP Server id 14.1.225.23; Sun, 9 Jun 2013 06:08:41 +0000 Received: from mail201-co9 (localhost [127.0.0.1]) by mail201-co9-R.bigfish.com (Postfix) with ESMTP id 5A1AC3C021E; Sun, 9 Jun 2013 06:08:41 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1f42h1ee6h1de0h1fdah1202h1e76h1d1ah1d2ah1fc6hzz8275bhz2dh2a8h668h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e23h1155h) Received: from mail201-co9 (localhost.localdomain [127.0.0.1]) by mail201-co9 (MessageSwitch) id 1370758119687911_23852; Sun, 9 Jun 2013 06:08:39 +0000 (UTC) Received: from CO9EHSMHS023.bigfish.com (unknown [10.236.132.235]) by mail201-co9.bigfish.com (Postfix) with ESMTP id A5168802DE; Sun, 9 Jun 2013 06:08:39 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO9EHSMHS023.bigfish.com (10.236.130.33) with Microsoft SMTP Server (TLS) id 14.1.225.23; Sun, 9 Jun 2013 06:08:39 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-001.039d.mgd.msft.net (10.84.1.13) with Microsoft SMTP Server (TLS) id 14.2.328.11; Sun, 9 Jun 2013 06:10:01 +0000 Received: from rock.am.freescale.net (rock.ap.freescale.net [10.193.20.106]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id r5968YwO003362; Sat, 8 Jun 2013 23:08:35 -0700 From: Wang Dongsheng To: , , Subject: [PATCH v2 2/2] powerpc/hibernate: PPC64 fix user threads access to kernel space Date: Sun, 9 Jun 2013 13:22:32 +0800 Message-ID: <1370755352-29901-1-git-send-email-dongsheng.wang@freescale.com> X-Mailer: git-send-email 1.8.0 MIME-Version: 1.0 X-OriginatorOrg: freescale.com Cc: scottwood@freescale.com, linuxppc-dev@lists.ozlabs.org, Wang Dongsheng X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 --- 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 }