Repository navigation
accel/ane: check H16/H17 DMA bases and LOAD sections against the program, and pin EXECUTE buffers before locking - #2876
Conversation
|
Review at b29dac1. Thanks for this, the DMA model and the lockdep/fault-hold rows are well done. Some things I'd like settled before merge:
The pin/unpin error paths look right to me: every exit after a pin goes through |
|
Review notes on the DMA base check (commit 1). I read it; no build.
Commits 2 and 3 look right to me. A minor point: buffers backed by VM_PFNMAP mappings now fail to pin where they used to be copied. That seems acceptable, but it might be worth a line in the commit message. |
A task names each buffer the engine reads or writes as a relocated [lo, hi] record, whose 64-bit offset is taken relative to the DVA of the buffer bound to the record's BAR slot. The validator checked that each register lies in a known block and that the operation section binds each slot to the right resource, but not the offset, nor that the slot is bound, nor that a base is relocated at all. At LOAD, once the operation section is checked and before anything is mapped, walk every task: - A DMA base (the input DMA's sources 1 and 2, the output DMA, the coefficient DMA and the lookup table) is written only by a relocated record covering exactly its lo and hi words, on a slot the operation section binds. - The end of the last 64-byte line its transfer touches, ALIGN(offset + extent, 64), stays inside that buffer: a surface's declared size, the scratch's __bss size, or the kernel section to the end of its last 16 KiB page, which is what the kernel slot maps. The offset is unsigned, so a negative one fails; products and sums are overflow-checked. - An input or output extent is width x element bytes x interleave, plus (rows - 1) x row stride, (channel groups - 1) x plane stride, (depth - 1) x depth stride and (groups - 1) x group stride, the interleave packing that many channels per plane. The coefficient extent is its furthest lane (offset plus size, at least the aligned per-channel size) plus each further group and output channel group, a channel group being 16 << (common word 0x40 & 7) channels. The lookup table is its size word, at least 64. - A task that enables an input DMA source, the output DMA or the lookup table (a non-zero configuration word) writes that DMA's base in the same task, and a height and channel count that are not zero. A zero width, depth or group count is read as one: the compiler writes 0 there, and a zero width is in a 256 x 256 matmul that runs correctly on an M4 Pro. Lookup-table tasks configure the coefficient DMA without a base, so that DMA is bounded by the running image below instead. - Fields the extent rules decode stay within what the compiler writes: the output channel group (0x40 & 7) at most 5, and no format bits besides the interleave, the element size and the bits every program sets. - The only other relocated records are the cache-allocation words on the custom BAR slot 4. Dense header bits 21, 22 and 30, and a slot without the relocation bit, are refused. - The DMA registers the bound does not model stay zero: metadata and compression, texture, crop and wrap, the bias, post-scale and palette tables, the destination pixel offset, and the wrap and offset fields beside the cache hints and formats. They stay refused until a program needs them. Outside the DMA blocks, 0x44d0 stays zero and the cache DMA block takes only the six words the compiler writes. The L2, planar engine and neural engine blocks configure on-chip buffers and arithmetic, and cannot be relocated, so they hold no buffer address. Whether the engine starts each task from its defaults or keeps registers from the task before is not known, so both readings are checked: each task over the defaults, and a running image carried across the stream, against which every base written so far is checked after each task with the geometry in force then. Programs leave a word out wherever it holds the default, also when an earlier task set another value. Where that leaves an earlier base with a larger extent, the stream fits only the first reading and is refused. Refusals are ENOEXEC, as for the validator's other program checks. No register documentation is available. The extent rules are read from the encoder of aurora-silicon/mil-hwx-compiler and checked against programs whose bound lands exactly on their buffer. Of the 224 H16G and H17 programs that aurora-silicon/mil-hwx-compiler builds from its fixtures and examples, a mobilenet in every schedule it accepts and the two KUnit fixtures, 215 pass, most of them with the bound exactly equal to the buffer, and every H17 program among them. The running image refuses 8 H16G programs (space-to-depth, depth-to-space, an attention fixture and five L2-resident schedules of the linked mobilenet). One H16G matrix-multiply example is refused under both readings: it gives two 128-channel output groups a channel group stride of 0x40000 over a 0x20000 scratch. KUnit: ane_hx_dma_bound_test and ane_hx_dma_kernel_test cover a base exactly at the end of its buffer, one line past it, negative, wrapping 64 bits, on an unbound slot, unrelocated, scattered, relocated off its pair, and beside an unmodelled register. ane_hx_dma_carry_test covers geometry in one task with the bases in the next, and a base kept while a later task enlarges its geometry. ane_hx_dma_strict_test covers an enabled DMA without its base or with a zero size, the channel group, a format bit and the registers outside the DMA blocks. ane_hx_dma_align_test covers a lookup table at offset 1, which touches two lines. program_add128_dma_test runs the cases through the add-128 fixture's LOAD checks. The mobilenet and add-128 fixture cases still pass. On a J775D (die 0, 27.2 firmware) add-128 x1000 and a [1,128,16,16] add x200 stay bit exact, the linked mobilenet program classifies 16 of 16 images, and programs whose bases leave their buffers are refused at LOAD before anything is mapped. Reported-by: Erik Bourget <erik@ebourget.net> Suggested-by: Erik Bourget <erik@ebourget.net> Signed-off-by: Jeff Queisser <funkzy@users.noreply.github.com>
…cked H16_LOAD takes four host-built sections. The generic and operation sections were checked against the HWX field by field, but not their reserved bytes, and the procedure and text-properties sections only for their size. The text properties give the firmware the task stream's framing: segment offset, segment size and task count. The kernel validates the stream as it frames it, from its prologue with the HWX's task count, so properties that frame it differently describe a stream nobody checked. Both sections have one form, which the selftests' h16-sections.py writes and the kernel now derives from the validated program: one procedure, and one text segment covering the whole task stream with its task count. H16_LOAD refuses any other size or byte. The reserved bytes of the generic header and of each entry, and an operation record's bytes after its last reference, must be zero, and an entry's tail word must be ANE_H16_GENERIC_ENTRY_TAIL, as h16-sections.py writes them. Refusals are ENOEXEC, before anything is mapped or sent. The add-128 and mobilenet sections that h16-sections.py builds, which the KUnit fixtures carry, are exactly the kernel's form. KUnit: program_sections_exact_test refuses another task count, segment offset or size, a longer section, a changed procedure, and a nonzero reserved byte in each place above, and refuses such a LOAD before any mapping or firmware traffic. The session tests now pass the procedure and text properties h16-sections.py writes instead of zeroes. On a J775D (die 0, 27.2 firmware) add-128 x1000 and a [1,128,16,16] add x200 stay bit exact and the linked mobilenet program classifies 16 of 16 images; sections in any other form are refused at LOAD. Reported-by: Erik Bourget <erik@ebourget.net> Suggested-by: Erik Bourget <erik@ebourget.net> Signed-off-by: Jeff Queisser <funkzy@users.noreply.github.com>
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal §1–§6 review at b29dac1a746c.
The overall architecture (LOAD-time DMA base bounding, exact-form section validation, and lock-free user page pinning in EXECUTE) is strong, lockdep/fault-hold testing on J775D is thorough, and §1 (no chip gates), §4 (human commits + Signed-off-by/Reported-by/Suggested-by, clean-room, PR Assisted-by), §6 (naming), and CI (host-tests) pass.
Blockers to address before merge:
- Blocker — Commit 1 (
ane_h16_tasks.h:269-274, 336-399): Unverified cross-task register carry-over and missing required-base enforcement:ane_hx_dma_image()resetsimg[]to defaults on every task, and the PR notes that register carry-over across tasks was not checked on hardware.- If the engine retains state across tasks, the validator is bypassable in both directions: task N writes large dims/strides with no base record (nothing checked), and task N+1 writes a base while omitting strides (validated against small defaults, executed with task N's strides), or vice versa.
- Similarly,
ane_hx_task_stream_dma_validate()only checks extent where a relocated[lo, hi]base record is written, without requiring every DMA enabled by a task to write a relocated base. - Fix: either prove on hardware (e.g. a two-task fault test) that hardware resets DMA/common state per task and require a relocated base for each enabled DMA, or maintain a running register image across tasks and validate every enabled DMA on every task.
- Blocker — Commit 1 (
ane_h16_tasks.h:392-394): Unaligned base offset breaks 64-byte line rounding:- Checking
offset + ALIGN(extent, 64) <= bound[slot]under-estimates the last byte touched whenoffsetis not 64-byte aligned (e.g.offset = 1, extent = 64computeslast = 65, while 64-byte DMA lines covering[offset, offset + extent)span[0, 128)). Either reject unaligned offsets (offset & 63) or boundALIGN(offset + extent, 64)with overflow checking.
- Checking
- Blocker — Commit 1 compatibility corpus & unmodelled blocks:
- The strict allowlist rejects registers it does not model, yet existing supported
#2748int8/uint8 programs and#1882zin-compiled programs have not been checked against the new DMA and exact-section validators, and the refused H16G matmul example has not been diagnosed (real compiler OOB vs. extent-model gap). Please run that corpus check before merge so working userspace is not regressed. - Also document (or bound) why the other allowed blocks in
ane_h16_register_valid()(0x4100-0x41a4,0x44d0,0x4500-0x453c,0x4900-0x4930,0x5900-0x5930) cannot carry DMA addresses or offsets.
- The strict allowlist rejects registers it does not model, yet existing supported
- Blocker — Commit 3 (
ane_h16_accel.c:193,ane_h16_user_pinwrap edge case,ane_h16_program.c:968-971):pin_user_pages_fast()returns-EFAULTonVM_PFNMAP/VM_IOmappings (such asdrm_gem_shmemGPU mmaps or CMA dma-buf mmaps) wherecopy_from_user()/copy_to_user()previously worked. Either explicitly document this UAPI change in the commit message or provide an unlocked bounce-copy fallback forVM_PFNMAPranges.- In
ane_h16_user_pin()(ane_h16_accel.c:42-45):DIV_ROUND_UP(u->offset + size, PAGE_SIZE) > INT_MAXcan wrap to0whenu->offset + size > SIZE_MAX - (PAGE_SIZE - 1)(e.g.ptr = PAGE_SIZE - 1,size = SIZE_MAX - (PAGE_SIZE - 1)passesptr + size >= ptr, overflowsDIV_ROUND_UPto0, and returns0withu->count = 0). Bounded by surface size in the ioctl path today, but the helper itself should checksize > (size_t)INT_MAX * PAGE_SIZE - u->offset(orcheck_add_overflow) cleanly. ane_h16_program.c:968-971: the updated comment says the node lock must never be taken under the mmap lock, which contradictsane_h16_mmap()(ane_h16_accel.c:300-316) takingf->lockanda->lockunder the mmap lock. The actual ordering after commit 3 ismmap_lock -> f->lock -> a->lock(nothing may fault/takemmap_lockundera->lock, andane_h16_export_put()defers becauseh16_give_back()calls it undera->lockandvma_closeundermmap_lock).
- Blocker — §5 hardware coverage:
- Only J775D die 0 (with
#2293+ an unposted DT commit, ALARM without SELinux AVC counts) has been tested. Still needed: a tree-supported H17/M5 row without out-of-tree DT, and H16 hardware rows (M4 / M4 Pro) running real models (MobileNet + zin/int8) plus out-of-bounds LOAD refusal with full regression counts.
- Only J775D die 0 (with
Assisted-by: LLM (Gemini 4 Neon)
b29dac1 to
1c027e7
Compare
|
Thanks to both of you. This covers Ryan's two comments and dj's review together. The new head is 1c027e7. Points follow Ryan's first comment; his second is marked R2, and dj's blockers 1-5 map to Ryan's 1, 2, 3 with R2-2, 4 with 5, and 6. 1, R2-1: task state and enabled DMAs. Both readings are now checked. Each task is checked on its own words over the defaults, as before. A running image carried across the stream is checked as well: after each task, every base written so far is checked against the geometry in force then. In addition, a task that enables an input DMA source, the output DMA or the lookup table (any non-zero configuration word) must write that DMA's base in the same task, with a non-zero height and channel count. Two limits:
To check per-task register reset directly on the J775D's H17, I ran two-task variants of the
This confirms H17 resets the output DMA base and the output and input0 row strides, and does not carry common widths, while input-base reset remains unproven. The running image stays enabled on every chip (no chip gate): on H17 it refuses nothing, and it is what bounds the coefficient DMA in lookup-table tasks as well as any unproven input-base carry. 2: line end. R2-2: unmodelled blocks. Zero isn't possible for most of them, since every program writes them. Instead:
The commit message gives the per-block reason. R2-3: decode hardening.
3: corpus. I don't have the #1882 programs or the #2748 int8/uint8 programs. The tree has only synthetic fixtures for both, and mil-hwx-compiler builds int8 only for H13/H14. So neither ran here, on the host or on hardware. This stays open before merge.
The refused H16G matmul ( 4, R2 note: unpinnable buffers. Not intended, thanks. When pinning fails and the range reaches a VM_PFNMAP or VM_IO mapping, the buffer is bounced:
dj's wrap case in 5: comment. The comment now gives the order that must not happen: the mmap lock, or a user fault, taken under the node lock. Taking the node lock under the mmap lock is what 6: rows. The J775D row at the new head is in the body. KUnit passes 279/0/1. The add programs stay bit exact, the mobilenet classifies 16/16, and every out-of-bounds and section case is refused at LOAD. A second client's LOAD takes 4.7 ms while one client's page fault is held, and the lockdep run reports nothing. It still needs #2293 and our J775D die 0 Neural Engine opt-in, e9754164afe3. That is a DT-only commit enabling die 0's ANE in Assisted-by: LLM (Claude:Opus 5.5), LLM (Gemini:Neon) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Re-review of 1c027e781aaa86cde7e21f92135b6f4467281a77 against pre-pr-checklist.md (§1–§6) (CI: Host tests / host-tests SUCCESS; MERGEABLE / CLEAN, non-draft).
Resolved since b29dac1a746c
- Dual per-task + running-image DMA checks, enabled-DMA base requirement, overflow-checked
ALIGN(offset + extent, 64), unmodelled-block audit (0x44d0zeroed, cache DMA allowlist, non-relocatable L2/PE/NE blocks), decode hardening (ane_hx_dma_strict_test),ane_h16_user_pin()INT_MAX * PAGE_SIZEwrap fix,VM_PFNMAP/VM_IObounce path, correctedane_h16_export_put()lock-order comment, and J775D per-task reset probes are all solid improvements. - §1, §4, §6: Clean — no chip gates; all 3 commits carry human author/committer + human
Signed-off-by:(Reported-by:/Suggested-by:) only, zero AI commit trailers; PR body disclosesAssisted-by:; naming clean.
Remaining blockers before approval
- New code bug —
drivers/accel/ane/ane_h16_accel.c:74-125(ane_h16_user_unpinnable()/ane_h16_user_bounce()/ane_h16_user_get()):ane_h16_user_unpinnable(ptr, size)returnstrueas soon as it sees anyVM_PFNMAP | VM_IOVMA in[ptr, ptr + size)without checkingVM_WRITEor verifying that the entire[ptr, ptr + size)range is mapped with no holes.- For a read-only
VM_PFNMAP/VM_IOoutput (or aVM_PFNMAP/VM_IOVMA followed by an unmapped hole or read-only VMA),ane_h16_user_pin(..., write=true)returns-EFAULT,ane_h16_user_unpinnable()returnstrue, andane_h16_user_bounce(..., write=true)skipscopy_from_user()and returns0. The ANE request then executes on hardware beforeane_h16_user_put()fails oncopy_to_user(), contradicting the commit message andane_h16_user_get()doc comment ("Unmapped memory and read-only outputs still fail before the request"). (ane_h16_accel_user_bounce_testmissed this becauserodid not haveVM_IOset.) - Fix: pass
writetoane_h16_user_unpinnable(), walk the full[ptr, ptr + size)range with no gaps, requireVM_WRITEon every VMA whenwriteis true (andVM_READwhen!write), returntrueonly if the entire range is validly mapped and at least one VMA hasVM_PFNMAP | VM_IO, and add KUnit coverage for a read-onlyVM_IOoutput and aVM_IO+ unmapped-hole range.
- Compatibility corpus blockers (open before merge):
#1882(zin-compiled) programs and#2748(int8/uint8) programs have still not been run through the DMA or exact-section checks (host or hardware).- The running image refuses 8
mil-hwx-compilerH16G programs (space-to-depth, depth-to-space, attention fixture, and 5 L2-resident MobileNet schedules) that omit default words after an earlier task set them, and the refused H16G matmuls_mm_256remains undiagnosed (real compiler OOB vs missing stride-unit rule for word0x3cbit 2).
- §3 H17 zero-width hazard: The J775D probe showed omitting common widths (
0x04/0x14) on H17 stalls and quarantines the program (firmware_stage program wedged), whileane_hx_dma_tile()still accepts width0as1; confirm whether width0on H17 can reach past its buffer before stalling (or tighten accordingly once H16mm256vs H17 behavior is settled). - §5 Hardware coverage: Still only tested on J775D die 0 with
#2293+ an unposted out-of-tree DT commit (e9754164afe3, ALARM/no SELinux). Still needed before merge: a tree-supported H17/M5 row without out-of-tree DT, and H16 hardware rows (M4 / M4 Pro, e.g., J616s and J713) running MobileNet +#1882/#2748programs bit-exact, refused OOB LOAD,s_mm_256baseline check, and the two-task per-task reset probe with full regression counts.
Assisted-by: LLM (Gemini 4 Neon)
…de lock Without DRM_ANE_H16_EXEC_IN_PLACE, H16_EXEC copied each input from user memory into its surface, and each output back, with the node lock held and the request counted active. A page fault in those copies waits for whatever backs the page, and for that long every other client's LOAD, EXECUTE, mmap and close waited on the lock, as did the PM notifier's drain at suspend, which waits for no request to be active. The fault also takes the mmap lock, while mmap() of a surface takes the file and node locks under it. Pin the user pages of every buffer with no driver lock held: outputs with FOLL_WRITE, so a buffer that cannot be written fails here with EFAULT instead of after the request ran. The buffers are checked against the loaded program before pinning, and again under the file lock after it, since the program may have changed in between. Under the node lock the copies go through the kernel mapping of the pinned pages and cannot fault; the pages are unpinned, outputs marked dirty, after both locks are dropped. There is still one copy each way. Pages in a VM_PFNMAP or VM_IO mapping cannot be pinned, and EXECUTE from a mapped GEM-shmem or dma-buf heap buffer worked with copy_from_user() before. A buffer that reaches such a mapping is bounced instead: an input is copied into a kernel buffer when it is taken, with no lock held, and an output is copied back to user memory after both locks are dropped, only if the request ran. Unmapped memory and read-only outputs still fail before the request. The comment on ane_h16_export_put() said an EXECUTE may wait for the mmap lock while holding the node lock, which is no longer true. It now gives the order that must not happen, the mmap lock or a user fault under the node lock, and what the deferral to a work item still avoids: a last put from h16_give_back(), which holds the node lock, and a munmap() that would wait under the mmap lock for a running request. KUnit: ane_h16_accel_user_pages_test pins an input and an output that cross a page boundary, compares the copies with copy_from_user() and copy_to_user(), and fails the pin, holding nothing, for an unmapped buffer, a read-only output, a range that wraps and a size whose page count would wrap; ane_h16_accel_user_bounce_test finds a VM_IO mapping in a range, takes an input and an output through the bounce copy, leaves an output the request did not write unchanged, and still fails a read-only output when taken. On a J775D (die 0, 27.2 firmware) another client's LOAD and EXECUTEs complete while one client's input page fault is outstanding, where they waited for it before. The add programs stay bit exact, and the mobilenet program classifies 16 of 16 images at a p50 request latency of 2.55 ms, as before (2.56 to 2.59 ms). EXECUTE with its buffers in a dma-buf system heap mmap stays bit exact (all buffers, only the inputs, only the output). Reported-by: Erik Bourget <erik@ebourget.net> Suggested-by: Erik Bourget <erik@ebourget.net> Suggested-by: Bartosz Nitka <niteria@gmail.com> Signed-off-by: Jeff Queisser <funkzy@users.noreply.github.com>
1c027e7 to
35b9d3b
Compare
|
Updated in
Arm64 KUnit on
Items 2–4 (the Assisted-by: LLM (Gemini:Neon) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal §1–§6 pre-PR checklist re-review at verified live head 35b9d3b40af538b0a912a2d2851a125149920806 (MERGEABLE / CLEAN, CI 1/1 green: Host tests / host-tests).
Resolved Since 1c027e781aaa
- Prior Blocker #1 (
ane_h16_user_unpinnable()/ bounce validation) — FIXED:drivers/accel/ane/ane_h16_accel.c:77-100now walks the entire[ptr, ptr + size)range with no gaps (!vma || vma->vm_start > addr), requiresVM_WRITEwhenwriteis set (VM_READotherwise) on every VMA in the range, and returnstrueonly when the entire range is validly mapped and at least one VMA carriesVM_PFNMAP | VM_IO.ane_h16_accel_user_bounce_testcovers both a read-onlyVM_IOoutput and aVM_IO+ unmapped-hole range, and arm64 KUnit at35b9d3b40af5passes 302/303 ANE cases (0 fail, 1 skip) includingane-h16-accel4/4,ane-h16-tasks11/11,ane-h16-program61/61.
Checklist Summary
- §1 No model gating: Pass (program-format/ioctl-driven, no chip gates).
- §2 Production-ready, no hacks: Code in commit 3 is clean; compatibility corpus questions remain open (Blocker 1).
- §3 Safety: Strong LOAD-time DMA bounding and lock-free user pinning/bouncing; H17 zero-width hazard remains open (Blocker 2).
- §4 Clean-room & attribution: Pass — all 3 commits carry human author/committer (
Jeff Queisser <funkzy@users.noreply.github.com>) and humanSigned-off-by:/Reported-by:/Suggested-by:only, zero AI trailers in commits; PR body disclosure present. - §5 Evidence: Blocked — see Blockers 1–3.
- §6 Naming: Pass.
Remaining Blockers (acknowledged open in 23:57Z comment)
- §2 / §5 — Compatibility corpus & refused H16G programs:
#1882(zin-compiled) and#2748(int8/uint8) programs have still not been run through the DMA or exact-section validators (host or hardware).- 8
mil-hwx-compilerH16G programs (space-to-depth, depth-to-space, attention fixture, 5 L2-resident MobileNet schedules) are refused by the running-image check, and the refused H16G matmuls_mm_256remains undiagnosed (real compiler OOB vs missing stride-unit rule for word0x3cbit 2).
- §3 — H17 zero-width behavior: Omitting common widths (
0x04/0x14) on J775D H17 stalled and quarantined the program (firmware_stage program wedged), whileane_hx_dma_tile()accepts width0as1. Confirm whether width0on H17 can touch past its buffer before stalling (or tighten once H16mm256vs H17 behavior is settled). - §5 — Multi-Mac & exact-head hardware coverage: No hardware run at
35b9d3b40af5yet; still needed before merge: a tree-supported H17/M5 row without out-of-tree DT, and H16 hardware rows (M4 / M4 Pro, e.g., J616s and J713) running MobileNet +#1882/#2748programs bit-exact, refused OOB LOAD,s_mm_256baseline check, and the two-task per-task reset probe with full regression counts.
Assisted-by: LLM (Gemini 4 Neon)
Problem
Three gaps in the H16/H17 LOAD and EXECUTE paths:
DRM_ANE_H16_EXEC_IN_PLACE, each input is copied from user memory, and each output back, with the node lock held. A page fault there waits for whatever backs the page, and every other client's LOAD, EXECUTE, mmap and close waits behind it, as does the PM notifier's drain at suspend. The fault also takes the mmap lock, whileane_h16_mmap()takes the file and node locks under it.Why this shape
ane_h16_operation_validate()already builds the table of what each slot binds. The DMA check takes its buffer sizes from that table, so no second copy of a size can disagree.Change
accel/ane: keep every H16/H17 DMA base inside the buffer its slot binds: at LOAD, every DMA base must be a relocated record on a slot the operation section binds. The end of the last 64-byte line its transfer touches must stay inside that buffer, using unsigned, overflow-checked arithmetic. A task that enables a DMA writes its base in the same task. Bases are checked per task and against a running image carried across tasks. DMA registers the check does not model stay refused, and fields it decodes stay within what the compiler writes. Refusals are ENOEXEC, before anything is mapped.accel/ane: send H16/H17 LOAD only the section bytes the validator checked: the procedure and text-properties sections must equal the form derived from the validated program, and the reserved bytes of the generic and operation sections must be zero.accel/ane: h16: copy EXECUTE buffers without user faults under the node lock: user pages are pinned before any lock, checked against the loaded program before and again under the file lock, copied under the node lock throughkmap_local_page(), and unpinned after both locks are dropped. Buffers in VM_PFNMAP or VM_IO mappings are bounced outside both locks. The comment onane_h16_export_put()now gives the lock order that must not happen and what its work item still avoids.The extent rules of the DMA check
__bsssize;No register documentation is available. The extent rules are read from the encoder of aurora-silicon/mil-hwx-compiler and checked against programs whose bound lands exactly on their buffer.
Testing
J775D (M5 Ultra, die 0, 27.2 firmware), read-only one-shot boots on the default command line and the published default Aura. Kit
anechk6is this PR on integration/aurora e892113 plus #2293, which describes the T6050 Neural Engine, and e9754164afe3, which enables the die 0 Neural Engine on the J775D. That commit is ours and not posted yet. These are the only additions the row needs. Kitanechk6bis the same base without this PR. Both kits add the ANE KUnit suites as modules.anechk6b(base)anechk6(this PR)ALARM has no SELinux, so there is no AVC count. In the main row, each arm logged one quarantine line and one DART fault line, the same on both, none of them during the LOAD-refusal or page-fault tests; the separate two-task probe windows below are counted there. Neither arm logged an SError.
Lock order: kit
anechkld5is extra evidence, the previous revision of this PR (head ca3e2c851fcc) on integration/aurora da67077 with the same needs, built with CONFIG_PROVE_LOCKING and run with the GPU module blacklisted (modprobe.blacklist=aurora), which trips lockdep at boot on its own. It differs from this head only in how the bounce copy is split out ofane_h16_user_get()and in that function's KUnit case. Over three rounds of EXECUTE followed by mmap() of a surface on one file, it reports nothing, and lockdep stays on. The first revision's base kit reportedpossible circular locking dependencythere (&f->lockfromane_h16_mmap()under the mmap lock, against__might_fault()inane_h16_exec_ioctl()).Host check over 224 H16G and H17 programs built with aurora-silicon/mil-hwx-compiler (its fixtures and examples, a mobilenet in every schedule it accepts, and the two KUnit fixtures):
h16-sections.pybuilds the procedure and text-properties sections byte-for-byte equal to the kernel's form.Per-task register reset probe on J775D H17 (windows
anerow5onanechk6andanerow6onanechk6b, two-task variants of[1,128,16,16]fp16 add where task 0 zeroesoutput0with full registers and task 1 omits one register):[1.0..16.0]bit-exact, 0 DART faults.0x5110(anechk6): rows 0..15 =[16.0, 0.0, ..., 0.0](resets to 0; 0 faults, 0 timeouts).0x4d18(anechk6): rows 0..15 =[1.0, 1.0, ..., 1.0](resets to 0; 0 faults, 0 timeouts).0x04/0x14(anechk6): EXECUTE timed out and the firmware quarantined the program (firmware_stage program wedged, quarantine count 1), with 0 DART faults (widths do not carry).0x5108(anechk6b):output0stayed0.0with IOMMU write faults from IOVA0x0(resets to 0).0x4d10(anechk6b): inconclusive.output0stayed0.0, which carrying task 0's zero input base also predicts, and the DART fault log was rate-limited after the 10 lines from0x5108immediately before it.The running image stays enabled on every chip: on H17 it refuses nothing, and it is what bounds the coefficient DMA (and any unproven input-base carry).
Still to run
Assisted-by: LLM (Claude:Opus 5.5), LLM (Gemini:Neon)