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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58C5DC433FE for ; Tue, 26 Apr 2022 16:47:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345814AbiDZQuT (ORCPT ); Tue, 26 Apr 2022 12:50:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345470AbiDZQtF (ORCPT ); Tue, 26 Apr 2022 12:49:05 -0400 Received: from mail-ed1-x54a.google.com (mail-ed1-x54a.google.com [IPv6:2a00:1450:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0207565EA for ; Tue, 26 Apr 2022 09:45:16 -0700 (PDT) Received: by mail-ed1-x54a.google.com with SMTP id b24-20020a50e798000000b0041631767675so10628652edn.23 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=7OIJtfVem5zhZJ+7rX5RBPhVJie9E8NOWQhlRLkxp5i/tpBsI7CA1jzGzq0N+9gVFg hivAxvPLx27LsLI7aFsnSRMz/XJTvmTxRY+4EzIwcPg1qICdFtPSUkTfPzDYOf1ONf1E WyVaObXGg/rzr5s54ALAkdOZec34ZBb/h7dUW8lc1MN6Eyv4v5ttN1+3FDHZihuNo3Gt 9xByvAHT5HELkMKvowMnRdXkroMWM/t/yJuN2d0uSGWnYHw1IJEHUL5L8mqrnggP5gKm Hx9onn48f2+TNMxif72Kqfp05C+4jUuLhl9BYz0MxecoNhS3bQWLxUECzrS2RAM67Yy3 MTUg== X-Gm-Message-State: AOAM5321M3jZbysXWborPLcC/xt7u4U7lDn/LMR3e3eyfXUeK+woJE9n boWzvmtYbkdSGJylbS2K8iUDpci2Ph4= X-Google-Smtp-Source: ABdhPJxSGoEtwF4OOq0yTBsFRqUEi4ydvzEhY/S3s2+/j9D6/negQ9CVvZDUHjNLSrRATTf6/ojzjnCmZdU= 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" Precedence: bulk List-ID: X-Mailing-List: linux-arch@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