powerpc/kasan: fix early boot failure on PPC32

Due to commit 4a6d8cf90017 ("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: 2edb16efc899 ("powerpc/32: Add KASAN support")
Cc: stable@vger.kernel.org # v5.2+
Reported-by: Erhard F. <erhard_f@mailbox.org>
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/da89670093651437f27d2975224712e0a130b055.1564552796.git.christophe.leroy@c-s.fr

authored by Christophe Leroy and committed by Michael Ellerman d7e23b88 7440ea8b

Changed files
+5 -2
arch
powerpc
mm
+5 -2
arch/powerpc/mm/kasan/kasan_init_32.c
··· 21 21 __set_pte_at(&init_mm, va, ptep, pfn_pte(PHYS_PFN(pa), prot), 0); 22 22 } 23 23 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) 25 25 { 26 26 pmd_t *pmd; 27 27 unsigned long k_cur, k_next; ··· 35 35 if ((void *)pmd_page_vaddr(*pmd) != kasan_early_shadow_pte) 36 36 continue; 37 37 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); 39 42 40 43 if (!new) 41 44 return -ENOMEM;