From: Muhammad Usama Anjum <usama.anjum@arm.com>
To: Ryan Roberts <ryan.roberts@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Ard Biesheuvel <ardb@kernel.org>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Andrey Ryabinin <ryabinin.a.a@gmail.com>,
Alexander Potapenko <glider@google.com>,
Andrey Konovalov <andreyknvl@gmail.com>,
Dmitry Vyukov <dvyukov@google.com>,
Vincenzo Frascino <vincenzo.frascino@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>,
Lorenzo Stoakes <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>
Cc: usama.anjum@arm.com, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org,
kasan-dev@googlegroups.com, linux-mm@kvack.org
Subject: Re: [PATCH 1/6] arm64: use hw_pte_t for HW PTE pointers
Date: Mon, 21 Sep 2026 09:20:25 +0100 [thread overview]
Message-ID: <0217ddbc-71b0-4263-9e2a-3218644d08d9@arm.com> (raw)
In-Reply-To: <3e3e8b33-cf24-4b09-a64c-f9b2bbe604e7@arm.com>
On 21/09/2026 8:59 am, Ryan Roberts wrote:
> On 14/09/2026 14:51, Muhammad Usama Anjum wrote:
>> With pte_t * used for HW PTE pointers, the compiler cannot distinguish
>> them from SW PTE value pointers. The generic HW PTE interfaces already
>> use hw_pte_t *, so arm64 HW PTE pointers must use that type before
>> ARCH_HAS_HW_PTE_T can make it distinct.
>>
>> Convert HW PTE pointers to hw_pte_t *, retaining pte_t for SW PTE
>> values. Helpers shared with PMD and PUD operations keep explicit casts
>> because this series does not introduce distinct entry types for those
>> levels.
>>
>> arm64 still uses the hw_pte_t alias in this patch. The new pointer
>> spelling therefore denotes the same type until the final opt-in.
>>
>> Include linux/pgtable_types.h in pi.h to make hw_pte_t visible.
>>
>> Signed-off-by: Muhammad Usama Anjum <usama.anjum@arm.com>
>> ---
>> arch/arm64/include/asm/hugetlb.h | 19 ++---
>> arch/arm64/include/asm/pgalloc.h | 2 +-
>> arch/arm64/include/asm/pgtable.h | 143 ++++++++++++++++++++------------------
>> arch/arm64/include/asm/vmalloc.h | 2 +-
>> arch/arm64/kernel/efi.c | 3 +-
>> arch/arm64/kernel/pi/map_kernel.c | 4 +-
>> arch/arm64/kernel/pi/map_range.c | 9 +--
>> arch/arm64/kernel/pi/pi.h | 3 +-
>> arch/arm64/mm/contpte.c | 49 +++++++------
>> arch/arm64/mm/fault.c | 5 +-
>> arch/arm64/mm/fixmap.c | 6 +-
>> arch/arm64/mm/hugetlbpage.c | 48 +++++++------
>> arch/arm64/mm/kasan_init.c | 4 +-
>> arch/arm64/mm/mmu.c | 46 +++++++-----
>> arch/arm64/mm/pageattr.c | 4 +-
>> arch/arm64/mm/trans_pgd.c | 4 +-
>> 16 files changed, 190 insertions(+), 161 deletions(-)
>>
>
> [...]
>
>> diff --git a/arch/arm64/mm/fixmap.c b/arch/arm64/mm/fixmap.c
>> index f66a0016dd02d..237a9136bc73b 100644
>> --- a/arch/arm64/mm/fixmap.c
>> +++ b/arch/arm64/mm/fixmap.c
>> @@ -35,7 +35,7 @@ static pte_t bm_pte[NR_BM_PTE_TABLES][PTRS_PER_PTE] __bss_pgtbl;
>> static pmd_t bm_pmd[PTRS_PER_PMD] __bss_pgtbl __maybe_unused;
>> static pud_t bm_pud[PTRS_PER_PUD] __bss_pgtbl __maybe_unused;
>>
>> -static inline pte_t *fixmap_pte(unsigned long addr)
>> +static inline hw_pte_t *fixmap_pte(unsigned long addr)
>> {
>> return &bm_pte[BM_PTE_TABLE_IDX(addr)][pte_index(addr)];
>
> How does this work, given you haven't yet converted bm_pte? You're returning a
> pte_t* where you need a hw_pte_t*. Either the compiler is implicitly converting
> (which would defeat the whole purpose of this series) or this patch doesn't
> compile until you convert bm_pte later on (which I suspect is more likely).
At this point, hw_pte_t is still a preprocessor alias for pte_t:
#define hw_pte_t pte_t
After preprocessing, both expressions therefore have type pte_t *; no
implicit pointer conversion is involved.
Patch 6/6 then selects ARCH_HAS_HW_PTE_T, replacing the alias with the
distinct wrapper type. This ordering keeps every intermediate patch
type-correct and enables compiler enforcement only after the pointers and
storage have both been converted.
>
>> }
>> @@ -43,7 +43,7 @@ static inline pte_t *fixmap_pte(unsigned long addr)
>> static void __init early_fixmap_init_pte(pmd_t *pmdp, unsigned long addr)
>> {
>> pmd_t pmd = READ_ONCE(*pmdp);
>> - pte_t *ptep;
>> + hw_pte_t *ptep;
>>
>> if (pmd_none(pmd)) {
>> ptep = bm_pte[BM_PTE_TABLE_IDX(addr)];
>
> Same problem here?
The same applies here.
--
Thanks,
Usama
next prev parent reply other threads:[~2026-09-21 8:21 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 13:51 [PATCH 0/6] arm64: distinguish HW PTE pointers from SW PTE value pointers Muhammad Usama Anjum
2026-09-14 13:51 ` [PATCH 1/6] arm64: use hw_pte_t for HW PTE pointers Muhammad Usama Anjum
2026-09-21 7:59 ` Ryan Roberts
2026-09-21 8:20 ` Muhammad Usama Anjum [this message]
2026-09-14 13:51 ` [PATCH 2/6] arm64: use hw_pte_val for HW PTE atomics Muhammad Usama Anjum
2026-09-18 15:55 ` Ryan Roberts
2026-09-21 8:49 ` Muhammad Usama Anjum
2026-09-14 13:51 ` [PATCH 3/6] arm64: convert between HW PTEs and SW PTE values Muhammad Usama Anjum
2026-09-18 15:56 ` Ryan Roberts
2026-09-21 8:26 ` Ryan Roberts
2026-09-21 9:50 ` Muhammad Usama Anjum
2026-09-14 13:51 ` [PATCH 4/6] arm64: use hw_pte_t for fixmap HW PTEs Muhammad Usama Anjum
2026-09-18 16:03 ` Ryan Roberts
2026-09-18 20:00 ` David Hildenbrand (Arm)
2026-09-21 7:37 ` Ryan Roberts
2026-09-21 8:29 ` Ryan Roberts
2026-09-14 13:51 ` [PATCH 5/6] arm64: use HW PTE accessors in early map_range() Muhammad Usama Anjum
2026-09-21 9:44 ` Ryan Roberts
2026-09-14 13:51 ` [PATCH 6/6] arm64: enable a distinct type for HW PTEs Muhammad Usama Anjum
2026-09-21 9:44 ` Ryan Roberts
2026-09-21 9:51 ` [PATCH 0/6] arm64: distinguish HW PTE pointers from SW PTE value pointers Ryan Roberts
2026-09-21 10:10 ` Muhammad Usama Anjum
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=0217ddbc-71b0-4263-9e2a-3218644d08d9@arm.com \
--to=usama.anjum@arm.com \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@gmail.com \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=david@kernel.org \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=ilias.apalodimas@linaro.org \
--cc=kasan-dev@googlegroups.com \
--cc=liam@infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mark.rutland@arm.com \
--cc=mhocko@suse.com \
--cc=rppt@kernel.org \
--cc=ryabinin.a.a@gmail.com \
--cc=ryan.roberts@arm.com \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=vincenzo.frascino@arm.com \
--cc=will@kernel.org \
/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
all inboxes | Powered by JetHome®