* [PATCH] arm64: mm: Make PUD folding check in set_pud() a runtime check
@ 2024-02-16 23:59 Ard Biesheuvel
2024-02-19 16:48 ` Catalin Marinas
0 siblings, 1 reply; 2+ messages in thread
From: Ard Biesheuvel @ 2024-02-16 23:59 UTC (permalink / raw)
To: linux-arm-kernel
Cc: Ard Biesheuvel, Catalin Marinas, Will Deacon, Marc Zyngier,
Mark Rutland, Ryan Roberts
From: Ard Biesheuvel <ardb@kernel.org>
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: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/arm64/include/asm/pgtable.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index b3c716fa8121..8bec85350865 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -699,14 +699,14 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)
#define pud_user(pud) pte_user(pud_pte(pud))
#define pud_user_exec(pud) pte_user_exec(pud_pte(pud))
+static inline bool pgtable_l4_enabled(void);
+
static inline void set_pud(pud_t *pudp, pud_t pud)
{
-#ifdef __PAGETABLE_PUD_FOLDED
- if (in_swapper_pgdir(pudp)) {
+ if (!pgtable_l4_enabled() && in_swapper_pgdir(pudp)) {
set_swapper_pgd((pgd_t *)pudp, __pgd(pud_val(pud)));
return;
}
-#endif /* __PAGETABLE_PUD_FOLDED */
WRITE_ONCE(*pudp, pud);
--
2.44.0.rc0.258.g7320e95886-goog
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] arm64: mm: Make PUD folding check in set_pud() a runtime check
2024-02-16 23:59 [PATCH] arm64: mm: Make PUD folding check in set_pud() a runtime check Ard Biesheuvel
@ 2024-02-19 16:48 ` Catalin Marinas
0 siblings, 0 replies; 2+ messages in thread
From: Catalin Marinas @ 2024-02-19 16:48 UTC (permalink / raw)
To: linux-arm-kernel, Ard Biesheuvel
Cc: Will Deacon, Ard Biesheuvel, Marc Zyngier, Mark Rutland,
Ryan Roberts
On Sat, 17 Feb 2024 00:59:44 +0100, Ard Biesheuvel wrote:
> 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().
>
> [...]
Applied to arm64 (for-next/stage1-lpa2), thanks!
[1/1] arm64: mm: Make PUD folding check in set_pud() a runtime check
https://git.kernel.org/arm64/c/90e636f60b76
--
Catalin
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-02-19 16:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-16 23:59 [PATCH] arm64: mm: Make PUD folding check in set_pud() a runtime check Ard Biesheuvel
2024-02-19 16:48 ` Catalin Marinas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).