Repository navigation
AArch64: vg_dit_enter and vg_dit_clear, with their effect on PSTATE.DIT proven - #4168
Merged
Merged
Conversation
reaperhulk
force-pushed
the
claude/vigilant-cori-v8lf1d-impl
branch
from
November 7, 2026 00:25
f800d8b to
6e85871
Compare
reaperhulk
force-pushed
the
claude/vigilant-cori-v8lf1d-impl
branch
from
November 7, 2026 01:11
6e85871 to
118378d
Compare
This was referenced Nov 7, 2026
|
This pull request has conflicts with Posted by |
…IT proven The code (`Impl/Dit/AArch64.lean`): * `vg_dit_enter`: `mrs x0, DIT; lsr x0, x0, #24; msr DIT, #1; ret` * `vg_dit_clear`: `msr DIT, #0; ret` The proofs (`Proof/Dit/AArch64.lean`): * `enter_verified`, `clear_verified`: the spec's contracts (no memory written, the calling convention's preserved state kept, constant time), like every artifact's. * `enter_dit`, `clear_dit`: what those contracts cannot name. Every run of `vg_dit_enter` in the model ends with PSTATE.DIT on and `x0` 1 if it was on and 0 if it was off; every run of `vg_dit_clear` ends with it off. They hold of every run (`Exec.det`), from any state. Registered with `features := ["dit"]` (`Artifacts/Dit/AArch64.lean`); the regenerated crate gains `dit.rs`, whose `VG_DIT_*_FEATURES` name the new `feature::DIT` (bit 21 of `verified-garbage-cpu`), which `src/cpu.rs` detects with `is_aarch64_feature_detected!("dit")` (or, without `std`, the target's `dit` feature, which `aarch64-apple-darwin` has) and `VG_CPU_FEATURES` can name. `src/dit.rs` holds, for now, only a test that runs the two functions on the CPU: entering reports the mode and turns it on, clearing turns it off. The `dit` group runs it on the AArch64 runner unrestricted (with FEAT_DIT) and under `none` (without it, where it calls neither). The guard that uses them comes with its callers, in the next PR. `RegUpd.dit_write` is the frame lemma of the new field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWyoNrCuvSgWWUoNG6S
CI's coverage left the closing brace of `if was == 0` uncovered: every runner starts the test's thread with PSTATE.DIT off, so the branch's false side never ran. The test now ends with `vg_dit_clear` whatever the mode was, which needs no branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWyoNrCuvSgWWUoNG6S
…ions now do Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWwnPmAfvKpXDUq9Tjq
`mrs`, then `cbz` past the `msr` when data independent timing is already on. Its contract makes the mode public (`Spec/Dit.lean`), and the proof shows that it leaks only whether the mode was off (`enter_leak`). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWwnPmAfvKpXDUq9Tjq
reaperhulk
force-pushed
the
claude/vigilant-cori-v8lf1d-impl
branch
from
November 7, 2026 20:32
118378d to
ebbe51c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The AArch64 implementation of
vg_dit_enterandvg_dit_clear, against the spec merged in #4157. It changes nothing inTCB/orSpec/. It now also includes the change from #4328 (closed):vg_dit_enterwrites PSTATE.DIT only if it was off.The DIT stack is now four PRs: #4157 (Spec, merged), this PR, #4210 (the
Dittokens), and #4543 (dit::scopeand the speculation barrier on Apple's targets).The code (
Impl/Dit/AArch64.lean)vg_dit_enter:vg_dit_clear:msr DIT, #0; ret.The emitted words are in
crates/verified-garbage-asm-aarch64/src/dit.rs, and their text is inassembly/dit.s.vg_dit_enterneeds FEAT_DIT, so the emitter gives it no dispatcher.The proofs (
Proof/Dit/AArch64.lean)enter_verified,clear_verified: the spec's contracts, like every artifact's: no memory written, the calling convention's preserved state kept, constant time.vg_dit_enter's contract makes the mode public (pubMode, Spec: vg_dit_enter and vg_dit_clear, entering and leaving data independent timing #4157).enter_leak: every run ofvg_dit_enterleaks exactly[.branch (!s.dit)]. SoConstantTime.of_leakagegives constant time under that contract.enter_dit,clear_dit: what the contracts can't name.vg_dit_enterends with PSTATE.DIT on, andx0is 1 if DIT was on and 0 if it was off.vg_dit_clearends with DIT off.Exec.det).The registration (
Artifacts/Dit/AArch64.lean) binds the code and its proofs withfeatures := ["dit"].Rust
feature::DIT, bit 21 inverified-garbage-cpu, which the generatedVG_DIT_*_FEATURESname.crates/verified-garbage-cpu/src/detect.rs, wheremainnow detects features, usesis_aarch64_feature_detected!("dit"). Withoutstdit uses the target'sditfeature, whichaarch64-apple-darwinenables andaarch64-unknown-linux-gnudoesn't.VG_CPU_FEATURESacceptsdit.src/dit.rsholds only a test that runs both functions on the CPU. It checks that entering turns DIT on and reports whether it was on, that entering again with DIT on (the path without the write) reports 1, and that clearing turns it off. The newditgroup inci/cpu_tests.pyruns it on the AArch64 runner unrestricted, and undernone, where it calls neither function.Guardand theDittoken arrive with their callers in Rust: every verified function takes a Dit token #4210, so this PR adds no unused code.Checked locally (on
mainafter #4157 merged)lake build,Emit.leanandEmit.lean --check(onlydit.rs,dit.sand the crate's module list change), the import, module, registration, speed, variant, arch-gate, vector and MCDT checks, andcpu_tests.py lint.cargo fmt --checkandclippy --all-targets --features cpu-features-env -D warningsfor the host,aarch64-unknown-linux-gnuandaarch64-apple-darwin; the host'scputests.ditandcputests pass with-cpu max(FEAT_DIT) and-cpu cortex-a72(no FEAT_DIT, where the test calls neither function).🤖 Generated with Claude Code
https://claude.ai/code/session_015ajQWwnPmAfvKpXDUq9Tjq