Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp4209123imc; Mon, 25 Feb 2019 00:24:36 -0800 (PST) X-Google-Smtp-Source: AHgI3IYHVI1vzS/UWUO946aPATT+lyuW0d7dkGne/PGr6guBNN78DhX1S08byGI6oVZ7NRhIvmqU X-Received: by 2002:a63:1c02:: with SMTP id c2mr18003841pgc.351.1551083076634; Mon, 25 Feb 2019 00:24:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551083076; cv=none; d=google.com; s=arc-20160816; b=hz1D8NRYoP/kHgyoPhkBS36DthJSWqn0m3S48QrCH/DGrBOJ94BFCLki1PFFa2BDqt CClxvMLH05RYVm8wELKBXOpqHNLslOdjceDVBpVuuc+JhdgaWwbTG7P2+SibMchlBl9v K1L0iUqJXZ2pHrYL8gLGCzwUJpc+z4eabxdtMqRG5cT/Ryr2fBrTUwNTMk+k0lirPkuA gehRziNzbbTMS0Vl/AVmASgDBMyHIrmif7QXWp6++U5tkEAen3aaH6MDIeFQm6Bwpj+z rKI4wD8q673eQJb4A0as9OwQqhZhBVhGIVgSSRWg91cDMV+/kKXB6k18jfTydhSB6Oyi W2eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=joEgo3UwIY9KA47qBDoIQLgG+6sHOK5Cn2T86SOVXBk=; b=oOuPYBfdbsQG87UcHMb+lRCCXstTd0guyEJONVr3XJnNpBuF/GqQRV/Prc+RPra1bU jWVINBavn8WAIYHvfkBHdJgL2bv/73UVtTVdKATugCxDC2rWslTlRbyWZqXZdov735ze qgI/Pn+1GHqTi6KnIO3k/F5ksG7c0wIJBgeWFuO8TNfk6TWFidh5NNXtuJo9z1gDCjOC C8e5rm/rRBD2jQupwYdIeYcqu8PFMwdw80Airhzb2WEqSK4vCa0zJlr/VF2vtS9ceQVH QIRO/BUagRiAAizFYFvRzN3pZNf525sNjIT+p6HVW55Xvla89oi7zTirvKR2VAIgU4vf 3LYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p7si8724501pgh.84.2019.02.25.00.24.21; Mon, 25 Feb 2019 00:24:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726185AbfBYIXg (ORCPT + 99 others); Mon, 25 Feb 2019 03:23:36 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:54923 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725942AbfBYIXg (ORCPT ); Mon, 25 Feb 2019 03:23:36 -0500 X-IronPort-AV: E=Sophos;i="5.58,410,1544457600"; d="scan'208";a="55180386" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 25 Feb 2019 16:23:33 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 533084724007; Mon, 25 Feb 2019 16:23:21 +0800 (CST) Received: from localhost.localdomain (10.167.225.56) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 25 Feb 2019 16:23:37 +0800 Date: Mon, 25 Feb 2019 16:23:18 +0800 From: Chao Fan To: Pingfan Liu CC: , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Baoquan He , Will Deacon , Nicolas Pitre , "Kirill A. Shutemov" , Ard Biesheuvel , Subject: Re: [PATCH] x86/boot/KASLR: skip the specified crashkernel reserved region Message-ID: <20190225082318.GB9326@localhost.localdomain> References: <1551081596-2856-1-git-send-email-kernelfans@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1551081596-2856-1-git-send-email-kernelfans@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Originating-IP: [10.167.225.56] X-yoursite-MailScanner-ID: 533084724007.A61F0 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: fanc.fnst@cn.fujitsu.com X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >Cc: Thomas Gleixner >Cc: Ingo Molnar >Cc: Borislav Petkov >Cc: "H. Peter Anvin" >Cc: Baoquan He >Cc: Will Deacon >Cc: Nicolas Pitre >Cc: Pingfan Liu >Cc: Chao Fan >Cc: "Kirill A. Shutemov" >Cc: Ard Biesheuvel >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. >+ >+ 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. >+} > > 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(); > { >@@ -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*(). Thanks, Chao Fan > } > } > >-- >2.7.4 > > >