[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200608125424.70198-2-kirill.shutemov@linux.intel.com>
Date: Mon, 8 Jun 2020 15:54:23 +0300
From: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
To: Dave Hansen <dave.hansen@...ux.intel.com>,
Andy Lutomirski <luto@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
"H. Peter Anvin" <hpa@...or.com>
Cc: Dan Williams <dan.j.williams@...el.com>,
Tony Luck <tony.luck@...el.com>, x86@...nel.org,
linux-mm@...ck.org, linux-kernel@...r.kernel.org,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Dave Hansen <dave.hansen@...el.com>, stable@...r.kernel.org
Subject: [PATCHv2 1/2] x86/mm: Fix boot with some memory above MAXMEM
A 5-level paging capable machine can have memory above 46-bit in the
physical address space. This memory is only addressable in the 5-level
paging mode: we don't have enough virtual address space to create direct
mapping for such memory in the 4-level paging mode.
Currently, we fail boot completely: NULL pointer dereference in
subsection_map_init().
Skip creating a memblock for such memory instead and notify user that
some memory is not addressable.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
Reviewed-by: Dave Hansen <dave.hansen@...el.com>
Cc: stable@...r.kernel.org # v4.14
---
arch/x86/kernel/e820.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index c5399e80c59c..c10bab121916 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -16,6 +16,7 @@
#include <linux/firmware-map.h>
#include <linux/sort.h>
#include <linux/memory_hotplug.h>
+#include <linux/string_helpers.h>
#include <asm/e820/api.h>
#include <asm/setup.h>
@@ -1280,8 +1281,8 @@ void __init e820__memory_setup(void)
void __init e820__memblock_setup(void)
{
+ u64 size, end, not_addressable = 0;
int i;
- u64 end;
/*
* The bootstrap memblock region count maximum is 128 entries
@@ -1307,7 +1308,26 @@ void __init e820__memblock_setup(void)
if (entry->type != E820_TYPE_RAM && entry->type != E820_TYPE_RESERVED_KERN)
continue;
- memblock_add(entry->addr, entry->size);
+ if (entry->addr >= MAXMEM) {
+ not_addressable += entry->size;
+ continue;
+ }
+
+ end = min_t(u64, end, MAXMEM - 1);
+ size = end - entry->addr;
+ not_addressable += entry->size - size;
+ memblock_add(entry->addr, size);
+ }
+
+ if (not_addressable) {
+ char tmp[10];
+
+ string_get_size(not_addressable, 1, STRING_UNITS_2, tmp, sizeof(tmp));
+ pr_err("%s of physical memory is not addressable in the %s paging mode\n",
+ tmp, pgtable_l5_enabled() ? "5-level" : "4-level");
+
+ if (!pgtable_l5_enabled())
+ pr_err("Consider enabling 5-level paging\n");
}
/* Throw away partial pages: */
--
2.26.2
Powered by blists - more mailing lists