Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1987652ybi; Sun, 16 Jun 2019 18:55:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9gvPh/8dGmlCwNOiD5eQGArQQ0gs1pkpDcUXpYGbrIbulbmvBzF6v0x/MzUL4Q3YP1uKv X-Received: by 2002:a17:90a:3603:: with SMTP id s3mr6612267pjb.17.1560736505272; Sun, 16 Jun 2019 18:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560736505; cv=none; d=google.com; s=arc-20160816; b=E/Wimc63l9OpiD5/r3vEy6TKyzADfb/6SzytPHm3o3Xy5eGHnW4MMAWcZNVWwG1cyH WuPxbnzoO2NkVcbFp5sECauBYmNHbkJHqmLyMnYWiYXOiBgCdVD46Y7kYpfxOC9/Ga/i GbLxQ9JrJQD6V0X6/M1jc9x519NX531dUdoaxQa49cGiarOnkPMqGLxYXN8YcUatfTUC xJOwxWTaFn6g/Zk5prTLY/kc+lybqYEzyqY5NEia9Jq+QbNUjRy567dT/IPDAQBWPcgU Dwo746dHCZ5n56BLrbz6Iun9uHRA+w/zoPzM+kQBW5Tsrxd9XQ6K5xImTJJCTV01OQVn +tdg== 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=23nOgTO4HJuPvT9bvyZ/5COiKe1e8xkbEPiV0YJykfA=; b=cv9rjDYrXP7yx0RuihvRCDQWIr1CGlk6JePJJcc1vyZBmlUPcPtXxcSplrenYIJWwv 9vYu+R/iFo2S24TS4+zNgahI/lPCOG/KQi8AsCMqYGsyK0oPhB/r5UumLoRUJxHP7mbO UUbjRmIguM3WSXEkhHYhX7Z5URQWECytpZbUilHUCMAIeATpmKHW8qp+QGDkQHQlS1Z/ f4vvYCKaPLIBtakBqZDhqbzWN42s51+/IuLBFkAPOmfFn6415kuIgG4qBOju9MiQxyk0 Gp8lUHnNX772mp/621S+N3oWtP1xRwbbjN2+cz1aplohStoCw3mL6BvIlD9RfIRhqWsf hEoA== 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 d63si9320785pfc.250.2019.06.16.18.54.50; Sun, 16 Jun 2019 18:55:05 -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 S1727536AbfFQByq (ORCPT + 99 others); Sun, 16 Jun 2019 21:54:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35432 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727389AbfFQByp (ORCPT ); Sun, 16 Jun 2019 21:54:45 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0074E3086220; Mon, 17 Jun 2019 01:54:45 +0000 (UTC) Received: from localhost (ovpn-12-57.pek2.redhat.com [10.72.12.57]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 56A58619CE; Mon, 17 Jun 2019 01:54:43 +0000 (UTC) Date: Mon, 17 Jun 2019 09:54:41 +0800 From: Baoquan He To: "Lendacky, Thomas" Cc: "linux-kernel@vger.kernel.org" , "x86@kernel.org" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Lianbo Jiang Subject: Re: [PATCH v2 1/2] x86/mm: Identify the end of the kernel area to be reserved Message-ID: <20190617015441.GA22289@MiWiFi-R3L-srv> References: <284d3650e2dae50d5645310a8b49664398fe5223.1560546537.git.thomas.lendacky@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <284d3650e2dae50d5645310a8b49664398fe5223.1560546537.git.thomas.lendacky@amd.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 17 Jun 2019 01:54:45 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/14/19 at 09:15pm, Lendacky, Thomas wrote: > 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) Looks good to me, thanks. To the series, Reviewed-by: Baoquan He Thanks Baoquan