From patchwork Fri Sep 12 03:03:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chun-Yi Lee X-Patchwork-Id: 4891661 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4F0D3BEEA5 for ; Fri, 12 Sep 2014 03:04:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 19FDD201D3 for ; Fri, 12 Sep 2014 03:04:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3431F20266 for ; Fri, 12 Sep 2014 03:04:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752835AbaILDES (ORCPT ); Thu, 11 Sep 2014 23:04:18 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:39170 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752168AbaILDER (ORCPT ); Thu, 11 Sep 2014 23:04:17 -0400 Received: by mail-pa0-f53.google.com with SMTP id rd3so232396pab.12 for ; Thu, 11 Sep 2014 20:04:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=42qIuG7nN8NgSh6jOZvqFc++9stCXZCefPzZv6n8nGE=; b=jRbWUja2ObCzm/RRF6PTb4z/dZUcF57NIbHaWMMvNtiF02rG17LJlCY4vMLntUEykr jPoXEWRB1HbPW1NAurq7UFurS5xzqYHfR80TgBJerZAUYLPs/VsaO03pOad2Hzo8veVf KKB4eeUyVAzPI7Yk79FfXU6nWcCpFJA5su8wPioK4isgjcRy3/D40Shi7yadtlcvTVxv 5f2cmGxZqwv0U8+r7LPl2wSMpHwqOg/Pfu12BVqdu+PcR3fv3QJtlzgAzAymb8DyleaT WX6gthuVPgQnASoKLMX44Ch4c3V5+QWiZeTUvzpGzdJZeh2CPVvQz0D/wxUkai9oaWLq YESg== X-Received: by 10.68.94.226 with SMTP id df2mr7402920pbb.122.1410491057129; Thu, 11 Sep 2014 20:04:17 -0700 (PDT) Received: from linux-rxt1.site ([130.57.30.250]) by mx.google.com with ESMTPSA id k11sm2303502pbq.64.2014.09.11.20.04.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Sep 2014 20:04:16 -0700 (PDT) From: "Lee, Chun-Yi" X-Google-Original-From: "Lee, Chun-Yi" To: "Rafael J. Wysocki" , Len Brown , Pavel Machek Cc: Takashi Iwai , Yinghai Lu , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, "Lee, Chun-Yi" , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" Subject: [PATCH v2] Hibernate: Do not assume the first e820 area to be RAM Date: Fri, 12 Sep 2014 11:03:58 +0800 Message-Id: <1410491038-17576-1-git-send-email-jlee@suse.com> X-Mailer: git-send-email 1.8.4.5 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In arch/x86/kernel/setup.c::trim_bios_range(), the codes introduced by 1b5576e6 (base on d8a9e6a5), it updates the first 4Kb of memory to be E820_RESERVED region. That's because it's a BIOS owned area but generally not listed in the E820 table: [ 0.000000] e820: BIOS-provided physical RAM map: [ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x0000000000096fff] usable [ 0.000000] BIOS-e820: [mem 0x0000000000097000-0x0000000000097fff] reserved ... [ 0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved [ 0.000000] e820: remove [mem 0x000a0000-0x000fffff] usable But the region of first 4Kb didn't register to nosave memory: [ 0.000000] PM: Registered nosave memory: [mem 0x00097000-0x00097fff] [ 0.000000] PM: Registered nosave memory: [mem 0x000a0000-0x000fffff] The codes in e820_mark_nosave_regions() assumes the first e820 area to be RAM, so it causes the first 4Kb E820_RESERVED region ignored when register to nosave. This patch removed assumption of the first e820 area. v2: To avoid the i > 0 checking in for loop. (coding suggestion from Yinghai Lu) Cc: "Rafael J. Wysocki" Cc: Len Brown Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: Yinghai Lu Acked-by: Pavel Machek Signed-off-by: Lee, Chun-Yi --- arch/x86/kernel/e820.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-3.12-SLE12/arch/x86/kernel/e820.c =================================================================== --- linux-3.12-SLE12.orig/arch/x86/kernel/e820.c +++ linux-3.12-SLE12/arch/x86/kernel/e820.c @@ -682,15 +682,14 @@ void __init parse_e820_ext(u64 phys_addr * hibernation (32 bit) or software suspend and suspend to RAM (64 bit). * * This function requires the e820 map to be sorted and without any - * overlapping entries and assumes the first e820 area to be RAM. + * overlapping entries. */ void __init e820_mark_nosave_regions(unsigned long limit_pfn) { int i; - unsigned long pfn; + unsigned long pfn = 0; - pfn = PFN_DOWN(e820.map[0].addr + e820.map[0].size); - for (i = 1; i < e820.nr_map; i++) { + for (i = 0; i < e820.nr_map; i++) { struct e820entry *ei = &e820.map[i]; if (pfn < PFN_UP(ei->addr))