Repository navigation
TCB: AArch64 barriers (DSB SY, ISB, SB) - #4373
Closed
reaperhulk wants to merge 2 commits into
Closed
reaperhulk wants to merge 2 commits into
reaperhulk wants to merge 2 commits into
Conversation
reaperhulk
force-pushed
the
claude/dit-barrier-tcb
branch
from
November 7, 2026 00:25
e4426ce to
3dd1a53
Compare
`Instr.barrier b`, with `Barrier.dsbSy`, `.isb` and `.sb`, for a speculation
barrier after setting PSTATE.DIT, which Apple's documentation asks for
("To ensure that subsequent instruction timing reflects the updated DIT
processor state, add a speculation barrier after turning on DIT"), with DSB
SY and ISB where FEAT_SB is missing, as Apple's corecrypto does.
Each leaves the model's state as it is and leaks nothing: DDI 0602 2026-03
gives their operations as DataSynchronizationBarrier,
InstructionSynchronizationBarrier and SpeculationBarrier, which act on
memory ordering, context synchronization and speculation, none of which
the model has. They have no operands. SB requires FEAT_SB ("SB": `if
!IsFeatureImplemented(FEAT_SB) then EndOfDecode(Decode_UNDEF)`), Rust's
`sb`; DSB and ISB are baseline. Encodings 0xD5033F9F, 0xD5033FDF and
0xD50330FF, checked with GNU as 2.46.
Framework: Inline.dstOf and exec_gpr, and the taint step (no change) with
its soundness case. VerifiedGarbageTest.AArch64Barrier checks the
semantics, text, encodings, requirements and taint.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ajQWwnPmAfvKpXDUq9Tjq
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWwnPmAfvKpXDUq9Tjq
reaperhulk
force-pushed
the
claude/dit-barrier-tcb
branch
from
November 7, 2026 01:12
3dd1a53 to
f233eb9
Compare
Member
Author
|
Replaced by #4483, which carries this change together with the other DIT TCB change, based on |
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.
Stacked on #4357. This is a trust change (
TCB/): it adds three instructions to the AArch64 model.What
Instr.barrier b, withBarrier.dsbSy(dsb sy),.isb(isb) and.sb(sb, FEAT_SB). The follow-up PR uses them to put a speculation barrier aftermsr DIT, #1on Apple's targets.Why
The two vendors disagree on whether a barrier is needed after turning PSTATE.DIT on:
sbwhere the CPU has FEAT_SB, elsedsb sy; isb(cc/src/cc_timing_safe.c).Go's runtime followed both, using the barrier on darwin/arm64 only (golang/go#77776,
src/internal/runtime/sys/dit_arm64.s). The follow-up does the same.Semantics, with citations
DDI 0602 2026-03 (A64 ISA):
CRm = '1111'(SY), the operation isDataSynchronizationBarrier(scope, types, nXS).InstructionSynchronizationBarrier().if !IsFeatureImplemented(FEAT_SB) then EndOfDecode(Decode_UNDEF); end;, operationSpeculationBarrier().The model has no memory ordering, pipeline or speculation, which is all these act on. So each leaves the state as it is (
exec (.barrier _) s = some s) and leaks nothing (addrsis[]). They have no operands, so their timing can't depend on data. Their time depends only on the instructions before them, whose leakage the model already accounts for.Requirements and encodings
sbrequires Rust'ssb(FEAT_SB), as above. DSB and ISB are baseline.11010101000000110011 CRm 1 opc 11111:dsb sy:0xD5033F9Fisb:0xD5033FDFsb:0xD50330FF-march=armv8.5-a). With-march=armv8-ait refusessb("selected processor does not support `sb'").Changes
TCB/AArch64/Isa.lean:BarrierandInstr.barrier.exec, with the pseudocode cited.requires(.barrier .sb => ["sb"]), and its docs citing the SB decode.TCB/AArch64/Encode.lean,Print.lean: the encodings and the text.Inline.dstOfandexec_gpr.Lit:ToExprforBarrier, somaterialize_codecan write code that contains one.VerifiedGarbageTest/AArch64Barrier.leanchecks:No artifact uses them yet, so
src/asm/is unchanged.🤖 Generated with Claude Code
https://claude.ai/code/session_015ajQWwnPmAfvKpXDUq9Tjq