Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4449913ioa; Wed, 27 Apr 2022 04:15:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtXnSVBB7NcfXjK4RAK6UkQ6Yf4cMWYh0pmfU7e/H4y3WrulTKXBAL2/hnghnw5ANKf6Xb X-Received: by 2002:a17:902:ca0b:b0:15c:f94a:bdd8 with SMTP id w11-20020a170902ca0b00b0015cf94abdd8mr19054126pld.17.1651058125141; Wed, 27 Apr 2022 04:15:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651058125; cv=none; d=google.com; s=arc-20160816; b=m0KP2E1QxWxxAekSWL2DZTlNvrcqcqISaIIjoIbULH0f3e66Q6k8OyF2ZKPCSyklNq WiNUh162HXux06NEYzHqI41qG3hgQ+/Vqq1JfwX5UV7FKocyd/23v4J7cK3RXPrVfDmZ PD9qXSZEfqnKOdiLVOt1L0l4hFPa0V3p8NjYxDGaA5sNIoaVyTD3yfWANAJS5txNXUVw yLLDem/HvlLGz4SFY4vuYFqmbztUr0vlZb1hpL2m9QRIkOKIXW0Qgvav6dE9zqGMGB1w ekMJA0GjKvxtuhmvG1KoA6QQZ6biHUR41qt8t/f2+kTsJ75AJYrKAHPJhdGtUF9Vya2L 2mAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=vFqZ9iNZJAVQIjd7MnY5jhYV4PJ/+WpYoNR2VRSWpiM=; b=T9BzI4ccXNgZQdaKU7RmJ0voIw8lsdPpM7RMak3hMKqQnxatdiPxd4dR6tjzftp6Jf 8xEl/Qc4C6JWSaSNMEc+D/PewFDQHK/M8hkTc0nqVUTdgU8/sk5pfpekn8knmVXdrWfn qmV/F9wRhOjyTlleY7ZZFxGb5DVJqA1AQNQ4X8i5IP1HItsfwj2cFDl3aV4XYVZZpqZ5 5egtnmJD9HEexlELUV3PEn3zxH5112KLB2xFXPuPbTfoojXWyqjmDkXEIeke2AOMwpRD ajCaxYnvyxJHf4sHXL0BWNuLANPbFOuGB/8Btj68mBz9VMx072U/5c8wI3JkhkYkMLa2 ZAvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="eaD4tCJ/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id m10-20020a170902db0a00b00153b2d165f6si1452818plx.510.2022.04.27.04.15.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 04:15:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="eaD4tCJ/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 94367456CAC; Wed, 27 Apr 2022 03:09:19 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353339AbiDZQuk (ORCPT + 99 others); Tue, 26 Apr 2022 12:50:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346708AbiDZQtG (ORCPT ); Tue, 26 Apr 2022 12:49:06 -0400 Received: from mail-ej1-x64a.google.com (mail-ej1-x64a.google.com [IPv6:2a00:1450:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0213D9FF0 for ; Tue, 26 Apr 2022 09:45:16 -0700 (PDT) Received: by mail-ej1-x64a.google.com with SMTP id sg44-20020a170907a42c00b006f3a40146e8so2520852ejc.19 for ; Tue, 26 Apr 2022 09:45:16 -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=vFqZ9iNZJAVQIjd7MnY5jhYV4PJ/+WpYoNR2VRSWpiM=; b=eaD4tCJ/YLTDe4ajl2gQ/TiaUeEA4djHXSqlMDmsulc+qbwyzuVd2W9yINHg7fHnga 3Y+nBojMivWb/vlWu7aJjqdQ3YqnLBqv0yN1IxxX322BLlHzj3IM9ELCwxkKAp16qOhv LyADFdDfCUsE+lxz9NxlRdyYnWL3NGagYS8JkeULjygmzHGrjysJLw6McGcbkSgOELQg 1Rc7TqbJxh506aPuLFlQCeuB/YWI3RUvsBYyts3m6+c10BC++lIyRNin1VxoT8iWyPi+ 5eWh+n4wLJVVQzkWe/7aM9SIO+vr3tXqfKqj3v7+4FSCDACZ5wNHzbimfz+M1Qn6e6s2 Njyw== 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=vFqZ9iNZJAVQIjd7MnY5jhYV4PJ/+WpYoNR2VRSWpiM=; b=7pB5awGjxyAPRCyheTGdpT/KgaJr024DmoF1B35WHQtdKRQ39TI5FMsYB7QDE2FKN1 Gekp34Bqb1CJATLDtJXzs9ecS1LwKqElVJDxCF0n4QVPk7DdcSHJWKcxwqmBA/q6ODPN bIhtx5nfmG8BocEXQoO8cFFLOdLUYSQnTaAdFDbEiOoYMtM3GSCnRXXXxrXmyqmys3sT YztVbp9XqJxKznDx9btrPJfDnr1Jfr2z5oAxfmwilYsUeCtwk7Up09RHXC9PDaTDufgM ES0CeQeCdfTsHDPtedYVVkFTzSZeedn2W3+K4g6en124XQddvl8nie3t2QPJuhHbmDSF Ijkw== X-Gm-Message-State: AOAM5320cLHi5pmVSMZmQQE54Pd/q+8+sBDNZMGhY/hIcM9kdoMFQA1f 1wX/hpsseOrraS6gd7D8F6yJbmQMFTM= X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:d580:abeb:bf6d:5726]) (user=glider job=sendgmr) by 2002:a17:906:3e05:b0:6f3:a14a:fd3f with SMTP id k5-20020a1709063e0500b006f3a14afd3fmr7558438eji.640.1650991515225; Tue, 26 Apr 2022 09:45:15 -0700 (PDT) Date: Tue, 26 Apr 2022 18:42:50 +0200 In-Reply-To: <20220426164315.625149-1-glider@google.com> Message-Id: <20220426164315.625149-22-glider@google.com> Mime-Version: 1.0 References: <20220426164315.625149-1-glider@google.com> X-Mailer: git-send-email 2.36.0.rc2.479.g8af0fa9b8e-goog Subject: [PATCH v3 21/46] kmsan: unpoison @tlb in arch_tlb_gather_mmu() From: Alexander Potapenko To: glider@google.com Cc: Alexander Viro , 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 afb7185ffdc45..2f3821268b311 100644 --- a/mm/mmu_gather.c +++ b/mm/mmu_gather.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -253,6 +254,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; -- 2.36.0.rc2.479.g8af0fa9b8e-goog