diff mbox

[v7,0/4] KASAN for arm64

Message ID 564B4BFC.1020905@virtuozzo.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andrey Ryabinin Nov. 17, 2015, 3:47 p.m. UTC
On 11/17/2015 05:58 PM, Suzuki K. Poulose wrote:
> On 16/11/15 15:34, Andrey Ryabinin wrote:
>> On 11/16/2015 02:16 PM, Suzuki K. Poulose wrote:
>>> On 13/10/15 09:34, Catalin Marinas wrote:
>>>> On Mon, Oct 12, 2015 at 06:52:56PM +0300, Andrey Ryabinin wrote:
> 
>>> Hi,
>>>
>>> I get the following failure with KASAN + 16K_PAGES + 48BIT_VA, with 4.4-rc1:
>>>
>>>
>>> arch/arm64/mm/kasan_init.c: In function ‘kasan_early_init’:
>>> include/linux/compiler.h:484:38: error: call to ‘__compiletime_assert_95’ declared with attribute error: BUILD_BUG_ON failed: !IS_ALIGNED(KASAN_SHADOW_END, PGDIR_SIZE)
>>>    _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
>>>                                        ^
> 
> ...
> 
>>
>> Yes, it's really needed, because some code relies on this (e.g.  clear_pgs() and kasan_init()).
>> But it should be possible to get rid of this requirement.
> 
> And the other important point I missed mentioning was that, my tool chain doesn't
> support KASAN. But still the KASAN support files are still compiled and generates
> the above error. Shouldn't we disable it at build time if we detect that compiler
> doesn't support it ? Something like we do for LSE_ATOMICS.
> 

We should either add proper Kconfig dependency for now, or just make it work.


From: Andrey Ryabinin <aryabinin@virtuozzo.com>
Subject: [PATCH] arm64: KASAN depends on !(ARM64_16K_PAGES && ARM64_VA_BITS_48)

On KASAN + 16K_PAGES + 48BIT_VA
 arch/arm64/mm/kasan_init.c: In function ‘kasan_early_init’:
 include/linux/compiler.h:484:38: error: call to ‘__compiletime_assert_95’ declared with attribute error: BUILD_BUG_ON failed: !IS_ALIGNED(KASAN_SHADOW_END, PGDIR_SIZE)
    _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)

Currently KASAN will not work on 16K_PAGES and 48BIT_VA, so
forbid such configuration to avoid above build failure.

Reported-by: Suzuki K. Poulose <Suzuki.Poulose@arm.com>
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 arch/arm64/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mark Rutland Nov. 26, 2015, 12:10 p.m. UTC | #1
Hi Catalin,

Can you pick up Andrey's patch below for v4.4, until we have a better
solution?

I stumbled across this myself and was about to post a similar patch.

FWIW:

Acked-by: Mark Rutland <mark.rutland@arm.com>

Thanks,
Mark.

On Tue, Nov 17, 2015 at 06:47:08PM +0300, Andrey Ryabinin wrote:
> We should either add proper Kconfig dependency for now, or just make it work.
> 
> 
> From: Andrey Ryabinin <aryabinin@virtuozzo.com>
> Subject: [PATCH] arm64: KASAN depends on !(ARM64_16K_PAGES && ARM64_VA_BITS_48)
> 
> On KASAN + 16K_PAGES + 48BIT_VA
>  arch/arm64/mm/kasan_init.c: In function ‘kasan_early_init’:
>  include/linux/compiler.h:484:38: error: call to ‘__compiletime_assert_95’ declared with attribute error: BUILD_BUG_ON failed: !IS_ALIGNED(KASAN_SHADOW_END, PGDIR_SIZE)
>     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
> 
> Currently KASAN will not work on 16K_PAGES and 48BIT_VA, so
> forbid such configuration to avoid above build failure.
> 
> Reported-by: Suzuki K. Poulose <Suzuki.Poulose@arm.com>
> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
> ---
>  arch/arm64/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 9ac16a4..bf7de69 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -49,7 +49,7 @@ config ARM64
>  	select HAVE_ARCH_AUDITSYSCALL
>  	select HAVE_ARCH_BITREVERSE
>  	select HAVE_ARCH_JUMP_LABEL
> -	select HAVE_ARCH_KASAN if SPARSEMEM_VMEMMAP
> +	select HAVE_ARCH_KASAN if SPARSEMEM_VMEMMAP && !(ARM64_16K_PAGES && ARM64_VA_BITS_48)
>  	select HAVE_ARCH_KGDB
>  	select HAVE_ARCH_SECCOMP_FILTER
>  	select HAVE_ARCH_TRACEHOOK
> -- 
> 2.4.10
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
Andrey Ryabinin Nov. 26, 2015, 12:22 p.m. UTC | #2
On 11/26/2015 03:10 PM, Mark Rutland wrote:
> Hi Catalin,
> 
> Can you pick up Andrey's patch below for v4.4, until we have a better
> solution?
> 

FYI, better solution is almost ready, I'm going to send it today.
However, I don't know for sure whether it works or not :)
I'm not able to test as I don't have any setup working with 16k pages.

> I stumbled across this myself and was about to post a similar patch.
> 
> FWIW:
> 
> Acked-by: Mark Rutland <mark.rutland@arm.com>
> 
> Thanks,
> Mark.
> 
> On Tue, Nov 17, 2015 at 06:47:08PM +0300, Andrey Ryabinin wrote:
>> We should either add proper Kconfig dependency for now, or just make it work.
>>
>>
>> From: Andrey Ryabinin <aryabinin@virtuozzo.com>
>> Subject: [PATCH] arm64: KASAN depends on !(ARM64_16K_PAGES && ARM64_VA_BITS_48)
>>
>> On KASAN + 16K_PAGES + 48BIT_VA
>>  arch/arm64/mm/kasan_init.c: In function ‘kasan_early_init’:
>>  include/linux/compiler.h:484:38: error: call to ‘__compiletime_assert_95’ declared with attribute error: BUILD_BUG_ON failed: !IS_ALIGNED(KASAN_SHADOW_END, PGDIR_SIZE)
>>     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
>>
>> Currently KASAN will not work on 16K_PAGES and 48BIT_VA, so
>> forbid such configuration to avoid above build failure.
>>
>> Reported-by: Suzuki K. Poulose <Suzuki.Poulose@arm.com>
>> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
>> ---
>>  arch/arm64/Kconfig | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>> index 9ac16a4..bf7de69 100644
>> --- a/arch/arm64/Kconfig
>> +++ b/arch/arm64/Kconfig
>> @@ -49,7 +49,7 @@ config ARM64
>>  	select HAVE_ARCH_AUDITSYSCALL
>>  	select HAVE_ARCH_BITREVERSE
>>  	select HAVE_ARCH_JUMP_LABEL
>> -	select HAVE_ARCH_KASAN if SPARSEMEM_VMEMMAP
>> +	select HAVE_ARCH_KASAN if SPARSEMEM_VMEMMAP && !(ARM64_16K_PAGES && ARM64_VA_BITS_48)
>>  	select HAVE_ARCH_KGDB
>>  	select HAVE_ARCH_SECCOMP_FILTER
>>  	select HAVE_ARCH_TRACEHOOK
>> -- 
>> 2.4.10
>>
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>>
Catalin Marinas Nov. 26, 2015, 3:05 p.m. UTC | #3
On Thu, Nov 26, 2015 at 03:22:41PM +0300, Andrey Ryabinin wrote:
> On 11/26/2015 03:10 PM, Mark Rutland wrote:
> > Can you pick up Andrey's patch below for v4.4, until we have a better
> > solution?
> 
> FYI, better solution is almost ready, I'm going to send it today.
> However, I don't know for sure whether it works or not :)

I merged the Kconfig fix for 4.4, it's not a significant loss since I
don't expect anyone to jump onto the 16K page configuration. We'll take
the proper fix for 4.5.

Thanks.
diff mbox

Patch

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 9ac16a4..bf7de69 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -49,7 +49,7 @@  config ARM64
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_ARCH_BITREVERSE
 	select HAVE_ARCH_JUMP_LABEL
-	select HAVE_ARCH_KASAN if SPARSEMEM_VMEMMAP
+	select HAVE_ARCH_KASAN if SPARSEMEM_VMEMMAP && !(ARM64_16K_PAGES && ARM64_VA_BITS_48)
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_SECCOMP_FILTER
 	select HAVE_ARCH_TRACEHOOK