From patchwork Thu Feb 16 21:54:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9578443 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 1E6A760209 for ; Thu, 16 Feb 2017 21:57:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E77C1FF1E for ; Thu, 16 Feb 2017 21:57:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02A5F283E2; Thu, 16 Feb 2017 21:57:20 +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 6056426E82 for ; Thu, 16 Feb 2017 21:57:19 +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 1ceU0o-0006O8-Fn; Thu, 16 Feb 2017 21:54:50 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ceU0n-0006Nz-7H for xen-devel@lists.xenproject.org; Thu, 16 Feb 2017 21:54:49 +0000 Received: from [85.158.143.35] by server-4.bemta-6.messagelabs.com id 39/BB-25093-8AF16A85; Thu, 16 Feb 2017 21:54:48 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIIsWRWlGSWpSXmKPExsVyMfTAat3l8ss iDE691rb4vmUykwOjx+EPV1gCGKNYM/OS8isSWDMufD/FWNAvWtGz+wJbA+NUoS5GLg4hgemM Et8+f2MCcVgELrNIdDzbxQziSAi8Y5HY+nM1SxcjJ5ATI3H5zSs2CLtCYvXlFUwgtpCAksTWD UuZIUY1MElsnfOEGSTBJqAlsadhPthYEYE53BJre/rZQBxmgd+MEpP2dIONEhbwk7g5/ToriM 0ioCrxqG82WDevgKXEvCXb2SHWGUvc7j/NOoGRbwEjwypGjeLUorLUIl1jI72kosz0jJLcxMw cXUMDM73c1OLixPTUnMSkYr3k/NxNjMCAYQCCHYyn1wUeYpTkYFIS5T3KvCxCiC8pP6UyI7E4 I76oNCe1+BCjDAeHkgSvvBxQTrAoNT21Ii0zBxi6MGkJDh4lEV43kDRvcUFibnFmOkTqFKMxR 0/X6ZdMHHt2XX7JJMSSl5+XKiXO6wpSKgBSmlGaBzcIFlOXGGWlhHkZgU4T4ilILcrNLEGVf8 UozsGoJMybDTKFJzOvBG7fK6BTmIBO6YxYCnJKSSJCSqqB0SDIIMelwu6gzP0fOeef7n8RLtr n3L1+aWzW7S+fdULDJ1noxXvKP1V+LLPzxveAXwLzRHWyjp2XuKHuHnX+imCg5ZN9dfEiG9be 3/Pi6TWP9RLGZhzBcRV7843sDNIZ86NuxZR98j+kI1Ev1XTmjPhPNqclolI3vCZs222Q2aEl2 7rgSFWyEktxRqKhFnNRcSIAYkudvaQCAAA= X-Env-Sender: thgarnie@google.com X-Msg-Ref: server-15.tower-21.messagelabs.com!1487282086!58042415!1 X-Originating-IP: [209.85.192.171] 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 26043 invoked from network); 16 Feb 2017 21:54:47 -0000 Received: from mail-pf0-f171.google.com (HELO mail-pf0-f171.google.com) (209.85.192.171) by server-15.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 16 Feb 2017 21:54:47 -0000 Received: by mail-pf0-f171.google.com with SMTP id e4so8262139pfg.1 for ; Thu, 16 Feb 2017 13:54: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=3sEceGQjx3IFnSKh/szfDx6OR1DmRzTxg2M3DHm7lJE=; b=arZEHHaD4sv7le9El2Zt/ZRPbRV+wxy0SzcTCzjFiYOOqDohA2gcCwWFEJ4aXofsHI o+4yHBRSl2FSvdpcIMn2VZ/Mo6JlC02dnvih4316DkR7YCGcv3nCWQz9DNNj5vYcu/+i SOBIuJolld5vwD/dMIhxPbiPkoTu2EB4WXj/dRrh3pXJnxnPqjmoxJw0XAb/US4ZDV92 T5kpxMpC1SovEhZYvdZUjAxxDp8xOEx36tpU+fuaPcgA2AgXu7aUyaTJ5kEysLgcQlB8 Hxqsf1ysLhpHVZrKIFBbVRmvNS/XVgn+swFNKI05djBSsTGHJI2G7c/WhcGdFtQmL9zk V2Dg== 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=3sEceGQjx3IFnSKh/szfDx6OR1DmRzTxg2M3DHm7lJE=; b=KBXzeF/9KkePAdXkNnpoeektpYo9KUcAL4lUhNsALVG7XlbbtdjnQEFO/GvKvAv5Ul 9sHcIN01wX/C2aNpB+tury/dl2f4+ZX4WLI6QtHEEGWNQ/rQjO9+j0GjhtvtKKuhKe3C S8h+NgGWnFRY2GVFB3VpZVjEQQ0PobZj2HF41yeSYvRC3aZa++D1qUkFMP28kPmphU06 OSXoUQG1EmM/HIjSHiJKZjQuEJOsjv8JeWvSYSSn7FkfY8i+dA7EYfofSytzxCEdOjK/ Vzowv8W4qk54YnOwFFQ6FIbNwSSjejMufedD0oU02PmWU2nYJ0/qNhlBaRk7tunod0a+ EVWw== X-Gm-Message-State: AMke39kyJUjPJGDu7+a35XJAQ8PlFFCRmvBHN7q5yPu6kHCWy+vkN1/D7a6B6Luqvs8JZJND X-Received: by 10.99.171.75 with SMTP id k11mr5625225pgp.16.1487282085617; Thu, 16 Feb 2017 13:54:45 -0800 (PST) Received: from skynet.sea.corp.google.com ([100.100.206.185]) by smtp.gmail.com with ESMTPSA id s65sm15391637pgb.64.2017.02.16.13.54.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Feb 2017 13:54:44 -0800 (PST) From: Thomas Garnier To: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Jonathan Corbet , Thomas Garnier , Kees Cook , Lorenzo Stoakes , Juergen Gross , Andy Lutomirski , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Jiri Kosina , Matt Fleming , Ard Biesheuvel , Boris Ostrovsky , Rusty Russell , Borislav Petkov , Christian Borntraeger , Brian Gerst , He Chen , "Luis R . Rodriguez" , Stanislaw Gruszka , Arnd Bergmann , Peter Zijlstra , Dave Hansen , Vitaly Kuznetsov , Paul Gortmaker , Josh Poimboeuf , Tim Chen , Andi Kleen , Jiri Olsa , Michael Ellerman , Joerg Roedel , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Andy Lutomirski Date: Thu, 16 Feb 2017 13:54:35 -0800 Message-Id: <20170216215438.126111-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-doc@vger.kernel.org, linux-kernel@vger.kernel.org, lguest@lists.ozlabs.org, kernel-hardening@lists.openwall.com, xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH v4 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 --- Documentation/x86/x86_64/mm.txt | 5 ++++- arch/x86/include/asm/pgtable_64_types.h | 3 ++- 2 files changed, 6 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)