Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp875148rwp; Thu, 13 Jul 2023 02:28:55 -0700 (PDT) X-Google-Smtp-Source: APBJJlGdXWm7H3nvSPW2nm9VYVYU0TwHDgalRWco0TP1zDVm5AM4MhDhkAZ8L/fax3RnoLLAgwef X-Received: by 2002:a05:6358:7205:b0:134:ea45:53d7 with SMTP id h5-20020a056358720500b00134ea4553d7mr1653659rwa.26.1689240535184; Thu, 13 Jul 2023 02:28:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689240535; cv=none; d=google.com; s=arc-20160816; b=Ty+7HzLb3IqgaBxM1RiAWs3kTPSqNtUG3gTQzBdgxVYKlB2iXKqPVZkbXlRzzki9dL sZmpAdaBDk0qXiNDGCNHffHNA5ngzNoRGxQlO8IlmJWhHDk3CDVCNNSSaijLANhApfDY nU4a3mUaP81dvO0KhZUXy+pVQv5aV/F0tBKMD7FoyS6BzTbVMZfoscTy8yMDO0HTt/SQ /+iUeX0XAPU2bjh8aV8Y98JkE+aJakoNwrDp51H6e5JRu0ikbd95AZ1QXOOxI5jQBLTp mPHiU3NXXYJNFmzfVRueZyjz42HwzpYNtFYcfLkNsIHjS97n/YXs0dIc6IqNByxmqCit 6EhA== 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 :message-id:date:subject:cc:to:from; bh=gMsA4BK5Xvp+11U5tarNoCOm+Zjkl/svxNpIsuWnpj0=; fh=Qzq6QG5Ym7V0kmH2SoXkUw/ygx1leQFSgoXNlS2xy4o=; b=bocpxfx0JxQXoBLo4Gr6oCY0CYlvUbfwM7LhaYlETpiUu9ptDDoXBMp4F3+ZmjIcGn 3blbtl1vybndJNh2ZwakrOg45emNYHaTth9eLtzTt51LF/7c8zVaMb4j7Huzlok7Bymx LZlhMEJ49ytodfM5B3tCnmQ5o06ZncDLlkUX5zweUDYIu67t+R1/nGuMzwfUzUx+WZfw tMRfWTcHlzxLikVpaijbq/tKM5GPmGWD0iG/6OB1oA4Bep1hxFyIjoWL8UH1LkngM0g2 fGwOIUs6JDu3QAhO1J+VRdaM0REhy2L/7F+GjnD/i0yXJuk7i453r5nYE5qL7GTkbnSV 4m4A== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n7-20020a63ee47000000b0054405fa924fsi4817479pgk.891.2023.07.13.02.28.43; Thu, 13 Jul 2023 02:28:55 -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 S234080AbjGMJUX (ORCPT + 99 others); Thu, 13 Jul 2023 05:20:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232776AbjGMJUV (ORCPT ); Thu, 13 Jul 2023 05:20:21 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F22E7B4 for ; Thu, 13 Jul 2023 02:20:19 -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 3F1851570; Thu, 13 Jul 2023 02:21:02 -0700 (PDT) Received: from a077893.arm.com (unknown [10.163.49.144]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 14E5E3F740; Thu, 13 Jul 2023 02:20:16 -0700 (PDT) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org Cc: david@redhat.com, Anshuman Khandual , Catalin Marinas , Will Deacon , Mark Rutland , linux-kernel@vger.kernel.org Subject: [PATCH] arm64/mm: Add pte_rdonly() helper Date: Thu, 13 Jul 2023 14:50:04 +0530 Message-Id: <20230713092004.693749-1-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 This replaces open coding PTE_RDONLY check with a new helper pte_rdonly(). No functional change is intended here. Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- This applies on v6.5-rc1 arch/arm64/include/asm/pgtable.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 171d6d7f8087..72c2e8431360 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -103,6 +103,7 @@ static inline pteval_t __phys_to_pte_val(phys_addr_t phys) #define pte_young(pte) (!!(pte_val(pte) & PTE_AF)) #define pte_special(pte) (!!(pte_val(pte) & PTE_SPECIAL)) #define pte_write(pte) (!!(pte_val(pte) & PTE_WRITE)) +#define pte_rdonly(pte) (!!(pte_val(pte) & PTE_RDONLY)) #define pte_user(pte) (!!(pte_val(pte) & PTE_USER)) #define pte_user_exec(pte) (!(pte_val(pte) & PTE_UXN)) #define pte_cont(pte) (!!(pte_val(pte) & PTE_CONT)) @@ -120,7 +121,7 @@ static inline pteval_t __phys_to_pte_val(phys_addr_t phys) (__boundary - 1 < (end) - 1) ? __boundary : (end); \ }) -#define pte_hw_dirty(pte) (pte_write(pte) && !(pte_val(pte) & PTE_RDONLY)) +#define pte_hw_dirty(pte) (pte_write(pte) && !pte_rdonly(pte)) #define pte_sw_dirty(pte) (!!(pte_val(pte) & PTE_DIRTY)) #define pte_dirty(pte) (pte_sw_dirty(pte) || pte_hw_dirty(pte)) -- 2.30.2