Skip to content

Commit 90e636f

Browse files
ardbiesheuvelctmarinas
authored andcommitted
arm64: mm: Make PUD folding check in set_pud() a runtime check
When set_pud() is called on a 4-level paging build config that runs with 3 levels at runtime (which happens with 16k page size builds with support for LPA2), the updated entry is in fact a PGD in swapper_pg_dir[], and this is mapped read-only after boot. So in this case, the existing check needs to be performed as well, even though __PAGETABLE_PUD_FOLDED is not #define'd. So replace the #ifdef with a call to pgtable_l4_enabled(). Cc: Will Deacon <[email protected]> Cc: Marc Zyngier <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Ryan Roberts <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Itaru Kitayama <[email protected]> Signed-off-by: Catalin Marinas <[email protected]>
1 parent 50e3ed0 commit 90e636f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arch/arm64/include/asm/pgtable.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -699,14 +699,14 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)
699699
#define pud_user(pud) pte_user(pud_pte(pud))
700700
#define pud_user_exec(pud) pte_user_exec(pud_pte(pud))
701701

702+
static inline bool pgtable_l4_enabled(void);
703+
702704
static inline void set_pud(pud_t *pudp, pud_t pud)
703705
{
704-
#ifdef __PAGETABLE_PUD_FOLDED
705-
if (in_swapper_pgdir(pudp)) {
706+
if (!pgtable_l4_enabled() && in_swapper_pgdir(pudp)) {
706707
set_swapper_pgd((pgd_t *)pudp, __pgd(pud_val(pud)));
707708
return;
708709
}
709-
#endif /* __PAGETABLE_PUD_FOLDED */
710710

711711
WRITE_ONCE(*pudp, pud);
712712

0 commit comments

Comments
 (0)