Skip to content

arm64: user4k: turn 4K userspace on by default, keep user4k=off - #2731

Merged
RyanTheTide merged 1 commit into
integration/aurorafrom
j713tips/user4k-default-on
Nov 22, 2026
Merged

RyanTheTide merged 1 commit into
integration/aurorafrom
j713tips/user4k-default-on

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Problem

4K userspace for x86 and 4K-page programs (FEX, aurora-userpages) needs user4k=on on every kernel command line. Every distribution and every lab Mac adds it, so the behaviour of every shipped system depends on a command-line knob.

Change

arm64_user4k_on now starts true. user4k=off (or 0/n) still turns the feature off for a boot, with the same effects as before; user4k=on is accepted and does nothing. The decision is still per CPU capability. Kconfig help, kernel-parameters.txt, user4k.rst, user_page_size.rst and the userpages launcher's hint describe user4k=off as the switch; the hint names both causes of EINVAL (booted with user4k=off, or not built in).

This replaces #2272 with the same code change, the review nits fixed (hint text, Kconfig help reflowed) and a commit that carries only the human sign-off.

Testing

  • 13-inch M4 MacBook Air (J713, T8132, 27.2 stub): its default kernel carries this change and boots with no user4k= argument; userpages 4k true runs, on three kernels built from integration/aurora plus open PRs (boots on 11-22), including the current default.
  • From arm64: user4k: turn 4K userspace on by default, keep user4k=off #2272 (same code): Neo (T8140), M2 Air (T8112) and M1 Pro (T6000) booted with no user4k= argument, userpages 4k true OK; the M4 Pro (T6040) and M3 Air (T8122) booted without it.
  • J713, the same kernel with user4k=off for one boot: userpages 4k true fails with EINVAL.
  • checkpatch --strict clean.

Still to run

  • userpages 4k true on the M4 Pro (T6040) and M3 Air (T8122), booted without user4k= (booted, not run).

Assisted-by: LLM (Claude:Opus 5.5)

Commit 1705968 ("arm64: user4k: keep 4K userspace off unless
booted with user4k=on") made the per-process user granule an opt-in
while it had been tested only on the J700. Since then every Aurora
distribution boots every supported Mac with user4k=on: Fedora's kiwi
images and aurora-userpages' %posttrans, Arch's
/etc/default/grub.d/50-aurora-user4k.cfg and NixOS's
aurora.userpages module all add it, and the lab fleet (M1 Pro, M2,
J616s, Neo) runs with it. The option that decides the behaviour of
every shipped system should be the kernel's default, not a command-line
knob each distribution has to add.

Initialise arm64_user4k_on to true. The early parameter is unchanged:
user4k=off (or 0/n) still turns the feature off for that boot, with the
same effects as before (the page-size prctls refuse non-native sizes,
every exec gets the native granule, no 4K user granule capability is
detected and the page_ext record is not reserved). user4k=on stays
accepted and is now a no-op.

The decision is still per CPU capability: a CPU without the 4K
translation granule gets no alternative, as before.

Update the comments, Kconfig help, kernel-parameters.txt, user4k.rst,
user_page_size.rst and the userpages launcher's hint and README to
describe user4k=off as the switch.

The userpages launcher's hint names both causes of EINVAL: a kernel
booted with user4k=off and one built without the per-process granule
support.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Same code as #2272 (only comment/help-text wording differs; compared patch by patch), so the hardware rows posted there apply: #2272 (comment) (booted without any user4k= argument on five Macs, userpages 4k true OK on the Neo, M2 and M1 Pro, 0 AVC/oops, dEQP-VK smoke unchanged).

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

user4k=off row, 13-inch M4 MacBook Air (J713, T8132, 27.2 stub), the default kernel (which carries this change) with user4k=off appended for one boot: userpages 4k true fails with EINVAL (rc=1). The hint printed is the installed userpages tool's older text; this PR updates it. The capability line is not shown at the default loglevel=3 on either boot. Back on the default boot (no user4k=), userpages 4k true runs.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merge-train adversarial review (MERGETRAIN-LINUX2) at 36e4785: NO BLOCKERS.

Code read only, nothing built here. Before the merge it still needs Dj's verdict at this head; the missing rows are listed below.

Full review

#2731 arm64: user4k: turn 4K userspace on by default, keep user4k=off @36e4785a

VERDICT: NO BLOCKERS

The code change is one line, arch/arm64/mm/context.c:48 bool arm64_user4k_on __ro_after_init = true;.
The parser is still kstrtobool() at context.c:50-53. Every reader goes through user4k_enabled()
(asm/mmu.h:32-35), and all of them run after early params: has_user4k_granule/has_user16k_granule
(cpufeature.c:1737-1760), arch_mm_init_exec (mmu_context.h:31), arm64_bprm_prepare_mm/
arch_exec_page_size_shift (process.c:1078-1103) and subpage_ext_needed (mm/user-subpage.c:77).
I found no reader that runs before parse_early_param(). This change follows the "default cmdline"
rule.

Things I checked that do not break:

  • Native 16K processes: an exec without a prctl request still gets requested_shift ?: native_shift
    (asm/mmu.h arm64_exec_page_shift). AArch32 would now get 4K automatically
    (compat ? has_4k ? 12), but no Apple Silicon core has AArch32 EL0, so this does not matter on our Macs.
  • ARM64_HAS_USER4K_GRANULE is ARM64_CPUCAP_SYSTEM_FEATURE (cpufeature.c:2665-2672). With the
    default on, a late CPU without TGRAN4 would be refused. Every Apple core has TGRAN4, so there is no
    effect.

Nits:

  1. Cost on every boot. The page_ext record is now reserved on every boot of every Mac. With 16K pages,
    struct mm_subpage_ext is 32 B, plus 8 B of page_ext flags, about 40 B per 16 KiB page (0.24%).
    That is about 20 MiB on an 8 GB Air, about 39 MiB at 16 GB and about 156 MiB at 64 GB. The fleet
    already paid this with user4k=on, but the commit message says nothing about it. Please state it
    there.
  2. The feature is still described as unqualified. Kconfig.debug:39-50 and user4k.rst:14-17 call it
    "experimental ... development ABI ... do not establish ... hardware qualification". Those words
    now describe the default behaviour of every shipped kernel. Either reword them or say in the PR
    that this is accepted. The option also still lives in Kconfig.debug ("Kernel hacking").
  3. mm/user-subpage.c:74 is now over 80 columns (fine at 100, but it is the only long comment line in
    that block).
  4. user4k-test.c:14769 "Safe with or without user4k=off; the other suites need it on" and
    Kconfig.debug:74-75 "only the arm64-user4k-policy suite is meant to run with it": "it" is
    ambiguous. Say "with user4k=off" explicitly.

Missing rows:

  • userpages 4k true on the M4 Pro (T6040) and M3 Air (T8122) booted without user4k=. The PR
    itself lists these as still to run.
  • An arm64 qemu KUnit run with the new default (no --kernel_args): the full user4k suites, plus the
    policy suite with user4k=off. The KUnit help text changed its meaning, and no KUnit run is cited.
  • The free-memory difference on an 8 GB Air between user4k=off and the default, to put the page_ext
    cost on record.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at live head 36e4785abf6387974a84e94a59ff550af7e0fc47 against all 6 sections of pre-pr-checklist.md. 0 code/policy/attribution/CI blockers; approved for merge.

Verified

  • §1–§2 Default cmdline & CPU-capability gating: Single-line functional change (bool arm64_user4k_on __ro_after_init = true; in arch/arm64/mm/context.c:48) removes the mandatory user4k=on cmdline knob while preserving user4k=off (0/n) via kstrtobool() and CPU-capability gating (ID_AA64MMFR0_EL1.TGran4 / ARM64_HAS_USER4K_GRANULE). No chip/board/firmware gates.
  • §3 Correctness across configs/arches:
    • Scoped to CONFIG_ARM64_USER4K_EXPERIMENTAL (arm64 16K/64K kernels); 4K arm64 kernels and other architectures are unaffected.
    • Confirmed every reader of user4k_enabled() / arch_mm_alt_granule_enabled() (has_user4k_granule, has_user16k_granule, subpage_ext_needed, arch_mm_init_exec, arm64_bprm_prepare_mm, arch_exec_page_size_shift) runs after parse_early_param().
    • Confirmed all 30 in-tree user4k=on references across docs, Kconfig, comments, KUnit tests, and tools/aurora-userpages are updated, and the #2272 review nits (Kconfig.debug line reflow and userpages.c off_hint() naming both user4k=off and not built in) are resolved.
  • §4 Clean-room & attribution: Commit 36e4785abf63 has human author/committer (Ryan Murray <[email protected]>) and human Signed-off-by: only (#2272's Co-Authored-By: trailer is removed); PR body includes Assisted-by:.
  • §5 Evidence & CI: All 7 CI checks (host-tests, source, rust-build, kunit, and all 3 DWC3/ATC build configurations) are green on 36e4785abf63. Hardware evidence covers both items requested on #2272:
    • user4k=off opt-out row on J713 (M4 Air, T8132, 27.2 stub): userpages 4k true returns EINVAL; default boot (no user4k=) runs userpages 4k true cleanly.
    • Identical code diff to #2272 proven across 4 SoC generations without user4k= (userpages 4k true OK on T6000 M1 Pro, T8112 M2 Air, T8132 M4 Air, T8140 MacBook Neo; plus T6040 M4 Pro and T8122 M3 Air booted cleanly; SELinux enforcing, 0 AVC, 0 failed units, 0 oops, s2idle 2/2, dEQP-VK 16,541 smoke unchanged).
  • §6 Naming: Clean.

Non-blocking nits

  • arch/arm64/Kconfig.debug:74-75 and arch/arm64/mm/user4k-test.c:14769: "with it" is slightly ambiguous; "with user4k=off" would be clearer.
  • mm/user-subpage.c:74: comment line slightly exceeds 80 columns.
  • Optionally record userpages 4k true on T6040/T8122 and an arm64 QEMU KUnit run (arm64-user4k-policy with user4k=off) as follow-up coverage.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide
RyanTheTide merged commit ffe545f into integration/aurora Nov 22, 2026
7 checks passed
@RyanTheTide
RyanTheTide deleted the j713tips/user4k-default-on branch November 27, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants