From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BB03C43603 for ; Fri, 20 Dec 2019 18:51:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1FCFF206D8 for ; Fri, 20 Dec 2019 18:51:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="PRhxAuZp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1FCFF206D8 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 C68F58E01C0; Fri, 20 Dec 2019 13:51:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C18118E019D; Fri, 20 Dec 2019 13:51:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B07D58E01C0; Fri, 20 Dec 2019 13:51:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0127.hostedemail.com [216.40.44.127]) by kanga.kvack.org (Postfix) with ESMTP id 994CD8E019D for ; Fri, 20 Dec 2019 13:51:35 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 5CF548249980 for ; Fri, 20 Dec 2019 18:51:35 +0000 (UTC) X-FDA: 76286413350.11.sort85_8238750166663 X-HE-Tag: sort85_8238750166663 X-Filterd-Recvd-Size: 5578 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Dec 2019 18:51:34 +0000 (UTC) Received: by mail-wm1-f74.google.com with SMTP id y125so4352495wmg.1 for ; Fri, 20 Dec 2019 10:51:34 -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=sBPvokdmOb4+jixnZRxRT84LYKy2EwXQk4bdSICtBpU=; b=PRhxAuZphNCbMSSUwPBLm+fKGURQduz3lGtixwo/N2j7baCKsGVwIuEHv4AmL+ZYvB a+AG8XM+qqnU2Ml66kd7ErgySgOKun0mKVAD796zqwa2nif5p0Llr1ZtKJ47DA+nzQY0 2i0LRsY1/rkxIoEll94maN7lNmAwfUh/lhBIR56Z+IRLdPXfl9jxwtYN8IvZ5OqvLr3b FnD9VP6ne00KtHGn5Y93wDrWRt9jvmUg2oNrngXhqpZQluzTR4wb7QzxGW+vKij6VmH6 aMqEEkbfttTfOLgBo/CPrBM0eANtKfCOOtMhOCFrcTDzg7fuaQ3xtH8830kCgmKD6T1A i1rQ== 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=sBPvokdmOb4+jixnZRxRT84LYKy2EwXQk4bdSICtBpU=; b=S8UTJchUmhcgjb0kfTkzX+Lo2GRwuDtzXAhKuJFms+ZZA18by0569hOm+5coG59rqS sEfC7knXRtRM9SlMqn2Q3aafaaoS7u5PpjvHth6iXTMU8GPZISYRAw+OnREvvTA1CA8c iVX7c2z060VmLHNgCbSRu+twp/He5y3kMoeM4Pzg2I7qWiL2itq12Q4D9cx5oiKI9yF8 EIJiSeKWoD4CZQecA+qKFhk8ctRYE1mglT7wYf4oYIqAMXrgdFdqbb0mhFblaX8/FtgF B242jfdQk4C0RU2MX4SGje/FL58giXIWmhs8eDiyNiS94qnX/aK8m1DnEUcvKUBD0J4f NZ3g== X-Gm-Message-State: APjAAAWHccS5nTNdw9STgHGq5fmU3zKNGlxcBRcJQqwQHQCL07/y6dBS OOiXk2fS4g3tDTS9SiC9oSCPooBxSDE= X-Google-Smtp-Source: APXvYqxiX8kRW1mpVOkCm3BVAvrPMlGlUwlg38j7FjBepEaysqcM37Q2fqAvCn39vKxPfHAUjW/Am1ZiGb4= X-Received: by 2002:adf:f606:: with SMTP id t6mr16176185wrp.85.1576867893283; Fri, 20 Dec 2019 10:51:33 -0800 (PST) Date: Fri, 20 Dec 2019 19:49:42 +0100 In-Reply-To: <20191220184955.223741-1-glider@google.com> Message-Id: <20191220184955.223741-30-glider@google.com> Mime-Version: 1.0 References: <20191220184955.223741-1-glider@google.com> X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog Subject: [PATCH RFC v4 29/42] 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 Content-Type: text/plain; charset="UTF-8" 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 --- 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 7d70e5c78f97..28105c267268 100644 --- a/mm/mmu_gather.c +++ b/mm/mmu_gather.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -206,6 +207,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? */ -- 2.24.1.735.g03f4e72817-goog