From patchwork Tue Mar 14 17:05:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9623947 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 267EE60244 for ; Tue, 14 Mar 2017 17:08:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 132D9285C3 for ; Tue, 14 Mar 2017 17:08:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0746A285CA; Tue, 14 Mar 2017 17:08:22 +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 8274D285C3 for ; Tue, 14 Mar 2017 17:08:20 +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 1cnpt7-0007AV-MP; Tue, 14 Mar 2017 17:05:33 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cnpt6-0007AP-7k for xen-devel@lists.xenproject.org; Tue, 14 Mar 2017 17:05:32 +0000 Received: from [85.158.139.211] by server-2.bemta-5.messagelabs.com id 53/CE-20080-BD228C85; Tue, 14 Mar 2017 17:05:31 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupgkeJIrShJLcpLzFFi42Lxqg020b2ldCL CYPYtNYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNaPzx3vWgt8KFYuub2JvYJwi08XIxSEkMJ1R onnzcVYQh0XgMovE1T/n2boYOTkkBN6xSJztFoCwYyS2b+plhbCrJB7vvc0IYgsJKEls3bCUG WJSA5PE5tkbwZrZBLQk9jTMZwJJiAg84pZY8/A6G4jDLLCWSWLb1TNAGQ4OYQE/ifYTYBtYBF QlDt84ALaBV8BSort/KytIiYSAiUTfZ5kJjHwLGBlWMWoUpxaVpRbpGhroJRVlpmeU5CZm5gB 5pnq5qcXFiempOYlJxXrJ+bmbGIGhwgAEOxjXTHU+xCjJwaQkyqsieCJCiC8pP6UyI7E4I76o NCe1+BCjDAeHkgTvBUWgnGBRanpqRVpmDjBoYdISHDxKIrwN8kBp3uKCxNzizHSI1ClGXY4P/ YffMAmx5OXnpUqJ84aDzBAAKcoozYMbAYugS4yyUsK8jEBHCfEUpBblZpagyr9iFOdgVBLmrQ KZwpOZVwK36RXQEUxARyT+PAJyREkiQkqqgbHxw7qNdTE3zd4f9Pl79uj6vAa27Hr1rbqztU9 8+qaclCG0M4DJxrq1yCg3tKjEjvHN08umzgJ6HKuvX5k0K7y0g5N3y9IfTdIOC91Lt7EKnNWQ ncitqtkf23Z3+p2Ts320l136v8ZsUrfivHtHcg1273zIY3Z8W5DPAium/arlxackC8xeRymxF GckGmoxFxUnAgA9IRIqmwIAAA== X-Env-Sender: thgarnie@google.com X-Msg-Ref: server-13.tower-206.messagelabs.com!1489511129!73917569!1 X-Originating-IP: [74.125.83.52] 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 34788 invoked from network); 14 Mar 2017 17:05:30 -0000 Received: from mail-pg0-f52.google.com (HELO mail-pg0-f52.google.com) (74.125.83.52) by server-13.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 14 Mar 2017 17:05:30 -0000 Received: by mail-pg0-f52.google.com with SMTP id 77so93235773pgc.1 for ; Tue, 14 Mar 2017 10:05:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=M/Eh5df723NxTou+Vb7unNH4cKBdhMNBTm2R41b5MQM=; b=rT8Qs//E/StB8dZflmii3NpKyw1SRzZTS5tuYNFl/rTPto/iKcqeqiOfrTIc8Kd3pi IjVFaCYR9sTdiJeYzjO3uHKwcaA3hvenmseEpSQ5X9d8hrsSBEEGFdzT/+XB78xcu5Zf 4Mrajyw3FB3FKwBLP3ZY6hVibmSzvBGQXSN32uuUjOSiKMI3wxLUAAwKVmu0TajjYvwY FlBgLarCDWHTmsiHXRSBVK1AfR4+MQYGutQrLrFO2Up3iGuPwedTraoS39BTcStGbJLz iCyPOPCowM3suxhfq6xHVv/9M7mNtle393oOURYG70byONHH5yRrmVy+SPBLdFIdJFSu 8M8g== 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=M/Eh5df723NxTou+Vb7unNH4cKBdhMNBTm2R41b5MQM=; b=WuqXDIijc+b6006lI2/1NHC/Mq0SkUmHsD27xnFkBsycnngG8b85P+uJBJ1d7I0D3A tIb4NB9DZGeaKHFvy4klnZHzK3EOZLrgNWxaCxl3KRXDmsktI/n0ubQR87fCV4smj6r0 FzL7PKhJntVoyUCJAxYOGfgzgbv4OtrUpozVEhyr/9Gel1d8k6nSage8FUxtu2AfJ9XI 676Fqna2OGO1UB+GE4RtiCz7OKtdTJJY0W4TdUVxANnsf8XkY5QfHCuVtHOmXZ13VxDW KudLOjF8CFA9DBMmopADd7BqF2mvoJ67EsShTKCp6KXj3AFpA3Qrro92swtXJn/wpmHl qR8g== X-Gm-Message-State: AMke39lgdJ7ZIgqqZAF32g6nVMvegAnV4JSD9vFtSh0F0WqITdudPeVI5RqpE2OITEC5ou/r X-Received: by 10.98.103.75 with SMTP id b72mr45692387pfc.105.1489511128523; Tue, 14 Mar 2017 10:05:28 -0700 (PDT) Received: from skynet.sea.corp.google.com ([100.100.206.185]) by smtp.gmail.com with ESMTPSA id r13sm39714525pfg.55.2017.03.14.10.05.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Mar 2017 10:05:27 -0700 (PDT) From: Thomas Garnier To: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Jonathan Corbet , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Thomas Garnier , Lorenzo Stoakes , Kees Cook , Juergen Gross , Andy Lutomirski , Paul Gortmaker , Andrew Morton , Michal Hocko , zijun_hu , Chris Wilson , 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 , Frederic Weisbecker , "Luis R . Rodriguez" , Stanislaw Gruszka , Peter Zijlstra , Josh Poimboeuf , Vitaly Kuznetsov , Tim Chen , Joerg Roedel , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Date: Tue, 14 Mar 2017 10:05:06 -0700 Message-Id: <20170314170508.100882-1-thgarnie@google.com> X-Mailer: git-send-email 2.12.0.367.g23dc2f6d3c-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 v7 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-20170308 --- 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 32979d945766..1fc9598ed019 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -35,6 +35,7 @@ #include #include #include +#include #include "internal.h"