All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Eric Curtin" <ericcurtin17@gmail.com>
Cc: "Ryan Roberts" <ryan.roberts@arm.com>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	"Randy Dunlap" <rdunlap@infradead.org>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Will Deacon" <will@kernel.org>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Marc Zyngier" <maz@kernel.org>,
	"Oliver Upton" <oupton@kernel.org>,
	"Fuad Tabba" <fuad.tabba@linux.dev>,
	"Joey Gouly" <joey.gouly@arm.com>,
	"Steffen Eiden" <seiden@linux.ibm.com>,
	"Suzuki K Poulose" <suzuki.poulose@arm.com>,
	"Zenghui Yu" <yuzenghui@huawei.com>,
	"Muchun Song" <muchun.song@linux.dev>,
	"Mike Rapoport" <rppt@kernel.org>,
	"David Hildenbrand" <david@kernel.org>,
	"Ard Biesheuvel" <ardb@kernel.org>,
	"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
	kvmarm@lists.linux.dev, linux-mm@kvack.org,
	linux-efi@vger.kernel.org
Subject: Re: [RFC PATCH v2 43/43] arm64: Enable boot-time page size selection
Date: Wed, 02 Dec 2026 02:34:54 +0000	[thread overview]
Message-ID: <sashiko-outbox-244703@kernel.org> (raw)
In-Reply-To: <20261201015240.1017259-44-ericcurtin17@gmail.com>

Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] arm64: Kconfig ARM64_BOOT_TIME_PAGE_SIZE defaults VA space
  choice to 42-bit
- [High] arm64: non-constant PAGE_SHIFT and PAGE_SIZE break build in
  core MM/net headers
- [Medium] arm64: Kconfig ARCH_MMAP_RND_BITS checks ARM64_64K_PAGES not
  PAGE_SIZE_64KB
- [Low] arm64: mm: missing linux/export.h include in
  arch/arm64/mm/pgtable-geometry.c
--

commit fdde9968b708f81560ecc9e1237491977b2dbeed
Author: Ryan Roberts <ryan.roberts@arm.com>

arm64: Enable boot-time page size selection

This commit introduces CONFIG_ARM64_BOOT_TIME_PAGE_SIZE to allow choosing the
4K, 16K or 64K translation granule at boot via the arm64.pagesize= command
line option, resolving page and page-table geometry macros through runtime
ptg_* variables initialized in early_map_kernel().

[Severity: Medium]
In arch/arm64/Kconfig, around line 319 in config ARCH_MMAP_RND_BITS, should
the 24-bit default check PAGE_SIZE_64KB instead of ARM64_64K_PAGES, matching
ARCH_MMAP_RND_BITS_MAX and ARCH_MMAP_RND_COMPAT_BITS_MIN?

When ARM64_BOOT_TIME_PAGE_SIZE=y, both ARM64_64K_PAGES and ARM64_16K_PAGES
are n, so ARCH_MMAP_RND_BITS falls through to 28 instead of the 64K-page
default of 24.  When booted with 64K pages (PAGE_SHIFT = 16), arch_mmap_rnd()
in mm/util.c shifts a 28-bit random value by 16 bits, randomizing user mmap
bases across 16 TiB (2^44 bytes, one bit below ARCH_MMAP_RND_BITS_MAX = 29)
instead of 1 TiB.

[Severity: High]
In arch/arm64/Kconfig, around lines 1608 and 1661-1674, does enabling
ARM64_BOOT_TIME_PAGE_SIZE cause the "Virtual address space size" choice block
to default to ARM64_VA_BITS_42 instead of ARM64_VA_BITS_48?

ARM64_BOOT_TIME_PAGE_SIZE selects HAVE_PAGE_SIZE_64KB (enabling
PAGE_SIZE_64KB=y) and disables the choice's default symbol ARM64_VA_BITS_52.
Because ARM64_VA_BITS_42 depends on PAGE_SIZE_64KB and precedes
ARM64_VA_BITS_48 in the choice block, Kconfig falls back to the first visible
entry and selects 42-bit VA by default, even though only 48-bit VA is
supported:

- With 42-bit VA and 64K pages, ARCH_MMAP_RND_BITS_MAX defaults to 27, so
  arch_mmap_rnd() can shift 27 + 16 = 43 bits, exceeding the 42-bit user VA
  space.
- With 42-bit VA and 4K pages (ptg_pgtable_levels = 4, PGDIR_SHIFT = 39), if
  KASLR places the kernel image in the top 512 GiB of the 2 TiB kernel VA
  range so it shares a PGD entry with the fixmap, early_fixmap_init_pud() in
  arch/arm64/mm/fixmap.c hits BUG_ON(PAGE_SIZE != SZ_16K).
- With 42-bit VA and 64K pages (ptg_pgtable_levels = 2, where ptg_init() sets
  PUD_SHIFT = PMD_SHIFT = PGDIR_SHIFT = 29 while __PAGETABLE_PMD_FOLDED is
  not defined because CONFIG_PGTABLE_LEVELS is 4), __flush_hugetlb_tlb_range()
  in arch/arm64/include/asm/hugetlb.h matches stride == PUD_SIZE and passes
  TTL level 1 instead of level 2 for PMD hugepages, and huge_pte_offset() in
  arch/arm64/mm/hugetlbpage.c computes pgd_offset(mm, addr) before masking
  addr &= CONT_PMD_MASK while pmd_offset() folds to the PGD entry without
  using the masked address.

Making ARM64_VA_BITS_42 depend on ARM64_64K_PAGES (or !ARM64_BOOT_TIME_PAGE_SIZE)
would keep 48-bit VA as the only selectable option.

[Severity: High]
In arch/arm64/include/asm/pgtable-geometry.h, around line 26, does replacing
ptg_page_shift with an extern int variable break compilation in core code
when CONFIG_ARM64_BOOT_TIME_PAGE_SIZE=y?

With PAGE_SHIFT defined as ptg_page_shift and PAGE_SIZE as
(_AC(1, UL) << PAGE_SHIFT), building with CONFIG_ARM64_BOOT_TIME_PAGE_SIZE=y
fails in two ways:

- Preprocessor directives that test PAGE_SHIFT or PAGE_SIZE, such as
  include/linux/mmzone.h:2002 (#if (MAX_PAGE_ORDER + PAGE_SHIFT) > SECTION_SIZE_BITS),
  include/linux/netlink.h:272 (#if PAGE_SIZE < 8192UL),
  include/net/page_pool/types.h:56 (#if PAGE_SIZE >= SZ_64K), and
  mm/memcontrol.c:2118 (#if PAGE_SHIFT > 16), evaluate ptg_page_shift in #if
  and fail under arch/arm64/Makefile's -Werror=undef.
- File-scope and struct array declarations sized by PAGE_SIZE, such as
  union swap_header in include/linux/swap.h:121, str_dup in
  mm/huge_memory.c:1172, and kasan_early_shadow_page in
  include/linux/kasan.h:53, fail to compile because PAGE_SIZE is no longer a
  compile-time constant.

[Severity: Low]
In arch/arm64/mm/pgtable-geometry.c, lines 6-32 use EXPORT_SYMBOL() without
including <linux/export.h>, which triggers a warning from scripts/misc-check
at W=2.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201015240.1017259-1-ericcurtin17@gmail.com?part=43

  reply	other threads:[~2026-12-02  2:34 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  1:51 [RFC PATCH v2 00/43] Boot-time page size selection for arm64 (core) Eric Curtin
2026-12-01  1:51 ` Eric Curtin
2026-12-01  1:51 ` [RFC PATCH v2 01/43] mm: Add macros ahead of supporting boot-time page size selection Eric Curtin
2026-12-01  1:51 ` [RFC PATCH v2 02/43] vmlinux.lds: Align page-aligned sections to PAGE_SIZE_MAX Eric Curtin
2026-12-02  2:34   ` sashiko-bot
2026-12-01  1:51 ` [RFC PATCH v2 03/43] mm: page_frag: Use PAGE_SIZE_MIN/MAX limits in page_frag_cache Eric Curtin
2026-12-01  1:51 ` [RFC PATCH v2 04/43] mm: page_frag: Add _MIN/_MAX variants of PAGE_FRAG_CACHE_MAX_SIZE Eric Curtin
2026-12-01  1:51 ` [RFC PATCH v2 05/43] mm: Avoid split pmd ptl if pmd level is run-time folded Eric Curtin
2026-12-01  1:51 ` [RFC PATCH v2 06/43] mm/vmstat: Use THREAD_SIZE_MAX for the KSTACK_* counters Eric Curtin
2026-12-02  2:34   ` sashiko-bot
2026-12-01  1:51 ` [RFC PATCH v2 07/43] fork: Permit boot-time THREAD_SIZE determination Eric Curtin
2026-12-01  1:51 ` [RFC PATCH v2 08/43] cgroup: Use DEFINE_GLOBAL_PAGE_SIZE_VAR for the kernfs_ops tables Eric Curtin
2026-12-01  1:51 ` [RFC PATCH v2 09/43] bpf: Do not embed page-aligned members in struct bpf_ringbuf Eric Curtin
2026-12-02  2:34   ` sashiko-bot
2026-12-01  1:51 ` [RFC PATCH v2 10/43] PM: hibernate: Do not size swap structures to exactly PAGE_SIZE Eric Curtin
2026-12-01  1:51 ` [RFC PATCH v2 11/43] perf/core: Handle a boot-time PAGE_SIZE in format attrs and mlock Eric Curtin
2026-12-01  1:51 ` [RFC PATCH v2 12/43] KVM: Check struct kvm_run against PAGE_SIZE_MIN Eric Curtin
2026-12-01  1:51 ` [RFC PATCH v2 13/43] crash: Check crash_notes size " Eric Curtin
2026-12-01  1:51 ` [RFC PATCH v2 14/43] arm64: Make INIT_DIR_SIZE and INIT_IDMAP_DIR_SIZE usable from C Eric Curtin
2026-12-01  1:51 ` [RFC PATCH v2 15/43] arm64: pi: Pass the early pgtable allocation limit to map_range() Eric Curtin
2026-12-01  1:51 ` [RFC PATCH v2 16/43] arm64: Introduce macros required for boot-time page size selection Eric Curtin
2026-12-01  1:51 ` [RFC PATCH v2 17/43] arm64: Parameterise early pgtable size macros by page shift Eric Curtin
2026-12-01  1:51 ` [RFC PATCH v2 18/43] arm64: Add arm64.pagesize= command line override Eric Curtin
2026-12-01  1:51 ` [RFC PATCH v2 19/43] arm64: pi: Select the page size at runtime during early boot Eric Curtin
2026-12-01  1:51 ` [RFC PATCH v2 20/43] arm64: pi: Clear the FDT ptes on every remap in map_fdt() Eric Curtin
2026-12-01  1:51 ` [RFC PATCH v2 21/43] arm64: Test PAGE_SIZE instead of CONFIG_ARM64_*K_PAGES Eric Curtin
2026-12-01  1:51 ` [RFC PATCH v2 22/43] arm64: Align image sections to PAGE_SIZE_MAX Eric Curtin
2026-12-01  1:51 ` [RFC PATCH v2 23/43] arm64: Map the trampoline rodata at its aligned offset Eric Curtin
2026-12-01  1:51 ` [RFC PATCH v2 24/43] arm64: fixmap: Size slots and page tables for PAGE_SIZE_MIN Eric Curtin
2026-12-01  1:51 ` [RFC PATCH v2 25/43] arm64: Size and align the zero page and FDT ptes for PAGE_SIZE_MAX Eric Curtin
2026-12-01  1:51 ` [RFC PATCH v2 26/43] arm64: Convert KVM and hugetlb size switches to if/else Eric Curtin
2026-12-02  2:34   ` sashiko-bot
2026-12-01  1:51 ` [RFC PATCH v2 27/43] arm64: mm: Make page size dependent BUILD_BUG_ON() checks runtime Eric Curtin
2026-12-01  1:52 ` [RFC PATCH v2 28/43] arm64: cpufeature: Add capabilities for the page size in use Eric Curtin
2026-12-01  1:52 ` [RFC PATCH v2 29/43] arm64: Look up the page size at runtime in assembly code Eric Curtin
2026-12-01  1:52 ` [RFC PATCH v2 30/43] arm64: Support runtime folding of the pmd level Eric Curtin
2026-12-02  2:34   ` sashiko-bot
2026-12-01  1:52 ` [RFC PATCH v2 31/43] arm64: Support runtime folding in idmap_kpti_install_ng_mappings Eric Curtin
2026-12-01  1:52 ` [RFC PATCH v2 32/43] arm64: Patch TRAMP_VALIAS into instructions at boot Eric Curtin
2026-12-01  1:52 ` [RFC PATCH v2 33/43] arm64: Determine THREAD_SIZE at boot time Eric Curtin
2026-12-01  1:52 ` [RFC PATCH v2 34/43] mm/damon/lru_sort: Initialise the stub access pattern at boot Eric Curtin
2026-12-01  1:52 ` [RFC PATCH v2 35/43] mm/zsmalloc: Size static limits for the worst-case page size Eric Curtin
2026-12-01  1:52 ` [RFC PATCH v2 36/43] arm64: Convert remaining page-size switches to if/else Eric Curtin
2026-12-02  2:34   ` sashiko-bot
2026-12-01  1:52 ` [RFC PATCH v2 37/43] vdso: Lay out the data pages in VDSO_PAGE_SIZE units Eric Curtin
2026-12-01  1:52 ` [RFC PATCH v2 38/43] mm: Use fixed sizes for shmem str_dup and swap cache PFN bits Eric Curtin
2026-12-01  1:52 ` [RFC PATCH v2 39/43] crash: Size the vmcoreinfo page array for the smallest page size Eric Curtin
2026-12-01  1:52 ` [RFC PATCH v2 40/43] arm64: Size kasan and pKVM stacktrace arrays for PAGE_SIZE_MAX Eric Curtin
2026-12-01  1:52 ` [RFC PATCH v2 41/43] exit: Use THREAD_SIZE_MAX for lowest_to_date Eric Curtin
2026-12-01  1:52 ` [RFC PATCH v2 42/43] tracing: Use PAGE_SIZE_MIN/MAX in the uprobe check and undefsyms page Eric Curtin
2026-12-01 13:15   ` Masami Hiramatsu (Google)
2026-12-01  1:52 ` [RFC PATCH v2 43/43] arm64: Enable boot-time page size selection Eric Curtin
2026-12-02  2:34   ` sashiko-bot [this message]
2026-12-01 10:41 ` [RFC PATCH v2 00/43] Boot-time page size selection for arm64 (core) Lorenzo Stoakes (ARM)
2026-12-01 10:41   ` Lorenzo Stoakes (ARM)

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-244703@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=ardb@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=corbet@lwn.net \
    --cc=david@kernel.org \
    --cc=ericcurtin17@gmail.com \
    --cc=fuad.tabba@linux.dev \
    --cc=ilias.apalodimas@linaro.org \
    --cc=joey.gouly@arm.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=oupton@kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=rppt@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=seiden@linux.ibm.com \
    --cc=skhan@linuxfoundation.org \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.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.