Re: [PATCHv2 2/2] x86/boot/KASLR: Fix boot with some memory above MAXMEM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jun 08, 2020 at 03:54:24PM +0300, Kirill A. Shutemov wrote:
> 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@xxxxxxxxxxxxxxx>
> Reviewed-by: Dave Hansen <dave.hansen@xxxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx # v4.14

Reviewed-by: Mike Rapoport <rppt@xxxxxxxxxxxxx>

> ---
>  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
> 
> 

-- 
Sincerely yours,
Mike.



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux