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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A5E49C77B75 for ; Mon, 22 May 2023 15:10:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0jZ+W95pI7ADYxYDkTRxDb5JwB49//fhf/B/v1HIh1s=; b=qGaBcTi9MeZf/8 mIiPfJG48uI7CKlNrGaS9sO59I4kWabjMbPBgCzjW8za8vGsS+POAPLQ7axFhXdUzK1aQ8UPeC4dd XSuQF3XBlLz02cuKdkmt8Rp1b0Au4IBWlfC++hh1iiTYa8I0tVm7bOLZtBbUbQU2CtkurLLfn+fcL AW++cmZkBuf4ot/nznT1CLrzt1wh/24XhVM86U5umbOGNv2mjBWUsU9q86+RvQp2tHVWqFFirJxQy JHIQSUZo8OGH4dNiAhlWjJcvkfhdQehWiqfBA3i9TTywxVKVqtHwd6xFmR2b/h54WBoGfTnto9Uk5 ytJWpLvJP2bbntBkIQ7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q17Aa-006xrL-0F; Mon, 22 May 2023 15:09:56 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q17AX-006xqx-2c for linux-arm-kernel@lists.infradead.org; Mon, 22 May 2023 15:09:55 +0000 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 5A12A61A5A; 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-Disposition: inline In-Reply-To: <20230522063725.284686-1-apopple@nvidia.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230522_080953_896987_804BAE26 X-CRM114-Status: GOOD ( 13.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel