Expand description
Reverie is a user space system-call interception framework for Linux. It can be used to intercept, modify, or elide a syscall before the kernel executes it.
Reverie is the instrumentation layer for Hermit.
For the command-line interface, see hermit-run.
For background, see Hermit: Deterministic Linux for Controlled Testing and Software Bug-finding.
Reverie consists of a family of crates:
reverie(this one): Primarily provides theTooltrait interface that Reverie tools must implement to intercept syscalls. It also defines theBackendtrait, which is the contract a backend implementation must satisfy in order to run an arbitrary tool.reverie-ptrace: The backend that uses ptrace to intercept syscalls. This is currently the only non-experimental backend and is the reference implementation of theBackendcontract. In the future, we may have a backend that uses binary rewriting to intercept syscalls within the guest process.reverie-syscalls: Provides typed syscalls, which provide safer and more ergonomic access to the arguments of a syscall. Also provides pretty printing of syscalls and their arguments.
The rest of the reverie-* crates are used in service to the above crates.
§Tools and backends
There are two sides to every Reverie program:
- A
Tooldecides what to do when the guest hits a trappable event. This is what most users write; see theTooltrait for the full handler API. - A
Backenddecides how those events are trapped and how the tool is run against a live guest process tree (spawning, syscall interception, hosting global state, teardown).reverie-ptraceis the reference backend; theBackendtrait spells out exactly what any alternative backend must provide.
For examples of usage, please see the reverie-examples folder.
See also README.md for a high-level overview of Reverie.
Re-exports§
pub use reverie_process as process;pub use reverie_syscalls as syscalls;pub use backend_stats::*;
Modules§
- backend_
stats - Common, lazily collected statistics for Reverie backends.
- pmu
- Processor-specific PMU event settings shared by execution backends.
- vdso
- Every function the Linux vDSO exports, with what it reads and what a backend does with it.
Structs§
- Auxv
- Represents the auxv table of a process.
- Backend
Child Wait Event - A backend-observed child waitability decision.
- Backend
Failure - The location of a fatal backend failure. The backend retains its typed cause;
this notification only ends dependent waits and must not invent guest status.
Host-side ordinary-ptrace capture failures use the run root’s PID/TID with
a
ptrace stdout captureorptrace stderr capturephase. Those locations identify the host run owner, not an inferred guest writer or guest failure. - Backend
Process Retirement - Final descriptor cleanup and worker joins for one exact process lifetime.
- Backend
Signal Control - The single run-level installation carries both publication and selection.
- Backtrace
- A backtrace is a list of stack frames. These stack frames may have originated from a remote process.
- Callback
Signal Site - Exact callback and unconsumed syscall boundary eligible for parked observation.
- Child
Exit Completion - A scheduler-authorized terminal child transition.
- Child
Exit Publication - Receipt for an irreversible child-completion publication.
- CpuId
Result - CPUID result. Low-level data-structure to store result of cpuid instruction.
- Dequeue
Id - Identity allocated once at removal, never at publication or delivery.
- Detlog
Memory Region - A guest-address-space memory region a backend can expose for deterministic
memory-map logging (
--detlog-stack/--detlog-heap). - Dispatch
Counters - Counts of intercepted guest events by the route that delivered them.
- Dispatch
Stats - The shared end-of-run dispatch record for one backend run.
- Errno
- Frame
- A stack frame.
- Into
Guest - Wraps a
Guest<T>such that it implementsGuest<U>. - Location
- The location of a symbol.
- Parked
Observation Lease - Scheduler-issued identity echoed by RPCs during one nested observation.
- Parked
Signal Failure Context - Identifies a retained effect ledger through caught handoff and cancellation.
- Parked
Signal Observation - Actual observation effects; this does not settle any scheduler wait.
- Pid
- A process ID (PID).
- Prepared
Signal Token - Backend-owned single-use selected event, awaiting frame/default-action delivery.
- Pretty
Backtrace - A backtrace with file and line information. This is more heavy-weight than a normal backtrace.
- Pretty
Frame - A stack frame with debugging information.
- Process
Alarm Signal Receipt - State captured when a process-alarm pending operation commits.
- Process
Dispatch Stats - The counters attributed to one guest process.
- Process
Signal Publication - An actual process-pending publication; it says nothing about recipient masks.
- Rdtsc
Result - Result returned by
Tool::handle_rdtsc_event. - RegDisplay
Options - Options for how
libc::user_regs_structcan be formatted for thestd::fmt::Displayimplementation. - Signal
Boundary Receipt - A consuming notification, not an ordinary scheduler resource request.
- Signal
Delivery Permit - Authorization for one task’s actual return-to-user selection.
- Signal
Dequeue - An irreversible pending-state removal with its original complete metadata.
- Signal
Event - A signal selected for deterministic delivery to one stopped guest thread.
- Signal
Process Id - A process lifetime, independent of PID reuse and disposition generations.
- Signal
Recipient - One eligible task in an authoritative, process-transaction snapshot.
- Signal
Task Identity - A live task identity, available before its first guest instruction.
- Site
Counters - Counts of distinct instrumentation sites.
- Subscription
- A set of events to subscribe to.
- Symbol
- A symbol from a frame.
Enums§
- Backend
Child Wait State - A child state and waitability decision observed by an execution backend.
- Backend
Signal Control Mode - Whether the Tool takes responsibility for recipient selection.
- Child
Exit Publication Effect - Effect committed by one child-completion publication.
- Child
Exit Publication Result - Complete result of publishing one scheduler-authorized child completion.
- Child
Exit Signal Disposition - Receiver state after accepting one process-directed child-exit event.
- Child
Exit Signal Error Kind - Why a child-exit event was refused before changing backend state.
- Child
Exit Signal Outcome - Complete result of a backend’s child-exit pending-state operation.
- Detlog
Region Kind - The logical kind of a guest memory region reported by
Guest::detlog_memory_regions. - Error
- A general error.
- Exit
Status - Describes the result of a process after it has exited.
- Pending
Domain - The pending queue actually selected, preserved through Tool replacement.
- Process
Alarm Signal Disposition - Current disposition of a process-pending alarm, before Tool filtering.
- Process
Alarm Signal Error Kind - Why a process-alarm operation was refused without changing backend state.
- Process
Alarm Signal Outcome - Complete result of publishing a process-pending SIGALRM.
- Process
Signal Publication Result - Publication errors retain the boundary between no effect and committed effect.
- Rdtsc
- Rdtsc/Rdtscp request.
- Signal
- Types of operating system signals
- Signal
Boundary Outcome - Actual completion of a permitted boundary, before guest entry.
- Signal
Consumer - The operation that actually removed a pending event.
- Signal
Observation Failure - Distinguishes refusal from a failure after irreversible removal.
- Signal
Observation Step - Committed selection outcomes, in their real dequeue order.
- Signal
Observation Stop - Why a sequential parked observation finished.
- Signal
Target - Identifies both the selected guest task and whether a signal was originally process-directed or thread-directed.
- Thread
Ownership - Who owns a guest thread: the single axis that governs both how the thread
executes and who owns its thread-synchronization primitives (
futex,CLONE_CHILD_CLEARTID). - Timer
Schedule - Options for scheduling a timer event.
Constants§
- DISPATCH_
STATS_ SCHEMA_ VERSION - Version of the serialized
DispatchStatslayout. - PERF_
EVENT_ SIGNAL - signal used by reverie perf counter timer.
- SIGNAL_
INFO_ SIZE - Size of Linux’s userspace
siginfo_trepresentation on supported targets. - SKID_
OVERSHOOT_ MARKER - The single, greppable marker emitted to stderr whenever an RCB-fallback
preemption path overshoots its programmed target by more than the configured
skid margin. This is the one canonical shape of the overshoot signal, and
it lives in the backend-agnostic
reveriecrate so every layer that can detect an overshoot — thereverie-ptraceprecise single-step guard and hermit’s detcorereport_rcb_overshootlog-and-continue path alike — emits exactly this token. A downstream harness then has a single string to grep for.
Traits§
- Backend
- A Reverie backend: a swappable implementation of process supervision and
event interception, equivalent in role to
reverie-ptrace. - GlobalRPC
- A handle to send messages to the global state (potentially a remote, inter-process communication).
- Global
Tool - The global half of a complete Reverie tool.
- Guest
- A representation of a guest task (thread).
- Process
Signal Control - Shared run-owned facade. Implementations must not retain a Tool or Guest.
- RegDisplay
- Trait providing reusable display formatting for registers
- Stack
- A low-level stack which stores untyped (but Sized) values
- Tool
- A trait that every Reverie tool must implement. The primary function of the tool specifies how syscalls and signals are handled.
Functions§
- record_
skid_ overshoot - Record that a skid overshoot was detected. Called at every overshoot-detection
site (the
reverie-ptraceprecise single-step guard and hermit’s detcorereport_rcb_overshootlog-and-continue path) alongside theSKID_OVERSHOOT_MARKERemission. Cheap and lock-free; the overshoot path is rare. - take_
skid_ overshoot_ count - Atomically read and reset the recorded skid-overshoot count. The in-process supervisor calls this after each verify run to attribute overshoots per run; resetting to zero keeps the two runs’ counts disjoint.
Type Aliases§
- Never
Nevertype is a stopgap for the unstable!type (i.e., the never type).- Tid
- The identifier for a specific thread, corresponding to the output of gettid. In many cases, Linux blurs the Pid/Tid distinction, but Reverie should consistently use TIDs when referring to threads, and Pids when referring to shared address spaces that (typically) correspond to processes.
Attribute Macros§
- backend
- Required for
impl Backend for MyBackendblocks. - global_
tool - Required for
impl GlobalTool for MyGlobalToolblocks. - tool
- Required for
impl Tool for MyToolblocks.