From patchwork Mon Mar 6 22:03:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9607721 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DFD05602B4 for ; Mon, 6 Mar 2017 22:06:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D739F2846D for ; Mon, 6 Mar 2017 22:06:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9D5927BE5; Mon, 6 Mar 2017 22:06:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4BFD827BE5 for ; Mon, 6 Mar 2017 22:06:30 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cl0jg-0006Sl-Gc; Mon, 06 Mar 2017 22:04:08 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cl0jf-0006Sf-7N for xen-devel@lists.xenproject.org; Mon, 06 Mar 2017 22:04:07 +0000 Received: from [193.109.254.147] by server-5.bemta-6.messagelabs.com id F1/A9-22382-6DCDDB85; Mon, 06 Mar 2017 22:04:06 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjkeJIrShJLcpLzFFi42K5GHpgne7VO3s jDGZO0bH4vmUykwOjx+EPV1gCGKNYM/OS8isSWDPWv+1mKfivUPG97QFzA+MMmS5GLg4hgVmM En9nf2DqYuTkYBG4zCIxvVMJxJYQeMcica2VCcKOkfjz/hoLhF0psWPJCkYQW0hASWLrhqXME IMamCTOTvkEVsQmoCWxp2E+WLOIwEc+iQN9rCBFzAJrmSS2XT0DlhAW8JO4/nkZC8RmVYnlZ2 exgti8AhYSzw78Z4PYZiFx5/ESpgmMfAsYGVYxahSnFpWlFukaGeklFWWmZ5TkJmbm6BoamOn lphYXJ6an5iQmFesl5+duYgSGCgMQ7GBcMz/wEKMkB5OSKK/bsr0RQnxJ+SmVGYnFGfFFpTmp xYcYZTg4lCR456wHygkWpaanVqRl5gCDFiYtwcGjJMJ7CiTNW1yQmFucmQ6ROsVozPHg1K43T Byf+g+/YRJiycvPS5US550OUioAUppRmgc3CBZNlxhlpYR5GYFOE+IpSC3KzSxBlX/FKM7BqC TMewFkCk9mXgncvldApzABnaLtCnZKSSJCSqqB0W6CpkpuUNLrZMuvm24/lp9aukN4gnsZ79/ U0+4Z9pxbGrb/dtEoPLJIeZPj92nxqmnvbDfKyIUapD71O1M7idlRT+9sxO3jPzRC9q0x7r21 /+a0w9qx6rVmkfuiHt8Uvv+lZrGaiei+ywURrD4LjprylibMmtsdLtkk59a1ibvDLfi47525S izFGYmGWsxFxYkAXKw7cqECAAA= X-Env-Sender: thgarnie@google.com X-Msg-Ref: server-12.tower-27.messagelabs.com!1488837844!88897012!1 X-Originating-IP: [209.85.192.174] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 34193 invoked from network); 6 Mar 2017 22:04:05 -0000 Received: from mail-pf0-f174.google.com (HELO mail-pf0-f174.google.com) (209.85.192.174) by server-12.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 6 Mar 2017 22:04:05 -0000 Received: by mail-pf0-f174.google.com with SMTP id w189so65581907pfb.0 for ; Mon, 06 Mar 2017 14:04:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=/QDhinrWor7GGCQa0jhhliHI+LKRzCgWgS2orNXh0os=; b=eOzAxgw+ZpMKy1E0AzIxTr6MwYWsWzP2iryhs+Ml/RGdX7gslxyGWpRE94GRkodW4S tijCWRsf18myyjV+0Zo96Lzm1LdJ8Y9ag+u79J+y/XWUN40pYOldSCFr4LCpPRb+Vem2 sH8DJsHNPGrtuUc419kGpi+rLPhawNrzv8d2BcW3JNRZyXZOfyNzJC2VKlbuH9k7eMl8 KBisze3bZo++DQM5pleNyTiCEhYKlDTkJrL5pDRXtSAoqNY/AI9caAZSlQJMWhWexT26 JUtWx5d0BhFBDYz+FPK7IUzOHqti+HpM0Y1s2o1UkdWy4U/Vg4zt91ZRmofravbQC8T0 R5Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=/QDhinrWor7GGCQa0jhhliHI+LKRzCgWgS2orNXh0os=; b=toGwjI3ddZVlBt1Y7bFRXPvHpwHIRleZ0MS86Jc6u5/KvcU2/ANPPoUy7csgJkQn45 U6Do01Zn3JvWuviVSUADVCyGSxvF3dWvKEJiK6sZFqlnnEE0ABzziVmya05js/GAu5gS ONbx+KjPpCokNgomZgvMiEyvE/4p77uBuQfTkO2gR6/xpsB3E4jol1mG1bOlihq89Z5S gdU/B35rC7j4NOP5Zmogeq+zA60ey+vFEJLx2R7gETcpf4QaRDeNMUdZduZL7Kw9e4Dh PPV2MARN8h80OBoJ+MkQEI1MexUA8VoQi4+H3yTU6TrCYdNOilv9nxnk23Db8R0r/n5n TLWw== X-Gm-Message-State: AMke39mOpvNM90TYVxFl66+io8j3h/RPUvuAjgtJRkghRU/OkAB+avlFM3NYWoefREdlPTiT X-Received: by 10.98.55.66 with SMTP id e63mr24092159pfa.156.1488837843625; Mon, 06 Mar 2017 14:04:03 -0800 (PST) Received: from skynet.sea.corp.google.com ([100.100.206.185]) by smtp.gmail.com with ESMTPSA id l72sm41407671pfi.93.2017.03.06.14.04.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Mar 2017 14:04:03 -0800 (PST) From: Thomas Garnier To: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Jonathan Corbet , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Thomas Garnier , Kees Cook , Juergen Gross , Lorenzo Stoakes , Andy Lutomirski , Paul Gortmaker , Andrew Morton , Michal Hocko , zijun_hu , Chris Wilson , Joonsoo Kim , Andy Lutomirski , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Jiri Kosina , Matt Fleming , Ard Biesheuvel , Boris Ostrovsky , Rusty Russell , Paolo Bonzini , Borislav Petkov , Christian Borntraeger , "Luis R . Rodriguez" , Fenghua Yu , He Chen , Brian Gerst , Frederic Weisbecker , Stanislaw Gruszka , Arnd Bergmann , Peter Zijlstra , Dave Hansen , Josh Poimboeuf , Vitaly Kuznetsov , David Vrabel , Tim Chen , Andi Kleen , Jiri Olsa , Prarit Bhargava , Michael Ellerman , Joerg Roedel , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Date: Mon, 6 Mar 2017 14:03:46 -0800 Message-Id: <20170306220348.79702-1-thgarnie@google.com> X-Mailer: git-send-email 2.12.0.rc1.440.g5b76565f74-goog Cc: linux-efi@vger.kernel.org, kvm@vger.kernel.org, linux-pm@vger.kernel.org, x86@kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, lguest@lists.ozlabs.org, kernel-hardening@lists.openwall.com, xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH v5 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch aligns MODULES_END to the beginning of the Fixmap section. It optimizes the space available for both sections. The address is pre-computed based on the number of pages required by the Fixmap section. It will allow GDT remapping in the Fixmap section. The current MODULES_END static address does not provide enough space for the kernel to support a large number of processors. Signed-off-by: Thomas Garnier --- Based on next-20170306 --- Documentation/x86/x86_64/mm.txt | 5 ++++- arch/x86/include/asm/pgtable_64_types.h | 3 ++- arch/x86/kernel/module.c | 1 + arch/x86/mm/dump_pagetables.c | 1 + arch/x86/mm/kasan_init_64.c | 1 + mm/vmalloc.c | 1 + 6 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Documentation/x86/x86_64/mm.txt b/Documentation/x86/x86_64/mm.txt index 5724092db811..ee3f9c30957c 100644 --- a/Documentation/x86/x86_64/mm.txt +++ b/Documentation/x86/x86_64/mm.txt @@ -19,7 +19,7 @@ ffffff0000000000 - ffffff7fffffffff (=39 bits) %esp fixup stacks ffffffef00000000 - fffffffeffffffff (=64 GB) EFI region mapping space ... unused hole ... ffffffff80000000 - ffffffff9fffffff (=512 MB) kernel text mapping, from phys 0 -ffffffffa0000000 - ffffffffff5fffff (=1526 MB) module mapping space +ffffffffa0000000 - ffffffffff5fffff (=1526 MB) module mapping space (variable) ffffffffff600000 - ffffffffffdfffff (=8 MB) vsyscalls ffffffffffe00000 - ffffffffffffffff (=2 MB) unused hole @@ -39,6 +39,9 @@ memory window (this size is arbitrary, it can be raised later if needed). The mappings are not part of any other kernel PGD and are only available during EFI runtime calls. +The module mapping space size changes based on the CONFIG requirements for the +following fixmap section. + Note that if CONFIG_RANDOMIZE_MEMORY is enabled, the direct mapping of all physical memory, vmalloc/ioremap space and virtual memory map are randomized. Their order is preserved but their base will be offset early at boot time. diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h index 3a264200c62f..bb05e21cf3c7 100644 --- a/arch/x86/include/asm/pgtable_64_types.h +++ b/arch/x86/include/asm/pgtable_64_types.h @@ -67,7 +67,8 @@ typedef struct { pteval_t pte; } pte_t; #endif /* CONFIG_RANDOMIZE_MEMORY */ #define VMALLOC_END (VMALLOC_START + _AC((VMALLOC_SIZE_TB << 40) - 1, UL)) #define MODULES_VADDR (__START_KERNEL_map + KERNEL_IMAGE_SIZE) -#define MODULES_END _AC(0xffffffffff000000, UL) +/* The module sections ends with the start of the fixmap */ +#define MODULES_END __fix_to_virt(__end_of_fixed_addresses + 1) #define MODULES_LEN (MODULES_END - MODULES_VADDR) #define ESPFIX_PGD_ENTRY _AC(-2, UL) #define ESPFIX_BASE_ADDR (ESPFIX_PGD_ENTRY << PGDIR_SHIFT) diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c index 477ae806c2fa..fad61caac75e 100644 --- a/arch/x86/kernel/module.c +++ b/arch/x86/kernel/module.c @@ -35,6 +35,7 @@ #include #include #include +#include #if 0 #define DEBUGP(fmt, ...) \ diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c index 58b5bee7ea27..75efeecc85eb 100644 --- a/arch/x86/mm/dump_pagetables.c +++ b/arch/x86/mm/dump_pagetables.c @@ -20,6 +20,7 @@ #include #include +#include /* * The dumper groups pagetable entries of the same type into one, and for diff --git a/arch/x86/mm/kasan_init_64.c b/arch/x86/mm/kasan_init_64.c index 8d63d7a104c3..1bde19ef86bd 100644 --- a/arch/x86/mm/kasan_init_64.c +++ b/arch/x86/mm/kasan_init_64.c @@ -9,6 +9,7 @@ #include #include +#include extern pgd_t early_level4_pgt[PTRS_PER_PGD]; extern struct range pfn_mapped[E820_X_MAX]; diff --git a/mm/vmalloc.c b/mm/vmalloc.c index b4024d688f38..91b0d5e19af6 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -35,6 +35,7 @@ #include #include #include +#include #include "internal.h"