Thread (11 messages) 11 messages, 2 authors, 2026-09-24

Re: [PATCH v2 3/6] arm64: use hw_pte_val for HW PTE loads and stores

flat view

From: Ryan Roberts <ryan.roberts@arm.com>
Date: 2026-09-24 12:23:21
Also in: linux-efi, linux-mm, lkml

On 22/09/2026 18:31, Muhammad Usama Anjum wrote:
__ptep_get() returns a SW PTE value, while __set_pte_nosync() accepts
one. When HW PTE storage uses a distinct hw_pte_t, reading or writing
*ptep as a pte_t no longer satisfies those interfaces.

Use hw_pte_val() to expose the pteval_t stored in either the hw_pte_t
wrapper or its pte_t alias. __set_pte_nosync() writes pte_val(pte) to
that storage, while __ptep_get() reads it and reconstructs a pte_t with
__pte().

This avoids imposing a generic conversion interface between HW and SW
PTE representations, which may require architecture-specific context
in the future.

Signed-off-by: Muhammad Usama Anjum <redacted>
Reviewed-by: Ryan Roberts <ryan.roberts@arm.com>
quoted hunk ↗ jump to hunk
---
 arch/arm64/include/asm/pgtable.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 4768ec59de555..ce6580ab63128 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -360,7 +360,7 @@ static inline pte_t pte_clear_uffd(pte_t pte)
 
 static inline void __set_pte_nosync(hw_pte_t *ptep, pte_t pte)
 {
-	WRITE_ONCE(*ptep, pte);
+	WRITE_ONCE(hw_pte_val(*ptep), pte_val(pte));
 }
 
 static inline void __set_pte_complete(pte_t pte)
@@ -381,7 +381,7 @@ static inline void __set_pte(hw_pte_t *ptep, pte_t pte)
 
 static inline pte_t __ptep_get(hw_pte_t *ptep)
 {
-	return READ_ONCE(*ptep);
+	return __pte(READ_ONCE(hw_pte_val(*ptep)));
 }
 
 extern void __sync_icache_dcache(pte_t pteval);
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help