From patchwork Thu Jan 26 16:59:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9539795 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 89CB3604A0 for ; Thu, 26 Jan 2017 17:06:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BAD92094F for ; Thu, 26 Jan 2017 17:06:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C30F269DA; Thu, 26 Jan 2017 17:06:26 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_MED, 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 CCB622094F for ; Thu, 26 Jan 2017 17:06:25 +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 1cWnSv-0002GK-1x; Thu, 26 Jan 2017 17:04:05 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWnOn-0001gj-D1 for xen-devel@lists.xenproject.org; Thu, 26 Jan 2017 16:59:49 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id AD/EE-27165-40B2A885; Thu, 26 Jan 2017 16:59:48 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprAIsWRWlGSWpSXmKPExsVyMfTANl1m7a4 Ig9tzrSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oy385YwFUyXqli3aTVzA+NFsS5GLg4hgVmM Eqd2n2AHcVgELrNIHP7fzQjiSAi8Y5F4976TtYuRE8iJkThw8hWUXSmxZPUcJhBbSEBJYuuGp cwQo/4xSvzvv88GkmAT0JLY0zCfCSQhIrCZV2LRnJvMIAlmgT+MEjN2moPYwgJ+Eh//PAeLsw ioSrzefRZsA6+AhcSZs9+YILYZS9zuP806gZFvASPDKkaN4tSistQiXSMDvaSizPSMktzEzBx dQwMzvdzU4uLE9NScxKRiveT83E2MwHBhAIIdjL+WBRxilORgUhLlbVTpihDiS8pPqcxILM6I LyrNSS0+xCjDwaEkwWumBZQTLEpNT61Iy8wBBi5MWoKDR0mE95YmUJq3uCAxtzgzHSJ1itGYo 6fr9Esmjj27Lr9kEmLJy89LlRLndQGZJABSmlGaBzcIFlGXGGWlhHkZgU4T4ilILcrNLEGVf8 UozsGoJMx7H2QhT2ZeCdy+V0CnMAGdcoG5HeSUkkSElFQDo8XqGSeOBhnWvOKOXtRcNE2oIiv fx2/6udDi2l5n8eCgrLU/t69usG/pO/fPPaq4YUlam8vtwPKaLfEPjeUNk80lpkZPWDKfU2Ft pe6kSeGdBhNrG2e767aKX1r/KGzK19kXMljPdbPHiTNP9GDU5Pxep3HH4qbekapjRV2LzQ5ZL 9PbYVaixFKckWioxVxUnAgAoCB1raMCAAA= X-Env-Sender: thgarnie@google.com X-Msg-Ref: server-4.tower-27.messagelabs.com!1485449986!83132002!1 X-Originating-IP: [209.85.192.182] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 13234 invoked from network); 26 Jan 2017 16:59:47 -0000 Received: from mail-pf0-f182.google.com (HELO mail-pf0-f182.google.com) (209.85.192.182) by server-4.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 26 Jan 2017 16:59:47 -0000 Received: by mail-pf0-f182.google.com with SMTP id y143so66574330pfb.0 for ; Thu, 26 Jan 2017 08:59:47 -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=VPdHxhUXfPNs8juYRqnFFm8/F20wvkC0cFS2a7K9VoM=; b=if9DRAvp2lTwg8At2FNPcOp+rqYFR3cvBTpTgPy94oxEyCbAUksAJZhaJJ1IXDIaeG dmtt48Mj7RWsdca0Io5ZMBmBsD1RynGTI/EY0SdFcJCXoW3agXe/YOW1/sXH/o8o4IYy 2bBqlvN8bm3uAsIaFxOIBNaz64TxpA6LYsI6ScqfEHJdx1FVKWw6eHi50SYPKNbJo2dW vT4BdT5KbeYDSZkwaMeKOivEnA7RdObs4vGYjK2kgv5LQTg91KOz+ww3JohYlVVkeNxG jwcqF6610oMD85MyeTKDC+5geH8iQXxjqlj0XT3HSiUtzDk8VrrxaS/VzWiOMpxV3/ZZ 7Xqw== 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=VPdHxhUXfPNs8juYRqnFFm8/F20wvkC0cFS2a7K9VoM=; b=NDD4Q605n4FaSGBqms4Bc3mUmXUBEZ50tqfLkf0hIw8GyfiycFyzxBMUNHy43E9BNb NFoUCszOLpnZP9+mfXO1ncQmUuw0At5Wx7FjCsNdvwbuRoqbPaJiQdT4D134AuJJIqNK 462Tbw3TZLogyL0s20efDeWpiIx1ehckuhwPEpst/C0GROI93eWqcWx84vLVh0tWHFBT +ETBmmyA3wSwhCxGtaStMIEsExLzy8WvjDtAr8ktt54iDJIVTPz6CSo3VitqUj1d4qEo QEbdvCesV45e8/WOhcefXC/5Ay/LsosBxJdi2A26baGLfugOCI8FjbZemhgmwl5vNpoK a78w== X-Gm-Message-State: AIkVDXJMAjTAIz8LDg8Yjj21sLzT5Z4K+2gzApqYGtml6fGcIuO+ZtFjXx4sEmK3mjRUlS+G X-Received: by 10.84.168.131 with SMTP id f3mr5517907plb.163.1485449985951; Thu, 26 Jan 2017 08:59:45 -0800 (PST) Received: from skynet.sea.corp.google.com ([100.100.206.185]) by smtp.gmail.com with ESMTPSA id y6sm4723469pge.16.2017.01.26.08.59.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Jan 2017 08:59:45 -0800 (PST) From: Thomas Garnier To: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Thomas Garnier , Kees Cook , Andy Lutomirski , Arjan van de Ven , Paul Gortmaker , Borislav Petkov , Andy Lutomirski , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Jiri Kosina , Matt Fleming , Ard Biesheuvel , Boris Ostrovsky , Juergen Gross , Rusty Russell , Christian Borntraeger , Fenghua Yu , He Chen , Brian Gerst , "Luis R . Rodriguez" , Adam Buchbinder , Stanislaw Gruszka , Arnd Bergmann , Dave Hansen , Chen Yucong , Vitaly Kuznetsov , David Vrabel , Josh Poimboeuf , Tim Chen , Rik van Riel , Andi Kleen , Jiri Olsa , Prarit Bhargava , Michael Ellerman , Joerg Roedel , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Date: Thu, 26 Jan 2017 08:59:38 -0800 Message-Id: <20170126165940.30799-1-thgarnie@google.com> X-Mailer: git-send-email 2.11.0.483.g087da7b7c-goog X-Mailman-Approved-At: Thu, 26 Jan 2017 17:04:04 +0000 Cc: linux-efi@vger.kernel.org, kvm@vger.kernel.org, linux-pm@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, lguest@lists.ozlabs.org, kernel-hardening@lists.openwall.com, xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH v2 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-20170125 --- arch/x86/include/asm/fixmap.h | 8 ++++++++ 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 + 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h index 8554f960e21b..c46289799b02 100644 --- a/arch/x86/include/asm/fixmap.h +++ b/arch/x86/include/asm/fixmap.h @@ -132,6 +132,14 @@ enum fixed_addresses { extern void reserve_top_address(unsigned long reserve); +/* On 64bit, the module sections ends with the start of the fixmap */ +#ifdef CONFIG_X86_64 +#define MODULES_VADDR (__START_KERNEL_map + KERNEL_IMAGE_SIZE) +#define MODULES_END __fix_to_virt(__end_of_fixed_addresses + 1) +#define MODULES_LEN (MODULES_END - MODULES_VADDR) +#endif /* CONFIG_X86_64 */ + + #define FIXADDR_SIZE (__end_of_permanent_fixed_addresses << PAGE_SHIFT) #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h index 3a264200c62f..de8bace10200 100644 --- a/arch/x86/include/asm/pgtable_64_types.h +++ b/arch/x86/include/asm/pgtable_64_types.h @@ -66,9 +66,6 @@ typedef struct { pteval_t pte; } pte_t; #define VMEMMAP_START __VMEMMAP_BASE #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) -#define MODULES_LEN (MODULES_END - MODULES_VADDR) #define ESPFIX_PGD_ENTRY _AC(-2, UL) #define ESPFIX_BASE_ADDR (ESPFIX_PGD_ENTRY << PGDIR_SHIFT) #define EFI_VA_START ( -4 * (_AC(1, UL) << 30)) 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 ea9c49adaa1f..eefd6d015d02 100644 --- a/arch/x86/mm/dump_pagetables.c +++ b/arch/x86/mm/dump_pagetables.c @@ -18,6 +18,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 0493c17b8a51..34f167cf3316 100644 --- a/arch/x86/mm/kasan_init_64.c +++ b/arch/x86/mm/kasan_init_64.c @@ -8,6 +8,7 @@ #include #include +#include extern pgd_t early_level4_pgt[PTRS_PER_PGD]; extern struct range pfn_mapped[E820_X_MAX];