From patchwork Sat Aug 15 12:13:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 52465 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by patches.linaro.org (Postfix) with ESMTPS id 7725122AA6 for ; Sat, 15 Aug 2015 12:17:06 +0000 (UTC) Received: by lbsm2 with SMTP id m2sf34212809lbs.1 for ; Sat, 15 Aug 2015 05:17:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:cc:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=UFfKTq9td6EAu1158duFC5bXyNouUPfXQeKJExcH0eY=; b=L7RMhh96m/CSFSJdrVsXFfotw8Ds/UF7cnV/EkT3HrRSklvDvky3WUUu3XPqEk3mBT sPQLgHaFGZh2Is8iAGIvm0xmvOFJs1hMsUZHDHMzTNm+Ow7yZf1xmlFJeV0WK+xoBx+O SgVrOWYPlMfo+3EuY4+lOmaZOkoX+fjzEgALEqJiiN2t8V8cGoREl/qxbpWbaqCSly48 1GLwEOMg3CDDgoe2LAIoObDahAZzVjNQu2Gk0H8pY4ge7sWnkV9JjH3qaqbfG2k5OlNQ 354uSRsETLbBFKuFKq/DZzIpxg9JckVcSyjweI4fNs0MEZhgTcJepjs/9YXaPoBocqT0 e7qQ== X-Gm-Message-State: ALoCoQmZ8vpAqr2uEZjhl2efJD4bpAgEnKBY7R8KbbpFVTmVFvz/HqFGF0ldUAJNk+CpXb/rqVKJ X-Received: by 10.152.28.100 with SMTP id a4mr14241042lah.4.1439641025120; Sat, 15 Aug 2015 05:17:05 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.129 with SMTP id s1ls519873las.11.gmail; Sat, 15 Aug 2015 05:17:05 -0700 (PDT) X-Received: by 10.112.185.66 with SMTP id fa2mr48377806lbc.42.1439641024981; Sat, 15 Aug 2015 05:17:04 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id ld2si7884807lac.132.2015.08.15.05.17.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 Aug 2015 05:17:04 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by labd1 with SMTP id d1so56817188lab.1 for ; Sat, 15 Aug 2015 05:17:04 -0700 (PDT) X-Received: by 10.112.166.106 with SMTP id zf10mr47604829lbb.36.1439641024844; Sat, 15 Aug 2015 05:17:04 -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.112.7.198 with SMTP id l6csp293052lba; Sat, 15 Aug 2015 05:17:03 -0700 (PDT) X-Received: by 10.70.118.163 with SMTP id kn3mr93954579pdb.115.1439641022914; Sat, 15 Aug 2015 05:17:02 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id lw2si8155480pdb.44.2015.08.15.05.17.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 Aug 2015 05:17:02 -0700 (PDT) Received-SPF: pass (google.com: 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; 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 1ZQaLx-0004jN-JQ; Sat, 15 Aug 2015 12:14:25 +0000 Received: from mail-wi0-f181.google.com ([209.85.212.181]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZQaLs-0004gq-PF for linux-arm-kernel@lists.infradead.org; Sat, 15 Aug 2015 12:14:22 +0000 Received: by wicne3 with SMTP id ne3so40208274wic.1 for ; Sat, 15 Aug 2015 05:13:59 -0700 (PDT) X-Received: by 10.180.86.138 with SMTP id p10mr16632996wiz.39.1439640838889; Sat, 15 Aug 2015 05:13:58 -0700 (PDT) Received: from localhost.localdomain (184.16.90.92.rev.sfr.net. [92.90.16.184]) by smtp.gmail.com with ESMTPSA id fz16sm7548260wic.3.2015.08.15.05.13.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 15 Aug 2015 05:13:57 -0700 (PDT) From: Ard Biesheuvel To: catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, stuart.yoder@freescale.com Subject: [PATCH] arm64: ignore memory outside of the linear range Date: Sat, 15 Aug 2015 14:13:44 +0200 Message-Id: <1439640824-30498-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150815_051420_975951_21B3CD85 X-CRM114-Status: GOOD ( 16.64 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.181 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.212.181 listed in wl.mailspike.net] -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.0 RCVD_IN_MSPIKE_WL Mailspike good senders 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: kevin.hilman@linaro.org, will.deacon@arm.com, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.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.215.52 as permitted sender) smtp.mailfrom=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 We need to ensure that we don't try to map system RAM ranges whose offset relative to the start of the kernel image exceeds the size of the linear range. This may happen even on systems that don't have huge amounts of RAM if it is laid out very sparsely. Signed-off-by: Ard Biesheuvel --- This is the minimal fix for addressing the issue we discussed. I dropped the other changes for now, let's revisit those when (if) my patches for decoupling the kernel mapping from the linear mapping are back under discussion. I will leave it up to the maintainers whether this constitutes a bugfix or not, but since this has never worked from the beginning afaict, I don't think it belongs in stable per se. arch/arm64/mm/init.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index ad87ce826cce..c65e57d4c3e7 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -158,6 +158,19 @@ early_param("mem", early_mem); void __init arm64_memblock_init(void) { + /* + * Remove the memory that we will not be able to cover + * with the linear mapping. + */ + const s64 linear_region_size = -(s64)PAGE_OFFSET; + + if (memstart_addr + linear_region_size < memblock_end_of_DRAM()) { + pr_warn("Ignoring memory outside of linear range (0x%012llx - 0x%012llx)\n", + memstart_addr + linear_region_size, + (u64)memblock_end_of_DRAM() - 1); + memblock_remove(memstart_addr + linear_region_size, ULLONG_MAX); + } + memblock_enforce_memory_limit(memory_limit); /*