diff mbox

x86: fix kdump, cleanup aborted E820_PRAM max_pfn manipulation

Message ID 147448744538.34910.11287693517367139607.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Williams Sept. 21, 2016, 7:50 p.m. UTC
In commit ec776ef6bbe1 "x86/mm: Add support for the non-standard
protected e820 type" Christoph references the original patch I wrote
implementing pmem support.  The intent of the 'max_pfn' changes in that
commit were to enable persistent memory ranges to be covered by the
struct page memmap by default.  However, that approach was abandoned
when Christoph ported the patches [1], and that functionality has since
been replaced by devm_memremap_pages().

In the meantime, this max_pfn manipulation is confusing kdump [2] that
assumes that everything covered by the max_pfn is "System RAM".  This
results in kdump hanging or crashing.

[1]: https://lists.01.org/pipermail/linux-nvdimm/2015-March/000348.html
[2]: https://bugzilla.redhat.com/show_bug.cgi?id=1351098

Cc: Christoph Hellwig <hch@lst.de>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Boaz Harrosh <boaz@plexistor.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Reported-by: Zhang Yi <yizhan@redhat.com>
Reported-by: Jeff Moyer <jmoyer@redhat.com>
Tested-by: Zhang Yi <yizhan@redhat.com>
Fixes: ec776ef6bbe1 ("x86/mm: Add support for the non-standard protected e820 type")
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 arch/x86/kernel/e820.c |   14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

Comments

Jeff Moyer Sept. 21, 2016, 8:22 p.m. UTC | #1
Dan Williams <dan.j.williams@intel.com> writes:

> In commit ec776ef6bbe1 "x86/mm: Add support for the non-standard
> protected e820 type" Christoph references the original patch I wrote
> implementing pmem support.  The intent of the 'max_pfn' changes in that
> commit were to enable persistent memory ranges to be covered by the
> struct page memmap by default.  However, that approach was abandoned
> when Christoph ported the patches [1], and that functionality has since
> been replaced by devm_memremap_pages().
>
> In the meantime, this max_pfn manipulation is confusing kdump [2] that
> assumes that everything covered by the max_pfn is "System RAM".  This
> results in kdump hanging or crashing.

That was my assumption, I'm not certain that the kdump code is assuming
the pmem region is usable as RAM.  The end result is a hung kdump
kernel.

> [1]: https://lists.01.org/pipermail/linux-nvdimm/2015-March/000348.html
> [2]: https://bugzilla.redhat.com/show_bug.cgi?id=1351098
>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Boaz Harrosh <boaz@plexistor.com>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@kernel.org>
> Reported-by: Zhang Yi <yizhan@redhat.com>
> Reported-by: Jeff Moyer <jmoyer@redhat.com>
> Tested-by: Zhang Yi <yizhan@redhat.com>

I actually did the testing.  You can leave that line as is, though, as
I'm sure Yi will also test it.  :)

> Fixes: ec776ef6bbe1 ("x86/mm: Add support for the non-standard protected e820 type")
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>

Reviewed-by: Jeff Moyer <jmoyer@redhat.com>

Thanks, Dan!

-Jeff
diff mbox

Patch

diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 621b501f8935..8a90f1517837 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -348,7 +348,7 @@  int __init sanitize_e820_map(struct e820entry *biosmap, int max_nr_map,
 		 * continue building up new bios map based on this
 		 * information
 		 */
-		if (current_type != last_type || current_type == E820_PRAM) {
+		if (current_type != last_type) {
 			if (last_type != 0)	 {
 				new_bios[new_bios_entry].size =
 					change_point[chgidx]->addr - last_addr;
@@ -754,7 +754,7 @@  u64 __init early_reserve_e820(u64 size, u64 align)
 /*
  * Find the highest page frame number we have available
  */
-static unsigned long __init e820_end_pfn(unsigned long limit_pfn)
+static unsigned long __init e820_end_pfn(unsigned long limit_pfn, unsigned type)
 {
 	int i;
 	unsigned long last_pfn = 0;
@@ -765,11 +765,7 @@  static unsigned long __init e820_end_pfn(unsigned long limit_pfn)
 		unsigned long start_pfn;
 		unsigned long end_pfn;
 
-		/*
-		 * Persistent memory is accounted as ram for purposes of
-		 * establishing max_pfn and mem_map.
-		 */
-		if (ei->type != E820_RAM && ei->type != E820_PRAM)
+		if (ei->type != type)
 			continue;
 
 		start_pfn = ei->addr >> PAGE_SHIFT;
@@ -794,12 +790,12 @@  static unsigned long __init e820_end_pfn(unsigned long limit_pfn)
 }
 unsigned long __init e820_end_of_ram_pfn(void)
 {
-	return e820_end_pfn(MAX_ARCH_PFN);
+	return e820_end_pfn(MAX_ARCH_PFN, E820_RAM);
 }
 
 unsigned long __init e820_end_of_low_ram_pfn(void)
 {
-	return e820_end_pfn(1UL << (32-PAGE_SHIFT));
+	return e820_end_pfn(1UL << (32 - PAGE_SHIFT), E820_RAM);
 }
 
 static void early_panic(char *msg)