From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED, USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75253C43381 for ; Wed, 20 Mar 2019 01:23:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4F10F206BA for ; Wed, 20 Mar 2019 01:23:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727569AbfCTBX6 (ORCPT ); Tue, 19 Mar 2019 21:23:58 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:55628 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726801AbfCTBX5 (ORCPT ); Tue, 19 Mar 2019 21:23:57 -0400 X-IronPort-AV: E=Sophos;i="5.60,246,1549900800"; d="scan'208";a="57182664" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 20 Mar 2019 09:23:56 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 6659E4CD447D; Wed, 20 Mar 2019 09:23:24 +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; Wed, 20 Mar 2019 09:24:01 +0800 Date: Wed, 20 Mar 2019 09: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: [PATCHv2] x86/boot/KASLR: skip the specified crashkernel reserved region Message-ID: <20190320012318.GF1590@localhost.localdomain> References: <1552450771-8360-1-git-send-email-kernelfans@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1552450771-8360-1-git-send-email-kernelfans@gmail.com> User-Agent: Mutt/1.11.3 (2019-02-01) X-Originating-IP: [10.167.225.56] X-yoursite-MailScanner-ID: 6659E4CD447D.AB6DA X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: fanc.fnst@cn.fujitsu.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 13, 2019 at 12:19:31PM +0800, Pingfan Liu wrote: Hi Pingfan, I wonder your test method and test case. Do you test it in the Qemu guest or real machine. Thanks, Chao Fan >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 >--- >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) >+{ >+ 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 > > >