From patchwork Mon Feb 22 20:54:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 62634 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1472606lbl; Mon, 22 Feb 2016 13:00:56 -0800 (PST) X-Received: by 10.66.145.194 with SMTP id sw2mr40697083pab.69.1456174856323; Mon, 22 Feb 2016 13:00:56 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id z12si41885088pas.77.2016.02.22.13.00.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Feb 2016 13:00:56 -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 1aXxaH-0007sS-Sb; Mon, 22 Feb 2016 20:59:57 +0000 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aXxWJ-0004gq-A0 for linux-arm-kernel@lists.infradead.org; Mon, 22 Feb 2016 20:55:55 +0000 Received: by mail-wm0-x231.google.com with SMTP id g62so182029919wme.0 for ; Mon, 22 Feb 2016 12:55:34 -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=KT3r0Ri8OAqboNbyVwKXeD4py8w+Iv9k+SwpgJv95E0=; b=f0wm9KxddxOHdbv7rjO+6KMmuC2P1XsRiFLb42w1eXjYekxDkOPSwv02EoAJ1DnvAp d08Dt71IDdvcmXqKebwJyEOqowFW2DL4BwXN7EeYwWYBh42FpEb/dr/VEbtz4QN/S1b5 +m+tM8XFLA/OQk5dHzbebXfeCg48mPnHTjWXs= 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=KT3r0Ri8OAqboNbyVwKXeD4py8w+Iv9k+SwpgJv95E0=; b=MogKEvvmCVz8D+VL7eQmp2pUBI5iJkRvcSvkZIXb5IKyP6HbXCvojeqcnnsjMkz/at 8ZIfEwGXFXgwGfJn30xFjaHRz5EEdcKqfdOwlvpQtK9hSvGMW5FjSim8EFyeXcIZg03L /aSyc6bj4TaMPZPSZJ5gIeqEpYmEfpskdJF8LT2xl4Jo5+jw4CT0JQS7nlS3TWF8SMei UTIDV008FXh9PIcvCj1kov0gTUp+lX1AmxliKv41ON59xZ6KIPz4gqYA603u6ZsrTgTZ IajunhPgGx12wGFjBP0535O8O4a/CPrkTwRxGdpEKehPoQbSQ85MRQpQgNsjHhcV59rk dR5w== X-Gm-Message-State: AG10YOQYyebH4A81zcfVH/ncOKwJKdXtrwUv5SB9gg4vmyTA2VptNDljP5VFdBwJb1rb6ScQ X-Received: by 10.194.58.12 with SMTP id m12mr33596877wjq.22.1456174533534; Mon, 22 Feb 2016 12:55:33 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id k8sm15012530wjr.38.2016.02.22.12.55.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Feb 2016 12:55:32 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, will.deacon@arm.com, catalin.marinas@arm.com, mark.rutland@arm.com Subject: [RFC PATCH 10/10] arm64: mm: restrict __pa() translations to linear virtual addresses Date: Mon, 22 Feb 2016 21:54:32 +0100 Message-Id: <1456174472-30028-11-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1456174472-30028-1-git-send-email-ard.biesheuvel@linaro.org> References: <1456174472-30028-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160222_125551_742060_7E602EF6 X-CRM114-Status: GOOD ( 11.33 ) 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:231 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_AU Message has a valid DKIM or DK signature from author's domain -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 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: Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Now that we have replaced all occurrences of __pa() translations involving virtual addresses that are covered by the kernel text, we can redefine __virt_to_phys and __pa() etc to only take virtual address that are covered by the linear mapping. This means we can remove the comparison with PAGE_OFFSET in the definition of __virt_to_phys(). Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/memory.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) -- 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 56d6739430f3..3b5dc5b243ac 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -86,11 +86,14 @@ * private definitions which should NOT be used outside memory.h * files. Use virt_to_phys/phys_to_virt/__pa/__va instead. */ -#define __virt_to_phys(x) ({ \ +#ifndef CONFIG_DEBUG_VM +#define __virt_to_phys(x) (((phys_addr_t)(x) & ~PAGE_OFFSET) + PHYS_OFFSET) +#else +#define __virt_to_phys(x) ({ \ phys_addr_t __x = (phys_addr_t)(x); \ - __x & BIT(VA_BITS - 1) ? (__x & ~PAGE_OFFSET) + PHYS_OFFSET : \ - (__x - kimage_voffset); }) - + BUG_ON(__x < PAGE_OFFSET); \ + (((phys_addr_t)__x & ~PAGE_OFFSET) + PHYS_OFFSET); }) +#endif #define __phys_to_virt(x) ((unsigned long)((x) - PHYS_OFFSET) | PAGE_OFFSET) #define __kimg_to_phys(x) ((phys_addr_t)(x) - kimage_voffset) @@ -134,7 +137,6 @@ #endif #ifndef __ASSEMBLY__ -#include extern phys_addr_t memstart_addr; /* PHYS_OFFSET - the physical address of the start of memory. */