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: 116976 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3039794vqx; Thu, 6 Jul 2023 22:37:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlFUrJEb3rmv3SQDcsGQ6NDA2Xp0tT7YOCAXulYkIzQm/Jypbjg410Ye/xW46K/7jdIwPD7R X-Received: by 2002:a05:6a00:2e92:b0:682:2152:45df with SMTP id fd18-20020a056a002e9200b00682215245dfmr3086256pfb.9.1688708261616; Thu, 06 Jul 2023 22:37:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688708261; cv=none; d=google.com; s=arc-20160816; b=KHnrmrY5gYz455U0ngTUxsYNG/Jf6MwU026J3za88Rikx/56XVGyOMvW5zTRucR17t 0PNU4M9d09Uz6heW97xLroG6dLhZcWFWNn4X3+C/oqKusVWcQlE2jm/SJ1xLf8oan227 BOWT8MExvDx81b8sDyzXY2lWNihQcWJO+AJmL1Tc35iEsy2nH+n6fHzoH3hdIbPWm+0y h/s3xKK+Ygvcbg7bnS0PnJnRJFFJQcTZOoi6rjenUjUU6DeX6ALRmf5nryH0oVsIQqEy QqHkSd0swU5hJZfaW3t1Y/oHmZUk2z2DsUbV3w/Fp4V8ot3BGZlQhuCh1hJqEF5xC3iC fkVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=jrzem4dssYQcq9RDp3bxleA9YeCfPVvM5nPmrsZl414=; fh=v8WkW07D8QHzh6geYHFbL/t66J83/bx/yAuOgJXvUtg=; b=U4xPdVRyBqMLH37GbQ7623VyEQvuiS6VUHaxKJATWKCsU6Urg0naFLDqpSwhQvE8sR MonZCvxbXUP6wmNgMu0UiKne5Hd0fbqwITkgscZ0JkI2ej2jNgz+Ak7ePz5QUsyFURse DXs2ZkguMfsJdgfFqnb4SOolmGT6K61Oxe8s2rhSo6rY49Sofft++CcL0qfgOCfGd10V vBYuXFyK2AYnPMPw63zBc41J23emdv961vkWMsEaIJkDUdg+fyWFrKr5qIT9//fG0cVZ 5bVX3cKjQFnJ6Lsm5nTD10uStkj/7zTYkaJv5fcAgl9DY1jtyxaogtuEgBpxycV4g0gS mRsg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eb13-20020a056a004c8d00b0068288aaf240si2926197pfb.212.2023.07.06.22.37.29; Thu, 06 Jul 2023 22:37:41 -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 S231959AbjGGFd6 (ORCPT + 99 others); Fri, 7 Jul 2023 01:33:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231950AbjGGFdz (ORCPT ); Fri, 7 Jul 2023 01:33:55 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6DFB01BF4; Thu, 6 Jul 2023 22:33:54 -0700 (PDT) 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770738954042169886?= X-GMAIL-MSGID: =?utf-8?q?1770738954042169886?= 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; }