Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp876459rdb; Wed, 6 Dec 2023 02:26:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IHRZ/AyyYigxcocdWoSxMQxtguhthkxrp/fb3O7QXUE8qpXKl8FdojqERsy6W+ec2zuPg3j X-Received: by 2002:a17:902:a501:b0:1d0:6ffd:e2bc with SMTP id s1-20020a170902a50100b001d06ffde2bcmr662403plq.86.1701858415717; Wed, 06 Dec 2023 02:26:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701858415; cv=none; d=google.com; s=arc-20160816; b=z+zr1FDcQsjTRwOsD7sB4rbuTnqeCGjz97/Wa2c9xeclJ8qGnk40CAhsCD/ExGtmF4 n9ixINnjMd16K6cLKA+jbWllq3YHqq9aHIoGCX0qkNxo+6Wwdb3T2c5UYOKgEQauDBd4 vQipnU4MH0mjAevVJRXkyYfO9eDgvnkP+cl+7xE446vGv0+yN5bXTWKg4HPBdE6MfsHa zZrOMfdnC2mSDFlp8YzGxVbxIz8/oTuOAIlTJcU3ircncqGyQ7ncfIAgwQIMgNDKUcnB EWnzCvPKkBgk8oI3vWuFtDF6vc8vxQuDLQj/KJTV17gylhW8Y92jrMpA9KqIqN0xionV Brxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=YMYHAutnNYJ5EoXt1oRAsc9ThGZQyZJY0Z3BTXKoQw8=; fh=ErXWpa0aFPNAu9NFGojpwTKMfrIlweU9CVDlSbs68ik=; b=aTIrv5iy9cwOwG1jk+7tXBepUm3WZQOtN0ixw2W+iQ/aVnX3TsCrT8/nVwCLI9BrxQ j0AeyclVNt6qcKfaiFgtQcPwQ/t/DDbThpy1FejuUk9IsAon41yGi1LNSuGNwpfHcksF f/CvyZGiRWi8ALIljaSoytdcsULDGou1SNVXxLCR8iyBtWfX/mMqyuaqcaq+ae1VzoVL tpM1c/Zk/mZ4e3X4G6o4PolkcAVDO/vi13j1ubb+vOrlR8s/fpZHfnWWTd4MnO+VxDM1 qezratZmwiZ870AZ1/13mbAWABkI9uRd4hmyw0H4D9DLiC7FNeguA3zZq+BmNG9XOs/X 2hTg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id k15-20020a170902c40f00b001cfd622b80dsi11387285plk.541.2023.12.06.02.26.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 02:26:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 59B80802C680; Wed, 6 Dec 2023 02:26:54 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377414AbjLFK0o (ORCPT + 99 others); Wed, 6 Dec 2023 05:26:44 -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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 06 Dec 2023 02:26:54 -0800 (PST) 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; > } >