From patchwork Thu Feb 11 14:41:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 61781 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp236706lbl; Thu, 11 Feb 2016 06:48:11 -0800 (PST) X-Received: by 10.66.90.133 with SMTP id bw5mr66945235pab.22.1455202091633; Thu, 11 Feb 2016 06:48:11 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id n16si13022170pfa.122.2016.02.11.06.48.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Feb 2016 06:48:11 -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 1aTsWT-0001my-Jd; Thu, 11 Feb 2016 14:47:09 +0000 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aTsRJ-0002pE-Q5 for linux-arm-kernel@lists.infradead.org; Thu, 11 Feb 2016 14:41:57 +0000 Received: by mail-wm0-x229.google.com with SMTP id 128so24047300wmz.1 for ; Thu, 11 Feb 2016 06:41:29 -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=kN34tnRsjJYRd5+EUhTFa2JndNL+0AFkgiWjtdg6DzA=; b=OJjyYd7r69S5eztzqHKLhfoLxQxChbqqnew2MmYA2Py4ermF9Evgfzwdogidf7Nwsq 6HjvwawW9MIJIat5dI0mqRCjI8O2dzSsAq3FIuBSIv9yIit4/FtPQSAhe8tXErfcn+gj aECUyTN1kw53QFtXFz13F/tKVq1L1CwMfCTa0= 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=kN34tnRsjJYRd5+EUhTFa2JndNL+0AFkgiWjtdg6DzA=; b=BIILCITUxEFuORJrHsFMmBtEh+0onJuOpm6hu7mdJVcUMA1uFAAD+eWbtGCYxquzQE xsBd6+PG56jNjOn4MTtSKrl5MrDA2nqOBg/vh8WgqMiTlNuGa0K8dei6xrOFEvk6esQn njeEFHiYgI26FkYS3J2Hc2Mw6+JfEWjeW9dEkSvhk+m5Z8lpAgYGv2pTisArDTYCjVq5 LSSgj8P665r+YXk3oBH1hHEUyrjrIHMtU0oIdv8wDqH5q29bWaW6f5XDOFV/UmkexFao 2uyLVtFGgu+vpWuR6esqBsU6cQpjcNctVtSGQZawkOLAmhCoWuGqyr9qSH8buYBJF+mh CNqA== X-Gm-Message-State: AG10YOTKrjnSDj0502bvM/AvVvpSgSunxvoi/JL7WzoRRQF1u/wKgaMmFqVn4Tc80+REfF4K X-Received: by 10.194.133.164 with SMTP id pd4mr54472201wjb.133.1455201688441; Thu, 11 Feb 2016 06:41:28 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id v2sm8307588wmd.24.2016.02.11.06.41.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Feb 2016 06:41:27 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, mark.rutland@arm.com Subject: [PATCH] arm64: defer __va() translations of initrd_start and initrd_end Date: Thu, 11 Feb 2016 15:41:21 +0100 Message-Id: <1455201681-29972-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-20160211_064150_389747_2E0EC975 X-CRM114-Status: GOOD ( 17.48 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -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_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 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 , laurentiu.tudor@nxp.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Commit 66f51676a095 ("arm64: allow kernel Image to be loaded anywhere in physical memory") defers the assignment of memstart_addr to the point where all memory has been discovered and possibly clipped based on the size of the linear region and the presence of a mem= command line parameter. However, this results in __va() translations that have been performed up to this point to have been carried out with a preliminary, incorrect value of memstart_addr, and these values need to be fixed up. To make this more transparent, change the initial value of memstart_addr to PAGE_OFFSET so that __va() translations are effectively identity functions, and fix up the values of initrd_start and initrd_end before use. Tested-by: Laurentiu Tudor Signed-off-by: Ard Biesheuvel --- This is the least ugly way to address this issue in the short term (since the offending patch is already in -next). The preferred way of dealing with this would be to parametrise early_init_dt_check_for_initrd() in such a way that we can decide per-arch whether it should perform the __va() translation or not. If this is the preferred approach also for the short term, I am happy to code that up as well. arch/arm64/mm/init.c | 20 +++++++++++++++----- 1 file changed, 15 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/mm/init.c b/arch/arm64/mm/init.c index 3a9fc46cbf80..bb53236e54d9 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -48,7 +48,13 @@ #include "mm.h" -phys_addr_t memstart_addr __read_mostly = 0; +/* + * Initialize memstart_addr to PAGE_OFFSET so that __va() translations + * performed before arm64_memblock_init() executes (i.e., assignments + * of initrd_start and initrd_end in the early FDT parsing code) are + * effectively identity functions. + */ +phys_addr_t memstart_addr __read_mostly = PAGE_OFFSET; phys_addr_t arm64_dma_phys_limit __read_mostly; #ifdef CONFIG_BLK_DEV_INITRD @@ -61,8 +67,8 @@ static int __init early_initrd(char *p) if (*endp == ',') { size = memparse(endp + 1, NULL); - initrd_start = (unsigned long)__va(start); - initrd_end = (unsigned long)__va(start + size); + initrd_start = start; + initrd_end = start + size; } return 0; } @@ -213,8 +219,12 @@ void __init arm64_memblock_init(void) */ memblock_reserve(__pa(_text), _end - _text); #ifdef CONFIG_BLK_DEV_INITRD - if (initrd_start) - memblock_reserve(__virt_to_phys(initrd_start), initrd_end - initrd_start); + if (initrd_start) { + memblock_reserve(initrd_start, initrd_end - initrd_start); + + initrd_start = phys_to_virt(initrd_start); + initrd_end = phys_to_virt(initrd_end); + } #endif early_init_fdt_scan_reserved_mem();