From patchwork Fri Oct 18 09:42:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11197985 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 22BAD14ED for ; Fri, 18 Oct 2019 09:43:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DE12220820 for ; Fri, 18 Oct 2019 09:43:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Uw11v+PW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DE12220820 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 E9A548E0025; Fri, 18 Oct 2019 05:43:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DFA518E0003; Fri, 18 Oct 2019 05:43:44 -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 C73DF8E0025; Fri, 18 Oct 2019 05:43:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0182.hostedemail.com [216.40.44.182]) by kanga.kvack.org (Postfix) with ESMTP id A65498E0003 for ; Fri, 18 Oct 2019 05:43:44 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 400F210EEE for ; Fri, 18 Oct 2019 09:43:44 +0000 (UTC) X-FDA: 76056418368.28.hot21_77e201e27bb57 X-Spam-Summary: 2,0,0,e2d9e36cc9d23bcc,d41d8cd98f00b204,3tompxqykcpkhmjefshpphmf.dpnmjovy-nnlwbdl.psh@flex--glider.bounces.google.com,:glider@google.com:vegard.nossum@oracle.com:akpm@linux-foundation.org:dvyukov@google.com:,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1431:1437:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3152:3352:3865:3866:3867:3868:3870:3871:4250:4321:5007:6120:6261:6653:7901:9036:9969:10004:10400:11026:11232:11473:11657:11658:11914:12043:12296:12297:12438:12555:12895:12986:13069:13311:13357:13846:14096:14097:14181:14394:14659:14721:21080:21365:21444:21451:21627:30054:30064,0,RBL:209.85.128.73:@flex--glider.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: hot21_77e201e27bb57 X-Filterd-Recvd-Size: 4501 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Fri, 18 Oct 2019 09:43:43 +0000 (UTC) Received: by mail-wm1-f73.google.com with SMTP id z5so623013wma.5 for ; Fri, 18 Oct 2019 02:43:43 -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=voMa8uMkO0bR++wyxPvNpVmAIPkUx6wSAyHVLN1gnqY=; b=Uw11v+PWXmwK/tlg4ihfCGzje2gofiJSgXAEdv/o1WZ02mRKczyGu2EhE4ll/Qx6ES GcgvS+RSYgAq6c+y/S0pIDMEZcqRuQW1g9zQRO2DcZnO0J4ZOt/oVoZHwVqLDcXjyJhF Bwxg59pRCYuYcYvyNikE9eul74jF/R9kEPTEOTbIPgTH62RAaMGNpLjanpT00X8lL7XD aP52AOZ7WmtFbbzGmo60ufp77C7hs/12piQ+PaVXvw5/bInkQMP0X1zCk7LkPcCKyfUs xeG6dtJrxXRBtRX2pa1ZSs2OCv98gcYJDPl4aEUQt0rABHsM4+UCbm0/I5MXCuL7Jdyy vV1g== 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=voMa8uMkO0bR++wyxPvNpVmAIPkUx6wSAyHVLN1gnqY=; b=OcCdCdlDK8pfzFUKTg5hehjgy6blBa3odq7dnGBpgvHw+kZckK16LDOHM8dHW3EXWt YZksvqSPZqG2DmgKxKdcxwy55it7qcz+sl8o3mJPVK4KFl3AucMJmB+M8OS8dIhSX2by FOxmHSaGmaDaVoRlGjl4dro24MAI6+wYyt1vzIxUX1Ry1XeP6rYt+tNI343LybAXaceJ DmHS/+pyIb8TukyqZLgaEM7gqpZNnQqCRGlrR0xcZdsbRwGx2LAYUVhL3GkwqpR0sjQi dURlh/RNRnCywunMoJbtT7OjKfBP6TJQ2cszZM98W9z9xsBrb+BQlsJLzolaCuXfwOPz xvAA== X-Gm-Message-State: APjAAAUZeHPDRDEp/ciVC1yc86P55WZIfCBP2os02wnu+NxznYnm789U bmQIhvPX7Xr0rH1+S//ft2tVJGcMj9Q= X-Google-Smtp-Source: APXvYqxc792Cv1nihwKH6Y90JXoOasFlhLR4/84MHPVrtaPJ+9Oowbv8s2Rqrjmr1aiFvqFrEWyKVMBDozQ= X-Received: by 2002:a5d:4ed2:: with SMTP id s18mr2984564wrv.187.1571391822586; Fri, 18 Oct 2019 02:43:42 -0700 (PDT) Date: Fri, 18 Oct 2019 11:42:48 +0200 In-Reply-To: <20191018094304.37056-1-glider@google.com> Message-Id: <20191018094304.37056-11-glider@google.com> Mime-Version: 1.0 References: <20191018094304.37056-1-glider@google.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog Subject: [PATCH RFC v1 10/26] kmsan: reduce vmalloc space From: glider@google.com To: Alexander Potapenko Cc: Vegard Nossum , Andrew Morton , Dmitry Vyukov , linux-mm@kvack.org 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 */