From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Muhammad Usama Anjum <usama.anjum@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Lorenzo Stoakes <ljs@kernel.org>,
Ryan Roberts <ryan.roberts@arm.com>,
Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Anshuman Khandual <anshuman.khandual@arm.com>,
Zi Yan <ziy@nvidia.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Samuel Holland <samuel.holland@sifive.com>,
Peter Xu <peterx@redhat.com>,
linux-mm@kvack.org, linux-arch@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 0/9] mm: distinguish HW PTE pointers from SW PTE value pointers
Date: Thu, 19 Nov 2026 18:00:32 +0100 [thread overview]
Message-ID: <d9253b46-19bf-42b9-a46f-55d3199d67d3@kernel.org> (raw)
In-Reply-To: <2a84fa4f-655d-4c4d-b6ad-b2ee9d37d972@arm.com>
On 11/18/26 22:48, Muhammad Usama Anjum wrote:
> On 16/11/2026 6:18 pm, David Hildenbrand (Arm) wrote:
>> On 11/16/26 18:41, Catalin Marinas wrote:
>>> Hi Usama,
>>>
>> Hi,
>>
>> David here :)
>>
>>> (trimmed the Cc list, some lists reject it as too many recipients)
>>>
>>>
>>> [...]
>>>
>>>
>>> I looked at this (and the arm64 counterpart) and I'm not fully convinced
>>> it's worth the effort (but I won't oppose it if the mm folk decide to go
>>> this route).
>>
>> I think this is the right thing to do to get type safety.
>>
>>>
>>> First, I'd like to see all such on-stack p*d pointers addressed as a
>>> prerequisite (e.g. fix pmd_populate() in __split_huge_zero_page_pmd()).
>>> If for some reason we deem pmd not fixable, I don't like half (or
>>> quarter) baked solutions just addressing the pte.
>>
>> IIRC doing the full PxD conversion is quite big; doens't make sense to post
>> these on the list and instead move stepwise.
>>
>> Agreed that it would be nice to get rid of all stack usage first.
>>
>>>
>>> Second, we could add a run-time page table check, at least for pmd/pte.
>>> Something like below, gated by CONFIG_PAGE_TABLE_CHECK or
>>> CONFIG_DEBUG_VM (untested and not entirely sure about using
>>> PageTable()):
>>>
>>> static inline void pgtable_ptr_check(struct mm_struct *mm, const void *p)
>>> {
>>> if (object_is_on_stack(p)) {
>>> WARN_ON_ONCE(1);
>>> return;
>>> }
>>> if (mm != &init_mm && virt_addr_valid(p))
>>> WARN_ON_ONCE(!PageTable(virt_to_page(p)));
>>> }
>>>
>>> You already have some coccinelle patches to make the conversion. Could
>>> we turn them into a coccicheck to detect new uses? With LLM reviews like
>>> Sashiko, we can probably catch new uses violating the requirement (we
>>> need to document it).
>>>
>>> LLMs and coccicheck won't catch all abuses nor does this series prevent
>>> one from declaring hw_pte_t on the stack.
>>>
>>> Once the above are in place, I'd look again at these patches and see
>>> whether they improve code clarity and are worth the churn.
>>>
>>> Maybe an argument in favour of these patchsets is future dynamic support
>>> for FEAT_D128, we'd need to separate the software representation of a
>>> pte from the hardware one but we've done this before (arm32 non-LPAE has
>>> different representations).
>>
>> Exactly; we'll need this and go one step further and disallow any ptep++ to
>> instead route this through helpers.
>
> Agreed, after the current series, we can easily make hw_pte_t opaque like the
> following (or in even better way if we spend some more time thinking about it):
>
Yes, exactly.
--
Cheers,
David
next prev parent reply other threads:[~2026-11-19 17:00 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 17:12 [PATCH v3 0/9] mm: distinguish HW PTE pointers from SW PTE value pointers Muhammad Usama Anjum
2026-09-22 17:12 ` [PATCH v3 1/9] mm: introduce hw_pte_t for PTE table storage Muhammad Usama Anjum
2026-09-22 17:20 ` sashiko-bot
2026-09-30 4:13 ` Anshuman Khandual
2026-09-30 15:27 ` Zi Yan
2026-09-22 17:12 ` [PATCH v3 2/9] mm: rename pointers to software PTE values as ptentp Muhammad Usama Anjum
2026-09-22 17:21 ` sashiko-bot
2026-09-30 4:20 ` Anshuman Khandual
2026-09-22 17:12 ` [PATCH v3 3/9] mm: use hw_pte_t for generic PTE table storage Muhammad Usama Anjum
2026-09-22 17:27 ` sashiko-bot
2026-09-30 4:35 ` Anshuman Khandual
2026-09-30 17:40 ` Muhammad Usama Anjum
2026-10-01 11:25 ` David Hildenbrand (Arm)
2026-10-01 11:26 ` David Hildenbrand (Arm)
2026-09-22 17:12 ` [PATCH v3 4/9] mm: convert PTE table entries in ptep_get() Muhammad Usama Anjum
2026-09-22 17:25 ` sashiko-bot
2026-09-30 5:10 ` Anshuman Khandual
2026-09-30 17:46 ` Muhammad Usama Anjum
2026-10-01 11:27 ` David Hildenbrand (Arm)
2026-09-22 17:12 ` [PATCH v3 5/9] mm: convert PTE table entry to pte Muhammad Usama Anjum
2026-09-22 17:19 ` sashiko-bot
2026-10-01 11:17 ` David Hildenbrand (Arm)
2026-10-02 14:57 ` Muhammad Usama Anjum
2026-09-22 17:12 ` [PATCH v3 6/9] mm: add hw_pte_val for HW PTE storage Muhammad Usama Anjum
2026-09-22 17:22 ` sashiko-bot
2026-10-01 11:19 ` David Hildenbrand (Arm)
2026-10-02 14:59 ` Muhammad Usama Anjum
2026-09-22 17:12 ` [PATCH v3 7/9] mm/kasan: use hw_pte_t for the early shadow PTE table Muhammad Usama Anjum
2026-09-22 17:21 ` sashiko-bot
2026-10-01 11:20 ` David Hildenbrand (Arm)
2026-09-22 17:12 ` [PATCH v3 8/9] drm/i915: use hw_pte_t for PTE range callbacks Muhammad Usama Anjum
2026-09-22 17:23 ` sashiko-bot
2026-10-01 11:21 ` David Hildenbrand (Arm)
2026-09-22 17:12 ` [PATCH v3 9/9] xen: " Muhammad Usama Anjum
2026-09-22 17:30 ` sashiko-bot
2026-10-01 11:22 ` David Hildenbrand (Arm)
2026-09-23 23:16 ` ✗ Fi.CI.BUILD: failure for mm: distinguish HW PTE pointers from SW PTE value pointers Patchwork
2026-09-28 7:09 ` [PATCH v3 0/9] " Alexander Gordeev
2026-11-16 17:41 ` Catalin Marinas
2026-11-16 18:18 ` David Hildenbrand (Arm)
2026-11-18 21:48 ` Muhammad Usama Anjum
2026-11-19 17:00 ` David Hildenbrand (Arm) [this message]
2026-11-18 21:41 ` Muhammad Usama Anjum
2026-11-20 16:48 ` Catalin Marinas
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=d9253b46-19bf-42b9-a46f-55d3199d67d3@kernel.org \
--to=david@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=catalin.marinas@arm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mark.rutland@arm.com \
--cc=peterx@redhat.com \
--cc=ryan.roberts@arm.com \
--cc=samuel.holland@sifive.com \
--cc=usama.anjum@arm.com \
--cc=will@kernel.org \
--cc=ziy@nvidia.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.