Skip to content

tests: cover the CTRR L3 split, SPTM-virt cpu-ids past 31 and the T6050 handoff bounds - #473

Merged
DjDeveloperr merged 1 commit into
mainfrom
test-coverage/aura-ctrr-l3-cpuids-t6050-bounds
Nov 23, 2026
Merged

DjDeveloperr merged 1 commit into
mainfrom
test-coverage/aura-ctrr-l3-cpuids-t6050-bounds

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Three merged changes have no test in the tree, so a later edit can undo them without CI noticing:

#471, #439 and #282 are open and rework the same T6050 checks, so #408's guards are the ones most likely to move soon.

Change

Three host tests, no production code. Each builds the source unchanged and replaces only what it touches (registers, ADT, device tree, tables):

  • tests/python/test_mmu_ctrr_l3.py: the page-table builder of memory.c with ctxr_range(), on host memory with 16K pages. The program prints the finished tables; the tests check which blocks became L3 pages, in every alias of the RAM, and that the registers are read once and only when they can be.
  • tests/python/test_sptm_virt_cpu_ids.py: the S2R trace's /cpus walk, the stop-mode and go-mode core masks, and the DCC cookie and errno, with cpu-ids on both sides of 32.
  • tests/python/test_t6050_handoff_bounds.py: a panel-less board through dt_set_display_handoff() and the panel path's t6050_check_adt(). The edges of each check are explicit cases; the device tree afterwards says whether anything was handed off.

Each file takes another source through an environment variable, which is how the negative controls below were run.

Testing

All local on x86 Linux, with gcc 16 and clang 22, pytest 9.1.1 and requirements.txt:

Still to run

  • The macOS jobs (macos-26, macos-15): there is no Darwin host here, so PR CI is their first run. The harnesses follow the existing ones for macOS (u64 types, the Mach-O section name for .init.t6050).
  • Nothing on hardware: the change is test-only.
What each test checks

test_mmu_ctrr_l3.py (#411), 67 cases

  • Nothing armed: L2 blocks above aura's base, as before.
  • CTRR_C armed as on the J873g: exactly its 32 MiB block is L3 pages, each page onto itself with the block's attributes, one L3 table per split block, and the range is logged once.
  • The split follows the output address: every alias of the RAM is split at the same block, RAM mapped at an unrelated virtual address is split where the range lands, and other memory mapped at the range's own virtual address is not.
  • Range edges: one 4K page at the start or end of a block, a range ending or starting exactly on a block boundary, a range across a boundary, several whole blocks, the first block above the base, the last block of the mapping, ranges below the base or outside the mapping. For CTRR_C and CTRR_D.
  • Not armed or not readable: unlocked Apple system registers and EL1 read no register; LWR 0, UPR below LWR, a wrapping UPR and a register that faults under the guard leave the tables as with nothing armed. A faulting CTRR_C does not hide CTRR_D.
  • The CTXR windows do not split. The ranges are read on the first L2 mapping only. A remap keeps the split and its table. An unmapping reads nothing and leaves no L3 table. The firmware RO split and the CTRR split work together. With the MMU on nothing is read.
  • 24 seeded layouts (ranges, bases, aliases, remaps, unmappings) are compared leaf by leaf with a model of the rule, and no L2 block's output holds a byte of an armed range.

test_sptm_virt_cpu_ids.py (#407), 23 cases

  • s2r_trace_cpus() takes 30 cores whose cpu-ids reach 34, and any single cpu-id from 0 to 63; it refuses 64 and above, a repeated cpu-id on either side of 32, a core with no cpu-id and a tree with no core.
  • Stop mode, cpu-ids 0, 5, 31, 32, 33, 34, 63: each core arms the WFI trap once, a core that never slept is not armed, an idle WFI is stepped over, the deep-sleep WFI parks every core but the committing one, and the final message prints the whole 64-bit mask.
  • Go mode: the first core opens the sleep window, each core's last WFI is counted, and the PMU scratch crumb still records cores 0 to 15 in its two bytes.
  • DCC: a core's cookie authorises that core's next doorbell only, for cpu-ids 0, 1, 30 to 34, 62, 63 in every pair; each core reads back its own errno; a cpu-id past the table shares the last slot.

test_t6050_handoff_bounds.py (#408), 98 cases

  • Framebuffer, panel-less and panel path: all of /vram, its first page, last page, last byte and an inside range are taken; a start at the end of /vram or past it (any size, up to the top of the address space), a start below it, and an end past it are refused. Also with /vram ending at the top of the address space.
  • Bandwidth scratch, panel-less path: offsets 0, inside and size - 4 are taken; size - 3 and above are refused; a block of 4 bytes takes offset 0 only; blocks of 0 to 3 bytes take nothing, for any offset; a device tree PMC node of another size than the ADT's block is refused.
  • A refusal leaves every node disabled, /chosen says refused, and no framebuffer reservation is added. A handoff enables the engine, its mailbox, both DARTs, the PMC node and the subsystem, and reserves /vram.
  • 216 seeded framebuffer and scratch cases are compared with the rule written in whole numbers.
Negative controls

A changed copy is "killed" when the test file fails against it. Every row was run with gcc and clang, with the same result.

test changed copies killed survive
test_mmu_ctrr_l3.py 37: memory.c from before #411, and 36 one-edit mutants of mmu_holds_ctrr(), mmu_ctrr_ranges() and the split in mmu_map() 36 1, equivalent
test_sptm_virt_cpu_ids.py 47: the three files from before #407 (together, and one at a time), and 43 one-edit mutants (masks back to u32, BIT(cpu & 31), 32 slots, clamps, limits) 47 0
test_t6050_handoff_bounds.py 21: #408's three guards taken out, and 20 one-edit mutants (each guard dropped, off by one, or written so that it wraps) 21 0

The equivalent one drops split_ctrr && in front of mmu_holds_ctrr() in the loop. There, split_ctrr false means split_ro is true, so the target is valid and mmu_ctrr_ranges() already ran and found nothing: mmu_holds_ctrr() is false either way.

Assisted-by: LLM (Claude:Opus 5.5), LLM (Claude:Fable 5.2)

…50 handoff bounds

Three merged changes had no test in the tree. Each gets a host test
that builds the code unchanged, with the registers, the ADT and the
device tree as stand-ins:

- test_mmu_ctrr_l3.py (#411): the page-table builder of memory.c and
  ctxr_range() run on host memory with 16K pages. An L2 block whose
  output range holds an armed CTRR_C or CTRR_D is built from L3 pages,
  in every alias of the RAM, and no other block is. The ranges are read
  once, and not at all with unlocked Apple system registers, off EL2 or
  for an unmapping; a register that faults under the guard changes
  nothing. Seeded layouts are compared with a model of the mapping rule.
- test_sptm_virt_cpu_ids.py (#407): the S2R trace's walk of /cpus, the
  stop-mode and go-mode core masks and the DCC transport's per-core
  cookie and errno, each driven with cpu-ids on both sides of 32, up to
  MAX_CPUS - 1.
- test_t6050_handoff_bounds.py (#408): a panel-less board through
  dt_set_display_handoff(), and the panel path's ADT checks. A boot
  framebuffer that starts at or past the end of /vram, and a bandwidth
  scratch in a PMC metadata block of under 4 bytes, are refused and the
  device tree is left as it was; the edges on the allowed side are
  still handed off. Seeded cases are compared with the rule in whole
  numbers, which cannot wrap.

Each test takes another source through an environment variable
(AURA_MMU_SOURCE, AURA_SPTM_SOURCE, AURA_T6050_SOURCE), so the same
file can be run against a changed copy as a negative control.

No production code changes.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at 1b414c5.

Test-only change, no production code touched. All 188 new cases pass locally with gcc and clang, and pytest tests/python in CI picks them up. Each harness builds the real source: #include "kboot_display_handoff.c", and for memory.c, ctxr_exec.c and sptm_virt_*.c the functions are lifted by text. If a function moves, the test errors; it cannot silently test stale code. Fixtures are synthetic. I spot-checked mutants and the tests fail as they should:

  • memory.c: an off-by-one overlap in mmu_holds_ctrr() fails 8 cases; ignoring apple_sysregs_unlocked in mmu_ctrr_ranges() fails 1.
  • sptm_virt_ctl.c: clamping the DCC index at 31 fails 1. sptm_virt_s2r.c: truncating s2r_parked_mask to 32 bits fails 1.
  • kboot_display_handoff.c: removing meta_size < 4 (t6050_ext_one) fails 15; removing fb - *vram >= *vram_size (t6050_headless_check) fails 18; >= changed to > in t6050_check_adt fails 4.
  1. Optional, outside kboot: T6050: fail closed on a bandwidth block under 4 bytes or a framebuffer past /vram, where the bounds checks wrapped #408: removing the older t6050.pmc_size < 4 guard in t6050_check_adt() (src/kboot_display_handoff.c:3569) leaves all 98 cases passing. The panel path's bandwidth check (:3580) and the dcpext fallback (:3998) both compute pmc_size - 4 and depend on that guard. A disp0 reg[4] of size 0 to 3 in the existing t6050_check_adt() cases would cover it, here or in a follow-up.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Formal §1–§6 pre-PR review at 1b414c58c6787531a7b8350de3d3e98b263e8b66 (base main).

Assessment

  • 0 blockers across §1–§6. Test-only PR (zero production code changes) adding 188 host cases across three pytest suites:
    • tests/python/test_mmu_ctrr_l3.py (#411): compiles src/memory.c and src/ctxr_exec.c unchanged under ASan+UBSan, verifying CTRR_C/CTRR_D L3 splitting by output address across aliases, guard-fault handling, table-leak accounting (lost == 0), and 24 seeded layouts against an independent Python model.
    • tests/python/test_sptm_virt_cpu_ids.py (#407): compiles sptm_virt_s2r_soc.c, sptm_virt_s2r.c, and sptm_virt_ctl.c unchanged, exercising cpu-id values across the 32-bit boundary (0..63, 30-core Ultra layout up to 34), 64-bit stop/go core masks, PMU crumbs, and per-core DCC cookie/errno isolation.
    • tests/python/test_t6050_handoff_bounds.py (#408): #include "kboot_display_handoff.c" unchanged (with Mach-O section adaptation on macOS, already green on macos-15 and macos-26), covering headless and panel /vram framebuffer bounds (including top-of-u64-space wrap cases) and < 4-byte PMC metadata scratch bounds across explicit edges and 216 seeded cases.
  • Negative controls: 104/105 single-edit mutants killed (1 verified equivalent), plus verified compatibility against open T6050 PRs (#471, #439, #282).

CI Status (Withholding APPROVE)

  • 14/16 checks are SUCCESS (including Pytest (ubuntu-latest + gcc), Pytest (macos-15 + llvm-brew), Pytest (macos-26 + llvm-brew), Pytest (ubuntu-24.04-arm, native start.S), format-check, build, policy, selftest) + 1 skipped duplicate selftest.
  • 2 checks still running: stage1-size / fedora (IN_PROGRESS) and test / Pytest (ubuntu-latest + llvm) (IN_PROGRESS).
  • Posting COMMENT (withholding APPROVE) solely until those 2 remaining CI checks finish green.

Non-blocking Note

  • Echoing the optional note already raised in comments: adding a disp0 reg[4] size < 4 case in t6050_check_adt() would also cover the pre-existing t6050.pmc_size < 4 guard in a follow-up (or here if convenient).

Checklist Summary

  • §1 No model gating: Pass (test-only).
  • §2 Production-ready, no hacks: Pass (test-only; AURA_*_SOURCE env vars are test-harness mutation hooks only).
  • §3 Safety: Pass (test-only, synthetic fixtures).
  • §4 Clean-room & attribution: Pass (single commit 1b414c58c678, human author/committer Ryan Murray <ryan@aurorasilicon.org>, human Signed-off-by:, zero AI commit trailers; Assisted-by: in PR body; no Apple code/tuning values).
  • §5 Evidence: Pass (test-only; 188 new cases + 104/105 mutants killed across gcc/clang; waiting on final 2 CI jobs).
  • §6 Naming: Pass.

Assisted-by: LLM (Gemini 4 Neon)

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All remaining CI checks (fedora, Pytest (ubuntu-latest + llvm)) have now passed (17/17 green) at 1b414c58c6787531a7b8350de3d3e98b263e8b66 with 0 checklist blockers. Approving and merging.

Assisted-by: LLM (Gemini 4 Neon)

@DjDeveloperr
DjDeveloperr merged commit cec4a10 into main Nov 23, 2026
17 checks passed
@RyanTheTide
RyanTheTide deleted the test-coverage/aura-ctrr-l3-cpuids-t6050-bounds branch November 27, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants