[PATCH V3 02/14] arm64/mm: Route all pgtable reads via ptval_get()

Anshuman Khandual anshuman.khandual at arm.com
Mon Nov 16 23:06:01 PST 2026


Define arm64 platform specific implementations for new pxdp_get() helpers.
These resolve into READ_ONCE(), thus ensuring required single copy atomic
semantics for the page table entry reads.

In future this infrastructure can be used for D128 to maintain single copy
atomicity semantics with inline asm blocks.

Cc: Catalin Marinas <catalin.marinas at arm.com>
Cc: Will Deacon <will at kernel.org>
Cc: Ryan Roberts <ryan.roberts at arm.com>
Cc: Mark Rutland <mark.rutland at arm.com>
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-kernel at vger.kernel.org
Reviewed-by: David Hildenbrand (Arm) <david at kernel.org>
Signed-off-by: Anshuman Khandual <anshuman.khandual at arm.com>
---
 arch/arm64/include/asm/pgtable.h | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index a760c65de5cbe..1c982ccc1e5e3 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -84,28 +84,30 @@ static inline void arch_leave_lazy_mmu_mode(void)
 	arch_flush_lazy_mmu_mode();
 }
 
+#define ptval_get(x)		READ_ONCE(x)
+
 #define pmdp_get pmdp_get
 static inline pmd_t pmdp_get(const pmd_t *pmdp)
 {
-	return READ_ONCE(*pmdp);
+	return ptval_get(*pmdp);
 }
 
 #define pudp_get pudp_get
 static inline pud_t pudp_get(const pud_t *pudp)
 {
-	return READ_ONCE(*pudp);
+	return ptval_get(*pudp);
 }
 
 #define p4dp_get p4dp_get
 static inline p4d_t p4dp_get(const p4d_t *p4dp)
 {
-	return READ_ONCE(*p4dp);
+	return ptval_get(*p4dp);
 }
 
 #define pgdp_get pgdp_get
 static inline pgd_t pgdp_get(const pgd_t *pgdp)
 {
-	return READ_ONCE(*pgdp);
+	return ptval_get(*pgdp);
 }
 
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
@@ -405,7 +407,7 @@ static inline void __set_pte(pte_t *ptep, pte_t pte)
 
 static inline pte_t __ptep_get(pte_t *ptep)
 {
-	return READ_ONCE(*ptep);
+	return ptval_get(*ptep);
 }
 
 extern void __sync_icache_dcache(pte_t pteval);
-- 
2.43.0




More information about the linux-arm-kernel mailing list