From patchwork Tue Feb 14 19:42:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9572651 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 9119660573 for ; Tue, 14 Feb 2017 19:45:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D7AF28391 for ; Tue, 14 Feb 2017 19:45:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 810FD283E1; Tue, 14 Feb 2017 19:45:41 +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 AA63B28391 for ; Tue, 14 Feb 2017 19:45:39 +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 1cdj0H-00022D-UF; Tue, 14 Feb 2017 19:43:09 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cdj0H-000227-3F for xen-devel@lists.xenproject.org; Tue, 14 Feb 2017 19:43:09 +0000 Received: from [85.158.137.68] by server-11.bemta-3.messagelabs.com id CD/62-01684-CCD53A85; Tue, 14 Feb 2017 19:43:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnkeJIrShJLcpLzFFi42K5GHrLUPd07OI Ig72nJSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oy7s6YxFcyQqljxZhNbA+MlsS5GLg4hgRmM EpeeHGEDcVgELrNINH99CeRwckgIvGORWPG3HsKOkfjccIwFwq6W+L78EROILSSgJLF1w1Jmi En/GSWeTnwFVsQmoCWxp2E+E0hCRGAOj8TLLWuYQRLMAn8YJWbsNAexhQX8JFadesAKYrMIqE osXHeXHcTmFbCQmLDtB9QVxhK3+0+zTmDkW8DIsIpRozi1qCy1SNfQUC+pKDM9oyQ3MTNH19D AWC83tbg4MT01JzGpWC85P3cTIzBYGIBgB+Pq306HGCU5mJREeSuCFkcI8SXlp1RmJBZnxBeV 5qQWH2KU4eBQkuD9EgOUEyxKTU+tSMvMAYYtTFqCg0dJhPcCSJq3uCAxtzgzHSJ1itGYo6fr9 Esmjj27Lr9kEmLJy89LlRLnPQVSKgBSmlGaBzcIFk+XGGWlhHkZgU4T4ilILcrNLEGVf8Uozs GoJMz7CmQKT2ZeCdy+V0CnMAGdwhq3EOSUkkSElFQD41QW9mNnFs5hLXqstH5Pc6R6v+WbeV8 vebs1sVmdNJj9wFjTRibnzZzZ3EUcahdcN32sWFyt9bDJ69xmuySR2awCzPOzGrMtMpPUipbM ehXuFZT8wCth34f2HK5l74yO6f7JCFJUEd6lw/3lvWZLX+Nc4+ssOr0b62d6JCrfcLvVs3dH+ qNLSizFGYmGWsxFxYkAuvQJ/6ICAAA= X-Env-Sender: thgarnie@google.com X-Msg-Ref: server-4.tower-31.messagelabs.com!1487101386!27506194!1 X-Originating-IP: [209.85.218.49] 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 26995 invoked from network); 14 Feb 2017 19:43:07 -0000 Received: from mail-oi0-f49.google.com (HELO mail-oi0-f49.google.com) (209.85.218.49) by server-4.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 14 Feb 2017 19:43:07 -0000 Received: by mail-oi0-f49.google.com with SMTP id j15so76428823oih.2 for ; Tue, 14 Feb 2017 11:43:07 -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=fkgdfxbO6Pf81+jqKZBzc48WryOmFj+SonreAcEy6NY=; b=DNz7Y7ayX/zpL8HgkXC3r8nNFILomu6pOmK8zR4igg5us/I+blRCzQ5S6MX8n66LD7 zW6wlCa0hOmQrly6fBWj4DOfBY6z2XCzOmWcuyB06YdBlAeWpBIXacxI3gJYCptAe9cq Ynk3a1RWrt3kh0mAAqj2hlu3Sy0WxsvdSOyTFlH9fhScbUvZETA3w/Yd/cQJiXsPbPeR QO3nORLMeMhkrqq+KgjGPpamk/BNq7wdK6d7wx4JlbWFq9fCEgFbkzicYkceQ1AAuaFM AJjn5THgnVNdlQkVLOPHsGKJLGKFsCZj6i4hdfjqy7Ibx5DhsuCHrSgDmiDCfds2060w e39A== 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=fkgdfxbO6Pf81+jqKZBzc48WryOmFj+SonreAcEy6NY=; b=rmLI8jEELclYJ6lecGNEIZyhRAy66lk2BzbboQGtrIuWwrgqksftnsLTJCHMwkG+04 UIi0Fu/XajILaatNZVX7XxZ/qplegOq6IywXJ5mRBFeBW4GVZEpf/CIX97gFMlZCrREb DCf6NcCIbWIBmw0V8MG4A7e+dKlTaQBn25yo9NGCjaWImHIxrm+CxvSIt2FrkKejq7MZ 4oGKkEG3/zb2tOrsVryqVsVdclGtcXy2lqRrJ3lp4pql/aHZEtinNbl/LyBlw3GD2r1a nFGaYii852ELIs8l2AJKoYM9EXz3R4/AgZySL/B12Kbvs+yHgtc7RlHkjwaL52krelug 4FOQ== X-Gm-Message-State: AMke39nI4aRgp7+XKaOaCAxaiqHDU7CIyzciHYal21oV66Qaue3gKTOuRqq0U6K8Q0sAdXxV X-Received: by 10.84.162.204 with SMTP id o12mr38640839plg.132.1487101385599; Tue, 14 Feb 2017 11:43:05 -0800 (PST) Received: from skynet.sea.corp.google.com ([100.100.206.185]) by smtp.gmail.com with ESMTPSA id r78sm2804161pfl.63.2017.02.14.11.43.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Feb 2017 11:43:05 -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 , Borislav Petkov , Paul Gortmaker , Andy Lutomirski , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Jiri Kosina , Matt Fleming , Ard Biesheuvel , Boris Ostrovsky , Juergen Gross , Rusty Russell , Peter Zijlstra , Christian Borntraeger , "Luis R . Rodriguez" , He Chen , Brian Gerst , Stanislaw Gruszka , Arnd Bergmann , Adam Buchbinder , Dave Hansen , Vitaly Kuznetsov , Josh Poimboeuf , Tim Chen , Rik van Riel , Andi Kleen , Jiri Olsa , Michael Ellerman , Joerg Roedel , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Date: Tue, 14 Feb 2017 11:42:56 -0800 Message-Id: <20170214194259.75960-1-thgarnie@google.com> X-Mailer: git-send-email 2.11.0.483.g087da7b7c-goog 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 v3 1/4] 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-20170213 --- 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..20231189e0e3 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 64-bit, 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 8aa6bea1cd6c..90170415f08a 100644 --- a/arch/x86/mm/dump_pagetables.c +++ b/arch/x86/mm/dump_pagetables.c @@ -19,6 +19,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];