lkml.org 
[lkml]   [2020]   [Jun]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCHv2 2/2] x86/boot/KASLR: Fix boot with some memory above MAXMEM
Date
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

Teach KASLR to avoid memory regions above MAXMEM or truncate the region
if the end is above MAXMEM.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reviewed-by: Dave Hansen <dave.hansen@intel.com>
Cc: stable@vger.kernel.org # v4.14
---
arch/x86/boot/compressed/kaslr.c | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
index d7408af55738..99db18eeb40e 100644
--- a/arch/x86/boot/compressed/kaslr.c
+++ b/arch/x86/boot/compressed/kaslr.c
@@ -695,7 +695,18 @@ static bool process_mem_region(struct mem_vector *region,
unsigned long long minimum,
unsigned long long image_size)
{
+ unsigned long long end;
int i;
+
+ /* Cannot access memory region above MAXMEM: skip it. */
+ if (region->start >= MAXMEM)
+ return 0;
+
+ /* Truncate the region if the end is above MAXMEM */
+ end = region->start + region->size;
+ end = min_t(unsigned long long, end, MAXMEM - 1);
+ region->size = end - region->start;
+
/*
* If no immovable memory found, or MEMORY_HOTREMOVE disabled,
* use @region directly.
--
2.26.2
\
 
 \ /
  Last update: 2020-06-08 14:55    [W:0.091 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site