diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 2e6fa8b49752e..388b32354bede 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -8349,10 +8349,10 @@ Kernel parameters user4k= [ARM64,EARLY] Format: - Enable the experimental per-process user page sizes - (4K userspace pages on a 16K or 64K kernel) built - with CONFIG_ARM64_USER4K_EXPERIMENTAL. - Default: off. While off, the private page-size + Enable or disable the experimental per-process user + page sizes (4K userspace pages on a 16K or 64K + kernel) built with CONFIG_ARM64_USER4K_EXPERIMENTAL. + Default: on. With user4k=off, the private page-size prctls refuse every non-native size with EINVAL, every exec uses the native page size and the 4K ownership record is not reserved in page_ext. diff --git a/Documentation/arch/arm64/user4k.rst b/Documentation/arch/arm64/user4k.rst index 4f6a02932e3d8..2cb5c41905243 100644 --- a/Documentation/arch/arm64/user4k.rst +++ b/Documentation/arch/arm64/user4k.rst @@ -11,8 +11,8 @@ fixed for its lifetime; exec can create a new address space with another supported granule. See :doc:`../../mm/user_page_size` for the generic launch policy and architecture integration contract. -This is an experimental feature and ABI. It is built into the kernel but -stays off unless the kernel is booted with ``user4k=on``. The launch +This is an experimental feature and ABI. It is built into the kernel and +on unless the kernel is booted with ``user4k=off``. The launch commands use private prctl numbers, not assigned upstream UAPI. The implementation and tests do not establish complete application, device or hardware qualification. @@ -36,7 +36,7 @@ Native kernel size AArch64 default AArch64 alternatives =================== ================== ============================ Capability detection uses the sanitized system-wide granule intersection, -and only runs with ``user4k=on``. AArch32 executables select 4K when that +and does not run with ``user4k=off``. AArch32 executables select 4K when that capability is available and retain the native granule otherwise, regardless of launch preferences. The latter case still enforces native mapping/protection alignment. AArch32 mmap2 file offsets retain their 4K @@ -52,12 +52,12 @@ Larger-than-native process granules are not exposed. Internal 64K-on-16K fixtures exercise allocation, mappings and argument staging, but those fixtures do not enable a public 64K process ABI on a 16K kernel. -Enabling at boot -================ +Turning it off at boot +====================== -Building the option in does not enable it. Add ``user4k=on`` to the kernel -command line to enable it for that boot; ``user4k=off`` or no parameter -leaves it off. The value is parsed with ``kstrtobool()``, so ``1``/``0`` +Building the option in enables it. Add ``user4k=off`` to the kernel +command line to turn it off for that boot; ``user4k=on`` or no parameter +leaves it on. The value is parsed with ``kstrtobool()``, so ``1``/``0`` and ``y``/``n`` also work, and it cannot be changed after boot. While it is off: @@ -76,13 +76,13 @@ While it is off: The shared MM code paths that serve every process are compiled in either way and do not change with the parameter. -With ``user4k=on`` the CPU capability line appears on CPUs that support +While it is on, the CPU capability line appears on CPUs that support the 4K translation granule, and the launcher below can select 4K pages. Selecting an executable's page size =================================== -The kernel must be booted with ``user4k=on``. Build the development +The kernel must not be booted with ``user4k=off``. Build the development launcher with:: make -C tools/aurora-userpages @@ -194,8 +194,8 @@ Test coverage ============= The arm64 selftests are in ``tools/testing/selftests/arm64/user4k``. The -fixtures that select another page size need a guest booted with -``user4k=on``. The ``page-contract`` executable checks the exposed +fixtures that select another page size need a guest booted without +``user4k=off``. The ``page-contract`` executable checks the exposed userspace contract. Extended fixtures cover exec policy, AArch32, shared mappings, accounting, reclaim, I/O and device-facing interfaces. Several are disposable-guest PID1 programs @@ -203,9 +203,10 @@ with companion executables or storage requirements; they are not ordinary host test commands. ``CONFIG_ARM64_USER4K_KUNIT_TEST`` and the data/TLB suites exercise internal -geometry and ownership. Boot them with ``user4k=on``, for example -``kunit.py run --kernel_args user4k=on``. The ``arm64-user4k-policy`` suite -also runs without it and checks that the feature stays closed while off. +geometry and ownership. Boot them without ``user4k=off``. The +``arm64-user4k-policy`` suite also runs with ``user4k=off`` (for example +``kunit.py run --kernel_args user4k=off``) and checks that the feature stays +closed while off. Some fixtures additionally require ``arm64.user4k_test=1`` and some hardware translation tests are disabled under KASAN. Check individual KTAP results and skips rather than treating boot success as a suite pass. diff --git a/Documentation/mm/user_page_size.rst b/Documentation/mm/user_page_size.rst index 654581c85929d..223a1dc41d39c 100644 --- a/Documentation/mm/user_page_size.rst +++ b/Documentation/mm/user_page_size.rst @@ -68,8 +68,8 @@ An architecture selecting ``ARCH_HAS_USER_PAGE_SIZE`` must implement: * ``arch_mm_alt_granule_enabled()``, optionally: report whether this boot may create alternative-granule address spaces. It must be fixed before memory management initialization. When it is false the ``MM_SUBPAGE`` - page_ext record is not reserved. arm64 returns true only when booted - with ``user4k=on``. + page_ext record is not reserved. arm64 returns true unless booted + with ``user4k=off``. * Binary-loader integration that resolves the final executable policy before exposing the address space. ``bprm_set_page_shift()`` transfers staged argument bytes when the final choice changes the initial granule. diff --git a/arch/arm64/Kconfig.debug b/arch/arm64/Kconfig.debug index c0ef0498f1439..1804d95b33263 100644 --- a/arch/arm64/Kconfig.debug +++ b/arch/arm64/Kconfig.debug @@ -37,14 +37,14 @@ config ARM64_USER4K_EXPERIMENTAL Build the in-development MM support for alternative 4K user tables on 16K/64K kernels and 16K user tables on 64K kernels. - This is experimental. The code is built in, but the feature is off - at run time unless the kernel is booted with user4k=on. While it is - off, the page-size prctls refuse every non-native size with EINVAL, - every exec gets the native granule, the CPUs report no alternative + This is experimental. The feature is on at run time unless the + kernel is booted with user4k=off. While it is off, the page-size + prctls refuse every non-native size with EINVAL, every exec gets + the native granule, the CPUs report no alternative user granule and the per-page 4K ownership record in page_ext is not reserved. The shared MM code paths remain compiled in either way. - With user4k=on, an experimental prctl selects a supported granule + While it is on, an experimental prctl selects a supported granule for the next exec. Ordinary address spaces and kernel tables retain the native granule. This is a development ABI: several MM interfaces and device mappings still require integration and validation. The @@ -71,9 +71,8 @@ config ARM64_USER4K_KUNIT_TEST help Exercise independent TTBR0 translation granules, subpage permissions and invalidation while TTBR1 retains the normal native kernel tables. - Boot the test kernel with user4k=on (kunit.py --kernel_args - user4k=on); only the arm64-user4k-policy suite is meant to run - without it. Hardware translation/uaccess fixtures also require + Do not boot the test kernel with user4k=off; only the + arm64-user4k-policy suite is meant to run with it. Hardware translation/uaccess fixtures also require arm64.user4k_test=1 and are disabled with KASAN. Software MM fixtures can run with KASAN without borrowing or replacing TTBR0. Run only in a disposable test VM. This regression harness does not @@ -136,4 +135,4 @@ config ARM64_USER4K_DATA_KUNIT_TEST Exercise packed allocation, slot reuse, copying and deferred lifetime. These tests use native kernel addresses without changing TTBR0, and can run with KASAN even when the architectural tests are disabled. - Boot the test kernel with user4k=on. + Do not boot the test kernel with user4k=off. diff --git a/arch/arm64/include/asm/mmu.h b/arch/arm64/include/asm/mmu.h index db721e655bb4b..d5c14bd818d14 100644 --- a/arch/arm64/include/asm/mmu.h +++ b/arch/arm64/include/asm/mmu.h @@ -26,8 +26,8 @@ extern bool arm64_user4k_on; /* - * Mixed-granule userspace is built in but experimental: it stays off unless - * the kernel is booted with user4k=on. Fixed once early parameters are parsed. + * Mixed-granule userspace is on unless the kernel is booted with user4k=off. + * Fixed once early parameters are parsed. */ static inline bool user4k_enabled(void) { @@ -43,7 +43,7 @@ static inline bool user4k_enabled(void) /* * Validate a page-size request for a later exec. Zero selects the native - * granule; an alternative needs user4k=on and CPU support. Pure for KUnit. + * granule; an alternative needs user4k enabled and CPU support. Pure for KUnit. */ static inline int arm64_exec_page_size_request(unsigned long size, bool enabled, bool has_4k, bool has_16k) diff --git a/arch/arm64/include/asm/mmu_context.h b/arch/arm64/include/asm/mmu_context.h index 2afded3c37dc7..141773f259f45 100644 --- a/arch/arm64/include/asm/mmu_context.h +++ b/arch/arm64/include/asm/mmu_context.h @@ -30,7 +30,7 @@ #define arch_mm_init_exec arch_mm_init_exec static inline void arch_mm_init_exec(struct mm_struct *mm, unsigned int page_shift) { - /* Without user4k=on every exec gets the native granule. */ + /* With user4k=off every exec gets the native granule. */ if (!user4k_enabled()) return; if (page_shift == 12) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 6648d300302f7..4e5ae7bf52b06 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1736,7 +1736,7 @@ early_param("arm64.user16k_deny_late_cpu", user16k_deny_late_cpu_setup); static bool has_user4k_granule(const struct arm64_cpu_capabilities *entry, int scope) { - /* Without user4k=on no alternative granule is offered or reported. */ + /* With user4k=off no alternative granule is offered or reported. */ if (!user4k_enabled()) return false; #ifdef CONFIG_ARM64_USER4K_KUNIT_TEST diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index f3b37107e5aad..97b1021052f41 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -1076,7 +1076,7 @@ unsigned long arch_align_stack(unsigned long sp) #ifdef CONFIG_ARM64_USER4K_EXPERIMENTAL int arm64_bprm_prepare_mm(struct linux_binprm *bprm, bool compat) { - /* Without user4k=on every image, AArch32 included, stays native. */ + /* With user4k=off every image, AArch32 included, stays native. */ bool enabled = user4k_enabled(); bool has_4k = enabled && cpus_have_final_cap(ARM64_HAS_USER4K_GRANULE); unsigned int requested = 0, shift; @@ -1094,7 +1094,7 @@ int arm64_bprm_prepare_mm(struct linux_binprm *bprm, bool compat) /* * Return zero for the native default, or a validated alternative shift. - * Every alternative is refused with -EINVAL unless booted with user4k=on. + * Every alternative is refused with -EINVAL when booted with user4k=off. */ int arch_exec_page_size_shift(unsigned long size) { diff --git a/arch/arm64/mm/context.c b/arch/arm64/mm/context.c index cac6b968a6888..c405fd3bf82db 100644 --- a/arch/arm64/mm/context.c +++ b/arch/arm64/mm/context.c @@ -41,11 +41,11 @@ static unsigned long *pinned_asid_map; #ifdef CONFIG_ARM64_USER4K_EXPERIMENTAL /* - * Experimental mixed-granule userspace is off unless booted with user4k=on. - * Early parameters are parsed in setup_arch(), before page_ext sizing and - * CPU capability detection read this. + * Mixed-granule userspace is on unless booted with user4k=off. Early + * parameters are parsed in setup_arch(), before page_ext sizing and CPU + * capability detection read this. */ -bool arm64_user4k_on __ro_after_init; +bool arm64_user4k_on __ro_after_init = true; static int __init user4k_setup(char *str) { diff --git a/arch/arm64/mm/user4k-test.c b/arch/arm64/mm/user4k-test.c index e07f0bb687118..224cc00bd629d 100644 --- a/arch/arm64/mm/user4k-test.c +++ b/arch/arm64/mm/user4k-test.c @@ -13770,7 +13770,7 @@ static void user4k_exec_granule_policy_test(struct kunit *test) } } -/* Exec page-size requests are refused unless booted with user4k=on. */ +/* Exec page-size requests are refused when booted with user4k=off. */ static void user4k_page_size_request_test(struct kunit *test) { static const struct { @@ -13828,7 +13828,7 @@ static void user4k_boot_switch_prctl_test(struct kunit *test) long expect = !user4k_enabled() ? -EINVAL : has_4k ? 0 : -EOPNOTSUPP; unsigned int i; - /* Without user4k=on the CPUs report no 4K user granule either. */ + /* With user4k=off the CPUs report no 4K user granule either. */ if (!user4k_enabled()) KUNIT_EXPECT_FALSE(test, has_4k); for (i = 0; i < ARRAY_SIZE(options); i++) { @@ -13862,7 +13862,7 @@ static void user4k_boot_switch_exec_test(struct kunit *test) KUNIT_ASSERT_NOT_NULL(test, mm); KUNIT_EXPECT_EQ(test, mm_page_shift(mm), user4k_enabled() ? 12U : PAGE_SHIFT); mmput(mm); - /* With user4k=on, user4k_exec_secure_granule_test covers staging. */ + /* With user4k enabled, user4k_exec_secure_granule_test covers staging. */ if (user4k_enabled()) return; for (compat = 0; compat < 2; compat++) { @@ -13887,7 +13887,7 @@ static void user4k_boot_switch_exec_test(struct kunit *test) } } -/* Native pages never have a 4K owner; without user4k=on there is no record. */ +/* Native pages never have a 4K owner; with user4k=off there is no record. */ static void user4k_boot_switch_page_ext_test(struct kunit *test) { struct mm_subpage_mapcounts counts; @@ -14766,7 +14766,7 @@ static struct kunit_suite user4k_test_suite = { .test_cases = user4k_test_cases, }; -/* Safe with or without user4k=on; the other suites need user4k=on. */ +/* Safe with or without user4k=off; the other suites need it on. */ static struct kunit_case user4k_policy_cases[] = { KUNIT_CASE(user4k_page_size_request_test), KUNIT_CASE(user4k_boot_switch_prctl_test), diff --git a/mm/user-subpage.c b/mm/user-subpage.c index 0497cbccfb65b..374ca5e9f3079 100644 --- a/mm/user-subpage.c +++ b/mm/user-subpage.c @@ -71,7 +71,7 @@ static_assert(SUBPAGES_PER_FOLIO <= sizeof(u16) * BITS_PER_BYTE); /* * The record is reserved only when this boot may create alternative-granule - * mms (on arm64, user4k=on). Otherwise page_ext may still exist for other + * mms (on arm64, unless booted with user4k=off). Otherwise page_ext may still exist for other * users, but mm_subpage_ext_ops has no offset in it and must not be read. */ static bool __init subpage_ext_needed(void) diff --git a/tools/aurora-userpages/README.rst b/tools/aurora-userpages/README.rst index 92b8a8c922412..bbd8a557f4276 100644 --- a/tools/aurora-userpages/README.rst +++ b/tools/aurora-userpages/README.rst @@ -4,9 +4,9 @@ Per-process userspace page-size launcher ======================================= Build with ``make`` in this directory. The running arm64 kernel must provide -Aurora's experimental per-process granule API and be booted with -``user4k=on``. The feature is off by default; without that parameter every -non-native size is refused with ``EINVAL`` and ``native`` still works. +Aurora's experimental per-process granule API. The feature is on by default; +a kernel booted with ``user4k=off`` refuses every non-native size with +``EINVAL``, and ``native`` still works. Examples:: diff --git a/tools/aurora-userpages/userpages.c b/tools/aurora-userpages/userpages.c index 51993fbc92fc0..03d58afd2c803 100644 --- a/tools/aurora-userpages/userpages.c +++ b/tools/aurora-userpages/userpages.c @@ -19,11 +19,11 @@ static int usage(const char *name, int status) return status; } -/* Without user4k=on the kernel refuses every smaller size with EINVAL. */ +/* Booted with user4k=off, the kernel refuses every smaller size with EINVAL. */ static int off_hint(unsigned long size, int error) { if (error == EINVAL && size && size < getauxval(AT_PAGESZ)) - fputs("Smaller page sizes need a kernel booted with user4k=on.\n", + fputs("Smaller page sizes are off: the kernel was booted with user4k=off.\n", stderr); return 1; }