From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 39B8F489FDE; Mon, 21 Sep 2026 10:58:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789988297; cv=none; b=lXabdLsHTHmX2aT2kPmmq2c5Ea5qCG6dWayzNQD2Dxs1Dn9FVUVncwFocNd0XQ3yHrzT9Tr3pOfuOJXw0WHijAP0osdebT5+8wj8Iqk44ut4S56vbojdtyUAW/nIGteaGtizZiuPEAy6A/gM+DER2S3ZvMfeqT/rAM/SympXEW4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789988297; c=relaxed/simple; bh=zghhBXP63HUkMVsnVTW1BBI8m5GQHzJyarBmwmrVkLw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nOV4DOTg65o0Pdc7AsBORjhE7ya58XHU+hLohJBHAOeXberR42SzDoZaFbf+27Y9RWTX/e+zFmK5xeInMlgqYruNG9jmp+b9w08m5P3TWlJ3ZSPdNeDrUX/mLKftO/wX6MGlZmerxL8zWxJGA9QFFRCbQSrlLZEhEdo3g8G2rMk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=MorCeI/0; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="MorCeI/0" 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() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 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