Re: [PATCH v2 3/6] arm64: use hw_pte_val for HW PTE loads and stores
From: Ryan Roberts
Date: Thu Sep 24 2026 - 08:29:32 EST
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 <usama.anjum@xxxxxxx>
Reviewed-by: Ryan Roberts <ryan.roberts@xxxxxxx>
> ---
> 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);
>