Walk CoreSight ROM tables within explicit limits. - #67
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 82d961b1cc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Component identity does not describe the children behind a ROM table. Derive entry geometry from the identified architecture and expose bounded entry reads over borrowed scalar memory. Retain presence and table-local power metadata without accessing children or requesting power. Validate format, reserved fields, and signed address arithmetic before a caller can follow an entry. Read both words of a 64-bit entry before decoding it, and return no partial entry after a failed read.
Reading individual entries leaves hierarchy traversal and failure handling with every caller. Walk present children in depth-first order, retaining parent links and partial results while bounding depth, visits, and entry reads across the entire walk. Use an iterative stack and reject repeated tables before another identity read. Skip children whose entries name power domains and report the incomplete result without requesting power. Stop on other failures because a memory error can invalidate the borrowed client. Preserve those causes and leave cleanup with the existing owner.
The example currently stops at the advertised component identity. Add an explicit walk mode that calls the public traversal API with fixed limits, prints partial results, and exits with a nonzero status when inspection is incomplete. Keep cleanup with the existing Arm debug owner. Record the complete micro:bit hierarchy and the ZCU104 access boundary in the opt-in hardware test and guides, including successful owner close after the target fault and the limits of that observation.
82d961b to
121ffb8
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Add entry decoding and bounded traversal to
coresight.Component.ROMTablerecognizes class 1 and Arm class 9 ROM architecture0x0af7, revision 0, and derives the entry count and width from that identity.ReadEntryvalidates one entry without accessing its child.Walkfollows present entries in depth-first order and returns the visits recorded so far when inspection cannot finish.Applications can validate their limits before opening hardware. This helper borrows an already-acquired MEM-AP and starts at its advertised entry:
Limits cover the entire walk. Root depth is zero, the component bound counts root and skipped or failed visits, and the entry bound includes absent entries and terminators. Parent indexes refer to the returned slice. A non-table root is a successful single visit. Unknown component architectures are leaves; recognized ROM architectures with unsupported revisions or formats return errors. The traversal uses an explicit stack and rejects repeated tables before another identity read, covering cycles and duplicate table references.
An entry with a valid power-domain ID is recorded with
ErrPowerDomainand skipped before any child access. Its accessible siblings are still inspected, but the walk returns a non-nil error. Every other failure stops the walk immediately, including a memory error which might invalidate the MEM-AP. Earlier visits remain available, anderrors.Iscan match the underlying cause,ErrWalkLimit,ErrRepeatedTable, orErrPowerDomain.The caller retains ownership. A MEM-AP borrowed from
armdebug.Conn.OpenMemAPis released by closing that connection and retrying failed cleanup; a directly acquired MEM-AP must be released before its debug port. Inspection changes the MEM-AP's address and transfer state through ordinary reads but introduces no cleanup owner. It writes no target memory, requests no component power, and performs no unlocks, CTI configuration, halt, reset, or board activation. The caller supplies a safe root address; the API does not establish access to an advertised power domain.Callers inspecting entries without following them can use the smaller operation on an identified component:
Entry decoding handles class 1 32-bit and class 9 32-bit or 64-bit layouts. It reads both words of a 64-bit entry before interpreting presence, rejects malformed encodings and address underflow or overflow, and returns no partial entry on failure. Power IDs remain scoped to the containing table. Class 1 FORMAT=0 is unsupported; all-ones entries are malformed.
The existing SWD example gains an explicit walk mode with depth 8, 256 visits, 4096 entry reads, and its existing ten-second deadline:
-base ADDRESScan override the advertised root. The example prints available identities, parent and entry indexes, component errors, and whether the walk completed. Incomplete inspection exits unsuccessfully after printing partial results and attempting the existing bounded cleanup. Without-walk, it retains the single-component behavior. The library also works through JTAG memory; the example configures SWD only.Why
A MEM-AP's advertised address often identifies a ROM table rather than the component an application needs. Entry decoding belongs above scalar memory, and traversal needs one place to enforce bounds, preserve failures, and skip components whose power-domain access has not been established. Separate entry reads remain useful for inspecting raw table contents without following children.
Documentation
Extend the CoreSight guide with entry layouts, traversal limits, parent links, power metadata, partial results, and bench observations. Update architecture, capabilities, composition, and example guides to expose those operations and the
-walkoption.Hardware evidence
On the macOS Nostalgia bench,
OSTIOLE_ROM_HIL=1 go test -tags=integration -run '^TestHILROMWalk$' -count=1 -v ./coresightopened two fresh 100 kHz sessions per path. Each used the advertised MEM-AP root, depth 8, 256 visits, 4096 entry reads, and a 120-second operation deadline.CMSIS-DAP v2 micro:bit serial
9900360140124e4500279015000000360000000097969901, SWD AP0, completed six identities from root0xf0000000, including the nested table at0xe00ff000and components at0xe000e000,0xe0001000,0xe0002000, and0xf0002000. The example also returned six visits andcomplete=truewith that exact serial and its ten-second deadline.FT4232H
01691/A on the externally enabled ZCU104 Arm0x5ba00477/IR4 and Xilinx0x14730093/IR12 JTAG chain, AP1, returned seventeen identities from root0x80000000, then stopped on a DAP FAULT at CIDR address0x803e0ff0. Both sessions retained the failed eighteenth visit for root entry 16. This is an incomplete walk and an observed access boundary, not an identified component or evidence that later entries are accessible. The error does not establish why that target access faulted.Every owner reported successful close, including after the ZCU104 fault; restored state was not independently measured after close. The observed tables were class 1. Class 9 layouts and power-domain skips have ordinary test coverage; large addresses and both memory byte orders also have public MEM-AP simulation coverage, not physical validation here.