roadmap BUILT

353. The aarch64 half of milestone 74: two decisions left, now that the counter runs

Filed 2026-09-03 as an unnumbered proposal by the milestone/74-cycle-counters-riscv lane, numbered 2026-09-19 by milestone 433 (drain), and the work it described was built the same day by the milestone/74-cycle-counters-aarch64 lane. PMCR_EL0.E and PMCNTENSET_EL0.C are written, so PMCCNTR_EL0 is no longer a stopped counter. What was left was two rulings. calef made both on 2026-10-07 (UTC), and the milestone/353-cycle-read lane built what they require the same day. The options they chose between follow the rulings, unchanged.

The rulings, 2026-10-07 (UTC)

calef answered "Yes" to both as stated below. Recorded as §261 (PMCCFILTR_EL0 is zero on every aarch64 board, and a cycle read carries its meaning) (number provisional).

Decision A: A1, zero on every aarch64 board, not argon's firmware value. The reason: PMCCFILTR_EL0's reset value is architecturally UNKNOWN and firmware-dependent, so argon's value says what argon's firmware does and what seL4's TX1 figures were measured under. It cannot set nife's policy. The kernel writes 0 (EL0 and EL1 counted, EL2 not), consistent with riscv64 and x86_64, which both count user and kernel. argon's firmware value is still read at first boot, for milestone 25 (cross-OS comparison) only: if firmware left P set, milestone 25 runs nife a second time with the filter matched to seL4's and labels that run as such.

Decision B: B4, in two steps. Step 1: one public function in crates/user_mode_runtime that returns the count paired with what it counts. On riscv64 that is core cycles, flagged if the kernel probe was handed hpmcounter3. On x86_64 it is the TSC, labeled as constant-rate reference cycles and not core cycles; rdpmc and CR4.PCE are not reopened. On aarch64 it is core cycles counting user and kernel, per A1. A program knows whether it may read from its own manifest's grant, so step 1 needs no system-call-surface change. Step 2, a kernel-provided "may I read" page or method, is a later system-call-surface fork and is not built.

What was built

Decision A: what PMCCFILTR_EL0 counts

The ruling is A1, above. This section holds the options as they were laid out.

What is being decided

PMCCFILTR_EL0 says in which exception levels PMCCNTR_EL0 increments. Its reset value is architecturally UNKNOWN on every field (Arm's AArch64-pmccfiltr_el0 page, read 2026-09-19 at arm.jonpalmisc.com/latest_sysreg/AArch64-pmccfiltr_el0). The fields that matter here:

bit field meaning when set
31 P do not count EL1
30 U do not count EL0
29, 28 NSK, NSU Non-secure EL1, EL0: counted as P, U say when equal to them, not counted when different
27 NSH do count EL2 (the one field whose sense is inverted)
26 M EL3: counted as P says when equal to it, not counted when different

The kernel writes 0 (PMCCFILTR_COUNT_EL0_AND_EL1, provisional until A1): EL0 and EL1, not EL2, and EL3 wherever MDCR_EL3 permits.

The options

value counts the question it answers
A1 0x0000_0000 EL0, EL1 (EL3 if permitted) "what did this operation cost the machine, kernel included, with nothing below us"
A2 0x0800_0000 (NSH) EL0, EL1, EL2 (EL3 if permitted) the same, plus any time a hypervisor below us spends on our behalf
A3 0x8000_0000 (P) EL0 only "what did userspace spend", a profile
A4 not written whatever firmware left "the same as whatever else ran on this board's firmware"

Question 1: What else was considered, and why each is a live option rather than a loser

None loses on the facts; they answer different questions, which is why this is an architect's.

Question 2: What this tree already does in the analogous case

Both other architectures count every privilege level, including the kernel's, and neither was decided as a published position; each is the mechanism's default:

So A1 (or A2) is the option consistent with the two numbers in this tree, and A3 would make aarch64 the odd one out. That is precedent, not a ruling: neither of those was put to calef either.

Question 3: The prior art, read

Question 4: Is the premise true?

Mostly, with one correction worth making before calef rules. The brief framed this as "seL4-comparable versus userspace-only". seL4-comparable is itself not a single value. It is A4 on the published board, which is whatever that board's firmware left (argon's boot line is the best guess at it, and QEMU's 0x0 would make it A1), and A2 in seL4's own hypervisor builds. So the decision is between "count the kernel" (A1 or A2) and "count userspace" (A3), with A1 against A2 a second, smaller question about a configuration nothing runs today.

Question 5: What each costs, measured rather than asserted

The same, to build: one constant. PMCCFILTR_PROVISIONAL is written once per core at init and never on the switch path, so no option moves script/fastpath-footprint or the icount tripwire (both were run with A1 in place; the block has the exit codes). Not measured: whether the filter changes what a read costs, because QEMU does not model that and there is no silicon here. One real cost difference exists and it is not performance: A3 breaks bench::cycles_per_tick, which reads the counter at EL1 and would see it stopped. Choosing A3 means moving the probe to EL0, which is milestone 237's grant build and a measurement build rather than the plain --features bench boot.

Question 6: How reversible, and who has already acted on it

The code is reversible in a line. The number is not, once published, and nothing has been: this lane printed only QEMU's 16.00, which is an instruction count and says so. radon's 250.00 and xenon's future figure are the precedent a reader will compare an aarch64 number against, and both count the kernel.

Question 7: Would the choice be the same if every option cost the same?

They do cost the same, so nothing here is an effort argument: it is a question about what nife wants its published numbers to mean.

What happened when calef ruled

He chose to wait for argon's firmware value on 2026-09-19, then A1 on 2026-10-07 (UTC): the rulings at the top of this block.

Decision B: the portable user-mode cycle read, its name and its promise

What is being decided

fixtures/src/cycle_counter_reader.rs carries the only user-mode read in the tree, one mrs (or csrr cycle, or rdtsc) per architecture, and its doc comment says a portable function is milestone 74's to design. This lane did not add it, by instruction. The questions are what crates/user_mode_runtime should call it, what it should promise, and whether it should exist yet.

The fact that decides most of it: the three user-readable counters are not the same quantity

what EL0/U-mode/ring 3 reads is it core cycles? granted by
aarch64 PMCCNTR_EL0 yes, filtered by decision A milestone 229's grant (PMUSERENR_EL0.CR)
riscv64 the cycle CSR yes, but the kernel's own probe may have been handed a different counter (hpmcounter3 on rva23s64) 229's grant (scounteren.CY), and mcounteren.CY in firmware
x86_64 rdtsc no: constant-rate, the same counter as user_mode_runtime::now() ambient (DECISIONS §139 part 3)

The kernel's cycles_per_tick probe on x86_64 deliberately does not read the TSC (milestone 309's whole argument: it would divide one counter by itself). A user-mode function called cycles() that read rdtsc on x86_64 would therefore be the exact mistake 309 was written to prevent, in the one place a stranger would call it. Reading core cycles from ring 3 needs rdpmc with CR4.PCE set, which milestone 228 deliberately closed and which is a DECISIONS §139 question, not a naming one.

The second fact: EL0 cannot ask whether it may read

An ungranted read is not an error return, it is a fault that ends the thread (that is the negative half of a_granted_thread_reads_the_cycle_counter_and_an_ungranted_one_faults). So a user-mode function cannot probe and fall back. Whatever it promises, it has to know from somewhere other than trying.

The options

The seven questions, briefly

  1. Alternatives: the four above; each answers a different "what does a caller need".
  2. This tree: user_mode_runtime::now() and cntfrq() are the analogous pair, and now() is documented per architecture with its caveats in a BUGS section. The kernel names the per-arch module pmu and the reading cycles() on all three, and on x86_64 that kernel cycles() is not the TSC. A user-mode cycles() that was the TSC would collide with the kernel's own meaning of the word.
  3. Prior art: seL4's sel4bench_get_cycle_count() is a raw read with no promise beyond "whatever PMCCNTR says" (libsel4bench, read 2026-09-19); Linux has no libc function and uses the mmap page above; Rust's core::arch::x86_64::_rdtsc names the instruction rather than the quantity.
  4. Premise: true that it is a naming decision; not only a naming decision, because B3 is a §139 extension on x86_64.
  5. Cost: B1 zero; B2 one function and a scope note; B3 a CR4.PCE grant on the switch path (milestone 237 measured what the aarch64 and riscv64 version of that cost the fastpath); B4 a page or a call. None was built or measured here.
  6. Reversibility: a public function in user_mode_runtime is a name programs compile against; renaming it later touches every caller, which is the expensive category.
  7. Equal cost: B1 and B2 are not chosen for being cheap; B4 would still be the most honest if all four cost the same, and B3 is the only one that is more than a naming question.

What happened when calef ruled

B4, in two steps, on 2026-10-07 (UTC): the rulings at the top of this block. Step 1 is built.

Where it came from

The riscv64 lane's handoff (2026-09-03) and the aarch64 lane that built the counter (2026-09-19). Everything cited was read on the date given, not recalled.

Follow-on

Index row

The two rulings the aarch64 half of milestone 74 (cycle counters) left, made by calef on 2026-10-07 (UTC) and built. A1: PMCCFILTR_EL0 is 0 on every aarch64 board, so aarch64 counts user and kernel like riscv64 and x86_64, and the boot and bench lines stopped saying PROVISIONAL; argon's firmware value is read for milestone 25 (cross-OS comparison) only. B4 step 1: user_mode_runtime::cycle_reading() returns the count with an abi::cycle_counter::CycleMeaning, core cycles on aarch64 and riscv64 and constant-rate reference cycles on x86_64, proved on all three by the granted-read test. Step 2, a "may I read" page or method, is a deferred system-call-surface fork and is proposed, not built.