Skip to content

third_party: carry the #812 imported-dma-buf pair (compile-proven, owner-gated, NOT installed) - #1134

Merged
bong-water-water-bong merged 3 commits into
mainfrom
1bit/amdxdna-812-carry
Nov 5, 2026
Merged

bong-water-water-bong merged 3 commits into
mainfrom
1bit/amdxdna-812-carry

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Patches only — no code in the engine tree, nothing installed anywhere.

Why: #812's two commits (~/wt/xdna812/src, ab885d8f + 412fdbc4, 2026-11-02) existed only in a scratch tree. That is
the durability hole this directory was created to close, and the same one that once shipped a panicking driver. They also no
longer applied — 0001 rewrote the mmap/invalidate region they touch — so the pair is re-expressed on top of the series
rather than copied:

# patch what it does
0006 don't invalidate an imported dma-buf BO at mmap time an imported BO was put on client->bo_invalid_list; its only drain path is hmm_range_fault() over a vma the exporter owns, so the client's next submit returned -EFAULT for every job, including a fresh context's admission. Imported BOs are left alone; amdxdna_mark_mapp_invalid() loses its last caller and goes with it (the driver builds -Werror)
0007 don't re-invalidate imported dma-buf BOs from the mmu notifier the same marking was applied again by amdxdna_hmm_invalidate(), so any real invalidation of the range re-poisoned the client. Skips the marking for imported BOs and keeps the sequence update + MMU_NOTIFY_UNMAP cleanup, which is why it is not simply an early return

Status is deliberately not "carried fix". Loading these is the owner's call (#812), and the runtime proof is the owner's
run; unlike the TDR series this pair has never been loaded (/lib/modules untouched, no modprobe, no parameter
changed). The README rows say so, and a new short section states that no image may pick them up before that word exists.

Verified, by building it: the exported patches apply in order on top of 0001..0005 in a clean pin worktree, the
resulting sources are cmp-identical to the tree the fingerprint came from, and that tree builds to
srcversion 336751493A77C50DE0B50F7 (rc 0, no warnings) — now a row in the README's fingerprint table. The failure the
patch fixes is measured in FACTS-libamdf.md §9 (0x30000000E = EFAULT from kernel_queue_create()), so this PR carries the
fix, not the claim.

Refs #812.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY (two nits, neither blocking)

Verified at 79519af4, by building it rather than reading the claim.

The series applies, 7/7, in numeric order, on a fresh clone of the pin (amd/xdna-driver @ 526c6081974e, nothing local applied):

for p in 000[1-7]-*.patch; git apply --check && git apply   ->  7 applied, 0 rejected
git status --short  -> 11 modified files under drivers/accel/amdxdna, no conflicts

The new fingerprint row reproduces exactly. Built the documented way against this box's headers, 4 jobs under thermal-run:

make -C drivers/accel/amdxdna modules ARCH=x86_64 KERNEL_VER=7.4.0-rc1-1bit \
     MODULE_VER_STR='2.21.0_20261104,526c6081974ea4f0f7dd22329186c5d6adb8fad5' -j4
rc=0   0 occurrences of "warning:" or "error:" in the build log
modinfo -F srcversion drivers/accel/amdxdna/amdxdna.ko  ->  336751493A77C50DE0B50F7

The cmp claim holds independently of the fingerprint: cmp over every drivers/accel/amdxdna/*.c and *.h against the two trees this lane's verification left on the box gives 0 differing files against ~/wt/xdna-series-verify/i812verify and ~/wt/xdna-series-verify/i812b.

The deletion is complete, and -Werror is why it had to be: grep -rn amdxdna_mark_mapp_invalid drivers/ -> 0 hits, and drivers/accel/amdxdna/Kbuild:19 is ccflags-y += -g -Werror, so the warning-free build above is the proof that no caller survives.

"carried, NOT installed" is the true state of this box: /sys/module/amdxdna/srcversion and modinfo -F srcversion /lib/modules/7.4.0-rc1-1bit/updates/amdxdna.ko both read 349FDC99CADC56900E0249A — the kernel lane's 0011v2 build, on disk since 07:19 and loaded — which is a different fingerprint from this pair's, so the running module does not contain it.

And nothing can pick it up by accident, which is the risk the new section exists to guard. Nothing in the tree applies third_party/patches/amdxdna/*.patch by glob (only docs/npu.md, app/npu_device_lock.h and the README reference the directory at all), os/mini/mkimage.sh:270 takes AMDXDNA_KO explicitly, and os/v3/puppy/g3-probe.sh:173 asserts the srcversion it expects. An image carries a built .ko, not a patch, and the probe fails a module it did not build.

Mechanism, read rather than assumed. The -EFAULT is reachable exactly as the message says: amdxdna_client_populate_ranges() walks client->bo_invalid_list, amdxdna_populate_range() returns -EFAULT when mmget_not_zero() or hmm_range_fault() fails over the exporter's vma (amdxdna_gem.c:1658-1698), and aie2_ctx.c:1191 calls the drain before every submit, client-wide — which is why one imported BO poisons every later job including a new context's admission. Imported BOs get their sgt from dma_buf_map_attachment at import time (:1110-1137), not from this list, so nothing that was load-bearing is removed. 0006's hunk sits inside the is_import_bo(abo) branch right after dma_buf_mmap(); 0007 keeps mmu_interval_set_seq() and the MMU_NOTIFY_UNMAP unregister, so it is not an early return.

Two nits:

  1. The ## Building recipe can no longer produce the fingerprint row this PR adds. Its git apply list is still 0001 0002 0004 0005 0003, so a reader who follows the copy-paste path builds the shipping stack, not 0001..0007; the new row's composition exists only in the table. Two more lines there, with # owner-gated, not installed beside them, closes it.
  2. Both patch headers carry a placeholder time: Date: Thu, 5 Nov 2026 13:2x:00 -0400 and 13:2x:30. git apply does not care, but 0003/0004/0005 carry real times and this directory's purpose is that the header is the provenance record.

Not verified by me, and correctly not claimed: the runtime behaviour. The pair has never been loaded and /lib/modules is untouched, so the load and the CTS proof stay the owner's, per #812.

CI at this head: build success, CodeQL + 5 Analyze success, hw_gate skipped, pr_agent queued (not red). MERGEABLE, BEHIND.

pi-hrx-fabric and others added 2 commits November 5, 2026 15:28
…ner-gated, NOT installed)

durability hole this directory was created to close - the same one that shipped a panicking driver
once. They also no longer applied: 0001 rewrote the mmap/invalidate region they touch, so the pair
had to be re-expressed on top of the series rather than copied.

 0006  don't invalidate an imported dma-buf BO at mmap time
 0007  and don't re-invalidate one from the mmu notifier

What they fix: an imported BO was put on client->bo_invalid_list, whose only drain path is
hmm_range_fault() over a vma the exporter owns, so the client's *next* submit returned -EFAULT for
every job - including a fresh context's admission (measured 2026-11-02: import + map succeed, then
kernel_queue_create() fails 0x30000000E and the process stays poisoned).

Status is deliberately not "carried fix": loading these is the owner's call, and the runtime proof is
the owner's run, so the README rows say "carried, NOT installed, owner-gated" and a new section states
that no image may pick them up before that word exists. Unlike the TDR series, this pair has never been
loaded anywhere.

Verified: the exported patches apply in order on top of 0001..0005 in a clean pin worktree, the
resulting sources are byte-identical (cmp) to the tree the number below came from, and that tree builds
to srcversion 336751493A77C50DE0B50F7 (rc 0, no warnings), now in the fingerprint table.
… the placeholder dates

Review of #1134 found two nits, both in the copy-paste path rather than in the
patch content:

* "## Building" listed only `0001 0002 0004 0005 0003`, so the fingerprint row
  this PR adds (`... + 0006 + 0007` -> `336751493A77C50DE0B50F7`) could not be
  reproduced from the recipe. It now has its own block, explicitly the compile
  proof and not an install path.
* both new patch headers carried a placeholder time (`13:2x:00`, `13:2x:30`).

Meta only: the hunks are untouched, so the build is unchanged. Verified rather
than assumed - the result of applying all seven patches in order to a clean
`526c608` checkout is `cmp`-identical to `~/wt/xdna-series-verify/i812{verify,b}`
over all 79 files of `drivers/accel/amdxdna`, i.e. the sources that built to
`336751493A77C50DE0B50F7` (rc 0, no warnings). `copyright.py --check` clean.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY

Re-verdicted at 75d615b0 (rebased onto main a56f0e9, so it is mergeable again after going CONFLICTING with #1127). Both nits are closed and, more usefully, closed without touching the thing that was proven:

  • The placeholders are real times now: git show 75d615b -- third_party/patches/amdxdna/*.patch is exactly two lines, Date: … 13:2x:00 -> 13:23:33 and 13:2x:30 -> 13:23:34. Nothing else in either patch moved.
  • The ## Building block now covers the pair: third_party/patches/amdxdna/README.md:77-83 is a "To reproduce the carried fingerprint row (…+0006+0007 -> 336751493A77C50DE0B50F7)" recipe that runs git apply on 0004, 0005, 0006, 0007 in order, labelled as the compile proof and not an install path.

I re-ran the recipe rather than reading it: on a clean copy of 526c6081, git apply --check + git apply for 0001..0007 in filename order gives 0001-0003 already-applied (that baseline is those three) and 0004, 0005, 0006, 0007 apply clean, in order. Then cmp of every .c/.h under drivers/accel/amdxdna against ~/wt/xdna-series-verify/i812verify - the tree I built at 79519af4 that produced srcversion 336751493A77C50DE0B50F7, rc 0, no warnings - is identical for all of them (diff --brief shows only build outputs: .o, .cmd, Module.symvers, config_kernel.h). So the fingerprint row in the README is reproducible from the copy-paste path and my earlier build result stands unchanged; the Date: header is not a build input.

Still carried, NOT installed, owner-gated, as it was: nothing in this PR writes to /lib/modules, modprobes, or touches a module parameter.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit 3002217)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

812 - Partially compliant

Compliant requirements:

  • The PR patches the amdxdna driver to fix the EFAULT error when executing on imported dma-buf ranges
  • The patches are applied in the correct order (0006 and 0007) on top of the series
  • The PR updates the README to document the carried patches and their status

Non-compliant requirements:

  • The patches are not installed, as per the owner's decision (this is a deliberate choice, not a failure to comply)

Requires further human verification:

  • The runtime proof of the fix needs to be verified by the owner, as the patches are not installed
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incorrect BO invalidation for imported dma-buf

The patch correctly prevents marking imported dma-buf BOs as invalid during mmap time, which was causing client-wide EFAULT errors due to hmm_range_fault() failing on the exporter's vma. This change ensures that imported BOs are not added to client->bo_invalid_list, preventing subsequent submissions from failing.

-		amdxdna_mark_mapp_invalid(abo, vma);
+		/*
+		 * Do not mark the mapping invalid. dma_buf_mmap() established the
+		 * mapping in the exporter's terms and the pages behind it are not
+		 * the shmem pages vm_insert_pages() would install below, so HMM
+		 * cannot refault them. Marking it invalid would put this BO on
+		 * client->bo_invalid_list, where amdxdna_populate_range() fails
+		 * with -EFAULT - and because that list is drained client-wide
+		 * before every submit, one imported BO would fail every later
+		 * submission of the process, not just the ones touching it.
+		 */
Prevent re-invalidation of imported dma-buf BOs

This patch ensures that imported dma-buf BOs are not marked invalid by amdxdna_hmm_invalidate(), which was causing the same client-wide EFAULT issue when the exporter performed real invalidation (e.g., unmap_mapping_range). The patch preserves necessary cleanup operations but skips the invalidation marking for imported BOs.

+	/*
+	 * An imported BO's population and migration belong to its exporter: any real invalidation of that range
+	 * (typically the exporter calling unmap_mapping_range() while it evicts or migrates) would put the BO back on
+	 * client->bo_invalid_list, and the next submit of the process would fail -EFAULT for every job, not just for
+	 * the one touching the range. The sequence update and the unmap cleanup below stay: readers waiting in
+	 * mmu_interval_read_retry() must make progress, and the notifier must be unregistered on unmap.
+	 */
+	if (!is_import_bo(abo)) {
+		if (client && !abo->dying && list_empty(&abo->node))
+			list_add_tail(&abo->node, &client->bo_invalid_list);
+		abo->mem.map_invalid = true;
+		mapp->invalid = true;
+	}

@bong-water-water-bong
bong-water-water-bong merged commit 91e2397 into main Nov 5, 2026
9 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/amdxdna-812-carry branch November 5, 2026 20:28
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit 3002217

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant