From patchwork Thu Feb 11 16:48:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 61791 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp316303lbl; Thu, 11 Feb 2016 08:50:15 -0800 (PST) X-Received: by 10.98.15.17 with SMTP id x17mr26820632pfi.52.1455209413379; Thu, 11 Feb 2016 08:50:13 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id c15si13522869pfd.225.2016.02.11.08.50.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Feb 2016 08:50:13 -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 1aTuQf-000245-JF; Thu, 11 Feb 2016 16:49:17 +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 1aTuQ0-0001Gh-1q for linux-arm-kernel@lists.infradead.org; Thu, 11 Feb 2016 16:48:38 +0000 Received: by mail-wm0-x22d.google.com with SMTP id p63so76521603wmp.1 for ; Thu, 11 Feb 2016 08:48:15 -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=DQ1/sNeKmXR+AL3zAjOH8FvMwbTge1L6Z/0rUAlLIxI=; b=MaTXbcRwuVNDVCAgDruTErLSBM05GMhPpL1LGobGT5iA12pjjo6IR6V35TuZne5qMc cYQFnY/UDQfMbiRPTsQxkasNK2w7OGYHRYDrLs4p/IHlavwr7MsSS4GCtLrKG1QkZlZD ZTaIHVZ/Iohd6PjcgLNH/urV3GiD3s3oY75Ww= 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=DQ1/sNeKmXR+AL3zAjOH8FvMwbTge1L6Z/0rUAlLIxI=; b=WaRlVDWaeUiAJfV2ZD27m77u/T9yghQalBFaBXracKUFCudIqCSeiOhxLcVNvmSx1h 1fL1D0J6NmGnAElHxSXd1LS514sxhFZpCov6IfvxjvzAuC1Now3fU0Pdtob/vwtkKGUV 6I12a21all9cLsYm726feCeQ7GspQE+CSI4YKJ38qy8We3vzRJnfYc/177AqHqI9EfH8 DJ21ba7l/HtbvDh9+ZO6a0H7v0jDBcZODwsxjmLt8Kg+SkqxwT/LLz+oTBqhDXRskN1e le66dV11EXzBLaFpvyz6BvSvnr1FGSK/fYlwXv2ZlPGcmaid5OCAX7LGIkPpInu5RkXZ y7Ug== X-Gm-Message-State: AG10YORp0lqlsoUwE4ampraK8I3K2PYDPvrnF2td523cfIuDyNWwcYlH2uH/lMmW0fyUi51v X-Received: by 10.194.123.167 with SMTP id mb7mr55816303wjb.0.1455209294416; Thu, 11 Feb 2016 08:48:14 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id g1sm3673798wmc.0.2016.02.11.08.48.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Feb 2016 08:48:13 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, mark.rutland@arm.com, laurentiu.tudor@nxp.com Subject: [PATCH v2 3/3] arm64: prevent __va() translations before memstart_addr is assigned Date: Thu, 11 Feb 2016 17:48:02 +0100 Message-Id: <1455209282-9596-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455209282-9596-1-git-send-email-ard.biesheuvel@linaro.org> References: <1455209282-9596-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160211_084836_481327_B927EA35 X-CRM114-Status: GOOD ( 12.44 ) 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_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 MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Just a hack to check whether all early __va() calls are gone. --- arch/arm64/include/asm/memory.h | 10 +++++++++- arch/arm64/mm/init.c | 2 +- 2 files changed, 10 insertions(+), 2 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 083361531a61..0d4d1b3b9695 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -90,7 +90,9 @@ __x >= PAGE_OFFSET ? (__x - PAGE_OFFSET + PHYS_OFFSET) : \ (__x - kimage_voffset); }) -#define __phys_to_virt(x) ((unsigned long)((x) - PHYS_OFFSET + PAGE_OFFSET)) +#define __phys_to_virt(x) ({ \ + assert_memstart_addr_assigned(); \ + (unsigned long)((x) - PHYS_OFFSET + PAGE_OFFSET); }) #define __phys_to_kimg(x) ((unsigned long)((x) + kimage_voffset)) /* @@ -133,6 +135,12 @@ extern u64 kimage_vaddr; /* the offset between the kernel virtual and physical mappings */ extern u64 kimage_voffset; +static inline void assert_memstart_addr_assigned(void) +{ + if (unlikely(memstart_addr == (phys_addr_t)-1)) + asm("brk #%0" :: "I"(0x800)); +} + /* * Allow all memory at the discovery stage. We will clip it later. */ diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index eff4751f8761..e88db8acd181 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -48,7 +48,7 @@ #include "mm.h" -phys_addr_t memstart_addr __read_mostly = 0; +phys_addr_t memstart_addr __read_mostly = (phys_addr_t)-1; phys_addr_t arm64_dma_phys_limit __read_mostly; #ifdef CONFIG_BLK_DEV_INITRD