From patchwork Wed Mar 2 08:47:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 63379 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2267054lbc; Wed, 2 Mar 2016 00:49:02 -0800 (PST) X-Received: by 10.67.23.161 with SMTP id ib1mr35544649pad.156.1456908542378; Wed, 02 Mar 2016 00:49:02 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id rw10si7299955pac.147.2016.03.02.00.49.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Mar 2016 00:49:02 -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 1ab2Rc-0000ip-H1; Wed, 02 Mar 2016 08:47:44 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ab2RZ-0000Vw-4f for linux-arm-kernel@lists.infradead.org; Wed, 02 Mar 2016 08:47:42 +0000 Received: by mail-wm0-x22d.google.com with SMTP id p65so69518355wmp.1 for ; Wed, 02 Mar 2016 00:47:19 -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; bh=jN+A2FL0ZRLzHqhwVYb9y/rHnMimUqn/iMHNEaTeVeU=; b=bYIVzG8tCWo68R3OtD8crCiD5g2h7+FnWrbwvLejavk70l73sSbbsW5Aomy9Y6XUbj qbnzBcyNLxJd5SxN+55KT+1PpjlIkItOcKB5u1tVMokzcx6MekJLZulkBFrYKFBTLbpr EyGSipVMJoQcTPncHTjkSe1kdxQH3F2zjT0n8= 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; bh=jN+A2FL0ZRLzHqhwVYb9y/rHnMimUqn/iMHNEaTeVeU=; b=L/DIg0/ylaRV4AbXRFCrB1btsVcKA5TNmn1BCgoLAeequ5WQSJZKUd1TRM37/NeuOI ORtQaNivE05zt0egYj8jNRZj2dkfFcas6D+kVIdV7+1c0ESHeGPDKw79Ww4doMAUx/8x ZfUksXvRNA9ZKTDGZuXjiYlXbI73Lb6g33D9dy+9uVhuRa0olnJv0sP2/M0pf4rmoqIl mncbcVDR9jnuGbJYyxII0wZcmjTDESxMnC7aG7QJhKXKQeQPGeKsk9HcvNLxyW0JkGfL v4/DhhY1z0zsnJEco8KO1iPHcHXt4k1pQemBo6TfJ/iwrACeh9Oothinp9H6heDkoVq1 BWuQ== X-Gm-Message-State: AD7BkJKO7wSzhUtejLIBmoNvwB7FCnCHKsd5polUT9dUo1QiwSKYxAHdfMhaH6bD3py3bocl X-Received: by 10.28.221.136 with SMTP id u130mr3212134wmg.40.1456908438629; Wed, 02 Mar 2016 00:47:18 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id c128sm3024445wma.11.2016.03.02.00.47.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Mar 2016 00:47:17 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com Subject: [PATCH] arm64: mm: check at build time that PAGE_OFFSET divides the VA space evenly Date: Wed, 2 Mar 2016 09:47:13 +0100 Message-Id: <1456908433-27149-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160302_004741_487911_7FBACA90 X-CRM114-Status: GOOD ( 11.68 ) 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:22d 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_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 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 Commit 8439e62a1561 ("arm64: mm: use bit ops rather than arithmetic in pa/va translations") changed the boundary check against PAGE_OFFSET from an arithmetic comparison to a bit test. This means we now silently assume that PAGE_OFFSET is a power of 2 that divides the kernel virtual address space into two equal halves. So make that assumption explicit. Signed-off-by: Ard Biesheuvel --- arch/arm64/mm/init.c | 7 +++++++ 1 file changed, 7 insertions(+) -- 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/mm/init.c b/arch/arm64/mm/init.c index 9cfe94b41b54..ea136b904f56 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -171,6 +171,13 @@ void __init arm64_memblock_init(void) const s64 linear_region_size = -(s64)PAGE_OFFSET; /* + * Ensure that the linear region takes up exactly half of the kernel + * virtual address space. This way, we can distinguish a linear address + * from a kernel/module/vmalloc address by testing a single bit. + */ + BUILD_BUG_ON(linear_region_size != BIT(VA_BITS - 1)); + + /* * Select a suitable value for the base of physical memory. */ memstart_addr = round_down(memblock_start_of_DRAM(),