Skip to content

Commit 4fa8a9c

Browse files
Anshuman Khandualctmarinas
authored andcommitted
arm64/mm: Check PXD_TYPE_TABLE in [p4d|pgd]_bad()
Check page table entries against PXD_TYPE_TABLE on PXD_TYPE_MASK mask bits in [p4d|pgd]_bad() while determining a table entry instead of just checking only for PXD_TABLE_BIT. Cc: Will Deacon <will@kernel.org> Cc: Ard Biesheuvel <ardb@kernel.org> Cc: Ryan Roberts <ryan.roberts@arm.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com> Link: https://lore.kernel.org/r/20250221044227.1145393-6-anshuman.khandual@arm.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 1601df9 commit 4fa8a9c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

arch/arm64/include/asm/pgtable.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,9 @@ static inline bool mm_pud_folded(const struct mm_struct *mm)
918918
pr_err("%s:%d: bad pud %016llx.\n", __FILE__, __LINE__, pud_val(e))
919919

920920
#define p4d_none(p4d) (pgtable_l4_enabled() && !p4d_val(p4d))
921-
#define p4d_bad(p4d) (pgtable_l4_enabled() && !(p4d_val(p4d) & P4D_TABLE_BIT))
921+
#define p4d_bad(p4d) (pgtable_l4_enabled() && \
922+
((p4d_val(p4d) & P4D_TYPE_MASK) != \
923+
P4D_TYPE_TABLE))
922924
#define p4d_present(p4d) (!p4d_none(p4d))
923925

924926
static inline void set_p4d(p4d_t *p4dp, p4d_t p4d)
@@ -1045,7 +1047,9 @@ static inline bool mm_p4d_folded(const struct mm_struct *mm)
10451047
pr_err("%s:%d: bad p4d %016llx.\n", __FILE__, __LINE__, p4d_val(e))
10461048

10471049
#define pgd_none(pgd) (pgtable_l5_enabled() && !pgd_val(pgd))
1048-
#define pgd_bad(pgd) (pgtable_l5_enabled() && !(pgd_val(pgd) & PGD_TABLE_BIT))
1050+
#define pgd_bad(pgd) (pgtable_l5_enabled() && \
1051+
((pgd_val(pgd) & PGD_TYPE_MASK) != \
1052+
PGD_TYPE_TABLE))
10491053
#define pgd_present(pgd) (!pgd_none(pgd))
10501054

10511055
static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)

0 commit comments

Comments
 (0)