From patchwork Fri Jul 7 05:33:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 13304439 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 F38DAEB64DA for ; Fri, 7 Jul 2023 05:34:19 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=v/9ELeSf1t6MGPEIyjtJw2+wfn3RMoMo+XrSHy1LfhY=; b=Zw6lPzEk7D250j QeT+ug4zZZDELuL7rHgI2OMdYEYlDLt5wbrBdQThtwJ7TWXtLR1eR6fY5Ihb8YsAWN36vrRng4s8v Ww+5j1eZWtGifWRPiaxTZgeJPWSqoZGf73ghAPfst7Dsa7+m0wL/6qlucE1BHLq7RRl8RZEuDd4xs K54+kWwwVlpshNu28ZlLBICu6H6FP3O9qVso7R8KwG91wnbiH156XiQko/nF5HLWCtiFz8ii8r5QY XYg9Kz7JzpP3UlohmDiQtse3jLIRChi3cW0Usbu84ngKDcDqADLbKpptxBmt6uHqVfqeylYe5FbxI cKNLM66mG8txDrz/Fe7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qHe6Q-003d9m-1C; Fri, 07 Jul 2023 05:33:58 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qHe6N-003d8L-0v for linux-arm-kernel@lists.infradead.org; Fri, 07 Jul 2023 05:33:56 +0000 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 025DAD75; Thu, 6 Jul 2023 22:34:36 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.48.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9B77D3F740; Thu, 6 Jul 2023 22:33:49 -0700 (PDT) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org Cc: Anshuman Khandual , Catalin Marinas , Will Deacon , Ryan Roberts , Mark Rutland , Andrew Morton , David Hildenbrand , Jonathan Corbet , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: [RFC 2/4] arm64/mm: Call pte_sw_mkdirty() while preserving the HW dirty state Date: Fri, 7 Jul 2023 11:03:29 +0530 Message-Id: <20230707053331.510041-3-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230707053331.510041-1-anshuman.khandual@arm.com> References: <20230707053331.510041-1-anshuman.khandual@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230706_223355_371407_F1E09E16 X-CRM114-Status: GOOD ( 11.42 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org pte_mkdirty() creates dirty states both in SW and HW bits which is really not required either in pte_wrprotect() or pte_modify() for preserving the HW dirty state. Instead pte_sw_mkdirty() is sufficient. Cc: Catalin Marinas Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/arm64/include/asm/pgtable.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index fb03be697819..dd20b752ed48 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -244,7 +244,7 @@ static inline pte_t pte_wrprotect(pte_t pte) * clear), set the PTE_DIRTY bit. */ if (pte_hw_dirty(pte)) - pte = pte_mkdirty(pte); + pte = pte_sw_mkdirty(pte); pte = clear_pte_bit(pte, __pgprot(PTE_WRITE)); pte = set_pte_bit(pte, __pgprot(PTE_RDONLY)); @@ -855,7 +855,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) PTE_ATTRINDX_MASK; /* preserve the hardware dirty information */ if (pte_hw_dirty(pte)) - pte = pte_mkdirty(pte); + pte = pte_sw_mkdirty(pte); pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask); return pte; }