Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Skip to content
BoardRunner

The execution pipeline

FastDyn turns a description of an experiment into an executable firmware environment. The same run can combine a firmware image, peripheral models, instruction-triggered interventions, observation plugins, and a physics backend. The central design choice is to prepare as much information as possible on the host, then give the native execution engine a compact description of what to do.

This creates three useful places to work: configuration describes the experiment; host preparation resolves firmware facts and builds instrumentation; execution runs the guest and applies the prepared behavior. A feature can use one or several of these stages without becoming a special case in the command-line frontend.

From a configuration to an experiment

flowchart TD
    A["TOML or Python run request"] --> B["Machine and CPU configuration"]
    B --> C["Enabled run preprocessors"]
    C --> D["Shared firmware analysis"]
    D --> E["Generated rules and artifacts"]
    B --> F["User virtuals and modifiers"]
    E --> G["Resolve and validate virtual rules"]
    F --> G
    G --> H["Patched QEMU and FastDyn plugin"]
    H --> I["Guest execution"]
    I --> J["Peripheral and physics interactions"]
    I --> K["Observations and interventions"]
    J --> I
    K --> L["Run artifacts"]

The Python run API and CLI share the run machinery. Configuration parsing builds the machine, CPU, memory, device, and plugin settings. The frontend prepares the work directory, optional FMU inputs, and other run resources before launching QEMU.

An enabled run preprocessor receives its own configuration table and a RunContext. It can query the firmware, write a schema or manifest, and return generated virtual instructions. Function Counter, for example, selects ELF function entries and generates one hook per selected entry. Introspection determines RTOS hooks and prepares a schema for the native walker.

FastDyn combines these generated hooks with explicit user rules and rules loaded through existing_config_path. It resolves trigger addresses, performs any per-virtual preparation, checks declared capabilities, and rejects conflicting virtual callbacks at a PC. Identical virtual rules are deduplicated. Modifiers have a separate serialization path and exact-line deduplication.

The resulting rule files are runtime inputs, not edits to the firmware:

Location under the work directoryRole
virtuals/virtuals.txtPrepared trigger PCs, callback names, and argument strings
virtuals/modifiers.txtPrepared inline state-update rules
virtual-artifacts/Data produced by individual virtual preprocessors
run-artifacts/<plugin>/Run-plugin schemas, manifests, observations, and final results

Native plugins resolve their own artifact names through the runtime SDK. A plugin therefore does not need to add a QEMU command-line option for each generated file.

What happens during translation

QEMU translates guest instructions into host-executable code in translation blocks. FastDyn's block-translation callback inspects the guest instruction addresses in a block and installs the configured instrumentation at matching PCs.

Virtual instructions and modifiers use two common execution mechanisms:

MechanismInstalled during translationAction when the guest reaches the PC
Virtual instructionAn instruction execution callbackInvoke the registered native C behavior
ModifierA specialized inline operation in the patched QEMU pathUpdate the configured register or memory state

The translation callback prepares instrumentation; it does not execute a firmware event merely because a block was translated. The installed action runs when the translated guest instruction executes, including subsequent executions of a cached block. This distinction matters for loops, counters, interrupts, and timing experiments.

The native core registers instrumentation in the following order within its instruction loop: coverage/register logging, a virtual callback, specialized inline I/O, modifiers, and legacy detours. This describes the current implementation's registration order. It is not a substitute for checking the semantics of overlapping interventions, especially interventions that change control flow.

Manual and automatic inline I/O

FastDyn already contains a specialized path that associates a known guest PC with an inline I/O load or store. [Machine].finline selects a user-supplied access-map file; the frontend forwards that path to the native parser. Each parsed record contains a PC, read/write direction, device name, offset, and register. The translation callback then installs QEMU_PLUGIN_INLINE_LOAD_IO or QEMU_PLUGIN_INLINE_STORE_IO.

This manual implementation addresses a global gpio_memory[0x400] buffer. The record's device name is parsed but does not choose a separate device backing block in this path. An inline hook executes before the original instruction; replacing an MMIO operation also requires a separately validated control-flow action that suppresses that original access. The inline device modeling chapter explains the backend semantics and a manual lab pinned to 5b8bf3d.

Revision e44dca2edbc3b32cb1f2a48d3d0be203bd9b5576 adds experimental automatic MMIO optimization through the mmio_opt run plugin. Model compilation produces a bounded operation descriptor, while host preparation discovers candidate firmware loads through shared constant propagation. The runtime reads that plan during plugin initialization and defers instance binding until after dev_init, before guest translation. It then registers typed replacements against each resolved elder instance's live allocation. This uses the public post-device-init lifecycle and runtime SDK and the optimizer's native binder.

The patched Cortex-M translator emits the model expression as one arm of the original scalar load, with a live address guard and MPU fallback. It does not use the manual array or a PC-skipping modifier. The initial host gate requires a single Cortex-M CPU and disables substitution for its declared incompatible capabilities. Automatic MMIO optimization documents conservative effect admission, model ABI 2, original-fault fallback, and observer-safe execution; the host gate and QEMU patch define the implemented scope.

Other translated hot paths

The same current QEMU patch series also adds two independent execution-path optimizations. The ordinary MMIO exporter supplies a scalar saved PC directly to version-2 device callbacks, avoiding the old allocating register-read path; this does not optimize or bypass the device model. An eligible constant ARM32-PC modifier uses QEMU's direct TB chaining instead of the general PC-modifier exit, with conservative fallback when chaining is unsafe. Neither feature changes the TOML rule grammar, and neither makes a particular arbitrary firmware faster by itself. See Hot-path optimization contracts.

Runtime models and observations

During ordinary peripheral execution, device dispatch handles the configured accesses. Runtime plugins may observe MMIO after dispatch, react to guest IRQ events, inspect translated blocks, or install prepared PC callbacks. An optimized access that bypasses dispatch has a different observation boundary, covered in the automatic-MMIO chapter. Physics integration exchanges actuator commands and simulated state through its selected backend. These interfaces allow a model, a tracer, and an experiment controller to coexist while retaining distinct responsibilities.

Results remain in the work directory. Some artifacts, such as Introspection's activity log, are updated during execution. Others, such as Function Counter's final sorted totals, depend on normal shutdown callbacks. Stop a run cleanly when its result contract includes exit-time output.

Architecture is a property of each layer

The execution framework is not synonymous with Cortex-M. FastDyn exposes register/ABI headers for ARM32, Cortex-M, AArch64, RV64, and x86-64, and the source includes architecture-specific configurations and adapters. Individual analyses have their own scope: the shared instruction decoder, VariableWatch's candidate analysis, and ObjectSan's planner currently require ARM Thumb/M-profile.

Select the guest architecture, machine, CPU, instruction mode, and plugin together. An execution backend supporting an architecture does not imply that every analysis or peripheral model supports it.

Source guide