Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1435007ybi; Sun, 16 Jun 2019 05:04:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyumu67ZTbrczRhXytLo2rHe9GM4td1QwjEut3XHKO284xceZBp+B1XVufAU57Sxy0jDMdB X-Received: by 2002:a17:90a:b115:: with SMTP id z21mr20745239pjq.64.1560686668921; Sun, 16 Jun 2019 05:04:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560686668; cv=none; d=google.com; s=arc-20160816; b=oxX4crT1/dKziqe1jf99j4vDWCE5X4PsB1YKUuE5GxZ5FvvZ6CRMSGBT4QIMXSJQ+x mHFbt73GDVOuPJPImodWXciLFarTGoT6Ewf4mG0rEJYSaioi19BH4hapKhrl4Yi4pOEm MfoZsEhJJgY4ZGgRpNPUIf6cE3RGUUFeYL/UXOKYH+MA3Rtray9RVVd3pEJzE4gNffet oZlnvBQp9/u8IGG9Dt7n4WWVzDVZwFex5hx6h++iIA64+vxoDWJ0rtFD4UCj70clcqPK QaDiIY8yAiLhU5G7PkN02ji4vIn0kY4B6j0lGIPUK8VZnc6AGezW8XLQ9V39bVUhmZCK HxUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=oO6mTEgLSAqfzM68nLVyh/KgCt4mdIfubVQK2QGbOFE=; b=yaVa/HrPHYX1YbCd5Qqp4QGEIfyWfDMKyPBAE1YNmq6iVrvW7PuBHhjUcyMrqPJKwh uPr1KkR+a/VPUivcyZ8em1lV4sY6gB81+7LJuAAnwJTbIy7/qdNYp7ztzvCV6JYMO9c/ tkMZtRtqF0KzNG5xHVnfELROVw8E8dzim7ACDkWaKlO3NdWIzsC+lUcPd/bMLXm4oumS maL/aqTtnAj9KfQNn4gpTC3QS7w4hoCIkNpqunB89StTNUNmq1wO6X/muGNz8g68eFON TfgAE27SESKq+5/jo9WipmO4UBFPHGyGUlliM/sj/xgse/owS9CWabGtQQXz6SIfu01f MSQg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h127si4978737pgc.176.2019.06.16.05.04.12; Sun, 16 Jun 2019 05:04:28 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727044AbfFPMEJ (ORCPT + 99 others); Sun, 16 Jun 2019 08:04:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38096 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725879AbfFPMEJ (ORCPT ); Sun, 16 Jun 2019 08:04:09 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A18133162908; Sun, 16 Jun 2019 12:04:07 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-102.pek2.redhat.com [10.72.12.102]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C0121001DE8; Sun, 16 Jun 2019 12:03:55 +0000 (UTC) Subject: Re: [PATCH v2 1/2] x86/mm: Identify the end of the kernel area to be reserved To: "Lendacky, Thomas" , "linux-kernel@vger.kernel.org" , "x86@kernel.org" Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Baoquan He References: <284d3650e2dae50d5645310a8b49664398fe5223.1560546537.git.thomas.lendacky@amd.com> From: lijiang Message-ID: <53f14fd0-dd96-06dc-f488-e47c6eacbedf@redhat.com> Date: Sun, 16 Jun 2019 20:03:50 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <284d3650e2dae50d5645310a8b49664398fe5223.1560546537.git.thomas.lendacky@amd.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Sun, 16 Jun 2019 12:04:08 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After applied the patch series(v2), the kexec-d kernel and the kdump kernel can successfully boot. Thanks. Tested-by: Lianbo Jiang 在 2019年06月15日 05:15, Lendacky, Thomas 写道: > The memory occupied by the kernel is reserved using memblock_reserve() > in setup_arch(). Currently, the area is from symbols _text to __bss_stop. > Everything after __bss_stop must be specifically reserved otherwise it > is discarded. This is not clearly documented. > > Add a new symbol, __end_of_kernel_reserve, that more readily identifies > what is reserved, along with comments that indicate what is reserved, > what is discarded and what needs to be done to prevent a section from > being discarded. > > Cc: Baoquan He > Cc: Lianbo Jiang > Signed-off-by: Tom Lendacky > --- > arch/x86/include/asm/sections.h | 2 ++ > arch/x86/kernel/setup.c | 8 +++++++- > arch/x86/kernel/vmlinux.lds.S | 9 ++++++++- > 3 files changed, 17 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/include/asm/sections.h b/arch/x86/include/asm/sections.h > index 8ea1cfdbeabc..71b32f2570ab 100644 > --- a/arch/x86/include/asm/sections.h > +++ b/arch/x86/include/asm/sections.h > @@ -13,4 +13,6 @@ extern char __end_rodata_aligned[]; > extern char __end_rodata_hpage_align[]; > #endif > > +extern char __end_of_kernel_reserve[]; > + > #endif /* _ASM_X86_SECTIONS_H */ > diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c > index 08a5f4a131f5..32eb70625b3b 100644 > --- a/arch/x86/kernel/setup.c > +++ b/arch/x86/kernel/setup.c > @@ -827,8 +827,14 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p) > > void __init setup_arch(char **cmdline_p) > { > + /* > + * Reserve the memory occupied by the kernel between _text and > + * __end_of_kernel_reserve symbols. Any kernel sections after the > + * __end_of_kernel_reserve symbol must be explicity reserved with a > + * separate memblock_reserve() or it will be discarded. > + */ > memblock_reserve(__pa_symbol(_text), > - (unsigned long)__bss_stop - (unsigned long)_text); > + (unsigned long)__end_of_kernel_reserve - (unsigned long)_text); > > /* > * Make sure page 0 is always reserved because on systems with > diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S > index 0850b5149345..ca2252ca6ad7 100644 > --- a/arch/x86/kernel/vmlinux.lds.S > +++ b/arch/x86/kernel/vmlinux.lds.S > @@ -368,6 +368,14 @@ SECTIONS > __bss_stop = .; > } > > + /* > + * The memory occupied from _text to here, __end_of_kernel_reserve, is > + * automatically reserved in setup_arch(). Anything after here must be > + * explicitly reserved using memblock_reserve() or it will be discarded > + * and treated as available memory. > + */ > + __end_of_kernel_reserve = .; > + > . = ALIGN(PAGE_SIZE); > .brk : AT(ADDR(.brk) - LOAD_OFFSET) { > __brk_base = .; > @@ -382,7 +390,6 @@ SECTIONS > STABS_DEBUG > DWARF_DEBUG > > - /* Sections to be discarded */ > DISCARDS > /DISCARD/ : { > *(.eh_frame) >