Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Documentation/admin-guide/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8349,10 +8349,10 @@ Kernel parameters

user4k= [ARM64,EARLY]
Format: <bool>
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.
Expand Down
31 changes: 16 additions & 15 deletions Documentation/arch/arm64/user4k.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -194,18 +194,19 @@ 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
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.
Expand Down
4 changes: 2 additions & 2 deletions Documentation/mm/user_page_size.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 8 additions & 9 deletions arch/arm64/Kconfig.debug
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
6 changes: 3 additions & 3 deletions arch/arm64/include/asm/mmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/include/asm/mmu_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/kernel/cpufeature.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions arch/arm64/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
{
Expand Down
8 changes: 4 additions & 4 deletions arch/arm64/mm/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
10 changes: 5 additions & 5 deletions arch/arm64/mm/user4k-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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++) {
Expand Down Expand Up @@ -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++) {
Expand All @@ -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;
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion mm/user-subpage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions tools/aurora-userpages/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::

Expand Down
4 changes: 2 additions & 2 deletions tools/aurora-userpages/userpages.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading