mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86: Add warning when memmap=nn!ss and CONFIG_RANDOMIZE_BASE enabled
@ 2016-11-17 20:36 Dave Jiang
  2016-11-18 11:33 ` Thomas Gleixner
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Jiang @ 2016-11-17 20:36 UTC (permalink / raw)
  To: tglx, mingo, hpa; +Cc: dan.j.williams, x86, david, linux-kernel, linux-nvdimm

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 <dave.jiang@intel.com>
---
 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);
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-11-18 17:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-17 20:36 [PATCH] x86: Add warning when memmap=nn!ss and CONFIG_RANDOMIZE_BASE enabled Dave Jiang
2016-11-18 11:33 ` Thomas Gleixner
2016-11-18 16:47   ` Dave Jiang
2016-11-18 17:07     ` Dan Williams
2016-11-18 17:13       ` Dave Jiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®