diff mbox series

[RFC,v3,20/36] kmsan: x86: increase stack sizes in KMSAN builds

Message ID 20191122112621.204798-21-glider@google.com (mailing list archive)
State New, archived
Headers show
Series Add KernelMemorySanitizer infrastructure | expand

Commit Message

Alexander Potapenko Nov. 22, 2019, 11:26 a.m. UTC
KMSAN instruments the code heavily, increasing register pressure and
preventing functions from being inlined. As a result, the kernel
requires more stack space to run.

Rename KASAN_STACK_ORDER to EXTRA_STACK_ORDER and set EXTRA_STACK_ORDER
to 2 for KMSAN builds, effectively making the stacks 4 times larger.

Signed-off-by: Alexander Potapenko <glider@google.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Vegard Nossum <vegard.nossum@oracle.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: linux-mm@kvack.org
---

Change-Id: I1d9df161419a885bf654abff141e247366895b68
---
 arch/x86/include/asm/page_64_types.h | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

Marco Elver Dec. 2, 2019, 2:31 p.m. UTC | #1
On Fri, 22 Nov 2019 at 12:27, <glider@google.com> wrote:
>
> KMSAN instruments the code heavily, increasing register pressure and
> preventing functions from being inlined. As a result, the kernel
> requires more stack space to run.
>
> Rename KASAN_STACK_ORDER to EXTRA_STACK_ORDER and set EXTRA_STACK_ORDER
> to 2 for KMSAN builds, effectively making the stacks 4 times larger.
>
> Signed-off-by: Alexander Potapenko <glider@google.com>
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Vegard Nossum <vegard.nossum@oracle.com>
> Cc: Dmitry Vyukov <dvyukov@google.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: linux-mm@kvack.org

Acked-by: Marco Elver <elver@google.com>

Thanks,
-- Marco

> ---
>
> Change-Id: I1d9df161419a885bf654abff141e247366895b68
> ---
>  arch/x86/include/asm/page_64_types.h | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/arch/x86/include/asm/page_64_types.h b/arch/x86/include/asm/page_64_types.h
> index 288b065955b7..ea9fbf09f43b 100644
> --- a/arch/x86/include/asm/page_64_types.h
> +++ b/arch/x86/include/asm/page_64_types.h
> @@ -7,18 +7,20 @@
>  #endif
>
>  #ifdef CONFIG_KASAN
> -#define KASAN_STACK_ORDER 1
> +#define EXTRA_STACK_ORDER 1
> +#elif defined(CONFIG_KMSAN)
> +#define EXTRA_STACK_ORDER 2
>  #else
> -#define KASAN_STACK_ORDER 0
> +#define EXTRA_STACK_ORDER 0
>  #endif
>
> -#define THREAD_SIZE_ORDER      (2 + KASAN_STACK_ORDER)
> +#define THREAD_SIZE_ORDER      (2 + EXTRA_STACK_ORDER)
>  #define THREAD_SIZE  (PAGE_SIZE << THREAD_SIZE_ORDER)
>
> -#define EXCEPTION_STACK_ORDER (0 + KASAN_STACK_ORDER)
> +#define EXCEPTION_STACK_ORDER (0 + EXTRA_STACK_ORDER)
>  #define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER)
>
> -#define IRQ_STACK_ORDER (2 + KASAN_STACK_ORDER)
> +#define IRQ_STACK_ORDER (2 + EXTRA_STACK_ORDER)
>  #define IRQ_STACK_SIZE (PAGE_SIZE << IRQ_STACK_ORDER)
>
>  /*
> --
> 2.24.0.432.g9d3f5f5b63-goog
>
diff mbox series

Patch

diff --git a/arch/x86/include/asm/page_64_types.h b/arch/x86/include/asm/page_64_types.h
index 288b065955b7..ea9fbf09f43b 100644
--- a/arch/x86/include/asm/page_64_types.h
+++ b/arch/x86/include/asm/page_64_types.h
@@ -7,18 +7,20 @@ 
 #endif
 
 #ifdef CONFIG_KASAN
-#define KASAN_STACK_ORDER 1
+#define EXTRA_STACK_ORDER 1
+#elif defined(CONFIG_KMSAN)
+#define EXTRA_STACK_ORDER 2
 #else
-#define KASAN_STACK_ORDER 0
+#define EXTRA_STACK_ORDER 0
 #endif
 
-#define THREAD_SIZE_ORDER	(2 + KASAN_STACK_ORDER)
+#define THREAD_SIZE_ORDER	(2 + EXTRA_STACK_ORDER)
 #define THREAD_SIZE  (PAGE_SIZE << THREAD_SIZE_ORDER)
 
-#define EXCEPTION_STACK_ORDER (0 + KASAN_STACK_ORDER)
+#define EXCEPTION_STACK_ORDER (0 + EXTRA_STACK_ORDER)
 #define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER)
 
-#define IRQ_STACK_ORDER (2 + KASAN_STACK_ORDER)
+#define IRQ_STACK_ORDER (2 + EXTRA_STACK_ORDER)
 #define IRQ_STACK_SIZE (PAGE_SIZE << IRQ_STACK_ORDER)
 
 /*