From: sashiko-bot@kernel.org
To: "Anshuman Khandual" <anshuman.khandual@arm.com>,
catalin.marinas@arm.com, will@kernel.org
Cc: "Ryan Roberts" <ryan.roberts@arm.com>,
"Mark Rutland" <mark.rutland@arm.com>,
"Lorenzo Stoakes" <ljs@kernel.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
"David Hildenbrand" <david@kernel.org>,
"Mike Rapoport" <rppt@kernel.org>,
"Linu Cherian" <linu.cherian@arm.com>,
linux-mm@kvack.org, kasan-dev@googlegroups.com
Subject: Re: [PATCH V4 4/4] arm64/mm: Use pgdp_get() for PGD accesses
Date: Fri, 06 Nov 2026 04:34:47 +0000 [thread overview]
Message-ID: <sashiko-outbox-200739@kernel.org> (raw)
In-Reply-To: <20261105043403.3326445-5-anshuman.khandual@arm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] arm64/mm: KASAN fault in p4d_offset_phys() during kasan_early_init()
--
commit e9bf68a7a555b3c58c2a0a8736f337dde8136ab9
Author: Anshuman Khandual <anshuman.khandual@arm.com>
arm64/mm: Use pgdp_get() for PGD accesses
This commit replaces READ_ONCE() with pgdp_get() for PGD accesses and moves
p4d_offset() and p4d_offset_phys() from arch/arm64/include/asm/pgtable.h
into arch/arm64/mm/mmu.c to avoid header include dependencies.
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index 5b5a85a0527d6..11015e1deb32f 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
[ ... ]
> @@ -2463,3 +2463,17 @@ pud_t *pud_offset(p4d_t *p4dp, unsigned long addr)
> return pud_offset_lockless(p4dp, p4dp_get(p4dp), addr);
> }
> #endif /* CONFIG_PGTABLE_LEVELS > 3 */
> +
> +#if CONFIG_PGTABLE_LEVELS > 4
> +phys_addr_t p4d_offset_phys(pgd_t *pgdp, unsigned long addr)
> +{
> + VM_WARN_ON_ONCE(!pgtable_l5_enabled());
> +
> + return pgd_page_paddr(pgdp_get(pgdp)) + p4d_index(addr) * sizeof(p4d_t);
> +}
[Severity: High]
Does moving p4d_offset_phys() (and pud_offset_phys() in the preceding patch)
out-of-line into arch/arm64/mm/mmu.c cause a translation fault during early
boot when KASAN is enabled with 5-level (or 4-level) page tables?
During early boot, __primary_switched calls kasan_early_init() before the
KASAN shadow region is mapped. Because any KASAN shadow check will fault
until kasan_early_init() finishes populating the early shadow page tables,
arch/arm64/mm/Makefile disables KASAN sanitization for kasan_init.o:
KASAN_SANITIZE_kasan_init.o := n
and set_swapper_pgd() in arch/arm64/mm/mmu.c is marked noinstr for the same
reason.
When kasan_early_init() populates the shadow page tables, it calls into
p4d_offset_phys() and pud_offset_phys():
kasan_early_init()
kasan_pgd_populate(..., early=true)
kasan_p4d_populate(..., early=true)
kasan_p4d_offset(..., early=true)
p4d_offset_kimg()
p4d_offset_phys()
kasan_pud_populate(..., early=true)
kasan_pud_offset(..., early=true)
pud_offset_kimg()
pud_offset_phys()
Previously, p4d_offset_phys() and pud_offset_phys() were static inline
functions in arch/arm64/include/asm/pgtable.h, so calls from kasan_init.c
were inlined into kasan_init.o and compiled without KASAN instrumentation.
Now that both functions live in arch/arm64/mm/mmu.c, which is KASAN-sanitized,
the compiler emits KASAN shadow checks for their memory accesses (such as
pgdp_get(pgdp), p4dp_get(p4dp), and vabits_actual) before the early shadow
memory is mapped.
Should p4d_offset_phys() and pud_offset_phys() be marked noinstr or
__no_sanitize_address?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105043403.3326445-1-anshuman.khandual@arm.com?part=4
next prev parent reply other threads:[~2026-11-06 4:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 4:33 [PATCH V4 0/4] arm64/mm: Convert pgtable READ_ONCE() as pxdp_get() Anshuman Khandual
2026-11-05 4:34 ` [PATCH V4 1/4] arm64/mm: Use pmdp_get() for PMD accesses Anshuman Khandual
2026-11-05 4:34 ` [PATCH V4 2/4] arm64/mm: Use pudp_get() for PUD accesses Anshuman Khandual
2026-11-05 4:34 ` [PATCH V4 3/4] arm64/mm: Use p4dp_get() for P4D accesses Anshuman Khandual
2026-11-06 4:34 ` sashiko-bot
2026-11-05 4:34 ` [PATCH V4 4/4] arm64/mm: Use pgdp_get() for PGD accesses Anshuman Khandual
2026-11-06 4:34 ` sashiko-bot [this message]
2026-11-11 11:54 ` Anshuman Khandual
2026-11-13 3:28 ` [PATCH V4 0/4] arm64/mm: Convert pgtable READ_ONCE() as pxdp_get() Anshuman Khandual
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=sashiko-outbox-200739@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=catalin.marinas@arm.com \
--cc=david@kernel.org \
--cc=kasan-dev@googlegroups.com \
--cc=linu.cherian@arm.com \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mark.rutland@arm.com \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=sashiko-reviews@lists.linux.dev \
--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 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.