Skip to content
Draft
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
19 changes: 17 additions & 2 deletions Documentation/arch/arm64/user4k.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,23 @@ While it is off:
16K pages). ``page_ext`` itself is still allocated if another user, such
as page_owner, needs it.

The shared MM code paths that serve every process are compiled in either
way and do not change with the parameter.
The shared MM code that serves every process is compiled in either way, and
the parameter does not switch it back to the upstream code. A kernel built
with this option therefore differs from upstream even while the feature is
off. The differences that callers can see are:

* ``vm_insert_pages()`` returns ``EFAULT`` for a start address that is not
aligned to the address space's page size.
* The ``fault_around_bytes`` debugfs file accepts values down to 4K, so
writing ``0`` reads back 4096 rather than the native page size.
* ``generic_access_phys()`` handles at most one user page per call.
``access_process_vm()`` and other callers that loop still move the same
total.
* ``locked_vm`` is counted in 4K units for every process. Limit checks and
``VmLck`` give the same results as before for native address spaces.

Other changes, such as the 64K zero page and ``pgtable_t`` holding a
``pte_t`` pointer, keep native results the same.

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.
Expand Down
5 changes: 4 additions & 1 deletion arch/arm64/Kconfig.debug
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@ config ARM64_USER4K_EXPERIMENTAL
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.
reserved. The shared MM code paths remain compiled in either way, so
a few behaviours differ from upstream even while it is off; see
Documentation/arch/arm64/user4k.rst.

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
private prctl numbers are not upstream assignments or a stable ABI
promise. Programs that do not use the prctl keep the native granule.
KSM does not merge the memory of programs that use another granule.

config ARM64_CPUINFO_KUNIT_TEST
bool "KUnit tests for the /proc/cpuinfo model name" if !KUNIT_ALL_TESTS
Expand Down
23 changes: 18 additions & 5 deletions fs/splice.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,22 +219,35 @@ static const struct pipe_buf_operations subpage_pipe_buf_ops = {
static int subpage_pipe_buf_retain(struct pipe_buffer *buf)
{
struct subpage_pipe_refs *refs;
struct mm_subpage *first;
unsigned int pos, count = 0;

if (!buf->len || buf->ops != &nosteal_pipe_buf_ops ||
!folio_test_anon(page_folio(buf->page)))
return 0;
/*
* Look up the first quarter before allocating. It has no owner on a
* native anonymous page, and none at all while user4k is off, so the
* common splice keeps its native reference without an allocation.
*/
pos = round_down(buf->offset, MM_SUBPAGE_SIZE);
first = mm_subpage_get_from_phys(page_to_phys(buf->page) + pos);
if (!first)
return 0;
refs = kmalloc(struct_size(refs, fragments, PAGE_SIZE / MM_SUBPAGE_SIZE), GFP_KERNEL);
if (!refs)
if (!refs) {
mm_subpage_put(first);
return -ENOMEM;
for (pos = round_down(buf->offset, MM_SUBPAGE_SIZE);
pos < buf->offset + buf->len; pos += MM_SUBPAGE_SIZE) {
struct mm_subpage *slot = mm_subpage_get_from_phys(page_to_phys(buf->page) + pos);
}
for (; pos < buf->offset + buf->len; pos += MM_SUBPAGE_SIZE) {
struct mm_subpage *slot = first;

if (count)
slot = mm_subpage_get_from_phys(page_to_phys(buf->page) + pos);
if (!slot) {
release_user_fragments(refs->fragments, count, false);
kfree(refs);
return count ? -EFAULT : 0;
return -EFAULT;
}
refs->fragments[count++] = (struct user_page_fragment) {
.folio = page_folio(buf->page),
Expand Down
Loading