Repository navigation
drm/asahi: GEM_USERPTR in processes with a smaller page size - #2226
Merged
DjDeveloperr merged 2 commits intoNov 19, 2026
Merged
DjDeveloperr merged 2 commits into
DjDeveloperr merged 2 commits into
Conversation
GEM_USERPTR pins its range with pin_user_pages_fast(). In a process whose user page size is smaller than the native one (CONFIG_MM_SUBPAGE, user4k: 4K processes on a 16K kernel, such as everything running under FEX), GUP cannot return pages, and every GEM_USERPTR fails with EOPNOTSUPP, so VK_EXT_external_memory_host imports fail there. Such a process maps each of its pages to a fragment of a native page, and pin_user_fragments_remote() pins those. The GPU maps native pages, so a native page can back the object only where the process maps all of it, its fragments in order at consecutive addresses: then the GPU sees exactly what the CPU sees, and nothing the process does not map. user_pages.c pins the range as fragments and checks that layout, all or nothing (EFAULT where a native page is not mapped whole and in order). The fragment records hold the pins and are released with the object; pinned_vm counts native pages, as for other processes. The GEM_USERPTR uAPI documentation states the layout requirement. Processes with the native page size keep pin_user_pages_fast(). Tested on an M4 Pro: see the userptr probe in the cover note (native 16K and userpages 4k). Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com> Assisted-by: LLM
gem-userptr re-executes itself as a 4K process and imports anonymous 32K ranges with DRM_IOCTL_ASAHI_GEM_USERPTR on the GPU render node, without submitting GPU work. A range whose 16K pages are each mapped whole and in order pins 32K in VmPin until the object is closed. A 16K page with one 4K page moved in from elsewhere, or with two of its own 4K pages swapped, fails with EFAULT and leaves VmPin unchanged. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com> Assisted-by: LLM
This was referenced Nov 19, 2026
DjDeveloperr
merged commit Nov 19, 2026
4c297ac
into
aurora-silicon:integration/aurora
1 check passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GEM_USERPTR (#1609) pins its range with
pin_user_pages_fast(). In a process whose user page size is smaller than the native one (CONFIG_MM_SUBPAGE: 4K processes on a 16K kernel, such as everything running under FEX), GUP cannot return pages. So every GEM_USERPTR fails with EOPNOTSUPP, andVK_EXT_external_memory_hostimports fail there.Such a process maps each of its pages to a fragment of a native page, and
pin_user_fragments_remote()pins those. The GPU maps native pages, so a native page can back the object only where the process maps all of it: its fragments in order, at consecutive addresses. Then the GPU sees exactly what the CPU sees, and nothing the process does not map.user_pages.cpins the range as fragments and checks that layout, all or nothing. It returns EFAULT where a native page is not mapped whole and in order. The fragment records hold the pins and are released with the object.pinned_vmcounts native pages, as for other processes. Processes with the native page size keeppin_user_pages_fast().The uAPI documentation of
drm_asahi_gem_userptrnow states the layout rule. This is a comment only; no struct, flag or value changes.The second commit adds
tools/testing/selftests/arm64/user4k/gem-userptr.c. It runs in a 4K process and submits no GPU work:Tested on the J616s (M4 Pro, 16K kernel)
dEQP-VK.*external_memory_host*gave 5 pass, 8 not supported, 0 fail. Host-pointer imports worked from a native process and from a FEX 4K process, including memory write-protected through userfaultfd (with mm: populate a subpage window's uffd-wp markers with the faulting page #2225's mm fix). The refusal path leaked no pins. 0 GPU recoveries.On this branch: KUnit 696 of 697 passed, one skipped (needs
CONFIG_UCLAMP_TASK).tools/asahi/run-host-tests.py --only g17passed 90/90.drivers/gpu/drm/asahi/builds with W=1 and no new warnings.Not done
mm/gup.c, not touched here: a read-only long-term pin throughfollow_subpage_fragment()takes the shared zero page. Native GUP unshares it first.🤖 Generated with Claude Code