All of lore.kernel.org
 help / color / mirror / Atom feed
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 3/4] arm64/mm: Use p4dp_get() for P4D accesses
Date: Fri, 06 Nov 2026 04:34:46 +0000	[thread overview]
Message-ID: <sashiko-outbox-200738@kernel.org> (raw)
In-Reply-To: <20261105043403.3326445-4-anshuman.khandual@arm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] arm64/mm: early boot KASAN fault in out-of-line pud_offset_phys()
--

commit eaa67607aabb8af35fe6970c5442e1ab262f0286
Author: Anshuman Khandual <anshuman.khandual@arm.com>

arm64/mm: Use p4dp_get() for P4D accesses

This commit replaces READ_ONCE() with p4dp_get() for P4D accesses across
arm64/mm and moves pud_offset_phys() and pud_offset() out of
arch/arm64/include/asm/pgtable.h into arch/arm64/mm/mmu.c to avoid header
dependency cycles.

> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index afa15b1a8a247..5b5a85a0527d6 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c

[ ... ]

> @@ -2449,3 +2449,17 @@ bool pmdp_test_and_clear_young(struct vm_area_struct *vma, unsigned long address
>  	return __ptep_test_and_clear_young(vma, address, (pte_t *)pmdp);
>  }
>  #endif /* CONFIG_TRANSPARENT_HUGEPAGE || CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG */
> +
> +#if CONFIG_PGTABLE_LEVELS > 3
> +phys_addr_t pud_offset_phys(p4d_t *p4dp, unsigned long addr)
> +{
> +	VM_WARN_ON_ONCE(!pgtable_l4_enabled());
> +
> +	return p4d_page_paddr(p4dp_get(p4dp)) + pud_index(addr) * sizeof(pud_t);
> +}

[Severity: High]
Does moving pud_offset_phys() out-of-line into arch/arm64/mm/mmu.c without
noinstr or __no_sanitize_address cause an early boot translation fault when
CONFIG_KASAN_GENERIC or CONFIG_KASAN_SW_TAGS is enabled with 4-level or
5-level page tables?

During early boot before start_kernel(), __primary_switched calls
kasan_early_init() in arch/arm64/mm/kasan_init.c to populate the initial
early KASAN shadow page tables:

  __primary_switched
    -> kasan_early_init()
      -> kasan_pgd_populate(..., true)
        -> kasan_p4d_populate(..., true)
          -> kasan_pud_populate(..., true)
            -> kasan_pud_offset(p4dp, addr, node, true)
              -> pud_offset_kimg(p4dp, addr)
                -> pud_offset_phys(p4dp, addr)

At that point, no KASAN shadow PTEs have been mapped yet, which is why
arch/arm64/mm/Makefile sets:

  KASAN_SANITIZE_kasan_init.o := n

Previously, pud_offset_phys() was a static inline helper in
arch/arm64/include/asm/pgtable.h, so it was inlined into kasan_init.o
without KASAN instrumentation.

With pud_offset_phys() moved into arch/arm64/mm/mmu.c, which is compiled with
KASAN sanitization enabled, calling pud_offset_phys() from kasan_early_init()
triggers KASAN shadow memory checks on p4dp before the early shadow memory
is mapped.

Should pud_offset_phys() be marked noinstr (like set_swapper_pgd() in the
same file) or __no_sanitize_address?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261105043403.3326445-1-anshuman.khandual@arm.com?part=3


  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 [this message]
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
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-200738@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.