Repository navigation
drm/asahi: m5, g18: clear retained storage between VMs, fail a refused job alone - #2949
Conversation
The M5 backend has one render pair and one compute queue for all clients. When a submission comes from a VM other than the current owner, rebind_vm() maps the retained USC pool, parameter buffer and compute storage into the new VM at the same addresses. Their contents were left as the previous VM's work wrote them. Zero the data storage before another VM maps it: the USC blocks, the parameter-buffer blocks, scene scratch and discard page, and the compute operand, preemption and robustness storage. rebind_vm() only runs once the pair has fully retired, and submissions are synchronous, so no work still uses the memory. Construction leaves the same storage zeroed. The USC directory and free list, the page list and the metrics are allocator and parameter-manager state that the retained firmware records and cursors refer to. They are kept unchanged. A same-VM resubmission does not clear anything. Add a host test that runs the production hand-over against mocks and checks every data object is zero when the next VM maps it, with the previous code and each clear removed as mutants. Signed-off-by: Ryan Murray <[email protected]>
…hanges VM The single application render job and the application compute job are handed from one client VM to the next by re-aliasing their objects at the same addresses. Only the render targets were cleared, so PB blocks (including grown ones), the scene scratch, the discard page and the USC scratch blocks of the render and compute pools still held what the previous VM's work left there. Once the job has retired and the previous VM's views are dropped, clear that storage before another VM maps it. Allocator structures, the PB block table, page list and ring cursors, and the pool directory, block list and descriptor are kept as they are: they hold only the owners' addresses and their cursors are owned by the PM/USC. A replacement compute pool that retains the old scratch objects inherits the last VM. The same VM again clears nothing. The job context only reads the command graph (the RCE register lists), so map the client view read-only, as g17 maps M5 command storage. Add a host test that runs the production paths against a model of the mappings, with mutants including the previous code. Signed-off-by: Ryan Murray <[email protected]>
Every error a submission met after admission ended the firmware session: an address the client unmapped after admission, its VM closed, or a render target allocation it sized made submit_application() return Failure::Fatal, and no client could submit again until reboot. ApplicationJob::prepare() now commits the frame (guard, generation, retired) only after its last fallible step, so an error leaves the job retired and the next prepare() rebuilds what this one changed; the first frame's kernel alias is made once. Nothing of a render reaches the firmware before prepare() returns. A prepare error that leaves the job unpublished is a new JobFailure::Refused: the submitter gets its errno, the session and the path keep serving and the client's VM is not poisoned. The compute path does the same when the failed preparation left its owner retired with no process, command or context published. Anything else, and any error on a crashed firmware, stays fatal. Also correct the documented defaults of the g18_admit_* parameters, which are 1. Add a host test that drives the production prepare and outcome paths against the hand-over model, with the previous code as a mutant. Signed-off-by: Ryan Murray <[email protected]>
There was a problem hiding this comment.
Formal §1–§6 pre-PR checklist review at 0a4f6d6576a39c4879259de5efc295d064793555.
Checklist Summary
- §1 No model gating: Pass — zero chip, SoC, board, or firmware-version gates; applies cleanly across the M5 and G18 VM hand-over paths.
- §2 Production-ready: Pass — no new parameters, hacks, sleeps, or lab-only paths; fixes stale doc comments on
g18_admit_*defaults (which are already1). - §3 Safety & security: Pass — thorough, clean isolation and error-handling fixes:
- M5 (
rebind_vm,M5GraphicsUsc::alias_into,M5ParameterBuffer::alias_into): verifies full retirement (scheduler_status == [2, 0]and stamps matchgeneration * 0x100), drops priorvm_aliasesand retracts old context roots before clearing all 25 retained data objects (19 USC blocks, 3 PB blocks,scene_scratch,discard,compute_storage), orders withfence(Ordering::SeqCst), and keeps allocator/PM state (directory,freelist,page_list,metrics). Same-VM resubmission clears nothing; handing back to the original owner VM still clears before reusing its own mappings. - G18 hand-over clear: verifies
self.retired, retractsprogramtoself.storage, dropsuser_aliasesandpool_aliases, clears all PB blocks (grown blocks included),scene_scratch, anddiscardon VM change, and maps the client command-graph view (va::GRAPHICS_JOB_LOW) read-only (PROT_GPU_SHARED_RO) so client GPU shaders cannot modify audited command buffers. Render and compute UMA pools trackclient_vm: Option<u64>, zero scratch blocks on VM change (propagatingclient_vmacrossreplacement_shared_compute), and build aliases into a localKVecinsidealias_into_process()so mid-aliasing failures do not poisonself.process_aliases. - G18
JobFailure::Refused:ApplicationJob::prepare()defers committingguard,generation,retired, andclient_framesuntil afterencode_application(), guards the first-frame kernel-lowergraphalias withself.job.aliases.is_empty(), encodesJobOutcome::Refusedas0x1000 - error.to_errno()(0x1001..0x1fff, cleanly disjoint from0,TICKET_RUNNING = 1,Recovered = 2,Stranded = 3, and negative fatal errnos), returns the submitter's errno without poisoning the client's VM, and keeps crashed firmware / post-publication / armed-compute errors fatal (application_compute_unpublished()also checksself.scheduler.binding(0).is_err()whenapplication_computeisNone).
- M5 (
- §4 Clean-room & attribution: Pass — all 3 commits carry human author/committer (
Ryan Murray <[email protected]>) and humanSigned-off-by:only, zero AI trailers in commits; PR body includesAssisted-by:; clean-room. - §5 Evidence & CI: Code + CI sound; hardware owner rows owed before merge.
host-testsCI is green, including all 3 new production-extracting host harnesses (m5-client-handoff-tests.py,g18-client-handoff-tests.py,g18-job-error-tests.py) with mutation suites killing every mutant including pre-fix basec5e25e0925351. Kernel build (drivers/gpu/drm/asahi/, fleet81 config) clean.- Because the author's lab lacks T8142 and T8152, hardware rows must come from T8142 and T8152 owners (M1–M4 stand-ins do not exercise the
m5/g18backends) and are genuinely needed before merge — in particular on T8152 to confirm hardware RCE executes cleanly withva::GRAPHICS_JOB_LOWmappedPROT_GPU_SHARED_ROand recovers cleanly from post-admission refusals, and on T8142 to confirm multi-MiB WC clears on VM hand-over retire without faults:- T8142 (M5) owner row: two clients alternating render and compute + regression tuple (
0 SELinux denials, 0 failed units, 0 new kernel errors). - T8152 (G18) owner row: two clients alternating render and compute (exercising
PROT_GPU_SHARED_RO+ hand-over clears) and one client triggering a post-admission refusal while another client keeps rendering without session death + regression tuple.
- T8142 (M5) owner row: two clients alternating render and compute + regression tuple (
- §6 Naming: Pass.
Non-blocking Audit Notes
- In
ApplicationJob::prepare()(drivers/gpu/drm/asahi/g18/runtime/graphics_job_application.rs:88-154), if a new client fails atvm.translate_iova()(line 153) afterremapandself.job.program.rebind_retired(vm)?(line 133),programanduser_aliasesstay bound to the refused VM withpool_aliasesempty andretired == true/guard == None. That matches the existing idle-retired state and the next submission either fillspool_aliases(same VM) or remaps cleanly (another VM), so it is safe; validatingvm.translate_iova()beforeremapwould just avoid unnecessary PB clear + remap work on a bad-address refusal. - In
G18UmaPoolMemory::clear_scratch_for(), updatingself.client_vm = Some(vm.id())beforealias_into_process()is safe on aliasing failure because scratch has already been zeroed (cannot leak data; at worst triggers one extra harmless clear on a later VM).
Verdict
COMMENT — 0 code/CI/policy blockers; code and mutation-tested host harnesses are solid. Holding APPROVE and merge until the T8142 (M5) and T8152 (G18) owner §5 hardware rows are posted.
There was a problem hiding this comment.
Formal §1–§6 pre-PR review on live head 0a4f6d6576a39c4879259de5efc295d064793555 (against live integration/aurora 70a00e583b03, not superseded; live CI host-tests green).
Checklist Summary
- §1 No model gating: Pass — no chip, SoC, board, or firmware-version gates.
- §2 Production-ready: Pass — no new parameters, hacks, sleeps, or lab-only code paths; corrects stale
g18_admit_*doc defaults to1. - §3 Safety & correctness: Pass — M5 (
rebind_vm) verifies full retirement and drops priorvm_aliasesbefore zeroing all 25 retained data objects withfence(Ordering::SeqCst)while preserving allocator/PM metadata; G18 drops prior aliases and clears PB blocks (including grown ones),scene_scratch,discard, and render/compute UMA pool scratch on VM change (carryingclient_vmacrossreplacement_shared_compute), maps clientva::GRAPHICS_JOB_LOWread-only (PROT_GPU_SHARED_RO), and defersApplicationJob::prepare()frame commit past all fallible steps so unpublished refusals fail only that job (JobFailure::Refused) without poisoning the client VM or ending the session. - §4 Clean-room & attribution: Pass — all 3 commits carry human author/committer (
Ryan Murray <[email protected]>) and humanSigned-off-by:only, zero AI commit trailers. - §5 Evidence (BLOCKER): Code and mutation-tested host harnesses (
m5-client-handoff-tests.py,g18-client-handoff-tests.py,g18-job-error-tests.py) are solid and live CIhost-testsis green, but hardware verification on the affected SoCs is still owed before merge:- T8142 (
m5backend) owner row at this head (default cmdline): two clients alternating render and compute across VM hand-overs without faults, plus regression tuple (0 SELinux denials, 0 failed units, 0 new kernel errors) and kernel build ID. - T8152 (
g18backend) owner row at this head (default cmdline): two clients alternating render and compute (confirming real RCE execution withva::GRAPHICS_JOB_LOWmappedPROT_GPU_SHARED_ROand hand-over clears) plus one client triggering a post-admission refusal while another keeps rendering without session death, plus regression tuple (0 SELinux denials, 0 failed units, 0 new kernel errors) and kernel build ID.
- T8142 (
- §6 Naming & CI: Pass — live
host-testsgreen on0a4f6d6576a39c4879259de5efc295d064793555.
Verdict
REQUEST_CHANGES — 0 code/CI/attribution blockers; holding approval solely for the T8142 (M5) and T8152 (G18) owner §5 hardware and regression rows.
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at 0a4f6d6576a3: the code is ready; it needs only a row at this head.
Blockers: none in the code. Missing row: the paths only run on T8142 (M5, rebind_vm) and T8152 (G18). Needed: one M5 run at this head with two clients switching VMs and the retained objects cleared, and a refused job failing alone. We'll run it on our J714s. These paths are shared by M5 and M6, so one T8152 run at this head is also needed before it merges.
Checked: no Apple material, no gates. All 25 retained objects are cleared after full retirement on a VM change, and the host harnesses are mutation-tested. CI green.
Superseded by the review at 0a4f6d6
|
0a4f6d6 J616s (T6040, M4 Pro) PASS: guarded one-shot combined batch (0aa9d658ff34 over main bc9b4c0, 0 merge-tree diffs on 17 changed files, default cmdline, stock Stage 2 1.0.0b17, boot 2546a528-6d7f-434e-b679-90a87d626c2e): 0 failed units, Enforcing, 0 new AVC, 0 GPU faults, 0 new kernel/subsystem errors, eDP connected pre/post, sep+mtp RTKit v12 clean, Borealis VK api.smoke 8/8 pre/post + glsl.loops 624/624, Wi-Fi 3/3 ping pre/post, 2/2 rtc1 s2idle; stock 7.3.0-aurora-fleet89 restored. |
|
PASS on a 14-inch MacBook Pro (J714s, M5 Pro/T6050, G17S B1), kernel Candidate The merged heads were #2906 Vulkan CTS returned identical per-case results on the baseline and candidate. The command line matched the default. SELinux was disabled. |
Problem
The M5 and G18 backends hand one render job (and one compute job) from one client VM to the next by mapping the same retained objects into the new VM. Two things were wrong with that hand-over:
Change
rebind_vm()before another VM maps it. Allocator and parameter-manager state the firmware records refer to (USC directory, free list, page list, metrics) is kept. The same VM resubmitting clears nothing.ApplicationJob::prepare()commits the frame only after its last fallible step. A preparation error that leaves the job unpublished is a newJobFailure::Refused: the submitter gets its errno, and the session and the other clients keep working. Errors after publication, or on a crashed firmware, stay fatal. The documented defaults of theg18_admit_*parameters are corrected to 1.No new parameters, gates or tables. The same-VM path is unchanged.
Testing
m5-client-handoff-tests.py,g18-client-handoff-tests.pyandg18-job-error-tests.pydrive the production hand-over and outcome paths against models of the mappings. Each runs with the previous code and each clear removed as mutants, and every mutant is caught. At this head: 2/2, 2/2 and 2/2 (run-host-tests.py --only).drivers/gpu/drm/asahi/builds at this head (fleet81 release config, all backends) with no new warnings.Still to run
Commits