From patchwork Wed Mar 30 14:46:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 64711 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2640169lbc; Wed, 30 Mar 2016 07:50:11 -0700 (PDT) X-Received: by 10.66.141.76 with SMTP id rm12mr14066530pab.30.1459349411031; Wed, 30 Mar 2016 07:50:11 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id o4si6961419pfj.169.2016.03.30.07.50.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Mar 2016 07:50:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1alHQa-0001aj-JH; Wed, 30 Mar 2016 14:49:00 +0000 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1alHOS-0008CL-HF for linux-arm-kernel@lists.infradead.org; Wed, 30 Mar 2016 14:46:51 +0000 Received: by mail-wm0-x233.google.com with SMTP id p65so75393136wmp.0 for ; Wed, 30 Mar 2016 07:46:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=v92zz1nmC3FFjWPOzv+OkMCAYFnyAh9UsI95phoO0Zw=; b=LRp1gVzGRyl1EUk7iuGXeVcGjqMziXoPulGxD+qIGNoM0whTWKLysUB0wjJmjNdF9X DjEPF8IGfeerREAN/aNYwjHerxR5fq4ZG5Qcj5++Muied0i2Wcw8Iq3cDpNiygxHNQ7w LpSGcXfXFxiqT+cBM2pmEFOYfwN4c3QcAo0hQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=v92zz1nmC3FFjWPOzv+OkMCAYFnyAh9UsI95phoO0Zw=; b=TgiQJfTzp29ozJq2G+l0EamiF6Hok/4DZkF6M1Lm4I7mwVuZsiu65LBaI6Ik52jJSE Jtbe7XKbHoKhkfUXNuuaR61RlgMbOT/mSDOm40+qxGahxxtO9GQu8xlTdK456060MaVw vZJBJy67IJsOJ8DSpo+mHmafsFdHh788bMHTG/9vRAyaTkCZXC+cwPeikTiDCCkE/Ue3 dC4GEpWsv3Bc38YJGpOMlOlx/HjdbGLyLf/hLu7GCbrgUsQmRugfl61JhsRt8Nwiuenl yJjNaVHg2xEie/yZXkJsyVQk9EfABK0tMcpmm9Dci8DQLhReNsrT+DPiUzSPwTqauiT/ voog== X-Gm-Message-State: AD7BkJLrpZEIVuVGDPVECpjQd9d0M7YQTmW9ogxBcWEgb32Mx0a5pTBu56qCUN5KqMU2IwiC X-Received: by 10.28.19.204 with SMTP id 195mr25253044wmt.1.1459349186988; Wed, 30 Mar 2016 07:46:26 -0700 (PDT) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id i5sm4325336wjx.15.2016.03.30.07.46.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Mar 2016 07:46:26 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will.deacon@arm.com, linux-mm@kvack.org, akpm@linux-foundation.org, nios2-dev@lists.rocketboards.org, lftan@altera.com, jonas@southpole.se, linux@lists.openrisc.net Subject: [PATCH v2 6/9] arm64: mm: restrict virt_to_page() to the linear mapping Date: Wed, 30 Mar 2016 16:46:01 +0200 Message-Id: <1459349164-27175-7-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459349164-27175-1-git-send-email-ard.biesheuvel@linaro.org> References: <1459349164-27175-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160330_074648_900693_0244B633 X-CRM114-Status: GOOD ( 10.14 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:233 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, steve.capper@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Now that the vmemmap region has been redefined to cover the linear region rather than the entire physical address space, we no longer need to perform a virtual-to-physical translation in the implementaion of virt_to_page(). This restricts virt_to_page() translations to the linear region, so redefine virt_addr_valid() as well. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/memory.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) -- 2.5.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index 8a2ab195ca77..f412f502ccdd 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -208,9 +208,19 @@ static inline void *phys_to_virt(phys_addr_t x) */ #define ARCH_PFN_OFFSET ((unsigned long)PHYS_PFN_OFFSET) +#ifndef CONFIG_SPARSEMEM_VMEMMAP #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) -#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) +#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) +#else +#define __virt_to_pgoff(kaddr) (((u64)(kaddr) & ~PAGE_OFFSET) / PAGE_SIZE * sizeof(struct page)) +#define __page_to_voff(kaddr) (((u64)(page) & ~VMEMMAP_START) * PAGE_SIZE / sizeof(struct page)) + +#define page_to_virt(page) ((void *)((__page_to_voff(page)) | PAGE_OFFSET)) +#define virt_to_page(vaddr) ((struct page *)((__virt_to_pgoff(vaddr)) | VMEMMAP_START)) +#define virt_addr_valid(kaddr) pfn_valid((((u64)(kaddr) & ~PAGE_OFFSET) \ + + PHYS_OFFSET) >> PAGE_SHIFT) +#endif #endif #include