# 2026-10-30 — kido-mpidr design deliberation (session 38, builder crew)

## Opening state

Session 37's remains are, again, all blocked or fenced: the QEMU
virt PSCI proof and the QEMU virt -smp proof need the toolchain
(absent a 21st time this session — `which` finds no
aarch64-linux-gnu-gcc, no qemu-system-aarch64; only the host gcc
13.3.0); the Gate wirings (vec into the boot path, GIC
enable(30) + timer arm into the scheduler tick, serial-irq init
into the boot path, HAL wiring, MMU call-site wiring, psci-init
gating policy, secondary entry stub, first sync/barrier/ipi/call
consumers) are Gate items, not things a scaffold session takes
unilaterally; the destroy bare-metal proof has its own design
(session 22, not swallowed here); D1 KIDO_ERR_NO_TASKS is
N8toriousAi's call; the BUBO peer is Phase 4. Per the session-22
precedent (degrade honestly to the next draftable module), this
session drafts kido-mpidr: the CPU-identity leaf.

Why this piece, why now: three modules have now refused, in
writing, to parse MPIDR — and each refusal named the parse as
a future. smp keeps affinities opaque (smp.h honesty law);
ipi C3 refused to parse MPIDR for the source CPU; call C8
refused to parse it for the poster. The refusals were right
at the time: each module had a job that did not need a
decoder, and a decoder smuggled into any of them would have
been a second invention inside a proven file. But the
refusals now point at a real gap: nothing in the tree can
answer "which PE am I, in affinity terms?" — and the next
SMP consumer (a scheduler that places work, a CALL handler
that knows its own slot, a Gate wiring that binds a CPU to
its mailbox) will need exactly that answer. This session
builds the decoder as its own leaf, touches zero existing
files (the session-24/25/26/33 fence pattern), and wires
nothing: the consumers stay Gate items, exactly as before.

The stub question, settled before it is asked: session 33's
deliberation D3 overruled writing the secondary .S stub in a
scaffold session ("a stub without its scheduler consumer is
untestable shape", and the stub is a scheduler/Gate item).
This session does NOT reopen D3. kido-mpidr is not the stub
by another name: it is a register decoder with a hosted
proof, testable on its own terms, and it changes no bring-up
policy.

## Circle

- P1 — identity realist. Decoding is a pure function of
  one register. No policy, no table, no mapping lives here.
- P2 — opaque-affinity auditor. smp/psci law stands:
  affinities are opaque to bring-up. This module decodes;
  it never assigns a slot.
- P3 — no-linear-index auditor. The Aff tuple is
  hierarchical; its only architectural guarantee is
  uniqueness of the whole tuple. Any flat CPU number
  derived from it is invented.
- P4 — sync-compat keeper. kido-sync already reads MPIDR
  raw and stores it as a lock owner. The decoder must not
  contradict that read, replace it, or change sync's
  stored type.
- P5 — test keeper. The hosted proof uses the sync
  injector precedent (a test-set raw value), never a fake
  bare-metal claim. The ARM64 read is one MRS, the same
  spelling sync already carries.
- P6 — honesty auditor. Reserved bits are masked, never
  interpreted, never policed. A decoder that refuses
  firmware values would turn an identity query into a
  boot failure.

## Field law (checked, not remembered)

MPIDR_EL1 per the Arm A-profile register reference
(developer.arm.com, MPIDR_EL1): Aff0 bits [7:0], Aff1
[15:8], Aff2 [23:16], MT bit [24], RES0 [29:25], U bit
[30], RES1 bit [31], Aff3 bits [39:32], RES0 [63:40].
Read-only at EL1 and above; the Aff tuple (Aff3, Aff2,
Aff1, Aff0) must be unique within the system. MT=1 means
PEs with different Aff0 and equal higher levels are very
interdependent (a multithreading hint, not a proof that
multithreading is implemented). U=1 means a
uniprocessor system, as distinct from PE 0 of a
multiprocessor system. In a uniprocessor system Arm
recommends all Aff fields read 0 — a recommendation, not
a law the decoder enforces. Aff3 is not supported in
AArch32 state — irrelevant here; this module is ARM64
only by the usual arch-discipline error.

## Challenges, answered

- C1 — A new leaf, or decode inside sync/smp? A new
  leaf (P1/P4). sync's owner needs only uniqueness of
  the raw value; smp's bring-up needs only opacity.
  Putting a decoder in either would couple a proven
  module to a consumer that does not exist yet. Zero
  existing files touched; the module-map row and the
  ledger entry are the only other edits.
- C2 — Does the module provide a linear CPU index?
  NO — this is the decision the whole module turns on
  (P3). QEMU virt -smp N happens to report Aff0 =
  the CPU number today, and that accident is exactly
  why the refusal matters: on a multi-cluster system
  Aff0 repeats across clusters, and an Aff0-as-index
  mapping would alias two PEs into one slot. The smp
  slot is assigned by bring_up and recorded in the
  smp table; a caller that needs slot-from-affinity
  does a table lookup against recorded affinities —
  a Gate policy, not arithmetic in this leaf. There
  is deliberately no kido_mpidr_index().
- C3 — What does "same CPU" mean? All four Aff levels
  equal (P1). MT and U are not identity: MT is a
  performance hint about Aff0 siblings, U describes
  the system shape, and neither changes which PE a
  tuple names. same_cpu() compares Aff3..Aff0 only.
  No "same cluster" or "same package" helper is
  offered: what Aff2/Aff1 mean physically (cluster
  signals on Cortex-A57, CPUID pins on A710) is
  IMPLEMENTATION DEFINED, and naming a grouping the
  architecture does not define would be the same
  invention C2 refuses, one level up.
- C4 — Reserved bits: bit 31 is RES1, so real hardware
  always returns it set; bits [63:40] and [29:25] are
  RES0. The decoder masks only the defined fields
  (P6). The raw value is carried whole in the struct
  so a future reader can see exactly what the
  register returned, but no function interprets a
  reserved bit, and no function refuses a value for
  having one set or clear. A hosted injector value
  with bit 31 clear still decodes — the register
  value is input, not a claim to validate.
- C5 — Which EL may call? EL1 or above, like every
  other EL1-register reader in the tree (the vec/hal
  EL1 contract precedent). MPIDR_EL1 from EL0 is
  UNDEFINED/trapping; the entry shim guarantees EL1
  before any C runs. Stated in the header, not
  enforced — there is no cheap EL query that is not
  itself another register read with the same problem.
- C6 — MT=1 changes Aff0's meaning (thread, not
  core). The decoder reports the MT flag alongside
  Aff0 and stops there (P1). Collapsing "thread" and
  "core" into one field would lose the distinction
  the flag exists to carry; interpreting it is the
  consumer's job.
- C7 — U=1 with nonzero Aff fields? Arm recommends
  zeros, recommends is not requires. The decoder
  decodes what it is given. A consumer that wants
  to treat U=1 as "there is only one PE" reads the
  flag itself; the decoder does not short-circuit
  same_cpu() on U.
- C8 — read() vs decode()? Both (P1). read() is the
  register path (MRS on ARM64, injector on hosted);
  decode() is the pure function over any raw value —
  including a recorded affinity from the smp table,
  which is how a future consumer answers "which PE
  was that?" about another CPU without reading its
  own register. One decode path, shared: read()
  calls decode() on the value it obtained, so the
  two can never drift.
- C9 — Does decode() fail? Only on a NULL out-pointer
  (EARLY_ENV, the tree-wide guard idiom). Any 64-bit
  input decodes: the fields are bit slices, and
  there is no firmware value that makes slicing
  undefined. No new header codes (sched-D1
  precedent).

## Preserved dissent

- D1 — A linear index for the common case (Aff0 when
  the system is one cluster). Overruled (C2): the
  "common case" is a platform accident, and a leaf
  that bakes it in teaches every future consumer the
  wrong law. If a consumer proves single-cluster, it
  proves it in its own policy, not in this decoder.
- D2 — Decode inside sync, replacing the raw owner
  with a decoded struct. Overruled (C1/P4): sync's
  owner comparison needs equality of the raw value,
  which the decoder does not improve, and the change
  would touch a proven module for no live consumer.
  When a consumer needs decoded identity, it calls
  this leaf; sync keeps its raw owner.
- D3 — Validate reserved bits (refuse if RES0 is
  nonzero or RES1 clear). Overruled (C4/P6): RES0
  means "should be zero", and a decoder is not the
  firmware police. Refusal would convert an identity
  query — the cheapest question in the tree — into
  a loud halt on hardware the kernel has not yet
  judged. Mask, carry raw, move on.

## Design, as built

- Struct: kido_mpidr_t { raw, aff0, aff1, aff2, aff3,
  mt, u } — mt/u as uint32_t 0/1 flags, fields as
  uint8_t. raw carried whole (P4/C4).
- API: kido_mpidr_read(out) / kido_mpidr_decode(raw,
  out) / kido_mpidr_same_cpu(a, b, &same) /
  hosted-only kido_mpidr_test_set_raw(raw).
- ARM64 read: one MRS, the sync spelling verbatim
  (`mrs %[id], mpidr_el1`). Hosted read: the injector
  value (default 0, the sync precedent). No other
  arch: the header refuses unknown arch exactly like
  smp/psci.
- No new header codes: NULL guards -> EARLY_ENV.
- Zero existing files touched. No wiring into smp,
  sync, ipi, call, or the boot path — consumers are
  Gate items, and the ipi C3 / call C8 futures now
  have a leaf to call instead of a parse to invent.
- Proof status: WRITTEN, NOT ASSEMBLED, NEVER
  EXECUTED on bare metal (toolchain absent, 21st data
  point). The module has exactly one asm instruction,
  and it is sync's already-carried spelling — what
  awaits a tooled VM is the disassembly check that
  the MRS is present, plus a QEMU virt -smp 2 run
  showing two distinct Aff tuples. The hosted proof
  pins the decode, not delivery across silicon.

## Outcome note (post-hoc)

The session-37 remains list is unchanged except for one
addition at its tail: kido-mpidr now exists, and the
ipi C3 / call C8 named future ("MPIDR parsing") is
closed as a module — a decoder any Gate consumer can
call, with the linear-index trap explicitly refused.
The secondary stub stays a Gate item (session-33 D3
stands, unreopened). Nothing in this record authorizes
any wiring from a scaffold session.
