All of lore.kernel.org
 help / color / mirror / Atom feed
From: ryabinin.a.a@gmail.com (Andrey Ryabinin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v7 0/4] KASAN for arm64
Date: Mon, 16 Nov 2015 18:34:27 +0300	[thread overview]
Message-ID: <5649F783.40109@gmail.com> (raw)
In-Reply-To: <5649BAFD.6030005@arm.com>

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:
>>> Andrey Ryabinin (3):
>>>    arm64: move PGD_SIZE definition to pgalloc.h
>>>    arm64: add KASAN support
>>>    Documentation/features/KASAN: arm64 supports KASAN now
>>>
>>> Linus Walleij (1):
>>>    ARM64: kasan: print memory assignment
>>
>> Patches queued for 4.4. Thanks.
>>
> 
> 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__)
>                                       ^
> include/linux/compiler.h:467:4: note: in definition of macro ?__compiletime_assert?
>     prefix ## suffix();    \
>     ^
> include/linux/compiler.h:484:2: note: in expansion of macro ?_compiletime_assert?
>   _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
>   ^
> include/linux/bug.h:50:37: note: in expansion of macro ?compiletime_assert?
>  #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>                                      ^
> include/linux/bug.h:74:2: note: in expansion of macro ?BUILD_BUG_ON_MSG?
>   BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
>   ^
> arch/arm64/mm/kasan_init.c:95:2: note: in expansion of macro ?BUILD_BUG_ON?
>   BUILD_BUG_ON(!IS_ALIGNED(KASAN_SHADOW_END, PGDIR_SIZE));
> 
> 
> ---
> 
> The problem is that the PGDIR_SIZE is (1UL << 47) with 16K+48bit, which makes
> the KASAN_SHADOW_END unaligned(which is aligned to (1UL << (48 - 3)) ). Is the
> alignment really needed ? Thoughts on how best we could fix this ?
> 

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.

At first we need to rework clear_pgs().
The purpose of clear_pgs() is to remove kasan shadow from swapper_pg_dir.
So clear_pgs() should clear the top most kasan_zero_* entries from page tables.
Previously it was enough to clear PGDs, in case of 16K_PAGES + 48BIT_VA we probably need to clear PMDs


We also have to change following part of kasan_init()
...
	/*
	 * We are going to perform proper setup of shadow memory.
	 * At first we should unmap early shadow (clear_pgds() call bellow).
	 * However, instrumented code couldn't execute without shadow memory.
	 * tmp_pg_dir used to keep early shadow mapped until full shadow
	 * setup will be finished.
	 */
	memcpy(tmp_pg_dir, swapper_pg_dir, sizeof(tmp_pg_dir));


Besides tmp_pg_dir we will need one more temporary page table to store those entries
which later will be removed from swapper_pg_dir by clear_pgds().



> Cheers
> Suzuki
> 

WARNING: multiple messages have this Message-ID (diff)
From: Andrey Ryabinin <ryabinin.a.a@gmail.com>
To: "Suzuki K. Poulose" <Suzuki.Poulose@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	linux-arm-kernel@lists.infradead.org, Yury <yury.norov@gmail.com>,
	Alexey Klimov <klimov.linux@gmail.com>,
	Arnd Bergmann <arnd@arndb.de>,
	linux-mm@kvack.org, Andrey Konovalov <andreyknvl@google.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	linux-kernel@vger.kernel.org,
	kasan-dev <kasan-dev@googlegroups.com>,
	David Keitel <dkeitel@codeaurora.org>,
	Alexander Potapenko <glider@google.com>,
	Dmitry Vyukov <dvyukov@google.com>
Subject: Re: [PATCH v7 0/4] KASAN for arm64
Date: Mon, 16 Nov 2015 18:34:27 +0300	[thread overview]
Message-ID: <5649F783.40109@gmail.com> (raw)
In-Reply-To: <5649BAFD.6030005@arm.com>

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:
>>> Andrey Ryabinin (3):
>>>    arm64: move PGD_SIZE definition to pgalloc.h
>>>    arm64: add KASAN support
>>>    Documentation/features/KASAN: arm64 supports KASAN now
>>>
>>> Linus Walleij (1):
>>>    ARM64: kasan: print memory assignment
>>
>> Patches queued for 4.4. Thanks.
>>
> 
> 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__)
>                                       ^
> include/linux/compiler.h:467:4: note: in definition of macro ?__compiletime_assert?
>     prefix ## suffix();    \
>     ^
> include/linux/compiler.h:484:2: note: in expansion of macro ?_compiletime_assert?
>   _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
>   ^
> include/linux/bug.h:50:37: note: in expansion of macro ?compiletime_assert?
>  #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>                                      ^
> include/linux/bug.h:74:2: note: in expansion of macro ?BUILD_BUG_ON_MSG?
>   BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
>   ^
> arch/arm64/mm/kasan_init.c:95:2: note: in expansion of macro ?BUILD_BUG_ON?
>   BUILD_BUG_ON(!IS_ALIGNED(KASAN_SHADOW_END, PGDIR_SIZE));
> 
> 
> ---
> 
> The problem is that the PGDIR_SIZE is (1UL << 47) with 16K+48bit, which makes
> the KASAN_SHADOW_END unaligned(which is aligned to (1UL << (48 - 3)) ). Is the
> alignment really needed ? Thoughts on how best we could fix this ?
> 

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.

At first we need to rework clear_pgs().
The purpose of clear_pgs() is to remove kasan shadow from swapper_pg_dir.
So clear_pgs() should clear the top most kasan_zero_* entries from page tables.
Previously it was enough to clear PGDs, in case of 16K_PAGES + 48BIT_VA we probably need to clear PMDs


We also have to change following part of kasan_init()
...
	/*
	 * We are going to perform proper setup of shadow memory.
	 * At first we should unmap early shadow (clear_pgds() call bellow).
	 * However, instrumented code couldn't execute without shadow memory.
	 * tmp_pg_dir used to keep early shadow mapped until full shadow
	 * setup will be finished.
	 */
	memcpy(tmp_pg_dir, swapper_pg_dir, sizeof(tmp_pg_dir));


Besides tmp_pg_dir we will need one more temporary page table to store those entries
which later will be removed from swapper_pg_dir by clear_pgds().



> Cheers
> Suzuki
> 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

WARNING: multiple messages have this Message-ID (diff)
From: Andrey Ryabinin <ryabinin.a.a@gmail.com>
To: "Suzuki K. Poulose" <Suzuki.Poulose@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	linux-arm-kernel@lists.infradead.org, Yury <yury.norov@gmail.com>,
	Alexey Klimov <klimov.linux@gmail.com>,
	Arnd Bergmann <arnd@arndb.de>,
	linux-mm@kvack.org, Andrey Konovalov <andreyknvl@google.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	linux-kernel@vger.kernel.org,
	kasan-dev <kasan-dev@googlegroups.com>,
	David Keitel <dkeitel@codeaurora.org>,
	Alexander Potapenko <glider@google.com>,
	Dmitry Vyukov <dvyukov@google.com>
Subject: Re: [PATCH v7 0/4] KASAN for arm64
Date: Mon, 16 Nov 2015 18:34:27 +0300	[thread overview]
Message-ID: <5649F783.40109@gmail.com> (raw)
In-Reply-To: <5649BAFD.6030005@arm.com>

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:
>>> Andrey Ryabinin (3):
>>>    arm64: move PGD_SIZE definition to pgalloc.h
>>>    arm64: add KASAN support
>>>    Documentation/features/KASAN: arm64 supports KASAN now
>>>
>>> Linus Walleij (1):
>>>    ARM64: kasan: print memory assignment
>>
>> Patches queued for 4.4. Thanks.
>>
> 
> 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__)
>                                       ^
> include/linux/compiler.h:467:4: note: in definition of macro ‘__compiletime_assert’
>     prefix ## suffix();    \
>     ^
> include/linux/compiler.h:484:2: note: in expansion of macro ‘_compiletime_assert’
>   _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
>   ^
> include/linux/bug.h:50:37: note: in expansion of macro ‘compiletime_assert’
>  #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>                                      ^
> include/linux/bug.h:74:2: note: in expansion of macro ‘BUILD_BUG_ON_MSG’
>   BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
>   ^
> arch/arm64/mm/kasan_init.c:95:2: note: in expansion of macro ‘BUILD_BUG_ON’
>   BUILD_BUG_ON(!IS_ALIGNED(KASAN_SHADOW_END, PGDIR_SIZE));
> 
> 
> ---
> 
> The problem is that the PGDIR_SIZE is (1UL << 47) with 16K+48bit, which makes
> the KASAN_SHADOW_END unaligned(which is aligned to (1UL << (48 - 3)) ). Is the
> alignment really needed ? Thoughts on how best we could fix this ?
> 

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.

At first we need to rework clear_pgs().
The purpose of clear_pgs() is to remove kasan shadow from swapper_pg_dir.
So clear_pgs() should clear the top most kasan_zero_* entries from page tables.
Previously it was enough to clear PGDs, in case of 16K_PAGES + 48BIT_VA we probably need to clear PMDs


We also have to change following part of kasan_init()
...
	/*
	 * We are going to perform proper setup of shadow memory.
	 * At first we should unmap early shadow (clear_pgds() call bellow).
	 * However, instrumented code couldn't execute without shadow memory.
	 * tmp_pg_dir used to keep early shadow mapped until full shadow
	 * setup will be finished.
	 */
	memcpy(tmp_pg_dir, swapper_pg_dir, sizeof(tmp_pg_dir));


Besides tmp_pg_dir we will need one more temporary page table to store those entries
which later will be removed from swapper_pg_dir by clear_pgds().



> Cheers
> Suzuki
> 

  reply	other threads:[~2015-11-16 15:34 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-12 15:52 [PATCH v7 0/4] KASAN for arm64 Andrey Ryabinin
2015-10-12 15:52 ` Andrey Ryabinin
2015-10-12 15:52 ` Andrey Ryabinin
2015-10-12 15:52 ` [PATCH v7 1/4] arm64: move PGD_SIZE definition to pgalloc.h Andrey Ryabinin
2015-10-12 15:52   ` Andrey Ryabinin
2015-10-12 15:52   ` Andrey Ryabinin
2015-10-12 15:52 ` [PATCH v7 2/4] arm64: add KASAN support Andrey Ryabinin
2015-10-12 15:52   ` Andrey Ryabinin
2015-10-12 15:52   ` Andrey Ryabinin
2015-10-12 15:52 ` [PATCH v7 3/4] ARM64: kasan: print memory assignment Andrey Ryabinin
2015-10-12 15:52   ` Andrey Ryabinin
2015-10-12 15:52   ` Andrey Ryabinin
2015-10-12 15:53 ` [PATCH v7 4/4] Documentation/features/KASAN: arm64 supports KASAN now Andrey Ryabinin
2015-10-12 15:53   ` Andrey Ryabinin
2015-10-12 15:53   ` Andrey Ryabinin
2015-10-13  8:34 ` [PATCH v7 0/4] KASAN for arm64 Catalin Marinas
2015-10-13  8:34   ` Catalin Marinas
2015-10-13  8:34   ` Catalin Marinas
2015-11-16 11:16   ` Suzuki K. Poulose
2015-11-16 11:16     ` Suzuki K. Poulose
2015-11-16 11:16     ` Suzuki K. Poulose
2015-11-16 15:34     ` Andrey Ryabinin [this message]
2015-11-16 15:34       ` Andrey Ryabinin
2015-11-16 15:34       ` Andrey Ryabinin
2015-11-16 16:51       ` Catalin Marinas
2015-11-16 16:51         ` Catalin Marinas
2015-11-16 16:51         ` Catalin Marinas
2015-11-18 14:33         ` Andrey Ryabinin
2015-11-18 14:33           ` Andrey Ryabinin
2015-11-18 14:33           ` Andrey Ryabinin
2015-11-18 15:48           ` Suzuki K. Poulose
2015-11-18 15:48             ` Suzuki K. Poulose
2015-11-18 15:48             ` Suzuki K. Poulose
2015-11-18 15:52             ` Ard Biesheuvel
2015-11-18 15:52               ` Ard Biesheuvel
2015-11-18 15:52               ` Ard Biesheuvel
2015-11-18 17:24           ` Catalin Marinas
2015-11-18 17:24             ` Catalin Marinas
2015-11-18 17:24             ` Catalin Marinas
2015-11-17 14:58       ` Suzuki K. Poulose
2015-11-17 14:58         ` Suzuki K. Poulose
2015-11-17 14:58         ` Suzuki K. Poulose
2015-11-17 15:47         ` Andrey Ryabinin
2015-11-17 15:47           ` Andrey Ryabinin
2015-11-17 15:47           ` Andrey Ryabinin
2015-11-26 12:10           ` Mark Rutland
2015-11-26 12:10             ` Mark Rutland
2015-11-26 12:10             ` Mark Rutland
2015-11-26 12:22             ` Andrey Ryabinin
2015-11-26 12:22               ` Andrey Ryabinin
2015-11-26 12:22               ` Andrey Ryabinin
2015-11-26 15:05               ` Catalin Marinas
2015-11-26 15:05                 ` Catalin Marinas
2015-11-26 15:05                 ` Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5649F783.40109@gmail.com \
    --to=ryabinin.a.a@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.