linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: ignore memory outside of the linear range
@ 2015-08-15 12:13 Ard Biesheuvel
  2015-08-17  9:43 ` Will Deacon
  2015-08-17 10:40 ` Catalin Marinas
  0 siblings, 2 replies; 11+ messages in thread
From: Ard Biesheuvel @ 2015-08-15 12:13 UTC (permalink / raw)
  To: linux-arm-kernel

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 <ard.biesheuvel@linaro.org>
---

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);
 
 	/*
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-08-17 12:07 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-15 12:13 [PATCH] arm64: ignore memory outside of the linear range Ard Biesheuvel
2015-08-17  9:43 ` Will Deacon
2015-08-17 10:35   ` Ard Biesheuvel
2015-08-17 10:53     ` Will Deacon
2015-08-17 10:55       ` Ard Biesheuvel
2015-08-17 11:11         ` Will Deacon
2015-08-17 10:40 ` Catalin Marinas
2015-08-17 10:44   ` Ard Biesheuvel
2015-08-17 11:04     ` Catalin Marinas
2015-08-17 11:06       ` Ard Biesheuvel
2015-08-17 12:07         ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).