From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756466AbcGHUjt (ORCPT ); Fri, 8 Jul 2016 16:39:49 -0400 Received: from terminus.zytor.com ([198.137.202.10]:35888 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753469AbcGHUj3 (ORCPT ); Fri, 8 Jul 2016 16:39:29 -0400 Date: Fri, 8 Jul 2016 13:36:40 -0700 From: tip-bot for Thomas Garnier Message-ID: Cc: mingo@kernel.org, kuleshovmail@gmail.com, hpa@zytor.com, boris.ostrovsky@oracle.com, kirill.shutemov@linux.intel.com, toshi.kani@hpe.com, brgerst@gmail.com, dyoung@redhat.com, alpopov@ptsecurity.com, JBeulich@suse.com, dvyukov@google.com, schwidefsky@de.ibm.com, corbet@lwn.net, tglx@linutronix.de, bp@alien8.de, guangrong.xiao@linux.intel.com, akpm@linux-foundation.org, matt@codeblueprint.co.uk, aneesh.kumar@linux.vnet.ibm.com, lv.zheng@intel.com, dave.hansen@linux.intel.com, jpoimboe@redhat.com, dan.j.williams@intel.com, luto@kernel.org, keescook@chromium.org, thgarnie@google.com, borntraeger@de.ibm.com, dvlasenk@redhat.com, bp@suse.de, bhe@redhat.com, jgross@suse.com, jroedel@suse.de, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, peterz@infradead.org, yinghai@kernel.org, sds@tycho.nsa.gov, msalter@redhat.com Reply-To: bp@alien8.de, tglx@linutronix.de, guangrong.xiao@linux.intel.com, akpm@linux-foundation.org, aneesh.kumar@linux.vnet.ibm.com, matt@codeblueprint.co.uk, dvyukov@google.com, JBeulich@suse.com, corbet@lwn.net, schwidefsky@de.ibm.com, toshi.kani@hpe.com, brgerst@gmail.com, alpopov@ptsecurity.com, dyoung@redhat.com, mingo@kernel.org, hpa@zytor.com, boris.ostrovsky@oracle.com, kuleshovmail@gmail.com, kirill.shutemov@linux.intel.com, peterz@infradead.org, torvalds@linux-foundation.org, sds@tycho.nsa.gov, msalter@redhat.com, yinghai@kernel.org, dvlasenk@redhat.com, bp@suse.de, bhe@redhat.com, jgross@suse.com, linux-kernel@vger.kernel.org, jroedel@suse.de, thgarnie@google.com, keescook@chromium.org, borntraeger@de.ibm.com, dave.hansen@linux.intel.com, lv.zheng@intel.com, dan.j.williams@intel.com, luto@kernel.org, jpoimboe@redhat.com In-Reply-To: <1466556426-32664-10-git-send-email-keescook@chromium.org> References: <1466556426-32664-10-git-send-email-keescook@chromium.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/boot] x86/mm: Add memory hotplug support for KASLR memory randomization Git-Commit-ID: 90397a41779645d3abba5599f6bb538fdcab9339 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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 90397a41779645d3abba5599f6bb538fdcab9339 Gitweb: http://git.kernel.org/tip/90397a41779645d3abba5599f6bb538fdcab9339 Author: Thomas Garnier AuthorDate: Tue, 21 Jun 2016 17:47:06 -0700 Committer: Ingo Molnar CommitDate: Fri, 8 Jul 2016 17:35:21 +0200 x86/mm: Add memory hotplug support for KASLR memory randomization Add a new option (CONFIG_RANDOMIZE_MEMORY_PHYSICAL_PADDING) to define the padding used for the physical memory mapping section when KASLR memory is enabled. It ensures there is enough virtual address space when CONFIG_MEMORY_HOTPLUG is used. The default value is 10 terabytes. If CONFIG_MEMORY_HOTPLUG is not used, no space is reserved increasing the entropy available. Signed-off-by: Thomas Garnier Signed-off-by: Kees Cook Cc: Alexander Kuleshov Cc: Alexander Popov Cc: Andrew Morton Cc: Andy Lutomirski Cc: Aneesh Kumar K.V Cc: Baoquan He Cc: Boris Ostrovsky Cc: Borislav Petkov Cc: Borislav Petkov Cc: Brian Gerst Cc: Christian Borntraeger Cc: Dan Williams Cc: Dave Hansen Cc: Dave Young Cc: Denys Vlasenko Cc: Dmitry Vyukov Cc: H. Peter Anvin Cc: Jan Beulich Cc: Joerg Roedel Cc: Jonathan Corbet Cc: Josh Poimboeuf Cc: Juergen Gross Cc: Kirill A. Shutemov Cc: Linus Torvalds Cc: Lv Zheng Cc: Mark Salter Cc: Martin Schwidefsky Cc: Matt Fleming Cc: Peter Zijlstra Cc: Stephen Smalley Cc: Thomas Gleixner Cc: Toshi Kani Cc: Xiao Guangrong Cc: Yinghai Lu Cc: kernel-hardening@lists.openwall.com Cc: linux-doc@vger.kernel.org Link: http://lkml.kernel.org/r/1466556426-32664-10-git-send-email-keescook@chromium.org Signed-off-by: Ingo Molnar --- arch/x86/Kconfig | 15 +++++++++++++++ arch/x86/mm/kaslr.c | 7 ++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 9719b8e..703413f 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2010,6 +2010,21 @@ config RANDOMIZE_MEMORY If unsure, say N. +config RANDOMIZE_MEMORY_PHYSICAL_PADDING + hex "Physical memory mapping padding" if EXPERT + depends on RANDOMIZE_MEMORY + default "0xa" if MEMORY_HOTPLUG + default "0x0" + range 0x1 0x40 if MEMORY_HOTPLUG + range 0x0 0x40 + ---help--- + Define the padding in terabytes added to the existing physical + memory size during kernel memory randomization. It is useful + for memory hotplug support but reduces the entropy available for + address randomization. + + If unsure, leave at the default value. + config HOTPLUG_CPU bool "Support for hot-pluggable CPUs" depends on SMP diff --git a/arch/x86/mm/kaslr.c b/arch/x86/mm/kaslr.c index c939cfe..26dccd6 100644 --- a/arch/x86/mm/kaslr.c +++ b/arch/x86/mm/kaslr.c @@ -92,8 +92,13 @@ void __init kernel_randomize_memory(void) if (!kaslr_memory_enabled()) return; + /* + * Update Physical memory mapping to available and + * add padding if needed (especially for memory hotplug support). + */ BUG_ON(kaslr_regions[0].base != &page_offset_base); - memory_tb = ((max_pfn << PAGE_SHIFT) >> TB_SHIFT); + memory_tb = ((max_pfn << PAGE_SHIFT) >> TB_SHIFT) + + CONFIG_RANDOMIZE_MEMORY_PHYSICAL_PADDING; /* Adapt phyiscal memory region size based on available memory */ if (memory_tb < kaslr_regions[0].size_tb)