From patchwork Wed Aug 6 19:32:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 34988 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 42B7321137 for ; Wed, 6 Aug 2014 19:36:35 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id la4sf8226333vcb.6 for ; Wed, 06 Aug 2014 12:36:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=6WIKUsD1/pxQF6fXpQkl0RZaWoaC1A1P37iTOa3Ntp8=; b=J/xrOYSA7SWR3iiN9GcOi1i4JiUoD3VQTIDNEU7I6DwRdeSSxu1cHu0c4CRGQYa9Ry feXiWjdTpiO+SDpKPOVKB8l0nNhBOiWgr4Bp1wQBGc4/RvkC5tS/VvPqbfaxQcpLTQ5r 7vLyOv5KywO1jrJBGjrKvWg158Qp0rDs/J4ckLqPzkyxOREviEeTKpktR0zcxcLNMwaQ QNnRl6LaiYBV+KVlPRI6JEnyEPrteIvvlYUp5bSkoWgrZeM67WALhBTKfZhgqzxs0zmQ 2FhXNPIMuIZ1+euVBYastJOiFh35tSxXqUSNKhhlpnKpKyj6zGdYQGss/TOjsNprbAEO DlKA== X-Gm-Message-State: ALoCoQm2JwYkrT4eInqgh7Yhg0ylLgB8f6ZgIAAtdObhpKaA5akzOCccyldEJ3IAgnbAeCfYKUuX X-Received: by 10.52.145.161 with SMTP id sv1mr6694845vdb.7.1407353795090; Wed, 06 Aug 2014 12:36:35 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.103.67 with SMTP id x61ls351375qge.41.gmail; Wed, 06 Aug 2014 12:36:34 -0700 (PDT) X-Received: by 10.220.144.10 with SMTP id x10mr12663810vcu.42.1407353794915; Wed, 06 Aug 2014 12:36:34 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id qu14si886691vdb.23.2014.08.06.12.36.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 06 Aug 2014 12:36:34 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id la4so4769066vcb.23 for ; Wed, 06 Aug 2014 12:36:34 -0700 (PDT) X-Received: by 10.52.137.2 with SMTP id qe2mr10700088vdb.11.1407353794806; Wed, 06 Aug 2014 12:36:34 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp49926vcb; Wed, 6 Aug 2014 12:36:34 -0700 (PDT) X-Received: by 10.68.68.133 with SMTP id w5mr4833533pbt.166.1407353793580; Wed, 06 Aug 2014 12:36:33 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l9si815951pdr.114.2014.08.06.12.36.32 for ; Wed, 06 Aug 2014 12:36:33 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757209AbaHFTgb (ORCPT + 26 others); Wed, 6 Aug 2014 15:36:31 -0400 Received: from smtp.outflux.net ([198.145.64.163]:40277 "EHLO smtp.outflux.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757108AbaHFTfo (ORCPT ); Wed, 6 Aug 2014 15:35:44 -0400 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 s76JWpoe004029; Wed, 6 Aug 2014 12:32:51 -0700 From: Kees Cook To: linux-kernel@vger.kernel.org Cc: Kees Cook , Mark Salter , Liu hua , Rabin Vincent , Nikolay Borisov , Nicolas Pitre , Leif Lindholm , Tomasz Figa , Rob Herring , Doug Anderson , Will Deacon , Laura Abbott , Catalin Marinas , Russell King - ARM Linux , linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/7] arm: use generic fixmap.h Date: Wed, 6 Aug 2014 12:32:38 -0700 Message-Id: <1407353564-21478-2-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 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: keescook@chromium.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Mark Salter ARM is different from other architectures in that fixmap pages are indexed with a positive offset from FIXADDR_START. Other architectures index with a negative offset from FIXADDR_TOP. In order to use the generic fixmap.h definitions, this patch redefines FIXADDR_TOP to be inclusive of the useable range. That is, FIXADDR_TOP is the virtual address of the topmost fixed page. The newly defined FIXADDR_END is the first virtual address past the fixed mappings. Signed-off-by: Mark Salter Reviewed-by: Doug Anderson [update for "ARM: 8031/2: change fixmap mapping region to support 32 CPUs"] Signed-off-by: Kees Cook --- arch/arm/include/asm/fixmap.h | 27 +++++++++------------------ arch/arm/mm/init.c | 2 +- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/arch/arm/include/asm/fixmap.h b/arch/arm/include/asm/fixmap.h index 74124b0d0d79..190142d174ee 100644 --- a/arch/arm/include/asm/fixmap.h +++ b/arch/arm/include/asm/fixmap.h @@ -2,27 +2,18 @@ #define _ASM_FIXMAP_H #define FIXADDR_START 0xffc00000UL -#define FIXADDR_TOP 0xffe00000UL -#define FIXADDR_SIZE (FIXADDR_TOP - FIXADDR_START) +#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) -#define __fix_to_virt(x) (FIXADDR_START + ((x) << PAGE_SHIFT)) -#define __virt_to_fix(x) (((x) - FIXADDR_START) >> PAGE_SHIFT) +enum fixed_addresses { + FIX_KMAP_BEGIN, + FIX_KMAP_END = FIX_KMAP_NR_PTES - 1, + __end_of_fixed_addresses +}; -extern void __this_fixmap_does_not_exist(void); - -static inline unsigned long fix_to_virt(const unsigned int idx) -{ - if (idx >= FIX_KMAP_NR_PTES) - __this_fixmap_does_not_exist(); - return __fix_to_virt(idx); -} - -static inline unsigned int virt_to_fix(const unsigned long vaddr) -{ - BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START); - return __virt_to_fix(vaddr); -} +#include #endif diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 659c75d808dc..ad82c05bfc3a 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -570,7 +570,7 @@ void __init mem_init(void) MLK(DTCM_OFFSET, (unsigned long) dtcm_end), MLK(ITCM_OFFSET, (unsigned long) itcm_end), #endif - MLK(FIXADDR_START, FIXADDR_TOP), + MLK(FIXADDR_START, FIXADDR_END), MLM(VMALLOC_START, VMALLOC_END), MLM(PAGE_OFFSET, (unsigned long)high_memory), #ifdef CONFIG_HIGHMEM