From patchwork Wed Aug 6 19:32:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 4688231 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 15AC2C0338 for ; Wed, 6 Aug 2014 19:37:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2029720145 for ; Wed, 6 Aug 2014 19:37:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4E09D20138 for ; Wed, 6 Aug 2014 19:37:20 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XF6zs-0005oV-5i; Wed, 06 Aug 2014 19:35:40 +0000 Received: from smtp.outflux.net ([2001:19d0:2:6:c0de:0:736d:7470]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XF6zp-0005fU-Bz for linux-arm-kernel@lists.infradead.org; Wed, 06 Aug 2014 19:35:38 +0000 Received: from www.outflux.net (serenity.outflux.net [10.2.0.2]) by vinyl.outflux.net (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id s76JWpwC004031; Wed, 6 Aug 2014 12:32:51 -0700 From: Kees Cook To: linux-kernel@vger.kernel.org Subject: [PATCH 3/7] arm: mm: reduce fixmap kmap from 32 to 16 CPUS Date: Wed, 6 Aug 2014 12:32:40 -0700 Message-Id: <1407353564-21478-4-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1407353564-21478-1-git-send-email-keescook@chromium.org> References: <1407353564-21478-1-git-send-email-keescook@chromium.org> X-MIMEDefang-Filter: outflux$Revision: 1.316 $ X-HELO: www.outflux.net X-Scanned-By: MIMEDefang 2.73 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140806_123537_489133_60EE59DD X-CRM114-Status: GOOD ( 11.98 ) X-Spam-Score: -3.0 (---) Cc: Nicolas Pitre , Rob Herring , Laura Abbott , Kees Cook , Liu hua , Catalin Marinas , Tomasz Figa , Will Deacon , Leif Lindholm , Doug Anderson , Rabin Vincent , Nikolay Borisov , Mark Salter , Russell King - ARM Linux , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP More room is needed in the fixmap range for non-kmap fixmap entries. This reduces the kmap range from 32 to 16 CPUs. Additionally, add PTE entry for fixmap regardless of CONFIG_HIGHMEM. Signed-off-by: Kees Cook --- arch/arm/include/asm/fixmap.h | 12 ++++++++++-- arch/arm/mm/highmem.c | 2 -- arch/arm/mm/mm.h | 3 +++ arch/arm/mm/mmu.c | 5 ++++- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/arch/arm/include/asm/fixmap.h b/arch/arm/include/asm/fixmap.h index 8ee7cb4f62ca..3ed08232be55 100644 --- a/arch/arm/include/asm/fixmap.h +++ b/arch/arm/include/asm/fixmap.h @@ -1,16 +1,24 @@ #ifndef _ASM_FIXMAP_H #define _ASM_FIXMAP_H +/* + * The fixmap uses 2MB. The KMAP fixmap needs 64k per CPU, so make room for + * 16 CPUs (taking 1MB) and leave the rest for additional fixmap areas. + */ #define FIXADDR_START 0xffc00000UL #define FIXADDR_END 0xffe00000UL #define FIXADDR_TOP (FIXADDR_END - PAGE_SIZE) #define FIXADDR_SIZE (FIXADDR_END - FIXADDR_START) -#define FIX_KMAP_NR_PTES (FIXADDR_SIZE >> PAGE_SHIFT) +/* 16 PTEs per CPU (64k of 4k pages). */ +#define FIX_KMAP_NR_PTES 16 +#define FIX_KMAP_NR_CPUS 16 enum fixed_addresses { + /* Support 16 CPUs for kmap as the first region of fixmap entries. */ FIX_KMAP_BEGIN, - FIX_KMAP_END = FIX_KMAP_NR_PTES - 1, + FIX_KMAP_END = (FIX_KMAP_NR_PTES * FIX_KMAP_NR_CPUS) - 1, + __end_of_fixed_addresses }; diff --git a/arch/arm/mm/highmem.c b/arch/arm/mm/highmem.c index 45aeaaca9052..cbbef0b533d6 100644 --- a/arch/arm/mm/highmem.c +++ b/arch/arm/mm/highmem.c @@ -18,8 +18,6 @@ #include #include "mm.h" -pte_t *fixmap_page_table; - static inline void set_fixmap_pte(int idx, pte_t pte) { unsigned long vaddr = __fix_to_virt(idx); diff --git a/arch/arm/mm/mm.h b/arch/arm/mm/mm.h index ce727d47275c..c8b5b2d05b55 100644 --- a/arch/arm/mm/mm.h +++ b/arch/arm/mm/mm.h @@ -7,6 +7,9 @@ /* the upper-most page table pointer */ extern pmd_t *top_pmd; +/* The fixmap PTE. */ +extern pte_t *fixmap_page_table; + /* * 0xffff8000 to 0xffffffff is reserved for any ARM architecture * specific hacks for copying pages efficiently, while 0xffff4000 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index b005a3337bc1..8dbdadc42d75 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -53,6 +53,9 @@ EXPORT_SYMBOL(empty_zero_page); */ pmd_t *top_pmd; +/* The fixmap PTE. */ +pte_t *fixmap_page_table; + #define CPOLICY_UNCACHED 0 #define CPOLICY_BUFFERED 1 #define CPOLICY_WRITETHROUGH 2 @@ -1342,10 +1345,10 @@ static void __init kmap_init(void) #ifdef CONFIG_HIGHMEM pkmap_page_table = early_pte_alloc(pmd_off_k(PKMAP_BASE), PKMAP_BASE, _PAGE_KERNEL_TABLE); +#endif fixmap_page_table = early_pte_alloc(pmd_off_k(FIXADDR_START), FIXADDR_START, _PAGE_KERNEL_TABLE); -#endif } static void __init map_lowmem(void)