[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190320002524.GD18740@MiWiFi-R3L-srv>
Date: Wed, 20 Mar 2019 08:25:24 +0800
From: Baoquan He <bhe@...hat.com>
To: Pingfan Liu <kernelfans@...il.com>
Cc: x86@...nel.org, Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
"H. Peter Anvin" <hpa@...or.com>,
Will Deacon <will.deacon@....com>,
Nicolas Pitre <nico@...aro.org>,
Chao Fan <fanc.fnst@...fujitsu.com>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Ard Biesheuvel <ard.biesheuvel@...aro.org>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCHv2] x86/boot/KASLR: skip the specified crashkernel
reserved region
Please change subject as:
"x86/boot/KASLR: skip the specified crashkernel region"
Don't see why reserved is needed here.
On 03/13/19 at 12:19pm, Pingfan Liu wrote:
> crashkernel=x@y option may fail to reserve the required memory region if
> KASLR puts kernel into the region. To avoid this uncertainty, making KASLR
> skip the required region.
>
> Signed-off-by: Pingfan Liu <kernelfans@...il.com>
> Cc: Thomas Gleixner <tglx@...utronix.de>
> Cc: Ingo Molnar <mingo@...hat.com>
> Cc: Borislav Petkov <bp@...en8.de>
> Cc: "H. Peter Anvin" <hpa@...or.com>
> Cc: Baoquan He <bhe@...hat.com>
> Cc: Will Deacon <will.deacon@....com>
> Cc: Nicolas Pitre <nico@...aro.org>
> Cc: Pingfan Liu <kernelfans@...il.com>
> Cc: Chao Fan <fanc.fnst@...fujitsu.com>
> Cc: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@...aro.org>
> Cc: linux-kernel@...r.kernel.org
> ---
> v1 -> v2: fix some trival format
>
> arch/x86/boot/compressed/kaslr.c | 26 ++++++++++++++++++++++++--
> 1 file changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
> index 9ed9709..e185318 100644
> --- a/arch/x86/boot/compressed/kaslr.c
> +++ b/arch/x86/boot/compressed/kaslr.c
> @@ -109,6 +109,7 @@ enum mem_avoid_index {
> MEM_AVOID_BOOTPARAMS,
> MEM_AVOID_MEMMAP_BEGIN,
> MEM_AVOID_MEMMAP_END = MEM_AVOID_MEMMAP_BEGIN + MAX_MEMMAP_REGIONS - 1,
> + MEM_AVOID_CRASHKERNEL,
> MEM_AVOID_MAX,
> };
>
> @@ -240,6 +241,25 @@ static void parse_gb_huge_pages(char *param, char *val)
> }
> }
>
> +/* parse crashkernel=x@y option */
> +static void mem_avoid_crashkernel_simple(char *option)
Chao ever mentioned this, I want to ask again, why does it has to be
xxx_simple()?
Except of these, patch looks good to me. It's a nice catch, and only
need a simple fix based on the current code.
Thanks
Baoquan
> +{
> + unsigned long long crash_size, crash_base;
> + char *cur = option;
> +
> + crash_size = memparse(option, &cur);
> + if (option == cur)
> + return;
> +
> + if (*cur == '@') {
> + option = cur + 1;
> + crash_base = memparse(option, &cur);
> + if (option == cur)
> + return;
> + mem_avoid[MEM_AVOID_CRASHKERNEL].start = crash_base;
> + mem_avoid[MEM_AVOID_CRASHKERNEL].size = crash_size;
> + }
> +}
>
> static void handle_mem_options(void)
> {
> @@ -250,7 +270,7 @@ static void handle_mem_options(void)
> u64 mem_size;
>
> if (!strstr(args, "memmap=") && !strstr(args, "mem=") &&
> - !strstr(args, "hugepages"))
> + !strstr(args, "hugepages") && !strstr(args, "crashkernel="))
> return;
>
> tmp_cmdline = malloc(len + 1);
> @@ -286,6 +306,8 @@ static void handle_mem_options(void)
> goto out;
>
> mem_limit = mem_size;
> + } else if (strstr(param, "crashkernel")) {
> + mem_avoid_crashkernel_simple(val);
> }
> }
>
> @@ -414,7 +436,7 @@ static void mem_avoid_init(unsigned long input, unsigned long input_size,
>
> /* We don't need to set a mapping for setup_data. */
>
> - /* Mark the memmap regions we need to avoid */
> + /* Mark the regions we need to avoid */
> handle_mem_options();
>
> #ifdef CONFIG_X86_VERBOSE_BOOTUP
> --
> 2.7.4
>
Powered by blists - more mailing lists