From patchwork Wed Feb 24 16:21:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 62803 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp2501236lbl; Wed, 24 Feb 2016 08:26:03 -0800 (PST) X-Received: by 10.98.75.196 with SMTP id d65mr56063791pfj.96.1456331163501; Wed, 24 Feb 2016 08:26:03 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id 86si5854495pfl.78.2016.02.24.08.26.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Feb 2016 08:26:03 -0800 (PST) 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; 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; dkim=neutral (body hash did not verify) header.i=@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 1aYcEx-0007kz-KG; Wed, 24 Feb 2016 16:24:39 +0000 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aYcCb-0005X5-3O for linux-arm-kernel@lists.infradead.org; Wed, 24 Feb 2016 16:22:17 +0000 Received: by mail-wm0-x22c.google.com with SMTP id g62so37418795wme.0 for ; Wed, 24 Feb 2016 08:21:52 -0800 (PST) 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=ydH/g3wjTuGYcuxZPPuc/43SUwEJENT1O6FgieslRCM=; b=WUa5cH8lKxvROoimcwt9gIz3CKNlkiLM08Da/UZ5vpifw5dSkUJru2y7taOItXumcE +46v85l0yztobY11JoWsyB5a0MSTrIV8cCNUq4pEIMlXicOWusFl6gz+2dLh1WGSBcsx tXU4joNoW4mZeOh2bxedCV0BFtNxGFPnyeUU8= 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=ydH/g3wjTuGYcuxZPPuc/43SUwEJENT1O6FgieslRCM=; b=OPcwsPuVujkQpWHhFLaaGP90w6UY1b5CN0WuhkXko/rtMgJMKOPLELM62QT1lHTlLQ N+oBSXhJOYj611nA0hwdZnmdvv7YukB7/C9acmrlwkMImFVpUTuRE4ysXSByn8hFD1g3 UyMIfXxzM7sWfE059ckjfGhSuJQpuziFOAw4MKn+KzUWSPN0RONlM9CfeeeMDk+x0ipv jYaxOG8AGJHpm0ayK1Pt44e9E3LH9CB5K+cB7jZqIKaCN44ahE7GcegPjeGgJI+muMWI QgI7VFdG2BV5GEWTaB8uzxWnXGY6ZnO1jR7xXVyStCb1GzTN8U+lYmF5iCL0RSVJKwj9 wcpA== X-Gm-Message-State: AG10YOQgmnANg2ubu4oRTX0P4olkIahOugk05I/wRbCrEBCeDXZHNCLdzJhgbsJSc8h64haf X-Received: by 10.28.54.197 with SMTP id y66mr23738063wmh.16.1456330911168; Wed, 24 Feb 2016 08:21:51 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id gb9sm3730412wjb.26.2016.02.24.08.21.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 Feb 2016 08:21:50 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will.deacon@arm.com Subject: [RFC PATCH 6/6] arm64: mm: disregard PHYS_OFFSET in virt_to_page() Date: Wed, 24 Feb 2016 17:21:33 +0100 Message-Id: <1456330893-19228-7-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1456330893-19228-1-git-send-email-ard.biesheuvel@linaro.org> References: <1456330893-19228-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160224_082213_744231_12194FC4 X-CRM114-Status: GOOD ( 11.42 ) 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:22c 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_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -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, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org The mm layer makes heavy use of virt_to_page(), which translates from virtual addresses to offsets in the struct page array using an intermediate translation to physical addresses. However, these physical translations are based on the actual placement of physical memory, which can only be discovered at runtime. This means virt_to_page() translations involve a global PHYS_OFFSET variable, and hence a memory access. 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 implementation of virt_to_page(), which means we can get rid of the memory access. 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 | 9 ++++++++- 1 file changed, 8 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 eb798156cf56..9d4b7733caa3 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -189,8 +189,15 @@ 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_page(kaddr) ((struct page *)VMEMMAP_START + \ + (((u64)(kaddr) & ~PAGE_OFFSET) >> PAGE_SHIFT)) +#define virt_addr_valid(kaddr) pfn_valid((((u64)(kaddr) & ~PAGE_OFFSET) \ + + PHYS_OFFSET) >> PAGE_SHIFT) +#endif #endif