Subject: Re: [PATCH v6 4/4] powerpc: Book3S 64-bit "heavyweight" KASAN support

From: Daniel Axtens <[email-masked]>
Date: Wed, 12 Feb 2020 23:16:21 +1100

Christophe Leroy <[email-masked]> writes:

> Le 12/02/2020 à 11:12, Daniel Axtens a écrit :
>> Christophe Leroy <[email-masked]> writes:
>> 
>>> Le 12/02/2020 à 06:47, Daniel Axtens a écrit :
>>>> diff --git a/arch/powerpc/include/asm/kasan.h b/arch/powerpc/include/asm/kasan.h
>>>> index fbff9ff9032e..2911fdd3a6a0 100644
>>>> --- a/arch/powerpc/include/asm/kasan.h
>>>> +++ b/arch/powerpc/include/asm/kasan.h
>>>> @@ -2,6 +2,8 @@
>>>>    #ifndef __ASM_KASAN_H
>>>>    #define __ASM_KASAN_H
>>>>    
>>>> +#include <asm/page.h>
>>>> +
>>>>    #ifdef CONFIG_KASAN
>>>>    #define _GLOBAL_KASAN(fn)	_GLOBAL(__##fn)
>>>>    #define _GLOBAL_TOC_KASAN(fn)	_GLOBAL_TOC(__##fn)
>>>> @@ -14,29 +16,41 @@
>>>>    
>>>>    #ifndef __ASSEMBLY__
>>>>    
>>>> -#include <asm/page.h>
>>>> -
>>>>    #define KASAN_SHADOW_SCALE_SHIFT	3
>>>>    
>>>>    #define KASAN_SHADOW_START	(KASAN_SHADOW_OFFSET + \
>>>>    				 (PAGE_OFFSET >> KASAN_SHADOW_SCALE_SHIFT))
>>>>    
>>>> +#ifdef CONFIG_KASAN_SHADOW_OFFSET
>>>>    #define KASAN_SHADOW_OFFSET	ASM_CONST(CONFIG_KASAN_SHADOW_OFFSET)
>>>> +#endif
>>>>    
>>>> +#ifdef CONFIG_PPC32
>>>>    #define KASAN_SHADOW_END	0UL
>>>>    
>>>> -#define KASAN_SHADOW_SIZE	(KASAN_SHADOW_END - KASAN_SHADOW_START)
>>>> +#ifdef CONFIG_KASAN
>>>> +void kasan_late_init(void);
>>>> +#else
>>>> +static inline void kasan_late_init(void) { }
>>>> +#endif
>>>> +
>>>> +#endif
>>>> +
>>>> +#ifdef CONFIG_PPC_BOOK3S_64
>>>> +#define KASAN_SHADOW_END	(KASAN_SHADOW_OFFSET + \
>>>> +				 (RADIX_VMEMMAP_END >> KASAN_SHADOW_SCALE_SHIFT))
>>>> +
>>>> +static inline void kasan_late_init(void) { }
>>>> +#endif
>>>>    
>>>>    #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
>>>
>>> Why modify all this kasan_late_init() stuff ?
>>>
>>> This function is only called from kasan init_32.c, it is never called by
>>> PPC64, so you should not need to modify anything at all.
>> 
>> I got a compile error for a missing symbol. I'll repro it and attach it.
>> 
>
> Oops, sorry. I looked too quickly. It is defined in kasan_init_32.c and 
> called from mm/mem.c
>
> We don't have a performance issue here, since this is called only once 
> during startup. Could you define an empty kasan_late_init() in 
> init_book3s_64.c instead ?

Yeah, I can do that, will respin tomorrow.

Would you mind having a quick check of the documentation changes in
patches 2 and 4? I just want to confirm I've accurately captured the
state of ppc32 kasan work.

Thanks!
Daniel
> Christophe