Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751839AbcKQUgi (ORCPT ); Thu, 17 Nov 2016 15:36:38 -0500 Received: from mga01.intel.com ([192.55.52.88]:15049 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750928AbcKQUgh (ORCPT ); Thu, 17 Nov 2016 15:36:37 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,655,1473145200"; d="scan'208";a="787726104" Subject: [PATCH] x86: Add warning when memmap=nn!ss and CONFIG_RANDOMIZE_BASE enabled From: Dave Jiang To: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com Cc: dan.j.williams@intel.com, x86@kernel.org, david@fromorbit.com, linux-kernel@vger.kernel.org, linux-nvdimm@ml01.01.org Date: Thu, 17 Nov 2016 13:36:35 -0700 Message-ID: <147941499514.131046.6450643991764692220.stgit@djiang5-desk3.ch.intel.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1910 Lines: 41 CONFIG_RANDOMIZE_BASE can place the kernel anywhere. This causes a problem for when memmap=nn!ss is used. This information is not known until after the kernel starts executing and the decision for where the randomized base goes happens before the kernel is uncompressed. memmap=nn!ss is not reliable in the presence of CONFIG_RANDOMIZE_BASE. Signed-off-by: Dave Jiang --- Documentation/kernel-parameters.txt | 5 ++++- arch/x86/kernel/e820.c | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 37babf9..4bf32ab 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -2290,7 +2290,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted. [KNL,X86] Mark specific memory as protected. Region of memory to be used, from ss to ss+nn. The memory region may be marked as e820 type 12 (0xc) - and is NVDIMM or ADR memory. + and is NVDIMM or ADR memory. If CONFIG_RANDOMIZE_BASE + is enabled the kernel image may collide overwrite the + pmem range on subsequent boots. memmap=nn!ss is not + reliable in the presence CONFIG_RANDOMIZE_BASE. memory_corruption_check=0/1 [X86] Some BIOSes seem to corrupt the first 64k of diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index b85fe5f..d85be72 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -904,6 +904,8 @@ static int __init parse_memmap_one(char *p) } else if (*p == '!') { start_at = memparse(p+1, &p); e820_add_region(start_at, mem_size, E820_PRAM); + if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) + pr_warn("e820: CONFIG_RANDOMIZE_BASE enabled, kernel image may collide/overwrite the pmem range on subsequent boots!\n"); } else e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1);