Skip to contentSkip to conversation

x86: on 32-bit do not initialize memory above 2GB

PATCH New Nadav Amit 1 participant 1 message Mar 13, 2021 KVM

lore
Share & tools
lore

Nadav Amit

author
#0 lore raw

PATCH 1/1 x86: on 32-bit do not initialize memory above 2GB

From: Nadav Amit <[email protected]>

taskswitch2 test fails on certain configurations with more than 2GB of memory.

The reason is that on i386, setup_mmu() creates a hole above 2GB and does not map that area.

Do not initialize the memory above 2GB on i386.

---
 lib/x86/setup.c | 9 +++++++++
 1 file changed, 9 insertions(+)
lib/x86/setup.c +9 -0
index 7befe09..001853c 100644
@@ -107,6 +107,15 @@ void setup_multiboot(struct mbi_bootinfo *bi)
 
 	u64 best_start = (uintptr_t) &edata;
 	u64 best_end = bootinfo->mem_upper * 1024ull;
+
+#ifndef __x86_64__
+	/*
+	 * On i386, setup_mmu() creates a hole above 2GB, so do not initialize
+	 * the memory above 2GB.
+	 */
+	if (best_end > 2ul << 30)
+		best_end = 2ul << 30;
+#endif
 	phys_alloc_init(best_start, best_end - best_start);
 
 	if (bootinfo->mods_count != 1)
Signature · 1 line
2.25.1