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 9DD24C46CA0 for ; Wed, 6 Dec 2023 10:26:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377434AbjLFK0p (ORCPT ); Wed, 6 Dec 2023 05:26:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377325AbjLFK0n (ORCPT ); Wed, 6 Dec 2023 05:26:43 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 72690D40 for ; Wed, 6 Dec 2023 02:26:49 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4ABAD1474; Wed, 6 Dec 2023 02:27:35 -0800 (PST) Received: from [10.57.73.130] (unknown [10.57.73.130]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 996183F762; Wed, 6 Dec 2023 02:26:47 -0800 (PST) Message-ID: <1ccb1e57-1aef-4797-b6d2-ab59efa488db@arm.com> Date: Wed, 6 Dec 2023 10:26:46 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] arm64: mm: Always make sw-dirty PTEs hw-dirty in pte_modify Content-Language: en-GB To: James Houghton , Steve Capper , Will Deacon , Andrew Morton Cc: Mike Kravetz , Muchun Song , Anshuman Khandual , Catalin Marinas , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20231204172646.2541916-1-jthoughton@google.com> <20231204172646.2541916-3-jthoughton@google.com> From: Ryan Roberts In-Reply-To: <20231204172646.2541916-3-jthoughton@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/12/2023 17:26, James Houghton wrote: > Make it impossible to create a sw-dirty, hw-clean PTE with pte_modify. > Such a PTE should be impossible to create, and there may be places that > assume that pte_dirty() implies pte_hw_dirty(). > > Signed-off-by: James Houghton Reviewed-by: Ryan Roberts > > diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h > index b19a8aee684c..79ce70fbb751 100644 > --- a/arch/arm64/include/asm/pgtable.h > +++ b/arch/arm64/include/asm/pgtable.h > @@ -834,6 +834,12 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) > pte = set_pte_bit(pte, __pgprot(PTE_DIRTY)); > > pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask); > + /* > + * If we end up clearing hw dirtiness for a sw-dirty PTE, set hardware > + * dirtiness again. > + */ > + if (pte_sw_dirty(pte)) > + pte = pte_mkdirty(pte); > return pte; > } >