Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752580AbcKNAS6 (ORCPT ); Sun, 13 Nov 2016 19:18:58 -0500 Received: from cloudserver094114.home.net.pl ([79.96.170.134]:57555 "EHLO cloudserver094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751966AbcKNAS4 (ORCPT ); Sun, 13 Nov 2016 19:18:56 -0500 From: "Rafael J. Wysocki" To: joeyli , Chen Yu Cc: linux-pm@vger.kernel.org, x86@kernel.org, Thomas Gleixner , "H. Peter Anvin" , Ingo Molnar , linux-kernel@vger.kernel.org, "Rafael J . Wysocki" , Pavel Machek , Borislav Petkov , Len Brown , Denys Vlasenko , Dan Williams Subject: Re: [PATCH][v12] PM / hibernate: Verify the consistent of e820 memory map by md5 digest Date: Mon, 14 Nov 2016 01:26:28 +0100 Message-ID: <9363379.0isTar43qg@vostro.rjw.lan> User-Agent: KMail/4.11.5 (Linux/4.9.0-rc5+; KDE/4.11.5; x86_64; ; ) In-Reply-To: <20161022030302.GB26548@linux-rxt1.site> References: <1476951292-19619-1-git-send-email-yu.c.chen@intel.com> <20161022030302.GB26548@linux-rxt1.site> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2905 Lines: 65 On Saturday, October 22, 2016 11:03:02 AM joeyli wrote: > Hi Chen Yu, > > On Thu, Oct 20, 2016 at 04:14:52PM +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. > > > > 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. > > > > As the format of image header has been modified, the magic number > > should also be adjusted as kernels with the same RESTORE_MAGIC have > > to use the same header format and interpret all of the fields in > > it in the same way. > > > > If the suspend kernel is built without md5 support, and the restore > > kernel has md5 support, then the latter will bypass the check process. > > Vice versa the restore kernel will bypass the check if it does not > > support md5 operation. > > > > Note: > > 1. Without this patch applied, it is possible that BIOS has > > provided an inconsistent memory map, but the resume kernel is still > > able to restore the image anyway(e.g, E820_RAM region is the superset > > of the previous one), although the system might be unstable. So this > > patch tries to treat any inconsistent e820 as illegal. > > > > 2. Another case is, this patch replies on comparing the e820_saved, but > > currently the e820_save might not be strictly the same across > > hibernation, even if BIOS has provided consistent e820 map - In > > theory mptable might modify the BIOS-provided e820_saved dynamically > > in early_reserve_e820_mpc_new, which would allocate a buffer from > > E820_RAM, and marks it from E820_RAM to E820_RESERVED). > > This is a potential and rare case we need to deal with in OS in > > the future. > > > > Suggested-by: Pavel Machek > > Suggested-by: Rafael J. Wysocki > > Cc: Rafael J. Wysocki > > Cc: Pavel Machek > > Cc: Lee Chun-Yi > > Cc: Borislav Petkov > > Cc: Len Brown > > Cc: Denys Vlasenko > > Cc: Dan Williams > > Signed-off-by: Chen Yu > > Please feel free to add: > Reviewed-by: Lee, Chun-Yi Applied (with the tag above). Thanks, Rafael