linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: joeyli <jlee@suse.com>
Cc: "Lee, Chun-Yi" <joeyli.kernel@gmail.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Len Brown <len.brown@intel.com>, Takashi Iwai <tiwai@suse.de>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] Hibernate: check unsafe page should not in e820 reserved region
Date: Thu, 7 Aug 2014 10:00:25 +0200	[thread overview]
Message-ID: <20140807080025.GA24700@amd.pavel.ucw.cz> (raw)
In-Reply-To: <20140807040543.GE26210@linux-rxt1.site>

Hi!

> > When the machine doesn't well handle the e820 persistent when hibernate
> > resuming, then it may causes page fault when writing image to snapshot
> > buffer:
> > 
> > [   17.929495] BUG: unable to handle kernel paging request at ffff880069d4f000
> > [   17.933469] IP: [<ffffffff810a1cf0>] load_image_lzo+0x810/0xe40
> > [   17.933469] PGD 2194067 PUD 77ffff067 PMD 2197067 PTE 0
> > [   17.933469] Oops: 0002 [#1] SMP
> > ...
> > 
> > The ffff880069d4f000 page is in e820 reserved region of resume boot
> > kernel:
> > 
> > [    0.000000] BIOS-e820: [mem 0x0000000069d4f000-0x0000000069e12fff] reserved
> > ...
> > [    0.000000] PM: Registered nosave memory: [mem 0x69d4f000-0x69e12fff]
> > 
> > So snapshot.c mark the pfn to forbidden pages map. But, this
> > page is also in the memory bitmap in snapshot image because it's an
> > original page used by image kernel, so it will also mark as an
> > unsafe(free) page in prepare_image().
> > 
> > That means the page in e820 when resuming mark as "forbidden" and
> > "free", it causes get_buffer() treat it as an allocated unsafe page.
> > Then snapshot_write_next() return this page to load_image, load_image
> > writing content to this address, but this page didn't really allocated
> > . So, we got page fault.
> > 
> > Although the root cause is from BIOS, I think aggressive check and
> > significant message in kernel will better then a page fault for
> > issue tracking, especially when serial console unavailable.
> > 
> > This patch adds code in mark_unsafe_pages() for check does free pages in
> > nosave region. If so, then it print message and return fault to stop whole
> > S4 resume process:
> > 
> > [    8.166004] PM: Image loading progress:   0%
> > [    8.658717] PM: 0x6796c000 in e820 nosave region: [mem 0x6796c000-0x6796cfff]
> > [    8.918737] PM: Read 2511940 kbytes in 1.04 seconds (2415.32 MB/s)
> > [    8.926633] PM: Error -14 resuming
> > [    8.933534] PM: Failed to load hibernation image, recovering.
> > 
> > v2:
> >  + removed empty check of nosave_regions list.
> >  + fixed the typo of "region" in code for error message and patch comment.
> > 
> > Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> > Cc: Len Brown <len.brown@intel.com>
> > Cc: Takashi Iwai <tiwai@suse.de>
> > Acked-by: Pavel Machek <pavel@ucw.cz>
> > Signed-off-by: Lee, Chun-Yi <jlee@suse.com>
> 
> I discussed with Vojtech Pavlik for this patch, he raised a situation is:
> 
> Maybe e820 changed but image kernel original pages do not fall into new e820 region.
> Then the hibernate will recovery success, but later kernel drivers may got problem
> when accessing memory. 
> 
> My idea is hashing the start/end pfn of each nosave region sequentially, put this
> nosave region digest to hibernate header then compare e820 digest in check_header()
> when hibernate resuming.
> 
> I am developing patch, then we don't need check unsafe page should not in unsave(e820)
> regions.

Actually, if you are doing such a check... it makes sense to check for
_all_ the regions, nosave or not. If e820 map changed at all, it is
not safe to resume.
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

  reply	other threads:[~2014-08-07  8:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-04 15:23 [PATCH v2] Hibernate: check unsafe page should not in e820 reserved region Lee, Chun-Yi
2014-08-04 16:36 ` Takashi Iwai
2014-08-07  4:05 ` joeyli
2014-08-07  8:00   ` Pavel Machek [this message]
2014-08-07  8:52     ` joeyli
2014-08-07  9:39       ` Pavel Machek
2014-08-07 10:17         ` joeyli
2014-08-07 21:05           ` Pavel Machek
2014-08-08  4:24             ` joeyli
2014-08-08  7:05               ` Pavel Machek

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=20140807080025.GA24700@amd.pavel.ucw.cz \
    --to=pavel@ucw.cz \
    --cc=jlee@suse.com \
    --cc=joeyli.kernel@gmail.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=tiwai@suse.de \
    /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;
as well as URLs for NNTP newsgroup(s).