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 787FBCAC5A7 for ; Tue, 23 Sep 2025 13:37:57 +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=E5mAqJCY1HvYO2gynuPoCQEYsLBhfSSeHsL+Ob0L4VE=; b=1Y2kESaDqIBn5X jQTo9QzjGObijxAkimiXRn2HEUsRl+HGuI7bWi2rgQmWTo8FPP9iXo5DsGC683R05vZ6PDRFkTS7T t/BoAEhZotIC1UwJIEZRQgRlgkWE7rBBrBqL4lhp49yNjNK/C9gYNS/6bGnDtP3BBXOikOFz1P8V3 dhiEQHA3voGfgiOX0jSC2PSUQhQq049B1rAZABIE+EFhX04qXCbEse9pvBKYTgWPRBFd0XP5EqNOE dYxT/xJ0LrK/ixBfpj//eZ/OVKZ9eBMa/4AtfGE020eNfh6wXW2p/YFgMiFC0+rq6ix9852Hv4+Eh r0AORN78zYulsKm4s3iw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1v13DL-0000000DXcL-0P55; Tue, 23 Sep 2025 13:37:51 +0000 Received: from szxga03-in.huawei.com ([45.249.212.189]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1v13D8-0000000DXO5-3Yi7; Tue, 23 Sep 2025 13:37:40 +0000 Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4cWLWg3pB3zddT4; Tue, 23 Sep 2025 21:32:47 +0800 (CST) Received: from kwepemr500001.china.huawei.com (unknown [7.202.194.229]) by mail.maildlp.com (Postfix) with ESMTPS id E43701800B1; Tue, 23 Sep 2025 21:37:25 +0800 (CST) Received: from huawei.com (10.175.101.6) 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; Tue, 23 Sep 2025 21:37:24 +0800 From: Yin Tirui To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , Subject: [PATCH RFC 1/2] pgtable: add pte_clrhuge() implementation for arm64 and riscv Date: Tue, 23 Sep 2025 21:31:03 +0800 Message-ID: <20250923133104.926672-2-yintirui@huawei.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250923133104.926672-1-yintirui@huawei.com> References: <20250923133104.926672-1-yintirui@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) 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-20250923_063739_083419_0BF1DA5D X-CRM114-Status: UNSURE ( 8.33 ) 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. 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 91697fbf1f90..125b241e6d2c 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