From patchwork Wed Oct 30 14:22:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11219621 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 B64041668 for ; Wed, 30 Oct 2019 14:23:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7812C20656 for ; Wed, 30 Oct 2019 14:23:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="tKtPfAyz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7812C20656 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 A4E2E6B0269; Wed, 30 Oct 2019 10:23:10 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 987356B026A; Wed, 30 Oct 2019 10:23:10 -0400 (EDT) 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 84E216B026B; Wed, 30 Oct 2019 10:23:10 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0165.hostedemail.com [216.40.44.165]) by kanga.kvack.org (Postfix) with ESMTP id 61A266B0269 for ; Wed, 30 Oct 2019 10:23:10 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 0CF0B180AD822 for ; Wed, 30 Oct 2019 14:23:10 +0000 (UTC) X-FDA: 76100668140.16.wood06_38b1013cc404b X-Spam-Summary: 2,0,0,d105e5b01584d5aa,d41d8cd98f00b204,3y5y5xqykcn4glidergoogle.comlinux-mmkvack.org@flex--glider.bounces.google.com,:vegard.nossum@oracle.com:akpm@linux-foundation.org:dvyukov@google.com::viro@zeniv.linux.org.uk:aryabinin@virtuozzo.com:luto@kernel.org:ard.biesheuvel@linaro.org:arnd@arndb.de:hch@lst.de:dmitry.torokhov@gmail.com:edumazet@google.com:ericvh@gmail.com:gregkh@linuxfoundation.org:harry.wentland@amd.com:herbert@gondor.apana.org.au:mingo@elte.hu:axboe@kernel.dk:martin.petersen@oracle.com:schwidefsky@de.ibm.com:mst@redhat.com:monstr@monstr.eu:pmladek@suse.com:sergey.senozhatsky@gmail.com:rostedt@goodmis.org:tiwai@suse.com:tytso@mit.edu:tglx@linutronix.de:wsa@the-dreams.de:gor@linux.ibm.com:iii@linux.ibm.com:mark.rutland@arm.com:willy@infradead.org:rdunlap@infradead.org:andreyknvl@google.com:elver@google.com:glider@google.com,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1431:1437:1516:1518:1535:1541:1593:1594:1711:1730 :1747:17 X-HE-Tag: wood06_38b1013cc404b X-Filterd-Recvd-Size: 5211 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) by imf05.hostedemail.com (Postfix) with ESMTP for ; Wed, 30 Oct 2019 14:23:09 +0000 (UTC) Received: by mail-wm1-f73.google.com with SMTP id g17so936460wmc.4 for ; Wed, 30 Oct 2019 07:23:09 -0700 (PDT) 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=B0/OKDvoBq/9N8RtHxhB5aWl4cTZk6XthTMcJiiHzTI=; b=tKtPfAyzDF7M0HlVHNOTLefC5+yn/DJWCxSSC1pxLA27y6INfzRL+b3TtGY1iIOidn rs3/7akrRCdR5bDT30QWT3l+Ssytz+TBffGgMSktvTcZta5vNsJtvaM5yHwaxnNfdoFh DSXcx0Ge87v10iQF+YGto1tNgbTbzVO5/aH5Su5ei0xaNEV/ahh0Ayyjlzj2vRKrijSW bWlbxJYS2BACp20+fR2nuPZ/RR3PbugUQFn/q4dWPBev4NwiZ3Yg3V4eY+KjS09XFzXQ G8LgC3U3QhlldABOiEEDc9dietKpWkpVF0smNcCG061OiWtBfId5QO7WC/2X4NynhXRt VHCw== 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=B0/OKDvoBq/9N8RtHxhB5aWl4cTZk6XthTMcJiiHzTI=; b=XV1+cZZ7DKGHfwu5Se0ThpiqQ2A0dVRZkccj772tmwvmb1lwzVTw/Jws6cY4M+scd7 6dlwD4owL/4vfgqxqMVzbFW+ghd/HZ/Eu7YqmO7RbtDnx8pnSvy3UpHDDmYKj7NrkToq fSXhhiS3aCBYwT8QRWZRcRsoLR4wHmoEmd++gukTHoK3TU39CTb4XoNsaL6AU9dwBPHc 7R4PaMTH35W3sJ14IHXRIfAACpL2ZCIiG5CRculwWnxaw2Pn4AnWEoNrQjrVfnPZxZwF ctqqhKATMj2zMxpBzSngvKpSZ0fAY/rNrXJ9e3dZ1wSfxTMsUh9Ia1Jn7x+EIl5kSn3+ 86Wg== X-Gm-Message-State: APjAAAUpyJ15vuiSUiLVLOHlOVmoeu68yyoyi09S5fWbyb0Oq+5z52Jd Y66JwkqLRHod1hPaJb13fVEDURp79Mk= X-Google-Smtp-Source: APXvYqxkTmPJltC//1rsh6xv6iKs4b8BP9HXBLViVnYMxTyNX4DgzBVyhUbmT2e69paLzsbYIFVjfrrdFRU= X-Received: by 2002:adf:dbd2:: with SMTP id e18mr125693wrj.268.1572445387900; Wed, 30 Oct 2019 07:23:07 -0700 (PDT) Date: Wed, 30 Oct 2019 15:22:20 +0100 In-Reply-To: <20191030142237.249532-1-glider@google.com> Message-Id: <20191030142237.249532-9-glider@google.com> Mime-Version: 1.0 References: <20191030142237.249532-1-glider@google.com> X-Mailer: git-send-email 2.24.0.rc0.303.g954a862665-goog Subject: [PATCH RFC v2 08/25] kmsan: reduce vmalloc space From: glider@google.com To: Vegard Nossum , Andrew Morton , Dmitry Vyukov , linux-mm@kvack.org Cc: viro@zeniv.linux.org.uk, aryabinin@virtuozzo.com, luto@kernel.org, ard.biesheuvel@linaro.org, arnd@arndb.de, hch@lst.de, dmitry.torokhov@gmail.com, edumazet@google.com, ericvh@gmail.com, gregkh@linuxfoundation.org, harry.wentland@amd.com, herbert@gondor.apana.org.au, mingo@elte.hu, axboe@kernel.dk, martin.petersen@oracle.com, schwidefsky@de.ibm.com, mst@redhat.com, monstr@monstr.eu, pmladek@suse.com, sergey.senozhatsky@gmail.com, rostedt@goodmis.org, tiwai@suse.com, tytso@mit.edu, tglx@linutronix.de, wsa@the-dreams.de, gor@linux.ibm.com, iii@linux.ibm.com, mark.rutland@arm.com, willy@infradead.org, rdunlap@infradead.org, andreyknvl@google.com, elver@google.com, Alexander Potapenko 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 */