Skip to content

sptm_virt: keep cpu-ids 32 to 34 in the S2R core masks and the DCC transport's per-core state - #407

Merged
DjDeveloperr merged 1 commit into
aurora-silicon:mainfrom
funkzy:pr/aura-s2r-u64
Nov 21, 2026
Merged

DjDeveloperr merged 1 commit into
aurora-silicon:mainfrom
funkzy:pr/aura-s2r-u64

Conversation

@funkzy

@funkzy funkzy commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

What is missing

dj's review of #262: s2r_twi_mask, s2r_parked_mask and s2r_crumb_wfi (src/sptm_virt_s2r.c) are u32, not
u64 as #262's description said, so BIT(cpu) for cpu-ids 32 to 34 is lost there: such a core never counts as armed,
parked or at its deep-sleep WFI.

Two more places in SPTM-virt are sized for 32 cpu-ids, from before MAX_CPUS went to 64:

  • s2r_trace_cpus() (src/sptm_virt_s2r_soc.c) refuses a cpu-id of 32 or more, so the T6050 timer-only trace
    setup fails on a tree whose cpu-ids reach 32, as the M5 Ultra's (J775D) do.
  • The DCC transport (src/sptm_virt_ctl.c) keeps its errno and presented cookie in 32 per-core slots and clamps
    smp_id() to the last one, so cpu-ids 31 to 34 share a slot: a doorbell on one of those cores can take the
    cookie another core presented, or read its errno.

What this changes

  • The three masks become u64, and the two stop-mode messages that print them use %lx.
  • s2r_trace_cpus() takes cpu-ids below MAX_CPUS; its seen mask is already u64.
  • ctl_dcc_errno[] and ctl_dcc_presented[] get MAX_CPUS slots. The clamp stays.
  • The PMU scratch crumb still records cores 0 to 15 in its two bytes, as before. Widening it would move the bytes
    after it.

Other per-CPU state indexed by smp_id() in hv, nv2 and sptm_virt is already sized by MAX_CPUS or held in u64 masks.
world_hist (sptm_virt_cl4.c) keeps 12 cores on purpose, for .bss, and skips the others.

Who runs the changed code

Only SPTM-virt development builds (SPTM_VIRT=1; the DCC transport with AURACTL=1), and no T6050 runs S2R today.
On a SoC whose cpu-ids stay below 32, the masks hold the same bits, the messages print the same values, and each core
keeps its own DCC slot. A release build does not contain these files.

Validation

On main at 3efa4a8, with clang/lld 23.1.4:

  • RELEASE=1 CHAINLOADING=1 ESP_STAGE2=1: main's 13 warnings; aura.bin 3997696 bytes, every section and
    _file_vital_end (0x11be50) as on main.
  • CHAINLOADING=1 ESP_STAGE2=1 SPTM_VIRT=1 AURACTL=1 SPTM_VIRT_ESP=1, which compiles the three files: main's
    warnings. The .bss objects grow by 396 bytes (the masks 12, the DCC slots 384), inside the padding: _bss_end
    0x390000 and aura.bin 3801088 bytes, as on main.
  • The host pytest suite as CI runs it (tests/python and the two T8122 GPU tests, pytest 9.1.1): 798 passed,
    57 skipped, as on main.
  • clang-format 20.1.8 (CI's) clean on the three files.

Hardware

Not run on hardware: no SPTM-virt build boots on a T6050 yet, and the release image does not contain these files.

…ansport's per-core state

MAX_CPUS is 64 since 0f5f939, for the M5 Ultra (J775D), whose cpu-ids
run to 34. Some SPTM-virt per-core state is still sized for 32:

- s2r_twi_mask, s2r_parked_mask and s2r_crumb_wfi are u32, so BIT(cpu)
  for a cpu-id of 32 or more is lost there: such a core never counts as
  armed, parked or at its deep-sleep WFI.
- s2r_trace_cpus() refuses a cpu-id of 32 or more, so the T6050
  timer-only trace setup fails on a tree with such cpu-ids.
- The DCC transport keeps its errno and presented cookie in 32 per-core
  slots, and cpu-ids 31 and up share the last one, so a doorbell on one
  of those cores can take the cookie another presented, or read its
  errno.

Widen the masks to u64 and size the rest by MAX_CPUS. The PMU scratch
crumb still records cores 0 to 15 in its two bytes, as before.

Only SPTM-virt builds run this code, and no T6050 runs S2R today. On a
SoC whose cpu-ids stay below 32 the masks hold the same bits and the
DCC slots are the same.

Signed-off-by: Jeff Queisser <funkzy@users.noreply.github.com>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for widening these. The u64 masks and the MAX_CPUS-sized DCC slots look right, and the build/size checks are helpful.

One thing before this can go in: the second commit ("gfya") deletes AGENTS.md, CLAUDE.md, GEMINI.md and .github/copilot-instructions.md, which looks unrelated to the change. Could you drop that commit so the PR only carries the SPTM-virt fix?

@RyanTheTide

Copy link
Copy Markdown
Contributor

Besides the S2R core-mask change, this branch deletes AGENTS.md, CLAUDE.md, GEMINI.md and .github/copilot-instructions.md. Those are the repo's copies of .github/aurora/AGENTS.md, and the aurora-agent-policy workflow puts them back on main, so the deletion would just bounce. Could you drop those four files from the PR so it carries only the src/sptm_virt_* change?

Assisted-by: LLM (Claude:Opus 5.5)

@funkzy

funkzy commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for catching that. The deletion wasn't in our commit: our fork had the repository's instruction-file policy workflow enabled, and on the push it healed the branch against the fork's stale default branch, adding a github-actions[bot] commit (c3d072e) that removes the four files. The branch is now back to the one src/sptm_virt_* commit (844860c), and Actions is off on our forks so it can't happen again.

@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.

Reviewed 844860c, now down to the one src/sptm_virt_* commit. Thanks for clearing the bot commit that deleted the policy files.

Correct:

  • The three masks are u64 and every user handles that: BIT() is 1UL <<, the atomics __atomic_fetch_or and __atomic_or_fetch work on the variable itself, and s2r_clean uses sizeof.
  • The stop-mode messages print %lx.
  • s2r_trace_cpus() bounds by MAX_CPUS against its u64 seen.
  • The DCC slots are MAX_CPUS.

Below cpu-id 32 the bits and slots are identical. The code is only in SPTM-virt development builds, not release images.

Hardware gate: the only machine where the behaviour changes (J775D, cpu-ids 32-34) can't run SPTM-virt yet, and every other machine gets identical state, so I'm not asking for a row. Merging once the queued CI finishes green on this head.

Assisted-by: Claude Opus 5.5

@DjDeveloperr
DjDeveloperr merged commit c2ec927 into aurora-silicon:main Nov 21, 2026
30 checks passed
term-guy pushed a commit to term-guy/aura that referenced this pull request Nov 23, 2026
…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 (aurora-silicon#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 (aurora-silicon#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 (aurora-silicon#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>
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.

3 participants