From patchwork Fri Jul 1 14:22:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 12903376 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4384DC433EF for ; Fri, 1 Jul 2022 14:24:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D25F86B0073; Fri, 1 Jul 2022 10:24:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CBA4D6B0075; Fri, 1 Jul 2022 10:24:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ADA396B0078; Fri, 1 Jul 2022 10:24:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 9D14F6B0073 for ; Fri, 1 Jul 2022 10:24:10 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 6A64860B9B for ; Fri, 1 Jul 2022 14:24:10 +0000 (UTC) X-FDA: 79638750660.29.37F633E Received: from mail-ed1-f73.google.com (mail-ed1-f73.google.com [209.85.208.73]) by imf16.hostedemail.com (Postfix) with ESMTP id 061EF18006A for ; Fri, 1 Jul 2022 14:24:09 +0000 (UTC) Received: by mail-ed1-f73.google.com with SMTP id t14-20020a056402524e00b0043595a18b91so1870160edd.13 for ; Fri, 01 Jul 2022 07:24:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=GNX0et0VeFDbRNtievhe/rlGdldiDAHSzzvJvy6PdeY=; b=sYf9Flp9INntHEwHp1o9tRTz2HbnWSqOM0+13jbX4U/+5ngXGJ1iU0hkzEzI7Yl6Jk jlH0nE7LDojywEMxRZBi0U0XGDKUUrXHG6C4Qt21C0ilgW5fLbkrrpGtDWltdc6Tw5Ya YHQJqpyVfLRTzczxIItYEgnay8aizN5mERMhqohjf+v62gF9XLNvQGeEcDq68s6syawh PIsw0Dg3A/+St8+47YO/SOm1rxeGm8eQwJ6SDQfP6Egws2HnP2QcRUDhdRO6+G85DaEs 34UNhJTVc5cvYOHCVw3XrE8e3CVUh9QKirtDvWgSK8qukjSrnnfPDSXOiJU5cGqgyDHU tXqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=GNX0et0VeFDbRNtievhe/rlGdldiDAHSzzvJvy6PdeY=; b=jzw/idn2fODIsJs5lzrswlT4PVLa/GpR8uc0qcKnVihMtwktM/WFYk82qVVgjtqxz4 Y6rqfm6oMZWMzf+T+9jGUiVb/9Oos70xPKxA7eK5rSViDvZeVi2URrs1fFCIQMK+fSXD AxjiNREkk5lYATP58x8Pnh7W1ZZOGd7rFt2oO7iJokCbeniOzF+wY2ujbyJvpwrekssk zer6QWE/DzZQIKzyUjGjJHjVpfuJxGNJGzcBcW2kxbHbzHf4Mu8vyqf6Lc6JOO56PIai GXS8wTYHoJ4wfcxx5uqcgcIDfVPbcyy588H9x9OdfE+qn4i+laiHtnxONXYj3aBBvfBk LugA== X-Gm-Message-State: AJIora9qr7HmLkBm9HMJBCRXHYpQn5K5PSMDd6NWdMfCIucMOz0YtEGe +2gNZbcFLKRLPzb332O+xVGXk45PbNw= X-Google-Smtp-Source: AGRyM1uzH9PjvdEPicdkmuZyhlg/emV06zmVNYqY3j0pzDHXQSlgbpj3K/6MPdVlVtvQnC8U1qYagZgOlpg= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:a6f5:f713:759c:abb6]) (user=glider job=sendgmr) by 2002:a05:6402:2985:b0:439:651b:c1f4 with SMTP id eq5-20020a056402298500b00439651bc1f4mr8429220edb.276.1656685448889; Fri, 01 Jul 2022 07:24:08 -0700 (PDT) Date: Fri, 1 Jul 2022 16:22:44 +0200 In-Reply-To: <20220701142310.2188015-1-glider@google.com> Message-Id: <20220701142310.2188015-20-glider@google.com> Mime-Version: 1.0 References: <20220701142310.2188015-1-glider@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [PATCH v4 19/45] kmsan: unpoison @tlb in arch_tlb_gather_mmu() From: Alexander Potapenko To: glider@google.com Cc: Alexander Viro , Alexei Starovoitov , Andrew Morton , Andrey Konovalov , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Christoph Hellwig , Christoph Lameter , David Rientjes , Dmitry Vyukov , Eric Dumazet , Greg Kroah-Hartman , Herbert Xu , Ilya Leoshkevich , Ingo Molnar , Jens Axboe , Joonsoo Kim , Kees Cook , Marco Elver , Mark Rutland , Matthew Wilcox , "Michael S. Tsirkin" , Pekka Enberg , Peter Zijlstra , Petr Mladek , Steven Rostedt , Thomas Gleixner , Vasily Gorbik , Vegard Nossum , Vlastimil Babka , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656685450; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=GNX0et0VeFDbRNtievhe/rlGdldiDAHSzzvJvy6PdeY=; b=A6mrYZw7rPCZmzaQzcK0RusTFq+i8tifjPKNNz0FkjiP5iGwXbEhhV+qBx3NtiqSw3Y/c5 nqgB+GBOWX2z2F4ri+Jl4GgOkiFxjsVAVkJPP2fWH+hp6JqGVHtXKskLGRXrq0L2MagyB4 oQvqeZ2jTHtd/muYNuD07r7xVKo3zQ4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656685450; a=rsa-sha256; cv=none; b=SWbACiL5Ne4vhqiMWYDp4EzB2LQmSyh95KlU+DWi5pH4tgDeuTp8i5QNh7BCVSei5lFEHZ W5BJ/0yEm+ZqH1ag0k479TpIQma0XyCGnXZzpK9+/X77C25lNeSX4VytoH1jVGQF5acBqP 7mp+D1q5bqbpNrxtJ2dIQaImfFyIp2c= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=sYf9Flp9; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf16.hostedemail.com: domain of 3iAO_YgYKCKcNSPKLYNVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--glider.bounces.google.com designates 209.85.208.73 as permitted sender) smtp.mailfrom=3iAO_YgYKCKcNSPKLYNVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--glider.bounces.google.com X-Stat-Signature: ruohh5qo3cn48tq14m6xchet6kseox7y X-Rspam-User: Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=sYf9Flp9; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf16.hostedemail.com: domain of 3iAO_YgYKCKcNSPKLYNVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--glider.bounces.google.com designates 209.85.208.73 as permitted sender) smtp.mailfrom=3iAO_YgYKCKcNSPKLYNVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--glider.bounces.google.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 061EF18006A X-HE-Tag: 1656685449-112346 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 Acked-by: Marco Elver --- Link: https://linux-review.googlesource.com/id/I76abee411b8323acfdbc29bc3a60dca8cff2de77 --- mm/mmu_gather.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mm/mmu_gather.c b/mm/mmu_gather.c index a71924bd38c0d..add4244e5790d 100644 --- a/mm/mmu_gather.c +++ b/mm/mmu_gather.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -265,6 +266,15 @@ void tlb_flush_mmu(struct mmu_gather *tlb) static void __tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, bool fullmm) { + /* + * 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_memory(tlb, sizeof(*tlb)); tlb->mm = mm; tlb->fullmm = fullmm;