From patchwork Thu Aug 7 15:01:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 35049 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f199.google.com (mail-pd0-f199.google.com [209.85.192.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 15B6721457 for ; Thu, 7 Aug 2014 15:04:04 +0000 (UTC) Received: by mail-pd0-f199.google.com with SMTP id ft15sf24503780pdb.2 for ; Thu, 07 Aug 2014 08:04:03 -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=oJxrWf8lzaON5M+kBVFuh+gYt8RFEkpSg9dZBjVk880=; b=VYVOaprcJ4YkeHh2fw43Sqi/5jdASJJYfc6i/B5C2vcbCdxEbj9Ue56w8mNCORinV8 OeSN+XM5Z+BcfxqPnMKhwx6U9AxEdpwyXQfXf1uxqJsNUMGSTgELDwu9uiQfQWNXXT6L xdaou9YHl3NUUROZmsFccVd9TbzPQZVnrUzG2gr2/3nGByyq7HsAwiZd8tsSPcqzFuED 20G4QdpAexN+beNBb3GWXbJpzsk0AYIJB6oWDYuPxQPd/v4Gm4uWUuh7NkVtaY7NSBjf lIWMZ6mMQf/ZXrTOA2q93TNO0WB9swUcsUpArbEYWfuO98kYqdvmN3U1CQO8KfoEgEe7 wxcw== X-Gm-Message-State: ALoCoQmrGb1HckyRQhvGvRvez3aH9XndIopa27EOqTDBkd+iBUfowYpLUpYULWsc12ITP+1iEpyV X-Received: by 10.66.189.106 with SMTP id gh10mr115132pac.23.1407423843390; Thu, 07 Aug 2014 08:04:03 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.109.196 with SMTP id l62ls168425qgf.83.gmail; Thu, 07 Aug 2014 08:04:03 -0700 (PDT) X-Received: by 10.221.68.135 with SMTP id xy7mr803682vcb.65.1407423843284; Thu, 07 Aug 2014 08:04:03 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id g14si1863586vdh.66.2014.08.07.08.04.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 07 Aug 2014 08:04:03 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.172 as permitted sender) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id im17so6461268vcb.31 for ; Thu, 07 Aug 2014 08:04:03 -0700 (PDT) X-Received: by 10.221.5.137 with SMTP id og9mr15840882vcb.18.1407423843199; Thu, 07 Aug 2014 08:04:03 -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 tc5csp37303vcb; Thu, 7 Aug 2014 08:04:01 -0700 (PDT) X-Received: by 10.70.22.163 with SMTP id e3mr2503193pdf.157.1407423840983; Thu, 07 Aug 2014 08:04:00 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id mx10si156380pdb.66.2014.08.07.08.03.59 for ; Thu, 07 Aug 2014 08:04:00 -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 S932479AbaHGPDj (ORCPT + 26 others); Thu, 7 Aug 2014 11:03:39 -0400 Received: from smtp.outflux.net ([198.145.64.163]:42470 "EHLO smtp.outflux.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932071AbaHGPDg (ORCPT ); Thu, 7 Aug 2014 11:03:36 -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 s77F2gNB020929; Thu, 7 Aug 2014 08:02:42 -0700 From: Kees Cook To: linux-kernel@vger.kernel.org Cc: Kees Cook , Mark Salter , Laura Abbott , Liu hua , Rabin Vincent , Nikolay Borisov , Nicolas Pitre , Leif Lindholm , Tomasz Figa , Rob Herring , Doug Anderson , Jason Wessel , Will Deacon , Catalin Marinas , Russell King - ARM Linux , linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/8] arm: use generic fixmap.h Date: Thu, 7 Aug 2014 08:01:46 -0700 Message-Id: <1407423713-4160-2-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1407423713-4160-1-git-send-email-keescook@chromium.org> References: <1407423713-4160-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.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 [update for "ARM: 8031/2: change fixmap mapping region to support 32 CPUs"] [flipped highmem order, thanks to Laura Abbott] Signed-off-by: Kees Cook Cc: Laura Abbott Tested-by: Leif Lindholm --- arch/arm/include/asm/fixmap.h | 27 +++++++++------------------ arch/arm/mm/highmem.c | 8 ++++++-- arch/arm/mm/init.c | 2 +- 3 files changed, 16 insertions(+), 21 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/highmem.c b/arch/arm/mm/highmem.c index 45aeaaca9052..a1241ee8425e 100644 --- a/arch/arm/mm/highmem.c +++ b/arch/arm/mm/highmem.c @@ -23,14 +23,18 @@ pte_t *fixmap_page_table; static inline void set_fixmap_pte(int idx, pte_t pte) { unsigned long vaddr = __fix_to_virt(idx); - set_pte_ext(fixmap_page_table + idx, pte, 0); + pte_t *ppte = pte_offset_kernel(pmd_off_k(FIXADDR_START), vaddr); + + set_pte_ext(ppte, pte, 0); local_flush_tlb_kernel_page(vaddr); } static inline pte_t get_fixmap_pte(unsigned long vaddr) { unsigned long idx = __virt_to_fix(vaddr); - return *(fixmap_page_table + idx); + pte_t *ppte = pte_offset_kernel(pmd_off_k(FIXADDR_START), vaddr); + + return *ppte; } void *kmap(struct page *page) 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