Skip to content

Commit d7e23b8

Browse files
chleroympe
authored andcommitted
powerpc/kasan: fix early boot failure on PPC32
Due to commit 4a6d8cf ("powerpc/mm: don't use pte_alloc_kernel() until slab is available on PPC32"), pte_alloc_kernel() cannot be used during early KASAN init. Fix it by using memblock_alloc() instead. Fixes: 2edb16e ("powerpc/32: Add KASAN support") Cc: [email protected] # v5.2+ Reported-by: Erhard F. <[email protected]> Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/da89670093651437f27d2975224712e0a130b055.1564552796.git.christophe.leroy@c-s.fr
1 parent 7440ea8 commit d7e23b8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

arch/powerpc/mm/kasan/kasan_init_32.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static void kasan_populate_pte(pte_t *ptep, pgprot_t prot)
2121
__set_pte_at(&init_mm, va, ptep, pfn_pte(PHYS_PFN(pa), prot), 0);
2222
}
2323

24-
static int kasan_init_shadow_page_tables(unsigned long k_start, unsigned long k_end)
24+
static int __ref kasan_init_shadow_page_tables(unsigned long k_start, unsigned long k_end)
2525
{
2626
pmd_t *pmd;
2727
unsigned long k_cur, k_next;
@@ -35,7 +35,10 @@ static int kasan_init_shadow_page_tables(unsigned long k_start, unsigned long k_
3535
if ((void *)pmd_page_vaddr(*pmd) != kasan_early_shadow_pte)
3636
continue;
3737

38-
new = pte_alloc_one_kernel(&init_mm);
38+
if (slab_is_available())
39+
new = pte_alloc_one_kernel(&init_mm);
40+
else
41+
new = memblock_alloc(PTE_FRAG_SIZE, PTE_FRAG_SIZE);
3942

4043
if (!new)
4144
return -ENOMEM;

0 commit comments

Comments
 (0)