From patchwork Fri Jan 20 16:41:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9528971 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 B23BB601AE for ; Fri, 20 Jan 2017 16:42:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC0DC28645 for ; Fri, 20 Jan 2017 16:42:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE1F428665; Fri, 20 Jan 2017 16:42:34 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 666B628645 for ; Fri, 20 Jan 2017 16:42:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753184AbdATQlx (ORCPT ); Fri, 20 Jan 2017 11:41:53 -0500 Received: from mail-pg0-f47.google.com ([74.125.83.47]:34179 "EHLO mail-pg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752836AbdATQlt (ORCPT ); Fri, 20 Jan 2017 11:41:49 -0500 Received: by mail-pg0-f47.google.com with SMTP id 14so24854617pgg.1 for ; Fri, 20 Jan 2017 08:41:49 -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=ZBbUmGv1kNK1tCawr8DWDAgnzvYps4JUV69Po7TEnHM=; b=ENtqBDwdqtBuOvA2fapHUtS2UY1FXa0JT1x3DpDawBrcz1WL+cnod4OMo7dLux00FJ eQbifG7BxBLmLnuuLYrtuu8bvFV2s7IycYohF38/idRrQ40KIOAxs7rEjO2Uw0A/RUls EuRA24b3e40Wow183bD3wvv3OT9h4Hz4IIl0jj1C3kWs4fpS3hcoP9XYBYmGK9O2Uagv G6PtJohUcWCHETRofukKI6fKRfx75+mwPFmb6CHByXj40MSKk2GzZlkVb/ZxC8Dr5LVA UQKwamRmOBjHbqJzugiTczL/V0EFk6IFLdmBgOkeSe2lUnaSrDhNatM7heIeTTBefoU+ MXRg== 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=ZBbUmGv1kNK1tCawr8DWDAgnzvYps4JUV69Po7TEnHM=; b=K8xGqk5hCP67qkAcLmehBJGKb/zJX6Xc8nPG/fj6xgW1wBu9uOvmmYpAuXXja/M0Ia 6lR/En+oKt945dpp++vwvulVmMHURf9i6/FUwPezoVpEEXdtUdS/lscf85vo+XRQDiNS yUYLwDsTedm5KIAHpXA1LJcR+WAZ314XUPSvIdpRw2AJjE1fVF6DQudGEzTXir6YQ/2/ apkHXE9PSDBh0jSsvzWxRBuGNuAEejX4SW4411SoC7BP6lg/JfNdSMxOGBbryTBF1k7L FEGpMed8MNp+uv9/2Ba1FpcEXPwt1GwwSlV1MRvKflN7RiNGX2fU6CPbGLvuXY1Bm1pN L6pw== X-Gm-Message-State: AIkVDXL4Aki0uYKirAt1XCdH4x2xvWlZJvhGFsPKd/0Rl45ZcZx8bG4jLgO3LFlh0W/aUUXk X-Received: by 10.84.202.163 with SMTP id x32mr23127645pld.46.1484930509017; Fri, 20 Jan 2017 08:41:49 -0800 (PST) Received: from skynet.sea.corp.google.com ([100.100.206.185]) by smtp.gmail.com with ESMTPSA id v186sm18085415pgv.44.2017.01.20.08.41.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 Jan 2017 08:41:48 -0800 (PST) From: Thomas Garnier To: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Thomas Garnier , Kees Cook , "Rafael J . Wysocki" , Pavel Machek , Andy Lutomirski , Borislav Petkov , Christian Borntraeger , Brian Gerst , He Chen , Dave Hansen , Chen Yucong , Baoquan He , Paul Gortmaker , Joerg Roedel , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Fenghua Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, kvm@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: [PATCH v1 1/3] x86/mm: Adapt MODULES_END based on Fixmap section size Date: Fri, 20 Jan 2017 08:41:24 -0800 Message-Id: <20170120164126.27624-1-thgarnie@google.com> X-Mailer: git-send-email 2.11.0.483.g087da7b7c-goog Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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-20170119 --- arch/x86/include/asm/fixmap.h | 8 ++++++++ arch/x86/include/asm/pgtable_64_types.h | 3 --- 2 files changed, 8 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))