Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1273977pxb; Thu, 21 Oct 2021 20:08:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3EWKXRYSvVIHx3qKNT2scA0vCwpHhWVWC8e07S767M+RkBvZUU9Qrpr0kOZhLvixbTbuN X-Received: by 2002:aa7:8882:0:b0:44c:9270:1cba with SMTP id z2-20020aa78882000000b0044c92701cbamr9635474pfe.26.1634872093201; Thu, 21 Oct 2021 20:08:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634872093; cv=none; d=google.com; s=arc-20160816; b=mVUL2jUqlswScIo4KSCTDuctsyfd4/sH+iFOXVj94mgrRt+WkQjAbD5Vw5KjsdrWFW A1tK9YqjwoRqrb8opMFw6ZQxGKAk/HpT4f80sF/qj8cY94H+aWAazEx/hA+NYc4d81xu AIPzWJ0MDC6pJRUjrHj+QrWln4sSlkVpbcGBWuji3gkzTLwXnUHubcl1TSoU8Prj54lh PKvfT1D2u1lxdYier/aTNMGrDk55IBlbmtPzVg11xoPJJwNSccJ7D4RG+g5bkNtk8Smg xO9c0XLrG27bg6HzIMmxwG1DTdqAuKBJFoFXlujCDBjGMA6WKrLBDORm/I0b6gARAO7+ VSbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=1u2yTTOYErJH1+OBU5BpidnksrEH5H9/82ODipj4Zpc=; b=BnoaOLqHk+etKYiS8II92CXhHMLDzOUAnYC5YtJG+cEnsA3WKs81cyybfMgfvuzl33 Lrs6uzEtkTvo//2cqFCz+rkW0zwmG5B+3fCGgLs6K/ov9Vps9cCChPETmkp7cVfFwyU/ maIqmq25ihmoJChNuusNCRr+70IR1qUAIH5ny0kEDomN49zCD4Zvr7HWUA0irko/VvI+ eXJq17QsRYHlE2oKs912U3gNRXKls3PdpoZPZVCqRBxe/p/8iaEewabEjHUWrpcY2Mhn 50Is4bEeyXN5IS/8uEfC5aVUs/FE23rU4WUmZf9ZErNPun1Op5HskvWbW+PsdlPk/4Fj 4/8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=lL9M+IUO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si9623277plm.320.2021.10.21.20.07.59; Thu, 21 Oct 2021 20:08:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=lL9M+IUO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232803AbhJVDJF (ORCPT + 99 others); Thu, 21 Oct 2021 23:09:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:36220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232462AbhJVDJD (ORCPT ); Thu, 21 Oct 2021 23:09:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C367E61507; Fri, 22 Oct 2021 03:06:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1634872006; bh=hehnqJ0TdJ0oTumpWm2Z7IQhH3FhJbTA99K6hy2daDk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=lL9M+IUOIWxlAjIje/cXUcaqf4psXejtDNY2+TcyvMervYHdDAT+EWywSAmKL2NYG ZrNpKGFzs1nBub0D4XyexXytz9beAgi6j7lhzyOOTIxQUphoIf02tzHvuh7YkCJs0E tYklmMvz6OcoYQhA5j4kBupaSCNwU8MN2120YzwY= Date: Thu, 21 Oct 2021 20:06:43 -0700 From: Andrew Morton To: Nadav Amit Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Nadav Amit , Andrea Arcangeli , Andrew Cooper , Andy Lutomirski , Dave Hansen , Peter Zijlstra , Thomas Gleixner , Will Deacon , Yu Zhao , Nick Piggin , x86@kernel.org Subject: Re: [PATCH] mm: use correct VMA flags when freeing page-tables Message-Id: <20211021200643.770f9d7bd3469b2ec9d6c401@linux-foundation.org> In-Reply-To: <20211021122322.592822-1-namit@vmware.com> References: <20211021122322.592822-1-namit@vmware.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 21 Oct 2021 05:23:22 -0700 Nadav Amit wrote: > From: Nadav Amit > > Consistent use of the mmu_gather interface requires a call to > tlb_start_vma() and tlb_end_vma() for each VMA. free_pgtables() does not > follow this pattern. > > Certain architectures need tlb_start_vma() to be called in order for > tlb_update_vma_flags() to update the VMA flags (tlb->vma_exec and > tlb->vma_huge), which are later used for the proper TLB flush to be > issued. Since tlb_start_vma() is not called, this can lead to the wrong > VMA flags being used when the flush is performed. > > Specifically, the munmap syscall would call unmap_region(), which unmaps > the VMAs and then frees the page-tables. A flush is needed after > the page-tables are removed to prevent page-walk caches from holding > stale entries, but this flush would use the flags of the VMA flags of > the last VMA that was flushed. This does not appear to be right. Any thoughts on what the worst-case end-user cisible effects of this would be? Again, I'm wondering about the desirability of a -stable backport. > Use tlb_start_vma() and tlb_end_vma() to prevent this from happening. > This might lead to unnecessary calls to flush_cache_range() on certain > arch's. If needed, a new flag can be added to mmu_gather to indicate > that the flush is not needed.