Repository navigation
s2r_dcp_pkt: T6050 DCP DART sids, whole-packet copies (debug only) - #560
Conversation
AURA_S2R_DCP_PKT copies 128 input and 56 output bytes per packet, too few for the swap and EDR calls (the swap record runs past 0x6e0). Add host knobs: AURA_S2R_DCP_PKT_MAX (head bytes per packet), AURA_S2R_DCP_PKT_FULL (up to 4 tags copied whole, input and output), AURA_S2R_DCP_PKT_FULLMAX (bytes each way for those, default 4096) and AURA_S2R_DCP_PKT_EVERY (one in N of each such tag, so a 120 Hz swap does not fill the ring). Defaults keep the old behaviour. tools/auractl/dcp_pkt_decode.py turns the CPKT records of an auractl dump into one line per packet plus per-packet .bin files.
T6050's DCP DARTs have sid-count 32 and the DCP's stream is sid 23
(K114s ADT dart-dcp: sid = 23, pt-region-23). The walk only tried
sids 0-15, so every shared-memory lookup failed ('dcp-pkt dva ...
not found (walkable sids 0x0)' in every K114s guest session) and no
packet was ever copied there. Read sid-count (up to 32) and sid from
the DART node; walk the DCP's own sid first. Others keep 16.
On J473 (T8112) every IOMFB shared-memory lookup failed: 'dcp-pkt dva 0x80003c000 not found (walkable sids 0x20)'. dart-dcp's vm-base there is 0x800000000 and the DVA already fits the walk's 36-bit IOVA, but the vm-base was subtracted and 0x3c000 walked. Subtract it only for a DVA past the walk's width (T6050 0x100000xx000, J613 0x1000003c000).
K114s (T6050) guest 11-29: sids 23 and 24 walk, yet no IOMFB DVA (0x1000004c000, ...) is found. Print each walkable sid's mapped page count and IOVA range against the IOVA looked for, so the next session shows where the shared memory really sits.
K114s (T6050) guest dh2: sid 23's top table holds a single entry at index 16 and the two-level walk read it as IOVA 0x20000000; the shared memory is at DVA 0x1000007c000, whose bits 46:36 are 16. So T6050's dart-dcp (vm-size 3 TB) is a three-level table: 64 GiB top entries, then 32 MiB and 16 KiB. For a DVA at or past 2^36 look each page up through the three levels first, the DCP's own sid first; the two-level walk stays for everything else.
|
K114s (M5 Pro) row, macOS 27.2.1 guest under the HV, lab branch lab/dcp-hvtrace 32635c2 (= this PR's 5 commits on #543), chainloaded over the enrolled HV Stage 1:
|
|
J473 (M2 mini, T8112) row, macOS 27.2 guest under the HV, lab branch lab/dcp-hvtrace-j473 d330270 (this PR's 5 commits + debug AFK tracer): commit 3 resolves the IOMFB shared memory, |
There was a problem hiding this comment.
Verdict: FINISH, then merge at fcec3c9e
Blockers:
- Stage 1 size / link failures (
gcc,fedora,nixallFAILURE):src/s2r_dcp_pkt.ois linked into Stage 1 builds (Makefile:310). The new lookup, whole-packet copy, and diagnostic formatting pushstage1.textheadroom below the4096 Bguard across all three toolchains (gcc:3664 B,fedora:4008 B,nix:3152 B) and breakstage1-dev-auditlinking (ld.lld: error: Code and data reach the DCP log buffer after stage 1!). Keep this debug-only tracer out ofstage1/RELEASEbuilds (or trim/gate it) soStage 1 roompasses ongcc,fedora, andnix. - Unsafe 3-level table walk on 2-level DARTs (
src/s2r_dcp_pkt.c:114-181):s2r_dcp_resolve()runss2r_dcp_lookup3()before the 2-level walk for anyd->lo >= BIT(36)without checkingDART_T8110_TCR_OFF + 4 * sid(translate enabled, not bypassed, multi-level) or checking that table addresses stay within DRAM (ram .. ram + mem_size_actual). On a 2-level DART whose DVA sits aboveBIT(36)(such as J613's0x1000003c000, cited in the comment right above),s2r_dcp_lookup3()treats L1 as L0, indexes L1[16], treats an L2 leaf PTE as a table pointer, and dereferences an arbitrary DCP buffer page as L2 PTEs — returning bogusd->pa[]pages and skipping the 2-level walk if bit 0 happens to be set. Gates2r_dcp_lookup3()on the stream's TCR (TRANSLATE_ENABLE,!BYPASS_DART,!REMAP_EN) and a real 3-level indicator (or run the validated 2-level walk first whend->have_vm_basefits within 36 bits), and bounds-check intermediate table PAs against DRAM.
Checked:
- Audited all 5 touched files (
src/s2r_dcp_pkt.c,src/s2r_dcp_pkt.h,proxyclient/tools/run_guest_sptm.py,tools/auractl/dcp_pkt_decode.py,tests/python/test_dcp_pkt_decode.py) and CI failure logs (gcc,fedora,nix). - Verified the whole-packet copy logic (
S2R_PKT_FULLbit 63 inopen[],s2r_dcp_full()tag/every throttling, 24-bit word capw < BIT(24),o + 8 <= S2R_DCP_RPCbounds), ADTsid-count/sidparsing (bounded to1..32), andtools/auractl/dcp_pkt_decode.py+tests/python/test_dcp_pkt_decode.pyround-trip decoding are otherwise clean (Pytestsuites andformat-checkpass). - Verified both K114s (
T6050) and J473 (T8112) guest capture rows posted in PR comments.
Evidence
- CI
gcc(141060551611):gcc stage1: headroom 3664 B is below 4096 B,gcc stage1-dev-audit: does not link. - CI
fedora(141060551864):fedora stage1: headroom 4008 B is below 4096 B,fedora stage1-dev-audit: ld.lld: error: Code and data reach the DCP log buffer after stage 1!. - CI
nix(141060551840):nix stage1: headroom 3152 B is below 4096 B,nix stage1-dev-audit: ld.lld: error: Code and data reach the DCP log buffer after stage 1!. src/s2r_dcp_pkt.c:114-139:s2r_dcp_lookup3()readsTTBR(0x1400 + 4 * sid) directly without checkingDART_T8110_TCR_OFF(0x1000 + 4 * sid) or DRAM bounds onl0/ intermediatet, and is called ahead ofdart_walk_locked_t8110()for everyd->lo >= BIT(36).- Non-blocking nit: once the blockers above are fixed, updating the PR description to drop the stale "Draft until rows show..." line and summarize both K114s and J473 rows at the new head will keep the top summary in sync.
Review on #560: - The three-level lookup ran before the validated two-level walk for any DVA past 2^36, without the stream's TCR check or table bounds: on a two-level DART with such a DVA (J613) it could read a buffer page as PTEs. Now it runs only after the two-level walk found nothing, only for a translating stream (TCR translate on, no bypass, no remap, TTBR valid), and every table and the final page must lie in DRAM. - Everything in this debug-only file is AURA_XTEXT (.rodata.xtext), so it no longer counts against Stage 1 text: gcc 14 RELEASE stage1 room text is 13120 B on both main 99b6dd1 and this branch.
|
Review fixes in 1615ca4 (normal push):
|
There was a problem hiding this comment.
Verdict: MERGE at 1615ca4d
Blockers: None (wait for queued CI jobs to finish; pre-existing stage1-dev-audit DCP log buffer headroom on main is tracked separately, and this branch now adds 0 B to Stage 1 .text).
Checked:
- Audited commit
1615ca4d(src/s2r_dcp_pkt.c): both blockers fromfcec3c9eare cleanly resolved. - Verified every function in
src/s2r_dcp_pkt.cnow carriesAURA_XTEXT(.rodata.xtext), adding0 Bto Stage 1.text(13120 Broom text on bothmain 99b6dd13and1615ca4dundertools/stage1_size.sh gcc). - Verified
s2r_dcp_lookup3()now runs only after the validated 2-leveldart_walk_locked_t8110()walk finds nothing, checksDART_T8110_TCR_OFF + 4 * sid(TRANSLATE_ENABLE,!BYPASS_DART,!REMAP_EN) plusTTBRvalid before walking, and bounds-checks every intermediate table and the final leaf page againstram .. ram + mem_size_actual - 0x4000. - Verified updated PR description (stale draft line removed, both K114s
T6050and J473T8112capture rows summarized) and previously auditeddcp_pkt_decode.py+test_dcp_pkt_decode.py+run_guest_sptm.py.
Evidence
src/s2r_dcp_pkt.c:96-123:s2r_dcp_lookup3()guardsd->dart_size < 0x1400 + 4 * ((u64)sid + 1), readstcr(+0x1000 + 4 * sid) andttbr(+0x1400 + 4 * sid), rejects non-translating/bypass/remap streams, and checkst >= ram && t <= ram_end - 0x4000before everysptm_virt_peek64()and before storingd->pa[i].src/s2r_dcp_pkt.c:178-192: 3-level fallback is placed strictly after the 2-leveldart_walk_locked_t8110()loop, so 2-level DARTs withd->lo >= BIT(36)(e.g. J613) resolve via the 2-level walk without enterings2r_dcp_lookup3().
|
Merge readiness at
Areas: none matched in CODEOWNERS Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
CI at 1615ca4: everything passes except the three Stage 1 room jobs (gcc 3664 B, fedora 4008 B, nix 3152 B, plus |
Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
|
Merging at |
|
code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at |
Debug-only SPTM-virt trace (AURA_S2R_DCP_PKT). Two fixes, needed to trace macOS's IOMFB calls (ep 0x37) on the K114s (M5 Pro) for display parity (VRR, HDR/EDR, colour, brightness).
dcp-pkt dva 0x100000xx000 not found (walkable sids 0x0). The DART walk tried sids 0-15, but T6050'sdart-dcphassid-count = 32and the DCP's stream issid = 23(pt-region-23). The walk now uses the DART node'ssid-count(up to 32) and tries its ownsidfirst. Other SoCs still walk 16 sids.AURA_S2R_DCP_PKT_MAX: input bytes per packet (default 128)AURA_S2R_DCP_PKT_FULL=A407,A408: up to 4 tags whose input and output are copied wholeAURA_S2R_DCP_PKT_FULLMAX: bytes each way for those (default 4096)AURA_S2R_DCP_PKT_EVERY: copy only one in N of each such tag, so a 120 Hz swap doesn't fill the 8 MiB ringtools/auractl/dcp_pkt_decode.pydecodes the CPKT records of anauractl readdump: one line per packet (time, auractl mark, DCP, call/callback/output, tag, sizes, hex) plus a per-packet.binandpackets.tsv.tests/python/test_dcp_pkt_decode.pyround-trips a synthetic call and reply.3. J473 (T8112): every lookup missed.
dcp-pkt dva 0x80003c000 not found (walkable sids 0x20):dart-dcp's vm-base is 0x800000000 and that DVA already fits the walk's 36-bit IOVA, but the vm-base was subtracted, so 0x3c000 was walked. The vm-base is now subtracted only for a DVA past the walk's width (T60500x100000xx000, J6130x1000003c000).Rows: K114s (T6050) macOS 27.2.1 guest:
sid 23, 3-level, 48 of 49 pages, thousands of packets decoded. J473 (T8112) macOS 27.2 guest:sid 5, 48 of 49 pages, packets decoded. Both are in the PR comments.Tested: K114s (T6050) macOS 27.2.1 guest under aura: sid 23, 3-level walk, 48 of 49 pages, thousands of IOMFB packets decoded. J473 (T8112) macOS 27.2 guest: sid 5, 48 of 49 pages, packets decoded.
tests/python/test_dcp_pkt_decode.pypasses. Rows were run on lab branches carrying this PR's first 5 commits; 1615ca4 only moves the code to.rodata.xtextand guards the third level, and the later merge of main adds main's commits.Risk: two-way · debug-only.
s2r_dcp_pkt.ois built only in SPTM_VIRT=1 images, its functions are AURA_XTEXT (out of Stage 1 text), and the packet copies only run when the host sets the AURA_S2R_DCP_PKT knobs. Default images are unchanged on every Mac.