Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3089436rwd; Mon, 22 May 2023 08:30:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4zb6T6OaksmflqYLIhCXj4ld8cnTNAaMiIvQL6ehX7zRKICbkLvb/91EGy0VRTGF8TZnAt X-Received: by 2002:a05:6a00:845:b0:63d:2c2f:e3a2 with SMTP id q5-20020a056a00084500b0063d2c2fe3a2mr14686434pfk.18.1684769416150; Mon, 22 May 2023 08:30:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684769416; cv=none; d=google.com; s=arc-20160816; b=W6Jbq8xSe1Z7CFlwfHNFKKoqkKvogQBM+SIFuka4bEjUIfSvXuOzOL6CqivphyPlhm rbay8u6P1TJ8Btmqcz/7laitZbFXR0R6RJCSINrZvm+N2W8s/pPDiTyiDreI5vGQTGcX iMHKDDcg/Aj7PCzLn2/byAgm8f/WWR9kf/zyA7cuCQupllqkt71AkDeoS837pPG6LDOw 2R/WgXQp5U0A3P5pvsDS1wiaYLyHjod+7N4MiLpaIfkSNOCg48b3mOhwZDfnVe0d4znT PU7T9HDzOQr5jcFxQx7zqvhJufIUg+fUFkmPOeDfl8mvVSdCC7mR3qPPT8jUn/sRZ7sQ QCOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=q8OzWUZsvflNIb/jtrCNrZDZLowr0ootMQq0jTF5q4A=; b=u/GYSTGJr048VIHlEEzBw9fyFl+EEKNKc5tGi2ex6p2tZ5Ou2LAbfcJ/R+IaDC5ane 8gsZk0ovkaElhRdHUsNH9bShgkMJLAOzoPYgtruIV4uXGOzhsYHGY6L4ud/fC4M0bb3c dUgGOMFtj/5Spv/n0D2BxqnbmnfeXUjz+yEYvhh1mGbgZNaE24ResLzXR/oFge2oh7HD mZ7G8kWOzubjnxqDxXpRyM91jF/S/Hu+WKxyCupxuqR2PoTogGcUIYQ9pdVG5kn9Lx/8 haxfcKLcf8hsNDW4KkDJn2Q/XGPHeSCdmtCC4XCFEBRx3XzIyQbAgybJLtixLXbRTqre xXXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g28-20020aa79ddc000000b0063b72afb4cdsi4817796pfq.5.2023.05.22.08.30.03; Mon, 22 May 2023 08:30:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234463AbjEVPKP (ORCPT + 99 others); Mon, 22 May 2023 11:10:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234510AbjEVPJy (ORCPT ); Mon, 22 May 2023 11:09:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C43EFB9; Mon, 22 May 2023 08:09:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5F5D161C36; Mon, 22 May 2023 15:09:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C414C433D2; Mon, 22 May 2023 15:09:50 +0000 (UTC) Date: Mon, 22 May 2023 16:09:47 +0100 From: Catalin Marinas To: Alistair Popple Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, robin.murphy@arm.com, will@kernel.org, nicolinc@nvidia.com, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, jgg@nvidia.com, John Hubbard Subject: Re: [PATCH] mmu_notifiers: Notify on pte permission upgrades Message-ID: References: <20230522063725.284686-1-apopple@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230522063725.284686-1-apopple@nvidia.com> X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Mon, May 22, 2023 at 04:37:25PM +1000, Alistair Popple wrote: > diff --git a/mm/memory.c b/mm/memory.c > index f526b9152bef..0ac78c6a232c 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -2098,6 +2098,7 @@ static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr, > struct mm_struct *mm = vma->vm_mm; > pte_t *pte, entry; > spinlock_t *ptl; > + bool changed = false; > > pte = get_locked_pte(mm, addr, &ptl); > if (!pte) > @@ -2120,8 +2121,10 @@ static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr, > } > entry = pte_mkyoung(*pte); > entry = maybe_mkwrite(pte_mkdirty(entry), vma); > - if (ptep_set_access_flags(vma, addr, pte, entry, 1)) > + if (ptep_set_access_flags(vma, addr, pte, entry, 1)) { > update_mmu_cache(vma, addr, pte); > + changed = true; > + } > } > goto out_unlock; > } I haven't checked all the corner cases but can we not have a ptep_set_access_flags_notify() that handles this (and the huge equivalent)? It matches the other API like ptep_clear_flush_notify(). -- Catalin