Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1740012ybi; Thu, 20 Jun 2019 03:00:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXucSFM8+qriwPLTCNWCZ1P3v9GaSHAZ2PbvSCaPYUWCB1GnNh7QcInrA8n6a1Yjd1h/rK X-Received: by 2002:a17:902:7603:: with SMTP id k3mr17044910pll.245.1561024854247; Thu, 20 Jun 2019 03:00:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561024854; cv=none; d=google.com; s=arc-20160816; b=DWkqUPRD+7svwvJYuAZkrgRP9Pmyc/FMaRczYBdQ+P4ekRY2LSPt3NbpfoiyrPvhYQ rz65nHZgYyWsOqFih6EGj7r4AOun62KoxsyI5WM5PPlIX7AjtQ5MLziwnGjIPVLKCNKO 4029j2zSsnLMRvd6lzxuR+VI1WkNaaynOu76efRuP+88BGCF3fCDnwRDiigbrvnpO2qd 6W+EN75/jQXqCLo6ExeqE7EzsnUuas1l6sz5u/LLHNABRm6V3Ef1IuLS5Y6coruzeB5d yslYDZaXHXdf7LHY1NWtgXUXSmtaBBX4lxFQAGyM8lnKZMcWgxDZN5b74atBjxY3TzTZ q9/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=8gIP6uyAeZBecJEWAZebwYMMjCbnoUAO9/4qg9zM7es=; b=DhaevCw/BxUp8fhI7/htmApwdhNTb7IG8VcK0GAudCK/pNKngHG3EoASsRdxthzoAq cs9lnV2LXCaiItozs8rty0IPmlJ4RPlwoYgHjykRAHm8+oRa6B9FrAYXVQENjtT3m+HN 7dgfZRuqknGf+TBGub37E60l+ObnlM5tzniJyNGVgXBQoY3w8CcQapB5INKc5DAFLo7f 9joSVOUkQHzmuMGi3Y/ghRm7Vd6s3PwkbnJ2K0B1EA81tZCfcg3YfApCYRxI0bEVw49z hihf/0qIQeHd6ZUfUx7h0bczRn7wlS6XX9P8AdUMljW7X3hxsoo4Qus/US1H8pgrhAZ2 wPaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019061801 header.b=Hk27VAAk; 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=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y82si19593410pfb.58.2019.06.20.03.00.37; Thu, 20 Jun 2019 03:00:54 -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; dkim=pass header.i=@zytor.com header.s=2019061801 header.b=Hk27VAAk; 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=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730913AbfFTKAJ (ORCPT + 99 others); Thu, 20 Jun 2019 06:00:09 -0400 Received: from terminus.zytor.com ([198.137.202.136]:40235 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726175AbfFTKAJ (ORCPT ); Thu, 20 Jun 2019 06:00:09 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x5K9wH5f906576 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Thu, 20 Jun 2019 02:58:17 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x5K9wH5f906576 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019061801; t=1561024698; bh=8gIP6uyAeZBecJEWAZebwYMMjCbnoUAO9/4qg9zM7es=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=Hk27VAAk61/B/X6uJaj0JwYWyfs1U0n1fwggOVdnnEWF3s6XJs1jtXRkF3EH6Ymw1 kRYMDmwmRtqg6aDcVdCrWoFrEnqXkjA7Kk+WE3EtEgukYGn3grCAzexKRtHm2Oo/SK OC6iHr5e1n+ua0mGginBhN1Lfa2AOlHz6AMONvtdi9IuJHqSTCEg4917gETCrU6yhW 4wo7vo5aHv53/5nAKUA40UYXjLvP8sfDkVlhlGDVlUTD+5SOaVD5vFHRDqo1y9QEGl RBiyoVBbogqLEWmqumSTGIyT7fP75zv9PvdCsJJ9QUV2OucRUKb5sK/aHu3fWbGN/m pIEV2uXQoYt0w== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x5K9wG4G906572; Thu, 20 Jun 2019 02:58:16 -0700 Date: Thu, 20 Jun 2019 02:58:16 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Thomas Lendacky Message-ID: Cc: dave.hansen@intel.com, keescook@chromium.org, ndesaulniers@google.com, luto@kernel.org, samitolvanen@google.com, mingo@redhat.com, dyoung@redhat.com, x86@kernel.org, Thomas.Lendacky@amd.com, hpa@zytor.com, brijesh.singh@amd.com, okaya@codeaurora.org, jgross@suse.com, linux-kernel@vger.kernel.org, mingo@kernel.org, lijiang@redhat.com, rrichter@marvell.com, pasha.tatashin@oracle.com, peterz@infradead.org, bp@suse.de, jroedel@suse.de, bhe@redhat.com, tglx@linutronix.de, thomas.lendacky@amd.com Reply-To: jgross@suse.com, linux-kernel@vger.kernel.org, brijesh.singh@amd.com, okaya@codeaurora.org, x86@kernel.org, hpa@zytor.com, Thomas.Lendacky@amd.com, mingo@kernel.org, lijiang@redhat.com, thomas.lendacky@amd.com, tglx@linutronix.de, bhe@redhat.com, jroedel@suse.de, peterz@infradead.org, bp@suse.de, rrichter@marvell.com, pasha.tatashin@oracle.com, dave.hansen@intel.com, luto@kernel.org, ndesaulniers@google.com, keescook@chromium.org, dyoung@redhat.com, mingo@redhat.com, samitolvanen@google.com In-Reply-To: <7db7da45b435f8477f25e66f292631ff766a844c.1560969363.git.thomas.lendacky@amd.com> References: <7db7da45b435f8477f25e66f292631ff766a844c.1560969363.git.thomas.lendacky@amd.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/kdump] x86/mm: Identify the end of the kernel area to be reserved Git-Commit-ID: c603a309cc75f3dd018ddb20ee44c05047918cbf X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_06_12,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, DKIM_VALID_EF autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: c603a309cc75f3dd018ddb20ee44c05047918cbf Gitweb: https://git.kernel.org/tip/c603a309cc75f3dd018ddb20ee44c05047918cbf Author: Thomas Lendacky AuthorDate: Wed, 19 Jun 2019 18:40:57 +0000 Committer: Borislav Petkov CommitDate: Thu, 20 Jun 2019 09:22:47 +0200 x86/mm: Identify the end of the kernel area to be reserved 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. Signed-off-by: Tom Lendacky Signed-off-by: Borislav Petkov Reviewed-by: Baoquan He Reviewed-by: Dave Hansen Tested-by: Lianbo Jiang Cc: Andy Lutomirski Cc: Brijesh Singh Cc: Dave Young Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: Joerg Roedel Cc: Juergen Gross Cc: Kees Cook Cc: Nick Desaulniers Cc: Pavel Tatashin Cc: Peter Zijlstra Cc: Robert Richter Cc: Sami Tolvanen Cc: Sinan Kaya Cc: Thomas Gleixner Cc: "x86@kernel.org" Link: https://lkml.kernel.org/r/7db7da45b435f8477f25e66f292631ff766a844c.1560969363.git.thomas.lendacky@amd.com --- 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..dac60ad37e5e 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 explicitly reserved with a + * separate memblock_reserve() or they 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)