diff options
author | Christophe Leroy <christophe.leroy@c-s.fr> | 2019-07-31 02:01:42 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2019-07-31 08:02:52 -0400 |
commit | d7e23b887f67178c4f840781be7a6aa6aeb52ab1 (patch) | |
tree | a79f299b178efa35799876153bb0b0744fbe9ad9 | |
parent | 7440ea8b2a4430eef5120d0a7faac6c39304ae6d (diff) |
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
-rw-r--r-- | arch/powerpc/mm/kasan/kasan_init_32.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/arch/powerpc/mm/kasan/kasan_init_32.c b/arch/powerpc/mm/kasan/kasan_init_32.c index 0d62be3cba47..74f4555a62ba 100644 --- a/arch/powerpc/mm/kasan/kasan_init_32.c +++ b/arch/powerpc/mm/kasan/kasan_init_32.c | |||
@@ -21,7 +21,7 @@ static void kasan_populate_pte(pte_t *ptep, pgprot_t prot) | |||
21 | __set_pte_at(&init_mm, va, ptep, pfn_pte(PHYS_PFN(pa), prot), 0); | 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 | pmd_t *pmd; | 26 | pmd_t *pmd; |
27 | unsigned long k_cur, k_next; | 27 | unsigned long k_cur, k_next; |
@@ -35,7 +35,10 @@ static int kasan_init_shadow_page_tables(unsigned long k_start, unsigned long k_ | |||
35 | if ((void *)pmd_page_vaddr(*pmd) != kasan_early_shadow_pte) | 35 | if ((void *)pmd_page_vaddr(*pmd) != kasan_early_shadow_pte) |
36 | continue; | 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 | if (!new) | 43 | if (!new) |
41 | return -ENOMEM; | 44 | return -ENOMEM; |