Index: boot/arch/ppc32/src/asm.S
===================================================================
--- boot/arch/ppc32/src/asm.S	(revision 566457ad2a776b2ac7fe206894a57dc9805ea7bc)
+++ boot/arch/ppc32/src/asm.S	(revision d59718e246e2f30ad97e0364fac7e75455fcb7d1)
@@ -403,5 +403,4 @@
 	# pc = kernel's entry point (r7)
 	# r3 = bootinfo (physical address)
-	# sprg0 = BOOT_OFFSET
 	# sprg3 = physical memory size
 	# sp = 0 (enforces the usage of sprg0 as exception stack)
@@ -409,6 +408,6 @@
 	mtspr srr0, r7
 
-	lis r31, BOOT_OFFSET@ha
-	addi r31, r31, BOOT_OFFSET@l
+	# Clear sprg0. Kernel will set it.
+	li r31, 0
 	mtsprg0 r31
 
@@ -416,4 +415,5 @@
 	# the physical memory size, get the lower 4 bytes
 
+	// FIXME: unchecked magic offset
 	lwz r31, 4(r3)
 	mtsprg3 r31
Index: boot/arch/ppc32/src/main.c
===================================================================
--- boot/arch/ppc32/src/main.c	(revision 566457ad2a776b2ac7fe206894a57dc9805ea7bc)
+++ boot/arch/ppc32/src/main.c	(revision d59718e246e2f30ad97e0364fac7e75455fcb7d1)
@@ -97,4 +97,14 @@
 	size_t pages = (balloc_start + ALIGN_UP(BALLOC_MAX_SIZE, PAGE_SIZE)) >>
 	    PAGE_WIDTH;
+
+	printf(" Boot allocations area: %p - %p\n", (void *) balloc_start,
+	    (void *) (pages << PAGE_WIDTH));
+
+	if ((pages << PAGE_WIDTH) >= (uintptr_t) loader_address_pa) {
+		printf("Boot allocations overlap loader area.\n");
+		printf("The boot image is too large. Halting.\n");
+		halt();
+	}
+
 	void *transtable;
 	void *transtable_pa;
Index: kernel/generic/src/main/main.c
===================================================================
--- kernel/generic/src/main/main.c	(revision 566457ad2a776b2ac7fe206894a57dc9805ea7bc)
+++ kernel/generic/src/main/main.c	(revision d59718e246e2f30ad97e0364fac7e75455fcb7d1)
@@ -172,31 +172,25 @@
 	config.kernel_size =
 	    ALIGN_UP((uintptr_t) kdata_end - config.base, PAGE_SIZE);
+
+	/* Place the stack after the kernel, init and ballocs. */
+	config.stack_base = config.base + config.kernel_size;
 	config.stack_size = STACK_SIZE;
-
-	/* Initialy the stack is placed just after the kernel */
-	config.stack_base = config.base + config.kernel_size;
 
 	/* Avoid placing stack on top of init */
 	size_t i;
 	for (i = 0; i < init.cnt; i++) {
-		if (overlaps(KA2PA(config.stack_base), config.stack_size,
-		    init.tasks[i].paddr, init.tasks[i].size)) {
-			/*
-			 * The init task overlaps with the memory behind the
-			 * kernel image so it must be in low memory and we can
-			 * use PA2KA on the init task's physical address.
-			 */
-			config.stack_base = ALIGN_UP(
-			    PA2KA(init.tasks[i].paddr) + init.tasks[i].size,
-			    config.stack_size);
-		}
+		uintptr_t p = init.tasks[i].paddr + init.tasks[i].size;
+		uintptr_t bottom = PA2KA(ALIGN_UP(p, PAGE_SIZE));
+
+		if (config.stack_base < bottom)
+			config.stack_base = bottom;
 	}
 
 	/* Avoid placing stack on top of boot allocations. */
 	if (ballocs.size) {
-		if (PA_OVERLAPS(config.stack_base, config.stack_size,
-		    ballocs.base, ballocs.size))
-			config.stack_base = ALIGN_UP(ballocs.base +
-			    ballocs.size, PAGE_SIZE);
+		uintptr_t bottom =
+		    ALIGN_UP(ballocs.base + ballocs.size, PAGE_SIZE);
+		if (config.stack_base < bottom)
+			config.stack_base = bottom;
 	}
 
