mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Lee, Chun-Yi" <joeyli.kernel@gmail.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Ingo Molnar <mingo@kernel.org>, Pavel Machek <pavel@ucw.cz>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	x86@kernel.org, linux-kernel@vger.kernel.org, "Lee,
	Chun-Yi" <jlee@suse.com>, Len Brown <len.brown@intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>, Yinghai Lu <yinghai@kernel.org>,
	Takashi Iwai <tiwai@suse.de>
Subject: [PATCH] x86/mm, hibernate: Fix misjudgment of register setup_data page to nosave region
Date: Fri, 30 Jan 2015 11:58:20 +0800	[thread overview]
Message-ID: <1422590300-13307-1-git-send-email-jlee@suse.com> (raw)

The reserve setup_data action break usable regions to not align to
page size. As following case:

BIOS-e820: [mem 0x0000000000088000-0x00000000000bffff] reserved
BIOS-e820: [mem 0x0000000000100000-0x0000000094caffff] usable
...
e820: update [mem 0x93c5f018-0x93c6f057] usable ==> usable	/* reserve setup_data */
e820: update [mem 0x93c4f018-0x93c5e057] usable ==> usable	/* reserve setup_data */
...
reserve setup_data: [mem0x0000000000088000-0x00000000000bffff] reserved
reserve setup_data: [mem0x0000000000100000-0x0000000093c4f017] usable /* not align */
reserve setup_data: [mem0x0000000093c4f018-0x0000000093c5e057] usable /* not align */
reserve setup_data: [mem0x0000000093c5e058-0x0000000093c5f017] usable /* not align */
reserve setup_data: [mem0x0000000093c5f018-0x0000000093c6f057] usable /* not align */
reserve setup_data: [mem0x0000000093c6f058-0x0000000094caffff] usable

The codes in e820_mark_nosave_regions() check pfn of each e820
entry to find out the hole between two entries then register it to
nosave region. This logic misjudges the non-align but continuous usable
region, then register one page in usable region to nosave. As following:

PM: Registered nosave memory: [mem 0x000c0000-0x000fffff]
PM: Registered nosave memory: [mem 0x93c4f000-0x93c4ffff] /* misjudgment */
PM: Registered nosave memory: [mem 0x93c5e000-0x93c5efff] /* misjudgment */
PM: Registered nosave memory: [mem 0x93c5f000-0x93c5ffff] /* misjudgment */
PM: Registered nosave memory: [mem 0x93c6f000-0x93c6ffff] /* misjudgment */
PM: Registered nosave memory: [mem 0x94cb0000-0x960affff]

The issue causes some usable pages didn't collect to hibernate snapshot image.
And, it also misjudges a usable page in nosave regions then hibernate resuming
process interrupted by the unsafe pages checking:
	https://bugzilla.opensuse.org/show_bug.cgi?id=913885

This patch changed the code in e820_mark_nosave_regions() to check the
address instead of pfn to avoid above issue.

Cc: Pavel Machek <pavel@ucw.cz>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Len Brown <len.brown@intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Lee, Chun-Yi <jlee@suse.com>
---
 arch/x86/kernel/e820.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 49f8864..6eae021 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -687,15 +687,16 @@ void __init parse_e820_ext(u64 phys_addr, u32 data_len)
 void __init e820_mark_nosave_regions(unsigned long limit_pfn)
 {
 	int i;
-	unsigned long pfn = 0;
+	unsigned long pfn = 0, pfnaddr = 0;
 
 	for (i = 0; i < e820.nr_map; i++) {
 		struct e820entry *ei = &e820.map[i];
 
-		if (pfn < PFN_UP(ei->addr))
+		if (pfnaddr < ei->addr)
 			register_nosave_region(pfn, PFN_UP(ei->addr));
 
-		pfn = PFN_DOWN(ei->addr + ei->size);
+		pfnaddr = ei->addr + ei->size;
+		pfn = PFN_DOWN(pfnaddr);
 		if (ei->type != E820_RAM && ei->type != E820_RESERVED_KERN)
 			register_nosave_region(PFN_UP(ei->addr), pfn);
 
-- 
1.8.4.5


             reply	other threads:[~2015-01-30  3:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-30  3:58 Lee, Chun-Yi [this message]
2015-01-30  7:35 ` Yinghai Lu
2015-01-30 14:41   ` joeyli
2015-01-30  8:30 ` Yinghai Lu
2015-01-30 14:46   ` joeyli
2015-01-30 16:28     ` joeyli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1422590300-13307-1-git-send-email-jlee@suse.com \
    --to=joeyli.kernel@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jlee@suse.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rjw@rjwysocki.net \
    --cc=tglx@linutronix.de \
    --cc=tiwai@suse.de \
    --cc=x86@kernel.org \
    --cc=yinghai@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome