linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>,
	Andy Lutomirski <luto@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Dan Williams <dan.j.williams@intel.com>,
	Tony Luck <tony.luck@intel.com>,
	x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Dave Hansen <dave.hansen@intel.com>,
	stable@vger.kernel.org
Subject: Re: [PATCHv2 2/2] x86/boot/KASLR: Fix boot with some memory above MAXMEM
Date: Wed, 10 Jun 2020 11:42:23 +0300	[thread overview]
Message-ID: <20200610084223.GE1151302@kernel.org> (raw)
In-Reply-To: <20200608125424.70198-3-kirill.shutemov@linux.intel.com>

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@linux.intel.com>
> Reviewed-by: Dave Hansen <dave.hansen@intel.com>
> Cc: stable@vger.kernel.org # v4.14

Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>

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

      reply	other threads:[~2020-06-10  8:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-08 12:54 [PATCHv2 0/2] x86: Fix boot with some memory above MAXMEM Kirill A. Shutemov
2020-06-08 12:54 ` [PATCHv2 1/2] x86/mm: " Kirill A. Shutemov
2020-06-10  8:41   ` Mike Rapoport
2020-06-11  2:17   ` [x86/mm] c7b2a6d1af: kernel_BUG_at_arch/x86/mm/physaddr.c kernel test robot
2020-06-08 12:54 ` [PATCHv2 2/2] x86/boot/KASLR: Fix boot with some memory above MAXMEM Kirill A. Shutemov
2020-06-10  8:42   ` Mike Rapoport [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200610084223.GE1151302@kernel.org \
    --to=rppt@kernel.org \
    --cc=bp@alien8.de \
    --cc=dan.j.williams@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).