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 56E0BC982ED for ; Mon, 21 Sep 2026 10:58:35 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=c6um4fAE+ApOP8CeIIHgSIPt3KS/GKuFUoAAtDrr13U=; b=lqcGF6B7SRzyJY Jy63/T7lTxXMBL6WGOgJ7dRbPop7NSnGNNjpJktDnvsGZnCf2f1azoNeoTJH/EOlJeIHLkND0ZJ3U DtWft2FtUzFS2n9oldT6wyBwA4lLN3jcLuT9iuB9hJI44waywbVe5Hx2dmwV+xTCL9aGHMwO1uYN7 UgwqbrlseFVWTjV0nv7nuRmcBZAcuD1MyWDpqo/KqCSap/+PwEh9V9Y7+qBWhOGhZANeJXLow2Vb9 9vZPSmL8wwSDfIKjfyZJA/gt218Cm3NuISMzV7Za5vc7tBF3mBLNt3PNbrX5ZaXpfcFhwuCNdVc1S l81QSWzotXy6Bw/ZdRYQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x8bj0-00000001mt1-3R84; Mon, 21 Sep 2026 10:58:18 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x8bix-00000001mot-1g0n; Mon, 21 Sep 2026 10:58:16 +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 40BDB1570; Mon, 21 Sep 2026 03:58:11 -0700 (PDT) Received: from e129823.arm.com (e129823.arm.com [10.2.213.3]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 825133F86C; Mon, 21 Sep 2026 03:58:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1789988294; bh=zghhBXP63HUkMVsnVTW1BBI8m5GQHzJyarBmwmrVkLw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=MorCeI/0C/ThGp2D4ZEh7K7qiGRxxQCGAsOHcPHI8GDUa1xn7PAojRccrrdxW6og8 7gC8n59mRHcXPujdGPAn1COCNTSdHIzjz22YYHLWyrX2pcSMdp+njUrasxT+e7EdHJ XyalCkCDo/UbMgMots6tY7qOdO97VEdNuudBqO4c= From: Yeoreum Yun Date: Mon, 21 Sep 2026 11:55:36 +0100 Subject: [PATCH 14/21] x86: mm: use pgtable_level enum in effective_prot_pXd() MIME-Version: 1.0 Message-Id: <20260921-dummy_ptxp3-v1-14-cd40cf68242e@arm.com> References: <20260921-dummy_ptxp3-v1-0-cd40cf68242e@arm.com> In-Reply-To: <20260921-dummy_ptxp3-v1-0-cd40cf68242e@arm.com> To: Russell King , Huacai Chen , WANG Xuerui , Thomas Bogendoerfer , Catalin Marinas , Will Deacon , Arnd Bergmann , Andrew Morton , Kairui Song , Qi Zheng , Shakeel Butt , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Johannes Weiner , David Hildenbrand , Michal Hocko , Lorenzo Stoakes , Tianrui Zhao , Bibo Mao , Anup Patel , Atish Patra , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jonas Bonn , Stefan Kristiansson , Stafford Horne Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-openrisc@vger.kernel.org, Yeoreum Yun X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2497; i=yeoreum.yun@arm.com; h=from:subject:message-id; bh=zghhBXP63HUkMVsnVTW1BBI8m5GQHzJyarBmwmrVkLw=; b=owEB7QES/pANAwAKAW3Vw9FaxTEzAcsmYgBqsQ1RutA9R6RYKg0XGt206R+FZYSBvFY5A7m64 WCknKwpoKOJAbMEAAEKAB0WIQQtg+CS3QUzuFh1pJ1t1cPRWsUxMwUCarENUQAKCRBt1cPRWsUx M1QqC/48OSPJozKEnLVOpX6otIW9FV5BhnqTBmb/jwyRutaZTgzJxzVOUro/bD5JHER9PhjqHfC eNHCzQ1aUnfnS7hLDorqqVWwzassmuk8DAzqYuKYx91zEvDYa7JHkMxtVu+yZwGD4suG0HUTQf+ dBbV/wqn4/Ti6iKvRok/awM2egxq3wOCeRisJK0d/rzhD4FGVvxR1DillMtTLyoQbZfBChN9JQP NS9xULrwDo4o0EjfcCUWv39K5oJhzQyWbtp9oqdCn/su/PFFe/MqZkv7neLUboJQqVqggUuY8T9 0m+0FAwi7HeXPlZGKY54LikTFhGv8+Q1tjO3XDJqbLRmZjXxuoSNMR53I02cOkTtEfur207dk5u PqU8kFQ9uSI+wNPOym96FPcqi5SPQomkOAkxT1DTaDPdy9LP/KsdH6btJ2oVPH4ATfgpa/1ZL5h FjqEaVjHTPbvc7Tq5zEvipHN2jBSw3foGfVlRqGbIDxVSrv3u88KbKb0TC3yEmyALLVEY= X-Developer-Key: i=yeoreum.yun@arm.com; a=openpgp; fpr=2D83E092DD0533B85875A49D6DD5C3D15AC53133 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260921_035815_520474_6754E2D0 X-CRM114-Status: GOOD ( 12.46 ) 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 Instead of using hard-coded integers in effective_prot_pXd(), use the page-table level enum so that architecture code does not need to know the numeric value of each page-table level, while also providing type safety. This also prepares for using generic MM helpers, mm_first_pgtable_level() which use symbolic names for page-table levels rather than integers. There should be no functional change. Reviewed-by: David Hildenbrand (Arm) Acked-by: Dave Hansen Signed-off-by: Yeoreum Yun --- arch/x86/mm/dump_pagetables.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c index 2afa7a23340e9..a18a61e732c3d 100644 --- a/arch/x86/mm/dump_pagetables.c +++ b/arch/x86/mm/dump_pagetables.c @@ -248,13 +248,13 @@ static void note_wx(struct pg_state *st, unsigned long addr) (void *)st->start_address); } -static void effective_prot(struct ptdump_state *pt_st, int level, u64 val) +static void effective_prot(struct ptdump_state *pt_st, enum pgtable_level level, u64 val) { struct pg_state *st = container_of(pt_st, struct pg_state, ptdump); pgprotval_t prot = val & PTE_FLAGS_MASK; pgprotval_t effective; - if (level > 0) { + if (level > PGTABLE_LEVEL_PGD) { pgprotval_t higher_prot = st->prot_levels[level - 1]; effective = (higher_prot & prot & (_PAGE_USER | _PAGE_RW)) | @@ -268,27 +268,27 @@ static void effective_prot(struct ptdump_state *pt_st, int level, u64 val) static void effective_prot_pte(struct ptdump_state *st, pte_t pte) { - effective_prot(st, 4, pte_val(pte)); + effective_prot(st, PGTABLE_LEVEL_PTE, pte_val(pte)); } static void effective_prot_pmd(struct ptdump_state *st, pmd_t pmd) { - effective_prot(st, 3, pmd_val(pmd)); + effective_prot(st, PGTABLE_LEVEL_PMD, pmd_val(pmd)); } static void effective_prot_pud(struct ptdump_state *st, pud_t pud) { - effective_prot(st, 2, pud_val(pud)); + effective_prot(st, PGTABLE_LEVEL_PUD, pud_val(pud)); } static void effective_prot_p4d(struct ptdump_state *st, p4d_t p4d) { - effective_prot(st, 1, p4d_val(p4d)); + effective_prot(st, PGTABLE_LEVEL_P4D, p4d_val(p4d)); } static void effective_prot_pgd(struct ptdump_state *st, pgd_t pgd) { - effective_prot(st, 0, pgd_val(pgd)); + effective_prot(st, PGTABLE_LEVEL_PGD, pgd_val(pgd)); } -- 2.43.0 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv