From: sashiko-bot@kernel.org
To: "Muhammad Usama Anjum" <usama.anjum@arm.com>
Cc: dri-devel@lists.freedesktop.org, damon@lists.linux.dev,
bpf@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH RFC 05/11] mm: convert PTE table entries in ptep_get()
Date: Mon, 27 Jul 2026 16:58:06 +0000 [thread overview]
Message-ID: <20260727165807.9212C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260727164715.2866609-6-usama.anjum@arm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Incorrect placement of READ_ONCE() around __pte_from_hw() in ptep_get() breaks atomic PTE reads and causes compilation failures for architectures overriding the hook.
- [Medium] ptep_get_lockless() fails to apply the __pte_from_hw() conversion hook when CONFIG_GUP_GET_PXX_LOW_HIGH is enabled.
--
--- Patch [5]: [PATCH RFC 05/11] mm: convert PTE table entries in ptep_get() ---
commit e1a429a7f2c12fbd880800f901c43b4ccbc922d7
Author: Muhammad Usama Anjum <usama.anjum@arm.com>
mm: convert PTE table entries in ptep_get()
This commit introduces a conversion hook __pte_from_hw() for ptep_get(),
allowing the function to accept a pointer to hw_pte_t and return a logical
pte_t value. The generic ptep_get() implementation is updated to use this
new hook.
> 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));
[Severity: High]
Does wrapping __pte_from_hw() inside READ_ONCE() break the atomic read
semantics and build stability?
READ_ONCE() requires an lvalue to perform a volatile read. If an architecture
implements __pte_from_hw() as an inline function returning an rvalue, this
will cause a compilation error (lvalue required as unary '&' operand).
If implemented as a macro returning a compound literal, it compiles but the
actual read of *ptep occurs outside the volatile scope during the
initialization of the stack temporary. This allows the compiler to tear or
reorder the memory load, potentially breaking the concurrency safety of the
page table read.
Should this be __pte_from_hw(READ_ONCE(*ptep)) instead, to ensure the memory
is read atomically before the conversion is applied?
[Severity: Medium]
Does the lockless fallback loop in ptep_get_lockless() also need to apply
this new __pte_from_hw() conversion hook?
Looking at ptep_get_lockless() in include/linux/pgtable.h for architectures
using CONFIG_GUP_GET_PXX_LOW_HIGH, it currently constructs and returns an
unconverted PTE directly:
do {
pte.pte_low = ptep->pte_low;
smp_rmb();
pte.pte_high = ptep->pte_high;
smp_rmb();
} while (unlikely(pte.pte_low != ptep->pte_low));
return pte;
If an architecture using this configuration requires a custom hw_pte_t
conversion, callers might misinterpret the logical bits of the unconverted
hardware PTE. Is it necessary to apply __pte_from_hw() to the assembled
PTE before returning it?
> }
> #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 */
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260727164715.2866609-1-usama.anjum@arm.com?part=5
next prev parent reply other threads:[~2026-07-27 16:58 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 16:46 [PATCH RFC 00/11] mm: distinguish PTE table storage from PTE values Muhammad Usama Anjum
2026-07-27 16:46 ` [PATCH RFC 01/11] mm: introduce hw_pte_t for PTE table storage Muhammad Usama Anjum
2026-07-27 16:58 ` sashiko-bot
2026-07-27 16:46 ` [PATCH RFC 02/11] mm: make hw_pte_t visible to generic PTE interfaces Muhammad Usama Anjum
2026-07-27 16:46 ` [PATCH RFC 03/11] mm: name pointers to copied PTE values ptentp Muhammad Usama Anjum
2026-07-27 16:46 ` [PATCH RFC 04/11] mm: use hw_pte_t for generic PTE table storage Muhammad Usama Anjum
2026-07-27 16:46 ` [PATCH RFC 05/11] mm: convert PTE table entries in ptep_get() Muhammad Usama Anjum
2026-07-27 16:58 ` sashiko-bot [this message]
2026-07-27 16:46 ` [PATCH RFC 06/11] mm/kasan: use hw_pte_t for the early shadow PTE table Muhammad Usama Anjum
2026-07-27 16:46 ` [PATCH RFC 07/11] mm/mremap: use ptep_get() for the destination PTE Muhammad Usama Anjum
2026-07-27 16:46 ` [PATCH RFC 08/11] drm/i915: use hw_pte_t for PTE range callbacks Muhammad Usama Anjum
2026-07-27 16:47 ` [PATCH RFC 09/11] misc/sgi-gru: use ptep_get() for page-table reads Muhammad Usama Anjum
2026-07-27 17:09 ` sashiko-bot
2026-07-27 16:47 ` [PATCH RFC 10/11] parisc: use hw_pte_t for the data-break callback Muhammad Usama Anjum
2026-07-27 16:47 ` [PATCH RFC 11/11] xen: use hw_pte_t for PTE range callbacks Muhammad Usama Anjum
2026-07-27 17:06 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260727165807.9212C1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=damon@lists.linux.dev \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=usama.anjum@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox