Skip to content

soc: apple: pmp: confirm a T8132 27.2 ioreg update with the entry's length, as macOS does - #2653

Open
DjDeveloperr wants to merge 1 commit into
hvtrace/m4drv8p-mods-pmp272-confirmfrom
djdev/t8132-pmp-272-confirm-len
Open

DjDeveloperr wants to merge 1 commit into
hvtrace/m4drv8p-mods-pmp272-confirmfrom
djdev/t8132-pmp-272-confirm-len

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On the T8132 27.2 PMP firmware the driver answers every UPDATE_IOREG with CONFIRM_IOREG 8, a constant. The confirmation is meant to carry the length of the entry the firmware names. This change sends that length.

  • The firmware names an entry by its own index. That index is word 0x48 of the entry's REGISTER_IOREG buffer. The driver now keeps it next to the entry's registered length, and CONFIRM_IOREG carries that length.
  • On the Mac mini (J773g) the firmware updates four entries: 0x17c, 0x17f, 0x182 and 0x18a. Each has length 8. That is what the driver sends today and what macOS sends in the hypervisor traces, so behaviour there is unchanged.
  • If an index names no registered entry, the driver keeps answering 8 and logs a warning. The traces never show that case.

Evidence

  • Hypervisor traces of macOS 27.2 (26B123) booting on the J773g (hv22, hv23) show the firmware's four UPDATE_IOREG messages, for 0x17c, 0x17f, 0x182 and 0x18a. Each is answered with 0x0037000000000008, CONFIRM_IOREG with value 8.
  • On the mini, the kit build of this change (with its dev_info) matched each of those four indices to a registered entry through word 0x48 of its REGISTER_IOREG buffer, and found length 8 every time (UPDATE_IOREG 0x17c: confirming its 8 bytes, likewise for 0x17f, 0x182 and 0x18a, 12 times each in the GPU lane's runs). Its confirmations equal the traced macOS values.
  • The driver already handles every PMP message type seen in the traces, with the same reply formats. This was the one value that differed.

Base

The base is the HV lane's 27.2 PMP kit branch, hvtrace/m4drv8p-mods-pmp272-confirm (head 19bf8a8). It is the source of the apple_pmp 27.2 module the mini runs. Because this PR is stacked on that feature branch, the repository's CI does not run on it.

The same change was built as an external module for the mini's running kernel (010c3eb) in a kit for the GPU lane. That kit build has an extra dev_info on every UPDATE_IOREG, for its tests.

Before this can merge: the base selects the 27.2 behaviour with a T8132 27.2-image check (apple_pmp_t8132_self_starts()), and this change inherits it. A firmware-version gate doesn't meet the agent guidelines for merged code. The merge candidate should select by what the firmware does: confirm with the registered length whenever the firmware sends UPDATE_IOREG for a registered entry. That is a change to the base, for its owner.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Reviewed the last commit (e544c86). Answering with the named entry's registered length is a small, contained change, and the J773g's four ioregs still confirm 8. Some points:

  • pmp.rs:452-453: ioreg_entries and ioreg_ids are two vectors that must stay index-aligned. If the second push() fails after the first succeeded (past the 340 preallocated), they drift and every later confirmation reads the wrong entry's length. One KVec<(u32, u32)> of (id, length), or pushing both after a single reserve(), keeps them in step.
  • Neither vector is cleared. If the PMP firmware registers its entries again (a restart or recovery, or after a sleep if it does that), the old pairs stay. position() then returns the first, stale match for a reused index, which may have a different length. Clearing both when the firmware starts its registry again (its init message) would fix that.
  • The new read of word 0x48 has // SAFETY: TODO around msg_buf.as_ref() plus an unwrap(). The unwrap() can't fail on a 4-byte slice, but the unsafe block needs its real justification, as the neighbouring as_mut() uses have.
  • The unmatched-index dev_warn! runs on every UPDATE_IOREG. If a firmware does start naming unknown entries, dev_warn_ratelimited! (or once per index) keeps the log usable.

The M4 Air (J713) boots the same T8132 27.2 PMP image, so a J713 boot with this would show whether its updates name the same four entries.

Assisted-by: LLM (Claude:Opus 5.5)

…ength

The T8132 27.2 PMP firmware sends UPDATE_IOREG for a registry entry it
names by its own index, and waits for the confirmation. The index is
word 0x48 of the entry's REGISTER_IOREG buffer, and the confirmation
carries the length of that entry: 8 for the four entries the firmware
updates on the Mac mini (J773g), which is what hypervisor traces of
macOS 27.2 show and what this driver sends for every update.

Keep the firmware's index of each registered entry and answer with that
entry's registered length. An index that names no registered entry
keeps the value 8, with a warning.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr
DjDeveloperr force-pushed the djdev/t8132-pmp-272-confirm-len branch from e544c86 to f5d413f Compare November 21, 2026 07:22
@RyanTheTide

Copy link
Copy Markdown
Contributor

Blockers: 3.

  1. confirm_ioreg_value() (pmp.rs:611) is still selected by apple_pmp_t8132_self_starts(), a SoC compatible plus a /chosen OS version string compare. An unrecognised 27.x build silently falls back to replying 0. Please select the reply by what the firmware does: reply with the registered length for a registered index, and say what other firmwares send and expect. Alternatively, key it on the PMP's own reported version or UUID and fail closed for unknown builds.
  2. The base, hvtrace/m4drv8p-mods-pmp272-confirm, is 50 commits ahead of integration/aurora. It includes DEBUG/WIP/TEST ONLY commits, older copies of M4 PMP: fan-based rail budget and self-described 27.2 PMP path #2533 and soc: apple: t8132-platform-handoff: apply the PMGR policy on every firmware #2588, and the 27.2 PMP enablement (216ec87, eb3ac37, 19bf8a8) this change needs. Retargeting would pull all of that in. Please put the enablement up as its own PR on integration and restack this commit on it.
  3. The new word-0x48 read (pmp.rs:398-403) has // SAFETY: TODO. Please state the invariant.
    Also: ioreg_entries and ioreg_ids can drift if the second push fails (pmp.rs:452-453). One KVec of (id, len) pairs avoids that. The unmatched-index warning should be rate-limited.
    Missing rows: J713 on 27.2, and a built-in J773g boot at this head, including a suspend/resume.

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