From patchwork Fri Nov 22 11:25:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11257875 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 45E761593 for ; Fri, 22 Nov 2019 11:26:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 120BB20674 for ; Fri, 22 Nov 2019 11:26:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="FYBhqnWX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 120BB20674 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 027956B04D0; Fri, 22 Nov 2019 06:26:54 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EF3936B04D1; Fri, 22 Nov 2019 06:26:53 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DECC66B04D2; Fri, 22 Nov 2019 06:26:53 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0090.hostedemail.com [216.40.44.90]) by kanga.kvack.org (Postfix) with ESMTP id C84026B04D0 for ; Fri, 22 Nov 2019 06:26:53 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 495A1180AD81C for ; Fri, 22 Nov 2019 11:26:53 +0000 (UTC) X-FDA: 76183686306.16.iron45_1df05f7a3538 X-Spam-Summary: 2,0,0,cf322753fe7322a3,d41d8cd98f00b204,3-8xxxqykcnoche9anckkcha.8kihejqt-iigr68g.knc@flex--glider.bounces.google.com,:vegard.nossum@oracle.com:akpm@linux-foundation.org:dvyukov@google.com::glider@google.com:viro@zeniv.linux.org.uk:adilger.kernel@dilger.ca:andreyknvl@google.com:aryabinin@virtuozzo.com:luto@kernel.org:ard.biesheuvel@linaro.org:arnd@arndb.de:hch@infradead.org:hch@lst.de:darrick.wong@oracle.com:davem@davemloft.net:dmitry.torokhov@gmail.com:ebiggers@google.com:edumazet@google.com:ericvh@gmail.com:gregkh@linuxfoundation.org:harry.wentland@amd.com:herbert@gondor.apana.org.au:iii@linux.ibm.com:mingo@elte.hu:jasowang@redhat.com:axboe@kernel.dk:m.szyprowski@samsung.com:elver@google.com:mark.rutland@arm.com:martin.petersen@oracle.com:schwidefsky@de.ibm.com:willy@infradead.org:mst@redhat.com:monstr@monstr.eu:pmladek@suse.com:cai@lca.pw:rdunlap@infradead.org:robin.murphy@arm.com:sergey.senozhatsky@gmail.com:rostedt@goodmis.org:tiwai@suse.com:tytso@mit.edu :tglx@li X-HE-Tag: iron45_1df05f7a3538 X-Filterd-Recvd-Size: 5382 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Fri, 22 Nov 2019 11:26:52 +0000 (UTC) Received: by mail-wr1-f74.google.com with SMTP id j12so3723893wrw.15 for ; Fri, 22 Nov 2019 03:26:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=EbVpZVj2vEJcS5ctv3ni4mREcUir0egQ89sEHPK1RWs=; b=FYBhqnWXugIBacqH3j75ca6BNVhqnnO1OI96GO01zYQWBkAhOhcNJw69oKlFNCXNeJ ACvdSjx4pjLcaL6/hMtOeBXpb4I+qngzHP5E4V2sZrBmy5YC6KkXHbr8eZUd0byTfLd1 9awgAfCHRl6NcSd2Kd8kN6sHxPxPeGhE8KmpjCtZn05oXfcpt7aKeKzyTPgmJ/1KFfyt Tqp5bJzWCKiXvTibjrIiH8RkoOnk9tr4v7ssl5U55Y6VFBhct9qLL87hPq3Xl3AU1tF1 IX4B27p0WzRppItuL21dv088clezWpG9GlXv2qr/iLb3u2XJcpT5G+fT4/VA71xMCl2K OtDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=EbVpZVj2vEJcS5ctv3ni4mREcUir0egQ89sEHPK1RWs=; b=WE0eHrC3W+3xTo3zth2wVCxapKBlJQgni8XbrNE9Rg7VJPGETAfgEywyzfcjF1UsCZ 7QgZW6WvrvN0okC71i5bCE2cEYF50HQcSGncIwJvslFt4UEfU//O3UYQA36Z4eMPALhG JC5IR6ofrHrtRkZsdocsUpkUrxXs3S+1cBPRcVmKhju71Q4u0sTiWoKOs+inq0L9u57R CiddWHuBrXlzyv1O+Aw3/TGxTWN5IioU7efUfdUHqrGr7irMah5f5Gw9c85CbD1pMH3O NFaDQgd5YOt+8Nqp/7P5eVx2nPwRADTSfC02OvVZP/KiUwuAEJNhHWKeYJKyeMafMe4g dr8g== X-Gm-Message-State: APjAAAXe9Ah3fTksxo6u1X3F/vKoyYpPXiyYJre7tIl7bap8aqvTQhiy qpHjXzi8X+b8MnPcizwx5P0eJz8Zcic= X-Google-Smtp-Source: APXvYqzFnuLiwYMT9dJeGEgLX+8kF2SYwyoEsxx+HKvI3f0xDB68OCj/uINc/1zhOA2u/4ELqb9848tf7fk= X-Received: by 2002:adf:e303:: with SMTP id b3mr1691692wrj.335.1574422011288; Fri, 22 Nov 2019 03:26:51 -0800 (PST) Date: Fri, 22 Nov 2019 12:25:53 +0100 In-Reply-To: <20191122112621.204798-1-glider@google.com> Message-Id: <20191122112621.204798-9-glider@google.com> Mime-Version: 1.0 References: <20191122112621.204798-1-glider@google.com> X-Mailer: git-send-email 2.24.0.432.g9d3f5f5b63-goog Subject: [PATCH RFC v3 08/36] kmsan: reduce vmalloc space From: glider@google.com To: Vegard Nossum , Andrew Morton , Dmitry Vyukov , linux-mm@kvack.org Cc: glider@google.com, viro@zeniv.linux.org.uk, adilger.kernel@dilger.ca, andreyknvl@google.com, aryabinin@virtuozzo.com, luto@kernel.org, ard.biesheuvel@linaro.org, arnd@arndb.de, hch@infradead.org, hch@lst.de, darrick.wong@oracle.com, davem@davemloft.net, dmitry.torokhov@gmail.com, ebiggers@google.com, edumazet@google.com, ericvh@gmail.com, gregkh@linuxfoundation.org, harry.wentland@amd.com, herbert@gondor.apana.org.au, iii@linux.ibm.com, mingo@elte.hu, jasowang@redhat.com, axboe@kernel.dk, m.szyprowski@samsung.com, elver@google.com, mark.rutland@arm.com, martin.petersen@oracle.com, schwidefsky@de.ibm.com, willy@infradead.org, mst@redhat.com, monstr@monstr.eu, pmladek@suse.com, cai@lca.pw, rdunlap@infradead.org, robin.murphy@arm.com, sergey.senozhatsky@gmail.com, rostedt@goodmis.org, tiwai@suse.com, tytso@mit.edu, tglx@linutronix.de, gor@linux.ibm.com, wsa@the-dreams.de X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: KMSAN is going to use 3/4 of existing vmalloc space to hold the metadata, therefore we lower VMALLOC_END to make sure vmalloc() doesn't allocate past the first 1/4. Signed-off-by: Alexander Potapenko To: Alexander Potapenko Cc: Vegard Nossum Cc: Andrew Morton Cc: Dmitry Vyukov Cc: linux-mm@kvack.org --- Change-Id: Iaa5e8e0fc2aa66c956f937f5a1de6e5ef40d57cc --- arch/x86/include/asm/pgtable_64_types.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h index 52e5f5f2240d..586629e20436 100644 --- a/arch/x86/include/asm/pgtable_64_types.h +++ b/arch/x86/include/asm/pgtable_64_types.h @@ -139,7 +139,22 @@ extern unsigned int ptrs_per_p4d; # define VMEMMAP_START __VMEMMAP_BASE_L4 #endif /* CONFIG_DYNAMIC_MEMORY_LAYOUT */ +#ifndef CONFIG_KMSAN #define VMALLOC_END (VMALLOC_START + (VMALLOC_SIZE_TB << 40) - 1) +#else +/* + * In KMSAN builds vmalloc area is four times smaller, and the remaining 3/4 + * are used to keep the metadata for virtual pages. + */ +#define VMALLOC_QUARTER_SIZE ((VMALLOC_SIZE_TB << 40) >> 2) +#define VMALLOC_END (VMALLOC_START + VMALLOC_QUARTER_SIZE - 1) +#define VMALLOC_SHADOW_OFFSET VMALLOC_QUARTER_SIZE +#define VMALLOC_ORIGIN_OFFSET (VMALLOC_QUARTER_SIZE * 2) +#define VMALLOC_META_END (VMALLOC_END + VMALLOC_ORIGIN_OFFSET) +#define MODULES_SHADOW_START (VMALLOC_META_END + 1) +#define MODULES_ORIGIN_START (MODULES_SHADOW_START + MODULES_LEN) +#define MODULES_ORIGIN_END (MODULES_ORIGIN_START + MODULES_LEN) +#endif #define MODULES_VADDR (__START_KERNEL_map + KERNEL_IMAGE_SIZE) /* The module sections ends with the start of the fixmap */