powerpc/kasan: Fix CONFIG_KASAN_VMALLOC for 8xx
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Fri, 11 Sep 2020 05:05:38 +0000 (05:05 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 15 Sep 2020 12:13:37 +0000 (22:13 +1000)
commit4c42dc5c69a8f24c467a6c997909d2f1d4efdc7f
treea4984a28f3affd458ffad2c5bbf9a7bb86ec4e2e
parent2c637d2df4ee4830e9d3eb2bd5412250522ce96e
powerpc/kasan: Fix CONFIG_KASAN_VMALLOC for 8xx

Before the commit identified below, pages tables allocation was
performed after the allocation of final shadow area for linear memory.
But that commit switched the order, leading to page tables being
already allocated at the time 8xx kasan_init_shadow_8M() is called.
Due to this, kasan_init_shadow_8M() doesn't map the needed
shadow entries because there are already page tables.

kasan_init_shadow_8M() installs huge PMD entries instead of page
tables. We could at that time free the page tables, but there is no
point in creating page tables that get freed before being used.

Only book3s/32 hash needs early allocation of page tables. For other
variants, we can keep the initial order and create remaining page
tables after the allocation of final shadow memory for linear mem.

Move back the allocation of shadow page tables for
CONFIG_KASAN_VMALLOC into kasan_init() after the loop which creates
final shadow memory for linear mem.

Fixes: 41ea93cf7ba4 ("powerpc/kasan: Fix shadow pages allocation failure")
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/8ae4554357da4882612644a74387ae05525b2aaa.1599800716.git.christophe.leroy@csgroup.eu
arch/powerpc/mm/kasan/kasan_init_32.c