powerpc/kasan: KASAN is not supported on RELOCATABLE && FSL_BOOKE
PATCH 1/1 powerpc/kasan: KASAN is not supported on RELOCATABLE && FSL_BOOKE
CONFIG_RELOCATABLE and CONFIG_KASAN cannot be enabled at the same time on ppce500 fsl_booke. All functions called before kasan_early_init() should be disabled with kasan check. When CONFIG_RELOCATABLE is enabled on ppce500 fsl_booke, relocate_init() is called before kasan_early_init() which triggers kasan check and results in boot failure.
Call trace and functions which triggers kasan check(*):
- _start
- set_ivor
- relocate_init(*)
- early_get_first_memblock_info(*)
- of_scan_flat_dt(*)
...
- kasan_early_init
Potential solutions could be 1. implement relocate_init and all its children function in a seperate file or 2. introduce a global vairable in KASAN, only enable KASAN check when init is done.
Disable KASAN when RELOCATABLE is selected on fsl_booke for now until it is supported.
--- arch/powerpc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/Kconfig +1 -1
@@ -171,7 +171,7 @@ config PPC select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_HUGE_VMAP if PPC_BOOK3S_64 && PPC_RADIX_MMU select HAVE_ARCH_JUMP_LABEL - select HAVE_ARCH_KASAN if PPC32 + select HAVE_ARCH_KASAN if PPC32 && !(RELOCATABLE && FSL_BOOKE) select HAVE_ARCH_KGDB select HAVE_ARCH_MMAP_RND_BITS select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT
Signature · 1 line
2.12.3
Le 29/11/2019 à 08:04, Lexi Shao a écrit :
Quoted 14 lines
CONFIG_RELOCATABLEandCONFIG_KASANcannot be enabled at the same time on ppce500fsl_booke. All functions called beforekasan_early_init()should be disabled with kasan check. WhenCONFIG_RELOCATABLEis enabled on ppce500fsl_booke,relocate_init()is called beforekasan_early_init()which triggers kasan check and results in boot failure.
Call trace and functions which triggers kasancheck(*):
-_start
-set_ivor
-relocate_init(*)
-early_get_first_memblock_info(*)
-of_scan_flat_dt(*)
...
-kasan_early_init
Quoted 3 lines
Potential solutions could be 1. implement
relocate_initand all its children function in a seperate file or 2. introduce a global vairable in KASAN, only enable KASAN check when init is done.
Solution 1 seems uneasy. of_scan_flat_dt() and children are general functions that can't be set aside. Solution 2 would destroy performance, and would anyway not work with inline instrumentation.
Have you tried moving the call to kasan_early_init() before the call of relocate_init() ?
On other PPC32, kasan_early_init() is the first thing done after activating the MMU. But AFAIU, MMU is always active on BOOKE though.
Christophe
Quoted 23 lines
Disable KASAN when RELOCATABLE is selected on
fsl_bookefor now until it is supported.Signed-off-by Lexi Shao <[email protected]>--- arch/powerpc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/powerpc/Kconfig +1
-1@@ -171,7 +171,7 @@ config PPC select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_HUGE_VMAP if PPC_BOOK3S_64 && PPC_RADIX_MMU select HAVE_ARCH_JUMP_LABEL - select HAVE_ARCH_KASAN if PPC32 + select HAVE_ARCH_KASAN if PPC32 && !(RELOCATABLE && FSL_BOOKE) select HAVE_ARCH_KGDB select HAVE_ARCH_MMAP_RND_BITS select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT
Le 29/11/2019 à 08:46, Christophe Leroy a écrit :
Quoted 17 lines
Le 29/11/2019 à 08:04, Lexi Shao a écrit :
Quoted 14 lines
CONFIG_RELOCATABLEandCONFIG_KASANcannot be enabled at the same time on ppce500fsl_booke. All functions called beforekasan_early_init()should be disabled with kasan check. WhenCONFIG_RELOCATABLEis enabled on ppce500fsl_booke,relocate_init()is called beforekasan_early_init()which triggers kasan check and results in boot failure.
Call trace and functions which triggers kasancheck(*):
-_start
-set_ivor
-relocate_init(*)
-early_get_first_memblock_info(*)
-of_scan_flat_dt(*)
...
-kasan_early_init
Quoted 8 lines
Quoted 3 lines
Potential solutions could be 1. implement
relocate_initand all its children function in a seperate file or 2. introduce a global vairable in KASAN, only enable KASAN check when init is done.Solution 1 seems uneasy.
of_scan_flat_dt()and children are general functions that can't be set aside. Solution 2 would destroy performance, and would anyway not work with inline instrumentation.Have you tried moving the call to
kasan_early_init()before the call ofrelocate_init()?
I just tried it with QEMU, it works. I'll send a patch out soon.
Christophe
Quoted 28 lines
On other PPC32,
kasan_early_init()is the first thing done after activating the MMU. But AFAIU, MMU is always active on BOOKE though.Christophe
Quoted 24 lines
Disable KASAN when RELOCATABLE is selected on
fsl_bookefor now until it is supported.Signed-off-by Lexi Shao <[email protected]>---
arch/powerpc/Kconfig| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)arch/powerpc/Kconfig +0
-0@@ -171,7 +171,7 @@ config PPCselect
HAVE_ARCH_AUDITSYSCALL
select HAVE_ARCH_HUGE_VMAP ifPPC_BOOK3S_64&&PPC_RADIX_MMUselectHAVE_ARCH_JUMP_LABEL
- select HAVE_ARCH_KASAN if PPC32
+ select HAVE_ARCH_KASAN if PPC32 && !(RELOCATABLE &&FSL_BOOKE)
selectHAVE_ARCH_KGDB
selectHAVE_ARCH_MMAP_RND_BITS
select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT