From patchwork Thu Sep 18 19:19:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 37604 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D36B72054D for ; Thu, 18 Sep 2014 19:21:49 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id 10sf610887lbg.1 for ; Thu, 18 Sep 2014 12:21:48 -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=uilePqzx8lMMFCtx5pk/cqaLc6Nl4SimoO57r9DamCE=; b=KJXMDX5web+WJDJPLH8JTZwrBqduR4tmcwAsxz3b2WKKalShi5Z8CVn2m2uSWKMeKF +KXk01GguNm4viiQhWrJmmdAycF/rl6k4Gw1pY0QQ3DGB0B0eQSbRq/7Zl+fyi7VOhC1 8E04p9LO9qyIAHUEBe7/7ZPxQr44MMIoexZl4FBTweJDuyywU1Pzof7Q0L5fkq1d5tN0 OYRhObSKBoqE66bY7/LNGoesB1WH8oCOQLxtSpovN34hX+95jPhuuf2FWzb4lSAHtsCW tetPXdaXtYtIqVgHz+/vTpVkEs4Ujn1GPX6CkMtDEvsrPy7rSHvqeAew24y+ymzhVE6k ilGA== X-Gm-Message-State: ALoCoQlGhfoXCPWtidz+qikKr3vZJnfMfWMqaqv/JoGDVqVDskuSD6WXXl62aUKvAD+iqE9cfw9S X-Received: by 10.152.19.131 with SMTP id f3mr1159552lae.0.1411068108228; Thu, 18 Sep 2014 12:21:48 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.134 with SMTP id b6ls264515lah.42.gmail; Thu, 18 Sep 2014 12:21:48 -0700 (PDT) X-Received: by 10.152.1.6 with SMTP id 6mr2009576lai.22.1411068108060; Thu, 18 Sep 2014 12:21:48 -0700 (PDT) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com [209.85.217.172]) by mx.google.com with ESMTPS id d6si34217949lbe.13.2014.09.18.12.21.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Sep 2014 12:21:48 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by mail-lb0-f172.google.com with SMTP id p9so1194442lbv.31 for ; Thu, 18 Sep 2014 12:21:48 -0700 (PDT) X-Received: by 10.152.7.8 with SMTP id f8mr1775956laa.27.1411068107976; Thu, 18 Sep 2014 12:21:47 -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.112.130.169 with SMTP id of9csp818429lbb; Thu, 18 Sep 2014 12:21:47 -0700 (PDT) X-Received: by 10.70.49.34 with SMTP id r2mr10044110pdn.134.1411068105948; Thu, 18 Sep 2014 12:21:45 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id jd9si41204415pbd.114.2014.09.18.12.21.45 for ; Thu, 18 Sep 2014 12:21:45 -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 S1756500AbaIRTV2 (ORCPT + 27 others); Thu, 18 Sep 2014 15:21:28 -0400 Received: from smtp.outflux.net ([198.145.64.163]:39639 "EHLO smtp.outflux.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756160AbaIRTVY (ORCPT ); Thu, 18 Sep 2014 15:21:24 -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 s8IJJGxm017057; Thu, 18 Sep 2014 12:19:16 -0700 From: Kees Cook To: linux-kernel@vger.kernel.org Cc: Kees Cook , Mark Salter , Laura Abbott , Rob Herring , Will Deacon , Rabin Vincent , Leif Lindholm , Liu hua , Nikolay Borisov , Nicolas Pitre , Doug Anderson , Jason Wessel , Catalin Marinas , Russell King - ARM Linux , linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 1/8] arm: use generic fixmap.h Date: Thu, 18 Sep 2014 12:19:02 -0700 Message-Id: <1411067949-10913-2-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1411067949-10913-1-git-send-email-keescook@chromium.org> References: <1411067949-10913-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.217.172 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 Acked-by: Nicolas Pitre --- 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