From patchwork Wed Mar 25 16:12:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11458281 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 6F0B96CA for ; Wed, 25 Mar 2020 16:14:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 32C2820409 for ; Wed, 25 Mar 2020 16:14:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kArDV6HC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 32C2820409 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 C61626B0010; Wed, 25 Mar 2020 12:14:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B9C516B009B; Wed, 25 Mar 2020 12:14:16 -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 A64256B009F; Wed, 25 Mar 2020 12:14:16 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0219.hostedemail.com [216.40.44.219]) by kanga.kvack.org (Postfix) with ESMTP id 85B526B0010 for ; Wed, 25 Mar 2020 12:14:16 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 6546D1815A4B5 for ; Wed, 25 Mar 2020 16:14:16 +0000 (UTC) X-FDA: 76634381712.02.base08_7c932de703909 X-Spam-Summary: 2,0,0,2a09401de04e7b1f,d41d8cd98f00b204,3v4n7xgykceyotqlmzowwotm.kwutqv25-uus3iks.wzo@flex--glider.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:968:973:982:988:989:1260:1277:1313:1314:1345:1359:1431:1437:1516:1518:1535:1542:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2693:2895:3138:3139:3140:3141:3142:3152:3353:3865:3867:3868:3870:3871:3872:4250:4321:5007:6261:6653:6742:6743:7875:9969:10004:10400:11026:11658:11914:12043:12048:12114:12296:12297:12438:12555:12895:12986:13846:14181:14394:14659:14721:21080:21365:21444:21451:21627:21990:30054:30064,0,RBL:209.85.217.74:@flex--glider.bounces.google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: base08_7c932de703909 X-Filterd-Recvd-Size: 5572 Received: from mail-vs1-f74.google.com (mail-vs1-f74.google.com [209.85.217.74]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Wed, 25 Mar 2020 16:14:15 +0000 (UTC) Received: by mail-vs1-f74.google.com with SMTP id s17so449686vss.13 for ; Wed, 25 Mar 2020 09:14:15 -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=+1ImLXF3l/Ipa3gAsWzPBFk/gFKHo02K1UNcHQIkRhA=; b=kArDV6HCjlwydcRPHSUXYTyLL1UjhaFtTiaX2HIxk9+4+hDhIP5uouw9YMXN1Vu72j 5I/ip6RxV0Y1aDaa7AuQJ1m9LBROs6ESqEtmVY1ch8U31EGAWzp6hhcx1UGriou+4S4W bJ1jwCHmb4zY2FIawTY5CHniuME0a2jHJWyqoyDo3sNlVJpO+zT1dR5uhN7syKu/2sdN RByBne6HsgvBo4z4/+AhduyMhT/WM3HHkEt+jM0/ptUZJqoA+othHAU4Edv96Afm6UBN CmqBNtq2+FzKPc88/mpHdzF5bsH6v9rdqVsfNsvPsV10rY77KygeErIL7iW6sS24hdux kweg== 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=+1ImLXF3l/Ipa3gAsWzPBFk/gFKHo02K1UNcHQIkRhA=; b=EmW9fahBHv6wscUs/i6isoW8RdYmz9WL7nVb1+J6/YmQtUkdMngAomIaQaOaJenX2m KWLKOoPI5uHrCeNJMv4JiXsQ7DspdWleg1m4LiYbGonSZeKVsmBnOXYD9rDQnqgxFmU8 kR4XbfxjgG69ftwZuJ7LdwNPZDC7ytAYffQpbF1xJcDPLm3kT/BsHIiGrF7doUrMjI5z 6TVXY+mf/aVYmlL8PbS2eF/ymaBxMD8GIV2ojIYVM4hPqE5x14VyGay4csTVMEsv10ax 40XMXXLhLQHgYgWSSVpDusILI58DSlz/P2X8l+0C98dNyUfywnlaR2t+V/Z94pxhazea QdWQ== X-Gm-Message-State: ANhLgQ001CwLOr6ZNFtgTmWLjFAmaKj6oEjqm02kz+MZUJx6jDlLHDqc jJyLBO/gYa8sE+2IzjI7d9Q5PQkAubk= X-Google-Smtp-Source: ADFU+vs2Jv2EYeUFlUVeoCis67biNjSKQGPoDzysxktIo0hAgVoJPhmvNfsrSVn4pmmAUfhFiYkuGgbe4Ng= X-Received: by 2002:ab0:710a:: with SMTP id x10mr2898993uan.76.1585152855214; Wed, 25 Mar 2020 09:14:15 -0700 (PDT) Date: Wed, 25 Mar 2020 17:12:36 +0100 In-Reply-To: <20200325161249.55095-1-glider@google.com> Message-Id: <20200325161249.55095-26-glider@google.com> Mime-Version: 1.0 References: <20200325161249.55095-1-glider@google.com> X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH v5 25/38] kmsan: unpoison |tlb| in arch_tlb_gather_mmu() From: glider@google.com To: Vegard Nossum , Dmitry Vyukov , Marco Elver , Andrey Konovalov , linux-mm@kvack.org Cc: glider@google.com, viro@zeniv.linux.org.uk, adilger.kernel@dilger.ca, akpm@linux-foundation.org, 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, mark.rutland@arm.com, martin.petersen@oracle.com, schwidefsky@de.ibm.com, willy@infradead.org, mst@redhat.com, mhocko@suse.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: This is a hack to reduce stackdepot pressure. struct mmu_gather contains 7 1-bit fields packed into a 32-bit unsigned int value. The remaining 25 bits remain uninitialized and are never used, but KMSAN updates the origin for them in zap_pXX_range() in mm/memory.c, thus creating very long origin chains. This is technically correct, but consumes too much memory. Unpoisoning the whole structure will prevent creating such chains. Signed-off-by: Alexander Potapenko To: Alexander Potapenko Cc: Vegard Nossum Cc: Dmitry Vyukov Cc: Marco Elver Cc: Andrey Konovalov Cc: linux-mm@kvack.org Reviewed-by: Andrey Konovalov --- v4: - removed a TODO, updated patch description Change-Id: I22a201e7e4f67ed74f8129072f12e5351b26103a --- mm/mmu_gather.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mm/mmu_gather.c b/mm/mmu_gather.c index a3538cb2bcbee..d3d57c276e301 100644 --- a/mm/mmu_gather.c +++ b/mm/mmu_gather.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -264,6 +265,15 @@ void tlb_flush_mmu(struct mmu_gather *tlb) void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end) { + /* + * struct mmu_gather contains 7 1-bit fields packed into a 32-bit + * unsigned int value. The remaining 25 bits remain uninitialized + * and are never used, but KMSAN updates the origin for them in + * zap_pXX_range() in mm/memory.c, thus creating very long origin + * chains. This is technically correct, but consumes too much memory. + * Unpoisoning the whole structure will prevent creating such chains. + */ + kmsan_unpoison_shadow(tlb, sizeof(*tlb)); tlb->mm = mm; /* Is it from 0 to ~0? */