On Mon, Feb 25, 2019 at 4:23 PM Chao Fan <fanc.f...@cn.fujitsu.com> wrote:
>
> On Mon, Feb 25, 2019 at 03:59:56PM +0800, 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 <kernelf...@gmail.com>
> >Cc: Thomas Gleixner <t...@linutronix.de>
> >Cc: Ingo Molnar <mi...@redhat.com>
> >Cc: Borislav Petkov <b...@alien8.de>
> >Cc: "H. Peter Anvin" <h...@zytor.com>
> >Cc: Baoquan He <b...@redhat.com>
> >Cc: Will Deacon <will.dea...@arm.com>
> >Cc: Nicolas Pitre <n...@linaro.org>
> >Cc: Pingfan Liu <kernelf...@gmail.com>
> >Cc: Chao Fan <fanc.f...@cn.fujitsu.com>
> >Cc: "Kirill A. Shutemov" <kirill.shute...@linux.intel.com>
> >Cc: Ard Biesheuvel <ard.biesheu...@linaro.org>
> >Cc: linux-kernel@vger.kernel.org
> >---
> > arch/x86/boot/compressed/kaslr.c | 26 +++++++++++++++++++++++++-
> > 1 file changed, 25 insertions(+), 1 deletion(-)
> >
>
> Hi Pingfan,
>
> Some not important comments:
>
> >diff --git a/arch/x86/boot/compressed/kaslr.c 
> >b/arch/x86/boot/compressed/kaslr.c
> >index 9ed9709..728bc4b 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,27 @@ static void parse_gb_huge_pages(char *param, char *val)
> >       }
> > }
> >
> >+/* parse crashkernel=x@y option */
> >+static int mem_avoid_crashkernel_simple(char *option)
> >+{
> >+      char *cur = option;
> >+      unsigned long long crash_size, crash_base;
>
> Change the position of two lines above.
>
Yes, it is better.
> >+
> >+      crash_size = memparse(option, &cur);
> >+      if (option == cur)
> >+              return -EINVAL;
> >+
> >+      if (*cur == '@') {
> >+              option = cur + 1;
> >+              crash_base = memparse(option, &cur);
> >+              if (option == cur)
> >+                      return -EINVAL;
> >+              mem_avoid[MEM_AVOID_CRASHKERNEL].start = crash_base;
> >+              mem_avoid[MEM_AVOID_CRASHKERNEL].size = crash_size;
> >+      }
> >+
> >+      return 0;
>
> You just call this function and don't use its return value.
> So why not change it as void type.
>
OK.
> >+}
> >
> > static void handle_mem_options(void)
>
> If you want to change this function, I think you could change the
> function name and the comment:
>
>         /* Mark the memmap regions we need to avoid */
>         handle_mem_options();
>
Yes, it is outdated, should fix the comment.
> > {
> >@@ -250,7 +272,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 +308,8 @@ static void handle_mem_options(void)
> >                               goto out;
> >
> >                       mem_limit = mem_size;
> >+              } else if (strstr(param, "crashkernel")) {
> >+                      mem_avoid_crashkernel_simple(val);
>
> I am wondering why you call this function mem_avoid_crashkernel_*simple*().
>
It follows the name of parse_crashkernel_simple()

Thanks,
Pingfan

Reply via email to