Subject: Re: [Bisected] PowerMac G5 fails booting kernel 6.6-rc3 (BUG: Unable to handle kernel data access at 0xfeffbb62ffec65fe)

From: Michael Ellerman <[email-masked]>
Date: Wed, 18 Oct 2023 16:45:04 +1100

Erhard Furtner <[email-masked]> writes:
> On Tue, 17 Oct 2023 14:40:49 +1100
> Michael Ellerman <[email-masked]> wrote:
>
>> I think I've reproduced the crash on my Quad G5 by using your config
>> with some things tweaked, but I don't get any output on the screen :/
>
> You could try PPC_EARLY_DEBUG=y with PPC_EARLY_DEBUG_BOOTX or PPC_EARLY_DEBUG_G5.

I have tried PPC_EARLY_DEBUG_BOOTX but it didn't help :/

>> Do you mind booting the commit above and taking a photo of the oops and
>> attach it here. The oops you transcribed didn't entirely make sense,
>> probably due to a typo here or there, so a photo would be best.
>> 
>> cheers
>
> No problem. Just thought transcribing the photo would make more sense
> for a mailing list. ;) But maybe some subtle errors slept crept in.
> Attached are 2 photos from the issue on current v6.6-rc6.

Thanks. Yeah text is generally better, it archives better and can be
grepped etc. but in this case I was going a bit mad trying to make sense
of the oops :)

In hindsight the bug is an obvious boot time ordering problem, can you
confirm this fixes it. That should apply on top of Linus' current
master.

cheers

diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 2f1026fba00d..71f16fb32ceb 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -948,6 +948,7 @@ void __init setup_arch(char **cmdline_p)
 
 	/* Parse memory topology */
 	mem_topology_setup();
+	set_max_mapnr(max_pfn);
 
 	/*
 	 * Release secondary cpus out of their spinloops at 0x60 now that
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 8b121df7b08f..07e8f4f1e07f 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -288,7 +288,6 @@ void __init mem_init(void)
 #endif
 
 	high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
-	set_max_mapnr(max_pfn);
 
 	kasan_late_init();