From patchwork Fri Oct 7 16:31:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: joeyli X-Patchwork-Id: 9366717 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 459BE60487 for ; Fri, 7 Oct 2016 16:31:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3797F29777 for ; Fri, 7 Oct 2016 16:31:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2BA3F29779; Fri, 7 Oct 2016 16:31:57 +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=-6.9 required=2.0 tests=BAYES_00,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 B8C0F29777 for ; Fri, 7 Oct 2016 16:31:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756742AbcJGQbz (ORCPT ); Fri, 7 Oct 2016 12:31:55 -0400 Received: from smtp.nue.novell.com ([195.135.221.5]:34531 "EHLO smtp.nue.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753234AbcJGQbz (ORCPT ); Fri, 7 Oct 2016 12:31:55 -0400 Received: from linux-rxt1.site (124-11-22-254.static.tfn.net.tw [124.11.22.254]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Fri, 07 Oct 2016 18:31:48 +0200 Date: Sat, 8 Oct 2016 00:31:08 +0800 From: joeyli To: Chen Yu Cc: linux-pm@vger.kernel.org, "Rafael J. Wysocki" , Pavel Machek , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, "Rafael J . Wysocki" , Borislav Petkov Subject: Re: [PATCH][v11] PM / hibernate: Verify the consistent of e820 memory map by md5 digest Message-ID: <20161007163108.GP27959@linux-rxt1.site> References: <1474777077-19535-1-git-send-email-yu.c.chen@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1474777077-19535-1-git-send-email-yu.c.chen@intel.com> User-Agent: Mutt/1.5.21 (2010-09-15) 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 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: [] 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 > #include > #include > +#include > +#include [...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: Other parts in your patch are good to me. Thanks a lot! Joey Lee --- 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/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; }