From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it1-f198.google.com (mail-it1-f198.google.com [209.85.166.198]) by kanga.kvack.org (Postfix) with ESMTP id 429176B02B9 for ; Mon, 12 Nov 2018 12:51:00 -0500 (EST) Received: by mail-it1-f198.google.com with SMTP id 199-v6so13256498ith.5 for ; Mon, 12 Nov 2018 09:51:00 -0800 (PST) Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 71-v6sor35306794jay.9.2018.11.12.09.50.58 for (Google Transport Security); Mon, 12 Nov 2018 09:50:58 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <20181107165438.34kb5ufoe5ve2f6i@lakrids.cambridge.arm.com> References: <86d1b17c755d8bfd6e44e6869a16f4a409e7bd06.1541525354.git.andreyknvl@google.com> <20181107165438.34kb5ufoe5ve2f6i@lakrids.cambridge.arm.com> From: Andrey Konovalov Date: Mon, 12 Nov 2018 18:50:57 +0100 Message-ID: Subject: Re: [PATCH v10 06/22] kasan, arm64: adjust shadow size for tag-based mode Content-Type: text/plain; charset="UTF-8" Sender: owner-linux-mm@kvack.org List-ID: To: Mark Rutland Cc: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Catalin Marinas , Will Deacon , Christoph Lameter , Andrew Morton , Nick Desaulniers , Marc Zyngier , Dave Martin , Ard Biesheuvel , "Eric W . Biederman" , Ingo Molnar , Paul Lawrence , Geert Uytterhoeven , Arnd Bergmann , "Kirill A . Shutemov" , Greg Kroah-Hartman , Kate Stewart , Mike Rapoport , kasan-dev@googlegroups.com, "open list:DOCUMENTATION" , LKML , Linux ARM , linux-sparse@vger.kernel.org, Linux Memory Management List , Linux Kbuild mailing list , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Jann Horn , Mark Brand , Chintan Pandya , Vishwath Mohan On Wed, Nov 7, 2018 at 5:54 PM, Mark Rutland wrote: [...] >> --- a/arch/arm64/Makefile >> +++ b/arch/arm64/Makefile >> @@ -94,7 +94,7 @@ endif >> # KASAN_SHADOW_OFFSET = VA_START + (1 << (VA_BITS - KASAN_SHADOW_SCALE_SHIFT)) >> # - (1 << (64 - KASAN_SHADOW_SCALE_SHIFT)) >> # in 32-bit arithmetic >> -KASAN_SHADOW_SCALE_SHIFT := 3 >> +KASAN_SHADOW_SCALE_SHIFT := $(if $(CONFIG_KASAN_SW_TAGS), 4, 3) > > > We could make this something like: > > ifeq ($(CONFIG_KASAN_SW_TAGS), y) > KASAN_SHADOW_SCALE_SHIFT := 4 > else > KASAN_SHADOW_SCALE_SHIFT := 3 > endif > > KBUILD_CFLAGS += -DKASAN_SHADOW_SCALE_SHIFT=$(KASAN_SHADOW_SCALE_SHIFT) Seems that we need the same for KBUILD_CPPFLAGS and KBUILD_AFLAGS. >> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h >> index b96442960aea..0f1e024a951f 100644 >> --- a/arch/arm64/include/asm/memory.h >> +++ b/arch/arm64/include/asm/memory.h >> @@ -74,12 +74,17 @@ >> #define KERNEL_END _end >> >> /* >> - * KASAN requires 1/8th of the kernel virtual address space for the shadow >> - * region. KASAN can bloat the stack significantly, so double the (minimum) >> - * stack size when KASAN is in use. >> + * Generic and tag-based KASAN require 1/8th and 1/16th of the kernel virtual >> + * address space for the shadow region respectively. They can bloat the stack >> + * significantly, so double the (minimum) stack size when they are in use. >> */ >> -#ifdef CONFIG_KASAN >> +#ifdef CONFIG_KASAN_GENERIC >> #define KASAN_SHADOW_SCALE_SHIFT 3 >> +#endif >> +#ifdef CONFIG_KASAN_SW_TAGS >> +#define KASAN_SHADOW_SCALE_SHIFT 4 >> +#endif >> +#ifdef CONFIG_KASAN > > ... and remove the constant entirely here, avoiding duplication. > > Maybe factor that into a Makefile.kasan if things are going to get much > more complicated. Will do in v11, thanks!