From patchwork Wed Sep 3 21:57: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: 36666 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4E85A204FF for ; Wed, 3 Sep 2014 21:59:24 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id tr6sf47306082ieb.10 for ; Wed, 03 Sep 2014 14:59:24 -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=YahmlYeoAMqMZmZUX/fyF48TTaYZfMnTD0Z0v6+Tq9bv2LtP+x+d7k896I9obOBDea hEmgS+bGjMqvjnR3VuGE8pUKraDqNikaytCE26/I+GCmnydC6nHXdHRlqxRmrTkHbdCb av0Cj86mLqn0saWcfiYIo9TY3zuYv7J2aSd/3dzG4E69wZqqSMOzPaGY2SzGaKZE97aP vSPEBrTFErITMcHxNHSi5uoSjlUXkC9LYugLmfLPvpFjZx290u93caPj1+hKeH2B5if+ C/TXRYdJ7qMkL0Jyx1i/KXXErUaM6dVLr7gXATE4fzSgrJz075+6f2LBXhwGIh4GZ5UH DQNg== X-Gm-Message-State: ALoCoQm3ctmDteT7Fyyercb9OH74IJeKc0UsbagRflHejUUCboVyFNaMPfTOhrkfldCfV9cqE8N7 X-Received: by 10.182.129.37 with SMTP id nt5mr222263obb.8.1409781564012; Wed, 03 Sep 2014 14:59:24 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.21.50 with SMTP id 47ls33143qgk.6.gmail; Wed, 03 Sep 2014 14:59:23 -0700 (PDT) X-Received: by 10.52.26.206 with SMTP id n14mr183848vdg.0.1409781563786; Wed, 03 Sep 2014 14:59:23 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id pr2si1788481vdb.23.2014.09.03.14.59.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Sep 2014 14:59:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id la4so9776312vcb.29 for ; Wed, 03 Sep 2014 14:59:23 -0700 (PDT) X-Received: by 10.52.120.51 with SMTP id kz19mr44872vdb.95.1409781563705; Wed, 03 Sep 2014 14:59:23 -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.45.67 with SMTP id uj3csp744086vcb; Wed, 3 Sep 2014 14:59:23 -0700 (PDT) X-Received: by 10.66.66.6 with SMTP id b6mr327018pat.51.1409781561715; Wed, 03 Sep 2014 14:59:21 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ts7si13483304pbc.116.2014.09.03.14.59.21 for ; Wed, 03 Sep 2014 14:59:21 -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 S932828AbaICV7M (ORCPT + 26 others); Wed, 3 Sep 2014 17:59:12 -0400 Received: from smtp.outflux.net ([198.145.64.163]:60822 "EHLO smtp.outflux.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932433AbaICV7A (ORCPT ); Wed, 3 Sep 2014 17:59:00 -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 s83LvH4l004771; Wed, 3 Sep 2014 14:57:17 -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 v5 1/8] arm: use generic fixmap.h Date: Wed, 3 Sep 2014 14:57:02 -0700 Message-Id: <1409781429-27593-2-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1409781429-27593-1-git-send-email-keescook@chromium.org> References: <1409781429-27593-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.170 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