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 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 0C3D7CCD194 for ; Thu, 16 Oct 2025 11:33:42 +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=k65Ci65SHuGFV7MJF/EY/hK2jZpf7SbfxGPY4rjtFE8=; b=MX7GaNmJlI+jjG PlchYINh6WMT7Lvj7sQDvk2CHV2uFLUnNIGsQr4q4pKwVEFM4eAsotAhVI/LeC6Z1ei9TWiAfmMjt lriL8jeDCOrCqzRcu/3qP2ECajsB8nkLSJpPLY2nWLLzYOb6EvGPZFAXDYV7XW4wScuQvXBPDyw8c uA23ca20QoLLwygF2aX+1vve1GLXkTk5Vb3PMdDtMoVPcyOUm7F//PWTS3rD2DL2ZfRevmT/7tise dVbVBKk3C/pKP4vEG/EBUNYmq78JhLiEuqUkoYV/2MnM8RvpRxHNPg6tgUvSoMLhk28O2TSu1AIcb UjSRU426+GFKdZEwJIqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1v9MEd-00000004aeG-3Ci2; Thu, 16 Oct 2025 11:33:31 +0000 Received: from canpmsgout01.his.huawei.com ([113.46.200.216]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1v9MEU-00000004aWO-2cji; Thu, 16 Oct 2025 11:33:25 +0000 dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=Kl8wFEk1Rfimj4SuE/d+n0dMIexnSNg7hsR/i17e6MY=; b=UJGB7Q6ViWGahyodIiBXCAq88T0wmr6s2XW5a8KOiGY2DS43aoyAWx2GYUkD71tQE/3aypdjO L02ClGRAWAt0XtsJxALWDX3IfEDdg/P5w6r1gvbBzhE0cv1lFlr6Df+BVX7M8qA7vtcq6lPuOlQ MnmG8B5ppm70Ym2pVG5vDPc= Received: from mail.maildlp.com (unknown [172.19.88.194]) by canpmsgout01.his.huawei.com (SkyGuard) with ESMTPS id 4cnQmC5MPzz1T4GB; Thu, 16 Oct 2025 19:32:27 +0800 (CST) Received: from kwepemr500001.china.huawei.com (unknown [7.202.194.229]) by mail.maildlp.com (Postfix) with ESMTPS id B884C140257; Thu, 16 Oct 2025 19:33:13 +0800 (CST) Received: from huawei.com (10.50.87.63) by kwepemr500001.china.huawei.com (7.202.194.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 16 Oct 2025 19:33:12 +0800 From: Yin Tirui To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , Subject: [PATCH RFC 1/2] pgtable: add pte_clrhuge() implementation for arm64 and riscv Date: Thu, 16 Oct 2025 19:27:03 +0800 Message-ID: <20251016112704.179280-2-yintirui@huawei.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251016112704.179280-1-yintirui@huawei.com> References: <20251016112704.179280-1-yintirui@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.50.87.63] X-ClientProxiedBy: kwepems200002.china.huawei.com (7.221.188.68) To kwepemr500001.china.huawei.com (7.202.194.229) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251016_043323_025334_E78E9559 X-CRM114-Status: UNSURE ( 8.62 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add pte_clrhuge() helper function for architectures that enable ARCH_SUPPORTS_HUGE_PFNMAP to clear huge page attributes from PTE entries. This function provides the inverse operation of pte_mkhuge() and will be needed for upcoming huge page splitting, where PTE entries derived from huge page mappings need to have their huge page attributes cleared. Future work will refactor pfn_pte() to automatically filter huge bits, removing the need for pte_clrhuge() across all architectures. Signed-off-by: Yin Tirui --- arch/arm64/include/asm/pgtable.h | 8 ++++++++ arch/riscv/include/asm/pgtable.h | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index abd2dee416b3..244755bad46f 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -366,6 +366,14 @@ static inline pte_t pte_mkinvalid(pte_t pte) return pte; } +static inline pte_t pte_clrhuge(pte_t pte) +{ + pteval_t mask = PTE_TYPE_MASK & ~PTE_VALID; + pteval_t val = PTE_TYPE_PAGE & ~PTE_VALID; + + return __pte((pte_val(pte) & ~mask) | val); +} + static inline pmd_t pmd_mkcont(pmd_t pmd) { return __pmd(pmd_val(pmd) | PMD_SECT_CONT); diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 815067742939..b0a20ddf780a 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -455,6 +455,11 @@ static inline pte_t pte_mkhuge(pte_t pte) return pte; } +static inline pte_t pte_clrhuge(pte_t pte) +{ + return pte; +} + #ifdef CONFIG_RISCV_ISA_SVNAPOT #define pte_leaf_size(pte) (pte_napot(pte) ? \ napot_cont_size(napot_cont_order(pte)) :\ -- 2.43.0 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv