From patchwork Wed Sep 19 07:37:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Yu X-Patchwork-Id: 10605421 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 1E77E112B for ; Wed, 19 Sep 2018 07:30:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02C112B95D for ; Wed, 19 Sep 2018 07:30:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F39A92B8C7; Wed, 19 Sep 2018 07:30:45 +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 9031E2B95D for ; Wed, 19 Sep 2018 07:30:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730951AbeISNHQ (ORCPT ); Wed, 19 Sep 2018 09:07:16 -0400 Received: from mga02.intel.com ([134.134.136.20]:39784 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730787AbeISNHP (ORCPT ); Wed, 19 Sep 2018 09:07:15 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Sep 2018 00:30:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,393,1531810800"; d="scan'208";a="87395401" Received: from chenyu-desktop.sh.intel.com ([10.239.160.116]) by fmsmga002.fm.intel.com with ESMTP; 19 Sep 2018 00:30:23 -0700 From: Chen Yu To: Thomas Gleixner , "Rafael J. Wysocki" Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Pavel Machek , Len Brown , Zhimin Gu , Yu Chen Subject: [PATCH 00/12][RFC v3] Backport several fixes from 64bits to 32bits hibernation Date: Wed, 19 Sep 2018 15:37:01 +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 32bits 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 been overwritten 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 system. In order to make this patch set more readable, these fixes are splitted into several sub patches. Chen Yu (1): PM / hibernate: Check the success of generating md5 digest before hibernation Zhimin Gu (11): x86, hibernate: Fix nosave_regions setup for hibernation x86/asm/power: Create stack frames in hibernate_asm_32.S x86, hibernate: Extract the common code of 64/32 bit system x86, hibernate: Enable CONFIG_ARCH_HIBERNATION_HEADER set on 32bit system x86, hibernate: Rename temp_level4_pgt to temp_pgt x86, hibernate: Use temp_pgt as the temporary page table x86, hibernate: Use the page size macro instead of constant value x86, hibernate: Switch to original page table after resumed x86, hibernate: Switch to relocated restore code during resume on 32bit system x86, hibernate: Set up temporary text mapping for 32bit system x86, hibernate: Adjust in_suspend after resumed on 32bit system arch/x86/Kconfig | 2 +- arch/x86/include/asm/suspend.h | 8 + arch/x86/include/asm/suspend_32.h | 4 + arch/x86/kernel/setup.c | 2 +- arch/x86/power/Makefile | 2 +- arch/x86/power/hibernate.c | 249 ++++++++++++++++++++++++++++++ arch/x86/power/hibernate_32.c | 52 +++++-- arch/x86/power/hibernate_64.c | 224 +-------------------------- arch/x86/power/hibernate_asm_32.S | 37 ++++- arch/x86/power/hibernate_asm_64.S | 2 +- 10 files changed, 335 insertions(+), 247 deletions(-) create mode 100644 arch/x86/power/hibernate.c