TestDL Specification Reference
This reference explains how to read, create, and modify ALVIE/Sancus specifications using the existing TestDL language. For a guided example, start with the V-B1 TestDL tutorial. For the precise meaning of individual actions, use the TestDL Action Reference. To add a language construct or a new observable behavior, use Extending TestDL Actions instead.
A full ALVIE/Sancus run is built by combining:
- one enclave (victim) spec file (
.etdl) - one attacker spec file (
.atdl)
The CLI merges both files and parses them as a single TestDL specification.
Where specs live
Section titled “Where specs live”- Main library of ready-to-use specs:
spec-lib/ - Running example:
spec-lib/example/- attacker:
spec-lib/example/attacker.atdl - enclave:
spec-lib/example/enclave.etdl
- attacker:
Commands in this reference run from alvie/code/.
Pass specifications with:
dune exec bin/learn.exe -- \ --att-spec path/to/attacker.atdl \ --encl-spec path/to/enclave.etdl \ ...Enclave specifications
Section titled “Enclave specifications”An enclave file defines the enclave { ... }; section.
Minimal shape:
enclave { <body>};Supported enclave atoms
Section titled “Supported enclave atoms”nop,dint,mov ...,add ...,cmp ...,jmp ...,push ...rstubrifz (<atom-list>) (<atom-list>)balanced_ifz (<instruction-list>)
TestDL combinators
Section titled “TestDL combinators”Attacker and enclave sections share these combinators:
- sequencing:
a; b - choice:
a | b - repetition:
a* - epsilon (empty action):
eps - grouping:
( ... )
ifz takes two non-empty, semicolon-separated branch lists.
Executable enclave branches currently support instruction atoms and rst; nested ifz, ubr, and balanced_ifz inside an ifz branch are not supported.
balanced_ifz accepts a non-empty instruction list, rather than an arbitrary TestDL expression.
Secret placeholder
Section titled “Secret placeholder”Inside enclave instructions, ? means “secret immediate value”.
Example:
cmp ?, r4;At runtime, ? is replaced by the value passed through --secret.
Attacker specifications
Section titled “Attacker specifications”An attacker file defines three sections:
isr { ... };prepare { ... };cleanup { ... };The sections must appear in this order.
isr: what the interrupt handler can doprepare: setup before interactioncleanup: teardown/reset actions
Supported attacker atoms
Section titled “Supported attacker atoms”rst/rst_nzjin <label>create <ts, te, ds, de>timer_enable <n>start_counting <n>reti- instruction atoms:
nop,dint,mov ...,add ...,cmp ...,jmp ...,push ... - conditional macro:
ifz (<atom-list>) (<atom-list>)
Attacker sections support the same combinators (;, |, *, eps, parentheses).
Both branches of attacker ifz must be non-empty lists of atoms.
Nested ifz is not supported.
How specifications guide learning
Section titled “How specifications guide learning”TestDL expressions describe languages of permitted action sequences; they are not templates that ALVIE/Sancus emits all at once. During learning, ALVIE/Sancus replays the current input/output history and offers only actions that can still extend a sequence accepted by the active expression:
a; brequiresabeforeb;a | bpermits either branch;a*permits zero or more repetitions;epspermits an empty body or choice branch;- parentheses control grouping.
The observed Sancus behavior selects which section is active:
| Active section | Inputs ALVIE/Sancus may generate | Typical transition |
|---|---|---|
prepare | attacker actions from prepare | jin/jump-in enters enclave |
enclave | victim actions from enclave | an interrupt enters isr; jump-out/reset enters cleanup |
isr | attacker actions from isr | reti resumes enclave or enters cleanup, depending on the return mode |
cleanup | attacker actions from cleanup | reset starts a new prepare phase |
An action written in another section is therefore not available merely because it occurs somewhere in the combined specification.
Within the active section, ALVIE/Sancus uses the derivative of the expression after the existing prefix and discards actions whose derivative has an empty language.
Every section is code that stays in memory, so a section that runs again runs the same instructions.
The enclave runs again after a jump-in or a reti, the isr after each interrupt, and cleanup after each jump-out (for example when cleanup re-enters the enclave with reti or jin).
When a section runs again, ALVIE/Sancus replays the actions of its longest earlier run, and offers new actions only after that run ends.
For example, with cleanup { (nop | reti); nop }, if the first run of cleanup chose reti, a second run of cleanup must start with reti too.
The same holds after a reset, which runs prepare again, and after a reti that re-enters the enclave where the timer last interrupted it: the enclave then runs the code it ran from that point the first time.
The rules that move a test between sections are in alvie/code/plugins/sancus/phases.yaml (see the Plugin Files Reference).
Illegal or unsupported observations invalidate the current generated path; reset, jump-in, jump-out, interrupt-handle, and reti observations update the active section as described above.
This is how .atdl and .etdl files limit both the learner’s alphabet and the order in which inputs can be queried.
Operands and registers
Section titled “Operands and registers”The parser accepts:
- registers:
r0tor14 - source operands:
rX,@rX,&label,#imm,? - destination operands:
rX,&rX,&label
Labels and symbolic immediates use letters, digits, _, and -.
Decimal timer arguments must be in 0..65535.
The ? source operand is supported in enclave instructions, where --secret expands it before code generation; do not use an unexpanded ? in attacker actions.
Examples:
mov #42, &data_scmp ?, r4jmp #enc_e
Creating or modifying a specification
Section titled “Creating or modifying a specification”- Start from
spec-lib/example/attacker.atdlandspec-lib/example/enclave.etdl(or another existing attacker/enclave pair inspec-lib/). - Encode victim behavior in
enclave { ... };using choices and sequences. - Encode attacker setup in
prepare, interrupt behavior inisr, cleanup incleanup. - If enclave uses
?, run with--secret <value>. - Learn and verify with existing scripts (
learn_one.sh,check_one.sh) or direct CLI commands.
Concrete syntax example
Section titled “Concrete syntax example”enclave.etdl:
enclave { cmp ?, r4; ifz (mov #42, &data_s; nop) (nop; mov #1, &data_s); jmp #enc_e};attacker.atdl:
isr { reti};
prepare { timer_enable 4; create <enc_s, enc_e, data_s, data_e>; jin enc_s};
cleanup { nop};To run a small checked-in example using the same syntax, start in alvie/code/ and execute:
dune exec bin/learn.exe -- \ --att-spec ../../spec-lib/example/attacker.atdl \ --encl-spec ../../spec-lib/example/enclave.etdl \ --res /tmp/alvie-testdl-example.dot \ --tmpdir /tmp/alvie-testdl-example \ --secret 0 \ --commit bf89c0b \ --sancus ../../sancus-core-gap \ --oracle randomwalk \ --step-limit 500 \ --reset-probability 0.09--att-spec and --encl-spec select the two TestDL files.
--secret 0 expands their victim-side ? operands, while --oracle randomwalk selects a bounded equivalence oracle.
--step-limit bounds each equivalence search, and --reset-probability controls how often it abandons the current exploration path.
--tmpdir contains generated programs and simulator artifacts, and --res receives the learned DOT model.
See the Executables Reference for every learner option.
Reference specifications in this repository
Section titled “Reference specifications in this repository”- Complete attacker profile:
spec-lib/complete.atdl - Attack-focused profiles:
spec-lib/b1.atdl,spec-lib/b2.atdl,spec-lib/b3.atdl,spec-lib/b4.atdl,spec-lib/b6.atdl,spec-lib/b7.atdl,spec-lib/b8.atdl,spec-lib/b9.atdl - Enclave baseline:
spec-lib/enclave-complete.etdl - Example pair:
spec-lib/example/attacker.atdl,spec-lib/example/enclave.etdl
Constraints
Section titled “Constraints”A specification can also state constraints between sections, in a constraint block in either file:
constraint { disjoint(writes(isr), reads(enclave)) };This one lets the ISR write no register that the enclave reads.
The attributes reads and writes are the registers in the source and destination operands of an instruction (for &rN, the register counts as written).
subset(writes(isr), {r12, r13}) limits the registers that the ISR writes to r12 and r13.
See Constraints for the rules.
Troubleshooting
Section titled “Troubleshooting”- Parser errors usually come from missing
;, missing section headers, or out-of-range registers. The message gives the file, line and column, and what was expected there, for exampleenclave.etdl:1:20: 15 is out of range: expected an integer from 0 to 14. ?is valid in enclave instructions; ensure a secret is provided when needed.- If
timer_enable/interrupt scheduling is not desired, use the CLI option to ignore interrupts.