Fail to boot 5.15 on mpc8347 with either debug_pagealloc or nobats

Maxime Bizon mbizon at freebox.fr
Sun Dec 5 01:10:31 AEDT 2021


On Saturday 04 Dec 2021 à 10:01:07 (+0000), Christophe Leroy wrote:

> In fact BAT4 is wrong. Both virtual and physical address of a 64M BAT 
> must be 64M aligned. I think the display is wrong as well (You took it

oh so hardware does simple bitmask after all

I got fooled by the lack of guard in the bat setup code, so I assumed
magical hardware

> from ptdump ?), BEPI and BRPN must be anded with complement of BL.

yes that was ptdump code with seq_printf replaced by printk

ptdump code is correct but iif the bat addresses are correctly
aligned, maybe add a safeguard like this ?

index 85062ce2d849..f7c5cf62ef41 100644
--- a/arch/powerpc/mm/book3s32/mmu.c
+++ b/arch/powerpc/mm/book3s32/mmu.c
@@ -275,6 +279,10 @@ void __init setbat(int index, unsigned long virt, phys_addr_t phys,
                       (unsigned long long)phys);
                return;
        }
+
+       WARN_ON(!is_power_of_2(size));
+       WARN_ON((phys & (size - 1)));
+       WARN_ON((virt & (size - 1)));
        bat = BATS[index];


> So here your 64M BAT maps 0xf8000000-0xfbffffff, therefore the address 
> 0xfd3fce00 is not mapped by any BAT hence the OOPS.

ok I think I found the issue:

diff --git a/arch/powerpc/mm/kasan/book3s_32.c b/arch/powerpc/mm/kasan/book3s_32.c
index 35b287b0a8da..fcbb9a136c1a 100644
--- a/arch/powerpc/mm/kasan/book3s_32.c
+++ b/arch/powerpc/mm/kasan/book3s_32.c
@@ -12,14 +12,14 @@ int __init kasan_init_region(void *start, size_t size)
        unsigned long k_end = (unsigned long)kasan_mem_to_shadow(start + size);
        unsigned long k_cur = k_start;
        int k_size = k_end - k_start;
-       int k_size_base = 1 << (ffs(k_size) - 1);
+       int k_size_base = 1 << (fls(k_size) - 1);
        int ret;
        void *block;
 
        block = memblock_alloc(k_size, k_size_base);
 
        if (block && k_size_base >= SZ_128K && k_start == ALIGN(k_start, k_size_base)) {
-               int shift = ffs(k_size - k_size_base);
+               int shift = fls(k_size - k_size_base);
                int k_size_more = shift ? 1 << (shift - 1) : 0;
 
                setbat(-1, k_start, __pa(block), k_size_base, PAGE_KERNEL);



-- 
Maxime


More information about the Linuxppc-dev mailing list