Skip to content

Commit

Permalink
powerpc/kasan: Fix shadow pages allocation failure
Browse files Browse the repository at this point in the history
Doing kasan pages allocation in MMU_init is too early, kernel doesn't
have access yet to the entire memory space and memblock_alloc() fails
when the kernel is a bit big.

Do it from kasan_init() instead.

Fixes: 2edb16e ("powerpc/32: Add KASAN support")
Cc: stable@vger.kernel.org
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/c24163ee5d5f8cdf52fefa45055ceb35435b8f15.1589866984.git.christophe.leroy@csgroup.eu
  • Loading branch information
chleroy authored and mpe committed May 20, 2020
1 parent 3a66a24 commit d2a91ce
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 0 additions & 2 deletions arch/powerpc/include/asm/kasan.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@

#ifdef CONFIG_KASAN
void kasan_early_init(void);
void kasan_mmu_init(void);
void kasan_init(void);
void kasan_late_init(void);
#else
static inline void kasan_init(void) { }
static inline void kasan_mmu_init(void) { }
static inline void kasan_late_init(void) { }
#endif

Expand Down
2 changes: 0 additions & 2 deletions arch/powerpc/mm/init_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ void __init MMU_init(void)
btext_unmap();
#endif

kasan_mmu_init();

setup_kup();

/* Shortly after that, the entire linear mapping will be available */
Expand Down
4 changes: 3 additions & 1 deletion arch/powerpc/mm/kasan/kasan_init_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static void __init kasan_unmap_early_shadow_vmalloc(void)
flush_tlb_kernel_range(k_start, k_end);
}

void __init kasan_mmu_init(void)
static void __init kasan_mmu_init(void)
{
int ret;
struct memblock_region *reg;
Expand Down Expand Up @@ -159,6 +159,8 @@ void __init kasan_mmu_init(void)

void __init kasan_init(void)
{
kasan_mmu_init();

kasan_remap_early_shadow_ro();

clear_page(kasan_early_shadow_page);
Expand Down

0 comments on commit d2a91ce

Please sign in to comment.