Re: [PATCH RFC 05/11] mm: convert PTE table entries in ptep_get()

From: Muhammad Usama Anjum

Date: Thu Jul 30 2026 - 06:34:38 EST


On 30/07/2026 11:08 am, Alexander Gordeev wrote:
> On Mon, Jul 27, 2026 at 05:46:56PM +0100, Muhammad Usama Anjum wrote:
>> ptep_get() now accepts a pointer to hw_pte_t storage but must continue to
>> return a logical pte_t value. Add __pte_from_hw() as the conversion hook
>> and apply it in the generic ptep_get() implementation.
>>
>> Signed-off-by: Muhammad Usama Anjum <usama.anjum@xxxxxxx>
>> ---
>> include/linux/pgtable.h | 2 +-
>> include/linux/pgtable_types.h | 1 +
>> 2 files changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h
>> index dad80d264aac2..3003ac9cd81fe 100644
>> --- a/include/linux/pgtable.h
>> +++ b/include/linux/pgtable.h
>> @@ -493,7 +493,7 @@ static inline int pudp_set_access_flags(struct vm_area_struct *vma,
>> #ifndef ptep_get
>> static inline pte_t ptep_get(hw_pte_t *ptep)
>> {
>> - return READ_ONCE(*ptep);
>> + return READ_ONCE(__pte_from_hw(*ptep));
>
> Should it be something like?
>
> return __pte_from_hw(READ_ONCE(*ptep));
I'd thought about it. My thinking is that we should get the pte_t first before
before calling READ_ONCE(). Please correct me what makes more sense?

>
>> }
>> #endif
>>
>> diff --git a/include/linux/pgtable_types.h b/include/linux/pgtable_types.h
>> index ed5dba42a4f8c..61afe27307ec2 100644
>> --- a/include/linux/pgtable_types.h
>> +++ b/include/linux/pgtable_types.h
>> @@ -6,6 +6,7 @@
>>
>> #ifndef __HAVE_ARCH_HW_PTE_T
>> #define hw_pte_t pte_t
>> +#define __pte_from_hw(pte) (pte)
>> #endif
>>
>> #endif /* _LINUX_PGTABLE_TYPES_H */
>> --
>> 2.47.3
>>

--
Thanks,
Usama