Skip to contentSkip to conversation

arm64 lpa2 fixes

PATCH Applied Ard Biesheuvel 3 participants 5 messages Mar 1, 2024 arm64

lore
Share & tools
lore
#0 lore raw

cover arm64 lpa2 fixes

From: Ard Biesheuvel <[email protected]>

A couple of fixes for the LPA2 code queued up in arm64/for-next.

Ard Biesheuvel (2):
arm64/mm: Use generic __pud_free() helper in pud_free() implementation arm64/mm: Avoid ID mapping of kpti flag if it is no longer needed

 arch/arm64/include/asm/pgalloc.h | 3 +--
 arch/arm64/mm/mmu.c              | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)
Signature · 7 lines
2.44.0.278.ge034bb2e1d-goog


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#1 lore raw

PATCH 1/2 arm64/mm: Use generic __pud_free() helper in pud_free() implementation

From: Ard Biesheuvel <[email protected]>

Commit 0dd4f60a2c76 ("arm64: mm: Add support for folding PUDs at runtime") implements specialized PUD alloc/free helpers to allow the decision whether or not to fold PUDs to be made at runtime when the number of paging levels is 4 or higher.

Its implementation of pud_free() is based on the generic version that existed when the patch was first written, but in the meantime, the freeing of a PUD has become a bit more involved, and so instead of simply freeing the page, we should invoke the generic __pud_free() that encapsulates whatever needs doing at this point.

This fixes a reported warning emitted by the page flags self-diagnostics.

---
 arch/arm64/include/asm/pgalloc.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/include/asm/pgalloc.h +1 -2
index aeba2cf15a25..8ff5f2a2579e 100644
@@ -60,8 +60,7 @@ static inline void pud_free(struct mm_struct *mm, pud_t *pud)
 {
 	if (!pgtable_l4_enabled())
 		return;
-	BUG_ON((unsigned long)pud & (PAGE_SIZE-1));
-	free_page((unsigned long)pud);
+	__pud_free(mm, pud);
 }
 #else
 static inline void __p4d_populate(p4d_t *p4dp, phys_addr_t pudp, p4dval_t prot)
Signature · 7 lines
2.44.0.278.ge034bb2e1d-goog


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Tested-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] arm64/mm: Use generic __pud_free() helper in pud_free() implementation

Quoted 13 lines · Ard Biesheuvel

From: Ard Biesheuvel <[email protected]>

Commit 0dd4f60a2c76 ("arm64: mm: Add support for folding PUDs at runtime") implements specialized PUD alloc/free helpers to allow the decision whether or not to fold PUDs to be made at runtime when the number of paging levels is 4 or higher.

Its implementation of pud_free() is based on the generic version that existed when the patch was first written, but in the meantime, the freeing of a PUD has become a bit more involved, and so instead of simply freeing the page, we should invoke the generic __pud_free() that encapsulates whatever needs doing at this point.

Quoted 5 lines

This fixes a reported warning emitted by the page flags self-diagnostics.

Quoted 9 lines
---
 arch/arm64/include/asm/pgalloc.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/include/asm/pgalloc.h +0 -0
index aeba2cf15a25..8ff5f2a2579e 100644

arch/arm64/include/asm/pgalloc.h static inline void pud_free(struct mm_struct *mm, pud_t *pud) · line 66

Quoted 9 lines
arch/arm64/include/asm/pgalloc.h +1 -2
@@ -60,8 +60,7 @@ static inline void pud_free(struct mm_struct *mm, pud_t *pud)
 {
 	if (!pgtable_l4_enabled())
 		return;
-	BUG_ON((unsigned long)pud & (PAGE_SIZE-1));
-	free_page((unsigned long)pud);
+	__pud_free(mm, pud);
 }
 #else
 static inline void __p4d_populate(p4d_t *p4dp, phys_addr_t pudp, p4dval_t prot)

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#3 lore raw

PATCH 2/2 arm64/mm: Avoid ID mapping of kpti flag if it is no longer needed

In reply to Ard Biesheuvel

From: Ard Biesheuvel <[email protected]>

arm64_use_ng_mappings will be set to 'true' by the early boot code if it decides to use non-global (nG) attributes for all kernel mappings, typically when enabling KASLR on a system that does not implement E0PD.

In this case, the G-to-nG update routines are never called, and so there is no reason to create the writable mapping of the associated status flag in the ID map.

---
 arch/arm64/mm/mmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/mm/mmu.c +1 -1
index b131ed31a6c8..bf5b1c426ad0 100644
@@ -777,7 +777,7 @@ static void __init create_idmap(void)
 		       IDMAP_ROOT_LEVEL, (pte_t *)idmap_pg_dir, false,
 		       __phys_to_virt(ptep) - ptep);
 
-	if (IS_ENABLED(CONFIG_UNMAP_KERNEL_AT_EL0)) {
+	if (IS_ENABLED(CONFIG_UNMAP_KERNEL_AT_EL0) && !arm64_use_ng_mappings) {
 		extern u32 __idmap_kpti_flag;
 		u64 pa = __pa_symbol(&__idmap_kpti_flag);
 
Signature · 7 lines
2.44.0.278.ge034bb2e1d-goog


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer Applied
#4 lore raw
In reply to Ard Biesheuvel
Quoted 8 lines · Ard Biesheuvel

A couple of fixes for the LPA2 code queued up in arm64/for-next.

Ard Biesheuvel (2):
arm64/mm: Use generic __pud_free() helper in pud_free() implementation arm64/mm: Avoid ID mapping of kpti flag if it is no longer needed

[...]

Applied to arm64 (for-next/stage1-lpa2), thanks!

[1/2] arm64/mm: Use generic __pud_free() helper in pud_free() implementation

      https://git.kernel.org/arm64/c/3137db4c66bf
[2/2] arm64/mm: Avoid ID mapping of kpti flag if it is no longer needed
      https://git.kernel.org/arm64/c/27f2b9fcddc7
Signature · 7 lines
Catalin


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel