From patchwork Tue Sep 11 17:19:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Yu X-Patchwork-Id: 10595981 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 69C5D13B8 for ; Tue, 11 Sep 2018 17:14:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DEFC29AD7 for ; Tue, 11 Sep 2018 17:14:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4157F29AE4; Tue, 11 Sep 2018 17:14:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6B1629AD7 for ; Tue, 11 Sep 2018 17:14:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727150AbeIKWOd (ORCPT ); Tue, 11 Sep 2018 18:14:33 -0400 Received: from mga17.intel.com ([192.55.52.151]:27760 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726943AbeIKWOd (ORCPT ); Tue, 11 Sep 2018 18:14:33 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Sep 2018 10:14:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,361,1531810800"; d="scan'208";a="89096759" Received: from chenyu-desktop.sh.intel.com ([10.239.160.116]) by fmsmga001.fm.intel.com with ESMTP; 11 Sep 2018 10:14:07 -0700 From: Chen Yu To: Thomas Gleixner , "Rafael J. Wysocki" Cc: Pavel Machek , Rui Zhang , Chen Yu , Zhimin Gu , Len Brown , linux-kernel@vger.kernel.org, x86@kernel.org, linux-pm@vger.kernel.org, Chen Yu Subject: [PATCH 0/4][v2] Fixes hibernation bugs on x86-32 system Date: Wed, 12 Sep 2018 01:19:55 +0800 Message-Id: X-Mailer: git-send-email 2.17.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently there are mainly three bugs in x86-32 system when doing hibernation: 1. The page copy code is not running in safe page, which might cause hang during resume. 2. There's no text mapping for the final jump address of the original kernel, which might cause the system jumping into illegal address and causes system hang during resume. 3. The restore kernel switches to its own kernel page table(swapper_pg_dir) rather than the original kernel page table after all the pages been copied back, which might cause invalid virtual-physical mapping issue during resume. To solve these problems: 1. Copy the code core_restore_code to a safe page, to avoid the instruction code be overwriten when image kernel pages are being copied. 2. Set up temporary text mapping for the image kernel's jump address, so that after all the pages have been copied back, the system could jump to this address. 3. Switch to the original kernel page table during resume. Furthermore, MD5 hash check for e820 map is also backported from 64bits Chen Yu (1): PM / hibernate: Check the success of generating md5 digest before hibernation Zhimin Gu (3): x86, hibernate: Fix nosave_regions setup for hibernation x86, hibernate: Extract the common code of 64/32 bit system x86, hibernate: Backport several fixes from 64bits to 32bits hibernation arch/x86/Kconfig | 2 +- arch/x86/include/asm/suspend_32.h | 4 + arch/x86/kernel/setup.c | 2 +- arch/x86/power/hibernate.c | 263 ++++++++++++++++++++++++++++++ arch/x86/power/hibernate_32.c | 60 ++++--- arch/x86/power/hibernate_64.c | 242 +-------------------------- arch/x86/power/hibernate_asm_32.S | 49 +++++- arch/x86/power/hibernate_asm_64.S | 2 +- 8 files changed, 350 insertions(+), 274 deletions(-) create mode 100644 arch/x86/power/hibernate.c