From patchwork Thu Mar 16 15:33:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9628729 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 BF94A60244 for ; Thu, 16 Mar 2017 15:36:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B03B427F99 for ; Thu, 16 Mar 2017 15:36:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A36B42864C; Thu, 16 Mar 2017 15:36:58 +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 0C57127F99 for ; Thu, 16 Mar 2017 15:36:57 +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 1coXQZ-0007aR-5q; Thu, 16 Mar 2017 15:34:59 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1coXQY-0007aD-3x for xen-devel@lists.xenproject.org; Thu, 16 Mar 2017 15:34:58 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 52/3A-12861-1A0BAC85; Thu, 16 Mar 2017 15:34:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrNIsWRWlGSWpSXmKPExsVyMfSage6CDac iDPYtkrH4vmUykwOjx+EPV1gCGKNYM/OS8isSWDNebfzEXPBYpuLn22tsDYxXJLoYuTiEBGYw Sixv2MsM4rAINLJKnGrYBeZICMxhlZj69BVrFyMnkJMj8ev+HDYIu1hix9El7CA2r4CgxMmZT 1hAbCEBD4mfW/Yxg9icAnoSW9pbmSHi0RKfZ15hBLHZBLQk9jTMZwKxWQRUJT5eucEKMSdA4t HCaWBxYYEgie+7zoH1iggoSSz+8hFsF7PAMT6Jn+/Duxg5gGx1ifXzhCYwCsxCcsUshMwCRqZ VjOrFqUVlqUW6ZnpJRZnpGSW5iZk5uoYGxnq5qcXFiempOYlJxXrJ+bmbGIFBWM/AwLiD8Uqb 8yFGSQ4mJVHe6+dORAjxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4DW9AJQTLEpNT61Iy8wBxgNMW oKDR0mE9wRIK29xQWJucWY6ROoUozHHg1O73jBxfOo//IZJiCUvPy9VSpx353mgUgGQ0ozSPL hBsDi9xCgrJczLyMDAIMRTkFqUm1mCKv+KUZyDUUmY9x/IFJ7MvBK4fa+ATmECOiXx5xGQU0o SEVJSDYxrrtrUVrxinLnpVqlZeJtLQ3Uz5xdW1tCVAUcepTGG/hVzihbevmHat41N3HuEN95p b7OXWZa0j1fz5/59GYE6TC1uk94e0H3sd+6amDhv/3WtY3714aecfZfN5uRs/nrYWeX23hMTV muejtULs99YrmkazVJ3SYLpp3qUkPoxp/2bDnz8dVGJpTgj0VCLuag4EQCa3ZyBzgIAAA== X-Env-Sender: thgarnie@google.com X-Msg-Ref: server-16.tower-31.messagelabs.com!1489678495!83030898!1 X-Originating-IP: [209.85.214.48] X-SpamReason: No, hits=0.3 required=7.0 tests=RCVD_BY_IP X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 45459 invoked from network); 16 Mar 2017 15:34:56 -0000 Received: from mail-it0-f48.google.com (HELO mail-it0-f48.google.com) (209.85.214.48) by server-16.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 16 Mar 2017 15:34:56 -0000 Received: by mail-it0-f48.google.com with SMTP id m27so91141589iti.0 for ; Thu, 16 Mar 2017 08:34:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=FlvMezFd0fIOgArrzoTxMnT3gFnRG92r6TdGDECewy4=; b=StWp14poA7h9A+MAE6P85SQdCvhgaHxk4BR2kmxV81+P0XbpxvTes3BEIAb17k/80a kQAMSuBmG/0pLmNSHvrJhWKIjmKhjVp6+V0AYYuoQnjL7y2wlWuRAPQfs/0sic9Hvo+X 6eeGaPCbxtuAgH3midmDX9PmCEovJDPi+5x3hRP03dvo3kOoFgUZS65ztC2fm519O5pb 6xnmr9Xgg2DOZr9dBR5SaJ8LW7VQATzXtEgPx/btD31pyMnI8wRjbazxahZaO7rflTDP lYSmfEGsydsafzQSBQnxeRDZK6s6c2AGGSYFX/1jnOjH2ksGB/K+YULocqPtBksNoo/k KnlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=FlvMezFd0fIOgArrzoTxMnT3gFnRG92r6TdGDECewy4=; b=FUH+eMWDD54S3O1Zgo2m1exvFsAHUoPJEinajn+t1fgpPjSTNqE/m08Sk5OQlI0oQ/ /feDc9R+j2yXQ7+ZbDWylik9gc7TeKmaaMH+kgRD7KofO9RQGERCDwtLvsbbXtZ/1EFu IcFVWZSPQN7rWsYFvyjiAlAgwXhr2gtKKpve1z6qZd9Npd7OOnVIjf1bqVOm7dLcSUYo IXml3O7qSvKbxDe41+OR58LmPjO+OfcYBAmqf8IXwmpVa3uBRVfUerPnQ92WPE68DF1h Y1AhQUhHEZdQ4+a9UrulPBNC3kRcCHlk8ON5f9ER2aMUE0NN+y9KXMGShwcfxyKlvkrc 45Cw== X-Gm-Message-State: AFeK/H1TWR9klO7WbErRwUf8CJTQlmgwldUNQIBUGeQjeSHGert7FYbkfzGBdr6rTrTExomG5MhYJnPfkw+kIdFC X-Received: by 10.107.8.215 with SMTP id h84mr12328529ioi.134.1489678413500; Thu, 16 Mar 2017 08:33:33 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.1.9 with HTTP; Thu, 16 Mar 2017 08:33:32 -0700 (PDT) In-Reply-To: <20170316081013.GB7815@gmail.com> References: <20170314170508.100882-1-thgarnie@google.com> <20170316081013.GB7815@gmail.com> From: Thomas Garnier Date: Thu, 16 Mar 2017 08:33:32 -0700 Message-ID: To: Ingo Molnar Cc: Michal Hocko , Stanislaw Gruszka , linux-doc@vger.kernel.org, kvm list , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Matt Fleming , Frederic Weisbecker , Chris Wilson , Linux-MM , Paul Gortmaker , linux-efi@vger.kernel.org, Alexander Potapenko , Pavel Machek , "H . Peter Anvin" , Kernel Hardening , Boris Ostrovsky , zijun_hu , lguest@lists.ozlabs.org, xen-devel@lists.xenproject.org, Jonathan Corbet , Joerg Roedel , the arch/x86 maintainers , kasan-dev , Christian Borntraeger , Ingo Molnar , Andrey Ryabinin , Borislav Petkov , Len Brown , Rusty Russell , Kees Cook , Linux PM list , Jiri Kosina , Andy Lutomirski , Josh Poimboeuf , Thomas Gleixner , Vitaly Kuznetsov , Dmitry Vyukov , Juergen Gross , Peter Zijlstra , Lorenzo Stoakes , Ard Biesheuvel , "Rafael J . Wysocki" , LKML , Andy Lutomirski , "Luis R . Rodriguez" , Paolo Bonzini , Andrew Morton , Tim Chen Subject: Re: [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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Mar 16, 2017 at 1:10 AM, Ingo Molnar wrote: > > Note that asm/fixmap.h is an x86-ism that isn't present in many other > architectures, so this hunk will break the build. > > To make progress with these patches I've fixed it up with an ugly #ifdef > CONFIG_X86, but it needs a real solution instead before this can be pushed > upstream. I also saw an error on x86 tip on special configuration. I found this new patch below to be a good solution to both. Let me know what you think. ===== 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.h | 1 + arch/x86/include/asm/pgtable_64_types.h | 3 ++- 3 files changed, 7 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.h b/arch/x86/include/asm/pgtable_64.h index 73c7ccc38912..67608d4abc2c 100644 --- a/arch/x86/include/asm/pgtable_64.h +++ b/arch/x86/include/asm/pgtable_64.h @@ -13,6 +13,7 @@ #include #include #include +#include extern pud_t level3_kernel_pgt[512]; extern pud_t level3_ident_pgt[512]; 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)