Post-merge review (COMMENT only): DMA/SMMU confinement after a failed abort
I read the full non-.crumb diff and checked dev/xhci_fence.c and core/smmu_svc.c at merge commit 2b77170d.
Verdict: this PR does not weaken any capability or DMA boundary. It makes release fail closed. If ck_dma_unconfine fails, the stream stays confined and the device stays owned (dev/devices.c ck_dev_nvme_release, dev/net_bind.c ck_net_release, dev/xhci_fence.c ck_xhci_release), and every later fence or bind refuses with CK_NET_E_SMMU or CK_XHCI_E_RELEASE. The SMMU state stays consistent too: core/smmu_svc.c:341-351 frees the STE slot (in->used[slot] = 0) only after ck_smmu_abort_ste succeeds. There is one follow-up on error reporting.
Findings
- The xHCI release failure is reported as success. This is the follow-up I'd fix. In
dev/xhci_fence.c:438-445, when the PCI xHCI has no keyboard,ck_xhci_fencecallsplat_fence_all(). If that returnsCK_XHCI_E_RELEASE, the code still overwritesx->state = "fenced"(L443) and returnshrc ? CK_XHCI_E_HALT : CK_XHCI_OK(L445). The new"release-failed"state set at L328-331 is lost, and the caller sees OK while a platform stream is still confined andck_xhci_live()is 1.- The DMA boundary still holds, because the stream stays confined and the next
ck_xhci_fencerefuses at L431-434. - Suggested fix: right after L441, add
if (prc == CK_XHCI_E_RELEASE) return prc;, which keeps"release-failed".
- The DMA boundary still holds, because the stream stays confined and the next
- Only part of the new behavior has a test.
svc/tests/stage_test.ccase 6b covers only the NVMe refused-abort path and its retry. The sameck_host_unconfine_failmock could also cover:ck_net_releasewithconfinedkept, followed byck_net_bindreturningCK_NET_E_SMMU;ck_xhci_release, thenplat_fence_allandck_xhci_fencereturningCK_XHCI_E_RELEASE, including the state check from item 1.
- A stuck stream is only retried by the next release. Nothing retries the abort on its own. That is acceptable because it fails closed. However, the device keeps a live translation onto its own DMA window. Please confirm that the backing buffers (
g_dma_memfor xHCI and the NVMe/net DMA pools) are never freed or reused while the matchingconfinedflag is 1. If they can be, that buffer reuse is the next boundary to close. - Ambiguous holders cannot be unconfined.
core/smmu_svc.c:345-346returnsCK_SMMU_EARGboth when the stream is not confined and when it is confined on two SMMUs. Callers now treat any non-zero return as "still confined", so a stream reported as ambiguous can never be released. That is fail-closed, so it's fine. A distinct code for "confined on two SMMUs" would make the console message clearer. - Housekeeping.
- The PR title still says "(draft, pending)", but the PR was merged.
- The probe never calls
ck_dma_faults, so SMMU fault events from a stream that could not be aborted are never drained or logged. The updatedB7B-PHYSICAL-BOOT-PREP.mdalready says this. Draining them once on the release-failed path would give evidence of what the device was doing.
No revert is needed.
— Grokbot