From patchwork Wed Aug 13 17:06:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 35384 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f70.google.com (mail-pa0-f70.google.com [209.85.220.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5415F203C5 for ; Wed, 13 Aug 2014 17:08:15 +0000 (UTC) Received: by mail-pa0-f70.google.com with SMTP id lf10sf216517pab.9 for ; Wed, 13 Aug 2014 10:08:14 -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=0vXTKsPurrncMeTJ0gtw4RxaJtLC1RVK3fT0gbeZRMI=; b=YgHIVcXm9rkl1XLMXV2jywFVU1jQaxTJkfIgn55BJC0UveWF+1qlHF560lnXVY3NB8 zHx1iiiHZu9FT7nV0GFjMhsQbr90hRqBDElRzEvO4Tdi2pEJa01IOFyKF14VhhhDXyZK BCRw1Iql8CxHK0p6BUzkdmUHwxXsNt5t5vDWqi9AF16Uts8SS9VcggBrvjT6ZVxhcu8o 9YiwuLnt0lKjxdy85hayNsyfy4bYtHyNaly5MEjn7TZL3DBjBZNYJ09t5yXekWsIUxHi D+qvhkuD/a8+pWa6gJuAECe0TCfytic2kL2qw0YQ0UnssmGCwcFjnAPsEgV2NCfmlFtt 385A== X-Gm-Message-State: ALoCoQkL2VJd13RJYHHUeHK7U2ESCUBjrKfEQ6H00yy+7zLh3FcRtwBvB8At0MXQCNLn9krWImAI X-Received: by 10.66.160.164 with SMTP id xl4mr423169pab.48.1407949694655; Wed, 13 Aug 2014 10:08:14 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.83.230 with SMTP id j93ls77036qgd.40.gmail; Wed, 13 Aug 2014 10:08:14 -0700 (PDT) X-Received: by 10.220.59.138 with SMTP id l10mr2080339vch.59.1407949694434; Wed, 13 Aug 2014 10:08:14 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id r6si1476040vcu.14.2014.08.13.10.08.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 13 Aug 2014 10:08:14 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id ik5so41066vcb.20 for ; Wed, 13 Aug 2014 10:08:14 -0700 (PDT) X-Received: by 10.52.94.108 with SMTP id db12mr464532vdb.8.1407949694362; Wed, 13 Aug 2014 10:08:14 -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 tc5csp346763vcb; Wed, 13 Aug 2014 10:08:13 -0700 (PDT) X-Received: by 10.67.5.36 with SMTP id cj4mr5246642pad.9.1407949692891; Wed, 13 Aug 2014 10:08:12 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id kj10si1944847pbd.63.2014.08.13.10.08.12 for ; Wed, 13 Aug 2014 10:08:12 -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 S1753709AbaHMRHh (ORCPT + 25 others); Wed, 13 Aug 2014 13:07:37 -0400 Received: from smtp.outflux.net ([198.145.64.163]:60067 "EHLO smtp.outflux.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753396AbaHMRHe (ORCPT ); Wed, 13 Aug 2014 13:07:34 -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 s7DH6akG031356; Wed, 13 Aug 2014 10:06:36 -0700 From: Kees Cook To: linux-kernel@vger.kernel.org Cc: Kees Cook , Mark Salter , Laura Abbott , Rob Herring , Leif Lindholm , Stephen Boyd , Rabin Vincent , Liu hua , Nikolay Borisov , Nicolas Pitre , Tomasz Figa , Doug Anderson , Jason Wessel , Will Deacon , Catalin Marinas , Russell King - ARM Linux , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org Subject: [PATCH v4 1/8] arm: use generic fixmap.h Date: Wed, 13 Aug 2014 10:06:26 -0700 Message-Id: <1407949593-16121-2-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1407949593-16121-1-git-send-email-keescook@chromium.org> References: <1407949593-16121-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.175 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 [kees: update for a05e54c103b0 "ARM: 8031/2: change fixmap ..."] Signed-off-by: Kees Cook Cc: Laura Abbott Cc: Rob Herring --- 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..a7add6f9315d 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 FIX_KMAP_NR_PTES (FIXADDR_SIZE >> PAGE_SHIFT) +#include -#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_BEGIN + (KM_TYPE_NR * NR_CPUS) - 1, -extern void __this_fixmap_does_not_exist(void); + __end_of_fixed_addresses +}; -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