Repository navigation
arm64: ctxr-execmem: follow-ups from the Neo run and a second review - #1079
Merged
Merged
Conversation
Nothing reported pool use, so an allocation failure on a user's machine wasn't diagnosable. Add /sys/kernel/execmem_confine/ with the window base and size and the pool's size, free and largest free extent. A tool can read the window from there too. While here, call both set_memory_nx() and set_memory_rw() on free rather than letting || short-circuit, and correct the comment: a set_memory_rw() failure would leave a read-only alias, not an executable one. Signed-off-by: Diljit Singh <hey@djdev.me>
A CTXR window already makes machine_kexec_prepare() refuse kexec and crash kernels, because the relocation code runs outside the window. The crashkernel= reservation then only takes memory a crash kernel can never use. Skip it with one warning when a window is active, in arch_reserve_crashkernel(), before reserve_crashkernel_generic() runs. Signed-off-by: Diljit Singh <hey@djdev.me>
…ne matches it A command-line window inside the device-tree window reserved only the sub-window, so the rest of the firmware's window went to the buddy allocator and EL0 stalled on it on a confined core, with every check keyed on the sub-window so nothing noticed. The whole firmware window has to be reserved. Accept a command-line window only when it is identical to the device-tree one; otherwise warn and use the device-tree window. A command-line window with no device-tree window (VM bring-up) is unchanged. Write the entry flag as ctxr_active && is_kernel_in_hyp_mode() so it plainly can't be set off a non-EL2 path, and drop the now-unused ctxr_within() helper. Signed-off-by: Diljit Singh <hey@djdev.me>
An out-of-window kernel fetch on a confined core dies as "execute from non-executable memory", which sends the reader looking at page permissions when the real cause is the CTXR window refusing a fetch from an in-range executable mapping. Add ctxr_exec_fetch_outside_window(), which walks the kernel page tables for the faulting address and reports whether its physical page is outside an active window, and say "execute from outside the CTXR window" when it is. Also refresh the stale ctxr_stay_el2 comment, which still said the flag was set once. Signed-off-by: Diljit Singh <hey@djdev.me>
The backstop's PFN-map branch took any follow_pfnmap() PFN and skipped the user-exec check the folio branch makes, and the comment claimed it covered struct-page-less mappings in general when follow_pfnmap() only handles VM_PFNMAP. Confirm a user-executable leaf (pte_user_exec() on the PFN and pgprot) before comparing, restrict the branch to VM_PFNMAP, and say plainly that a special VM_MIXEDMAP PTE is left to the hardware fault, which is the real guarantee; this kill is a diagnostic backstop. The documentation of the whole-window reservation invariant is tightened to match the command-line-window fix. Signed-off-by: Diljit Singh <hey@djdev.me>
RyanTheTide
added a commit
that referenced
this pull request
Nov 7, 2026
Brings aurora-wip up to the tested release branch: CTXR execmem (#985, #1079), KFIX speaker sleep and resume fixes (#1077, #1080), JPEG v2 (#1072), Jonathan's G17 and USB work (#1073-#1076), brcmfmac flowring count (#1081), ANE H16 startup restart (#1066) and the Touch ID per-prompt match (#904). Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Assisted-by: LLM
This was referenced Nov 7, 2026
Merged
Merged
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.
Follow-up to #985, which merged at
273b9e8. These five commits landed onfeat/ctxr-execmemafter the merge, so they aren't inintegration/aurorayet. They answer the rest of Ryan's Neo run and a second independent review.d56b6e6292fmm/execmem: report the window and pool use via sysfs./sys/kernel/execmem_confine/giveswindow_base,window_size,pool_size,pool_freeandpool_largest_free, in bytes, so anENOMEMon a user's Mac is diagnosable. Tools can read the window from there instead of the boot log, which wraps in minutes on the Neo.set_memory_nx()andset_memory_rw()on free, where||used to short-circuit.25e007f8256: skips thecrashkernel=reservation, with one warning, while a window is active. kexec is refused then, so the memory was wasted.590be8c8957: uses the device-tree window unlessctxr_exec_window=matches it exactly. With a smaller command-line window inside the device tree's, only the sub-window was reserved, and the rest of the firmware's window went to the page allocator. EL0 can't execute there on a confined core. Under the simulator, with the enforced window equal to the device tree's 128 MiB,/inithung on CPU2, and 31.7 MiB of user pages landed in the window withmaxcpus=1.c6a7e1f3ef7: names the CTXR window in the oops when a kernel fetch outside it faults on a confined core, instead of "execute from non-executable memory" (Ryan's item 3).c3c11153cda: the EL0 backstop checks only a user-executable PFN-mapped page.Ryan's
6315aea/273b9e8covered the BPF JIT fill, so the BPF clamp from the same round was dropped.Tested. Only in QEMU; none of this has booted on hardware.
c3c11153cda, simulator enforcing on CPU1 and CPU2, guest system files clean before and after. These all pass:Still open: what takes 74 MiB of the window on the Neo's U-Boot and GRUB path, against 17 MiB on the M5.
🤖 Generated with Claude Code