Files
LithosAnanake/experiments/bare_metal/runs/doe-aarch64-20260803-221007.csv
T
Robert Allan JamesandClaude Sonnet 5 43aa0a2a36 aarch64: arm the ARM Generic Timer -- CNTP/CNTHP TVAL+CTL, per-tick re-arm
Punch list §25 item 0.7 complete. This is what finally makes items 0.5 and
0.6 provably work end to end.

apic_timer_start(): writes CNTP_TVAL_EL0 (or CNTHP_TVAL_EL2 at EL2 --
aarch64_current_el(), same EL-aware discipline as 0.4-0.6) to
s_timer_period_tsc, then CTL.ENABLE=1/IMASK=0, followed by an ISB. The ISB
is not decorative: confirmed against Linux's own arch_timer_reg_write_cp15()
(arch/arm64/include/asm/arch_timer.h) that only the *control* register write
needs synchronising before the enable/mask state is guaranteed visible to
the interrupt pipeline -- TVAL/CVAL writes do not carry the same
requirement, which is why apic_timer_rearm() omits it.

TVAL is architecturally 32-bit but MSR-to-system-register is always a
64-bit instruction form -- passing a uint32_t operand directly failed to
build (-Wasm-operand-widths). Fixed by truncating to 32 bits ourselves then
zero-extending back to 64 for the operand, which supplies explicit,
provably-correct zeros in the RES0 upper field rather than depending on
unverified hardware behaviour -- Linux's own driver never exercises this
path (it always uses the 64-bit CVAL form instead), so there was no local
source to confirm the alternative against.

apic_timer_rearm() (new): re-writes TVAL only, no ISB needed. TVAL is
relative to "now," not an absolute deadline like riscv64's SBI interface
(item 0.3), so there is no drift-correction bookkeeping -- each write means
"N ticks from this instant." Wired into aarch64_irq_handler() and called
*first*, before heartbeat_tick(), matching riscv64_timer_rearm()'s ordering
discipline exactly: the ARM Generic Timer does not auto-reload, so a return
path that skips this leaves the interrupt condition latched, which the GIC
would redeliver the instant it's EOI'd -- a real storm, the same class of
failure item 0.6's verification investigated (and that time found absent,
because nothing was armed yet).

Verified: builds clean; every generated instruction checked against
disassembly, not just reviewed by eye (both EL branches, correct TVAL/CTL
register names, single shared ISB in apic_timer_start(), no ISB in
apic_timer_rearm()). Boots to ok> with no regression, dict_hash
0x3d4e1daf289da94f unchanged.

Rate measured directly against real wall-clock time via QEMU's own -d int
trap trace (same method as riscv64's item 0.3), two independent windows:
1,090 interrupts over 11.05 s (98.679 Hz) and 4,031 over 40.88 s (98.614 Hz)
-- consistent across both, so this is a real, small, systematic bias
(~1.3-1.4% slow), not measurement noise from polling granularity, which
would have shrunk with the longer window and did not. Attributed to genuine
per-interrupt service latency: TVAL is rewritten mid-ISR, so the trampoline
save/restore, GICC_IAR read, EL branch and GICC_EOIR write all lengthen the
effective period slightly versus the nominal 10 ms, inherent to any
relative-countdown re-arm scheme. Reported as measured, not smoothed over.
The interrupt sustained continuously across both windows with no stall and
no storm, which is the primary evidence re-arm-every-tick is correct;
the small rate bias is overhead, not a defect.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-03 22:14:52 -04:00

4.0 KiB

1tick_numberelapsed_nstick_interval_nscache_hits_deltabucket_hits_deltaword_executions_deltahot_word_countavg_word_heat_q48window_widthactual_window_sizepredicted_label_hitsjitter_bitsapic_tickstime_trust_q48variance_q48vm_call_depth_maxhera_heat_q48hermes_heat_q48artemis_heat_q48
2110000100000018344573173100065536006553600
3220000100000017354458258200065536006553600
4330000100000018466058258200065536006553600
544000010000001748714096000065536006553600
6550000100000015097858258200065536006553600
7660000100000015911734096000065536006553600
87700001000000188157168568500065536006553600
98800001000000214168368568500065536006553600
10990000100000021619824096000065536006553600
11101000001000000222218456756700065536006553600
12111100001000000207238673173100065536006553600
1312120000100000018926834096000065536006553600
14131300001000000221288073173100065536006553600
15141400001000000204298368568500065536006553600
16151500001000000203308273173100065536006553600
17161600001000000201328356756700065536006553600
18171700001000000190348673173100065536006553600
19181800001000000170357358258200065536006553600
20191900001000000154284473173100065536006553600
21202000001000000154284156756700065536006553600
2221210000100000015332394096000065536006553600
23222200001000000167354258258200065536006553600
24232300001000000176374168568500065536006553600
25242400001000000175373973173100065536006553600
26252500001000000196383773173100065536006553600
2726260000100000019241374096000065536006553600
28272700001000000158403868568500065536006553600
2928280000100000015840354096000065536006553600
3029290000100000016441374096000065536006553600
31303000001000000154433968568500065536006553600
32313100001000000172463558258200065536006553600
33323200001000000180493456756700065536006553600
34333300001000000145513556756700065536006553600
35343400001000000203533758258200065536006553600
36353500001000000154553973173100065536006553600
3736360000100000014457374096000065536006553600
3837370000100000014457354096000065536006553600
3938380000100000013257344096000065536006553600
4039390000100000018057324096000065536006553600
4140400000100000022063294096000065536006553600
42414100001000000215642840962400065536006553600
43424200001000000208682940962400065536006553600
44434300001000000177722740962400065536006553600
45444400001000000199772840962400065536006553600
46454500001000000223822640963000065536006553600
47464600001000000202852440966700065536006553600
484747000010000002189125409619800065536006553600
494848000010000002219226409635000065536006553600
504949000010000002259726409652800065536006553600
5150500000100000021410027409669400065536006553600
5251510000100000022710228409688300065536006553600
53525200001000000208102294096104300065536006553600
54535300001000000207102304096120200065536006553600
55545400001000000200102314096131900065536006553600
56555500001000000205103324096146400065536006553600
57565600001000000211103324096162000065536006553600
58575700001000000193110334096171200065536006553600
595858000010000001905674096177500065536006553600