linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chen Yu <yu.c.chen@intel.com>
To: joeyli <jlee@suse.com>
Cc: linux-pm@vger.kernel.org, "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Pavel Machek <pavel@ucw.cz>, Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
	Borislav Petkov <bp@alien8.de>
Subject: Re: [PATCH][v11] PM / hibernate: Verify the consistent of e820 memory map by md5 digest
Date: Sun, 9 Oct 2016 01:03:12 +0800	[thread overview]
Message-ID: <20161008170312.GC24225@sharon> (raw)
In-Reply-To: <20161007163108.GP27959@linux-rxt1.site>

Hi Joey,
On Sat, Oct 08, 2016 at 12:31:08AM +0800, joeyli wrote:
> Hi Chen Yu,
> 
> On Sun, Sep 25, 2016 at 12:17:57PM +0800, Chen Yu wrote:
> > On some platforms, there is occasional panic triggered when trying to
> > resume from hibernation, a typical panic looks like:
> > 
> > "BUG: unable to handle kernel paging request at ffff880085894000
> > IP: [<ffffffff810c5dc2>] load_image_lzo+0x8c2/0xe70"
> > 
> > Investigation carried out by Lee Chun-Yi shows that this is because
> > e820 map has been changed by BIOS across hibernation, and one
> > of the page frames from suspend kernel is right located in restore
> > kernel's unmapped region, so panic comes out when accessing unmapped
> > kernel address.
> >
> 
> Sorry for finally I can not find the issue machine back now. So I add
> a patch to fool kernel as the e820 changed when S4 resume for testing.
>  
> > In order to expose this issue earlier, the md5 hash of e820 map
> > is passed from suspend kernel to restore kernel, and the restore
> > kernel will terminate the resume process once it finds the md5
> > hash are not the same.
> >
> [...snip] 
> > ---
> >  arch/x86/power/hibernate_64.c | 92 ++++++++++++++++++++++++++++++++++++++++++-
> >  1 file changed, 90 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/x86/power/hibernate_64.c b/arch/x86/power/hibernate_64.c
> > index 9634557..d81b1af 100644
> > --- a/arch/x86/power/hibernate_64.c
> > +++ b/arch/x86/power/hibernate_64.c
> > @@ -11,6 +11,10 @@
> >  #include <linux/gfp.h>
> >  #include <linux/smp.h>
> >  #include <linux/suspend.h>
> > +#include <linux/scatterlist.h>
> > +#include <linux/kdebug.h>
> 
> [...snip]
> 
> > @@ -216,5 +297,12 @@ int arch_hibernation_header_restore(void *addr)
> >  	restore_jump_address = rdr->jump_address;
> >  	jump_address_phys = rdr->jump_address_phys;
> >  	restore_cr3 = rdr->cr3;
> > -	return (rdr->magic == RESTORE_MAGIC) ? 0 : -EINVAL;
> > +
> > +	if (rdr->magic != RESTORE_MAGIC)
> > +		return -EINVAL;
> > +
> > +	if (hibernation_e820_mismatch(rdr->e820_digest))
> > +		return -ENODEV;
> > +
> > +	return 0;
> >  }
> > --
> 
> Because the check_image_kernel() function doesn't check the return error,
> kernel only shows "PM: Image mismatch: architecture specific data". The
> message covered two different fail reason.
>  
> I suggest that it prints out a log like the restore function in ARM64
> architecture. Something like this, please feel free to modify the
> wording:
> 
> Index: linux/arch/x86/power/hibernate_64.c
> ===================================================================
> --- linux.orig/arch/x86/power/hibernate_64.c
> +++ linux/arch/x86/power/hibernate_64.c
> @@ -298,11 +298,16 @@ int arch_hibernation_header_restore(void
>         jump_address_phys = rdr->jump_address_phys;
>         restore_cr3 = rdr->cr3;
>  
> -       if (rdr->magic != RESTORE_MAGIC)
> +
> +       if (rdr->magic != RESTORE_MAGIC) {
> +               pr_crit("Hibernate image not generated by this kernel!\n");
>                 return -EINVAL;
> +       }
>  
> -       if (hibernation_e820_mismatch(rdr->e820_digest))
> +       if (hibernation_e820_mismatch(rdr->e820_digest)) {
> +               pr_crit("The e820 saved regions changed!\n");
>                 return -ENODEV;
> +       }
>  
>         return 0;
>  }
> 
OK, will refresh it after 4.9-rc1 released due to a e820 modification
recently.

Thanks,
Yu

      reply	other threads:[~2016-10-08 16:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-25  4:17 [PATCH][v11] PM / hibernate: Verify the consistent of e820 memory map by md5 digest Chen Yu
2016-10-07 16:31 ` joeyli
2016-10-08 17:03   ` Chen Yu [this message]

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=20161008170312.GC24225@sharon \
    --to=yu.c.chen@intel.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=jlee@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pavel@ucw.cz \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rjw@rjwysocki.net \
    --cc=tglx@linutronix.de \
    --cc=x86@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;
as well as URLs for NNTP newsgroup(s).