diff mbox series

[RFC,v4,20/42] kmsan: x86: increase stack sizes in KMSAN builds

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

Commit Message

Alexander Potapenko Dec. 20, 2019, 6:49 p.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: Marco Elver <elver@google.com>
Cc: Andrey Konovalov <andreyknvl@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

Arnd Bergmann Dec. 30, 2019, 5:39 p.m. UTC | #1
On Sun, Dec 22, 2019 at 2:25 PM <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>

What about CONFIG_FRAME_WARN? Do you need to change that as well to get
a warning-free build? If so, what is the minimum value that you need?

     Arnd
Alexander Potapenko Jan. 8, 2020, 3:31 p.m. UTC | #2
On Mon, Dec 30, 2019 at 6:39 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Sun, Dec 22, 2019 at 2:25 PM <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>
>
> What about CONFIG_FRAME_WARN? Do you need to change that as well to get
> a warning-free build? If so, what is the minimum value that you need?

Right now my config only yields a single warning about a frame of 2056 bytes.
Actually, KMSAN tends to have even smaller frames than KASAN, so
making the stacks so big might be too heavy-handed.
I'll look into decreasing the stack sizes.
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)
 
 /*