Skip to documentation
SLOP

tiny.machine.checkpoint

Reference tiny.machine checkpoint

Defined in tiny.machine.

A program running under a virtual machine has to be halted and turned into a value that carries a name, and a run has to be started again from that value later.

API (44)

Actions

Public operations.

Types and contracts

Public types and contracts.

Namespaces

Public namespaces.

Values and defaults

Public values and defaults.

No direct callersNo direct callstiny.machinecheckpoint
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/machine/src/checkpoint/owner/state.zig:77

zig
/// An exclusive publication claim for caller-filled memory. The caller aborts/// an active claim when the fill stops part way. Publication consumes the/// active claim.pub const Materialization = struct {    storage: *Storage,    ram: []align(layout.page_bytes) u8,    active: bool = true,};

Source: lib/machine/src/checkpoint/owner/state.zig:69

zig
/// The result of crash recovery. A published result carries a handle borrowing/// the supplied storage and memory. By contrast, an empty result means the/// storage holds nothing and can take a publication.pub const Recovery = union(enum) {    empty,    published: Checkpoint,};

Source: lib/machine/src/checkpoint/owner/types.zig:59

zig
/// The authenticated metadata that checkpoint inspection returns. The value/// carries the checkpoint root, the memory digest, and the material.pub const Contents = struct {    root: Root,    memory: MemoryDigest,    material: Material,};

Source: lib/machine/src/checkpoint/owner/types.zig:41

zig
/// A checkpoint root together with the digest of its settled receipt. The/// `root` field authenticates the checkpoint state. The `semantic` field/// identifies the settled execution receipt. Restore and world boundaries carry/// this pair.pub const Identity = struct {    root: Root,    semantic: os.abi.Digest,};

Source: lib/machine/src/checkpoint/owner/types.zig:50

zig
/// Holds what a restore needs to recompute a checkpoint identity and start/// execution again: the profile fingerprint, the settled receipt, the CPU/// restart frame, and the immutable image descriptor. The value has a fixed/// size and owns no external storage.pub const Material = struct {    profile: profile.ProfileFingerprint,    receipt: instance_receipt.SemanticReceipt,    cpu: CpuState,    immutable_image: core.provenance.ImmutableImage,};

Source: lib/machine/src/checkpoint/source.zig:7

zig
/// Verified identity and material prepared for building a machine from a/// capture.pub const Prepared = struct {    identity: checkpoint.Identity,    material: checkpoint.Material,};

Source: lib/machine/src/checkpoint/source.zig:17

zig
/// Borrowed capture used as the source of a restore. A durable source/// references a complete normalized memory image. By contrast, a hot source/// references ordered changed pages against a durable parent. The caller keeps/// the selected checkpoint or snapshot alive for as long as the source can be/// used.pub const Source = union(enum) {    durable: *const checkpoint.Checkpoint,    hot: *const hot.Snapshot,    /// Checks the selected source and hands back the identity it would restore.    pub fn identity(self: @This()) checkpoint.Error!checkpoint.Identity {        return switch (self) {            .durable => |value| value.identity(),            .hot => |value| value.identity(),        };    }    /// Verifies the source and the expected checkpoint root before a machine is    /// constructed. A stored root other than the expected one returns    /// `CheckpointRootMismatch`. The destination must have `ram_alignment` and    /// `ram_bytes`. A hot source further requires the destination to hold    /// parent memory that has been authenticated.    pub fn prepareForRestore(        self: @This(),        expected: checkpoint.Root,        destination: []align(checkpoint.ram_alignment) const u8,    ) checkpoint.Error!Prepared {        return switch (self) {            .durable => |value| durable: {                const contents = try checkpoint.inspect(value);                if (!std.meta.eql(contents.root, expected)) {                    return error.CheckpointRootMismatch;                }                if (destination.len != checkpoint.ram_bytes) {                    return error.RamBytesMismatch;                }                break :durable .{                    .identity = try checkpoint.identify(                        contents.material,                        contents.memory,                    ),                    .material = contents.material,                };            },            .hot => |value| .{                .identity = try value.prepareForRestore(expected, destination),                .material = value.material,            },        };    }    /// Fills a caller-owned memory region that lies outside the source and    /// returns the restore material. A durable source copies the whole memory    /// image. By contrast, a hot source overlays its ordered changed pages on    /// authenticated parent memory. A failure after the copying starts can    /// leave the destination bytes changed.    pub fn materializeForRestore(        self: @This(),        expected: checkpoint.Root,        destination: []align(checkpoint.ram_alignment) u8,    ) checkpoint.Error!checkpoint.Material {        return switch (self) {            .durable => |value| checkpoint.materializeForRestore(                value,                expected,                destination,            ),            .hot => |value| (try value.materializeForRestore(                expected,                destination,            )).material,        };    }    /// Returns the complete memory image used as the source's evidence. A hot    /// source returns its durable parent's normalized memory.    pub fn evidenceRam(        self: @This(),    ) []align(checkpoint.ram_alignment) const u8 {        return switch (self) {            .durable => |value| value.ram,            .hot => |value| value.evidenceRam(),        };    }    /// Reports whether bytes overlap any handle, metadata, memory, index, or    /// page storage the source borrows.    pub fn aliases(self: @This(), bytes: []const u8) bool {        return switch (self) {            .durable => |value| buffersOverlap(bytes, std.mem.asBytes(value)) or                buffersOverlap(bytes, &value.storage.bytes) or                buffersOverlap(bytes, value.ram),            .hot => |value| value.aliases(bytes),        };    }};

Source: lib/machine/src/checkpoint/owner/identity.zig:24

zig
/// Requires a child and its parent to share the profile fingerprint, the/// immutable image descriptor, and the execution fingerprint. The call returns/// the error naming the field that differs: `ParentProfileMismatch`,/// `ParentImageMismatch`, or `ParentExecutionMismatch`.pub fn validateParent(child: types.Material, parent: types.Material) Error!void {    if (!std.meta.eql(child.profile, parent.profile)) {        return error.ParentProfileMismatch;    }    if (!std.meta.eql(child.immutable_image, parent.immutable_image)) {        return error.ParentImageMismatch;    }    if (!std.meta.eql(        child.receipt.execution_fingerprint,        parent.receipt.execution_fingerprint,    )) {        return error.ParentExecutionMismatch;    }}

Source: lib/machine/src/checkpoint/owner/memory.zig:69

zig
/// Captures the pages of live memory that differ from a normalized parent/// image. The call writes strictly ascending page indices into the caller's/// index array and one matching 4096-byte page record into the caller's page/// array. Page tables, the boot frame, the transport rings, and the stack keep/// their parent bytes, and no captured index names one of those pages. The two/// output slices must be disjoint from each other and from both memory images,/// and each index slot has exactly one aligned page waiting for it in the page/// array. Every failure, including too few index slots, happens before any/// output byte is written. The call returns the child memory digest and the/// number of changed pages.pub fn captureDelta(    parent: []align(layout.page_bytes) const u8,    current: []align(layout.page_bytes) const u8,    image: provenance.ImmutableImage,    indices: []u16,    pages: []align(layout.page_bytes) u8,) Error!Delta {    try validateDeltaStorage(indices, pages);    try validateCaptureAliases(parent, current, indices, pages);    try validateLive(current, image);    try validateNormalizedMemory(parent, image);    var dirty = DirtyPageSet.empty;    const facts = deltaFacts(parent, current, &dirty);    if (facts.page_count > indices.len) return error.DeltaCapacityExceeded;    fillDelta(current, indices, pages, &dirty);    return facts;}
Called byCallstest sourcelib.machine.src.checkpoint.owner.memorytest: capture delta matches the pre-f...test sourcelib.machine.src.checkpoint.owner.memorytest: capture delta refuses capacity ...private sourcelib.machine.src.checkpoint.owner.memorydeltaFactsprivate sourcelib.machine.src.checkpoint.owner.memoryfillDeltaprivate sourcelib.machine.src.checkpoint.owner.memoryvalidateCaptureAliasesprivate sourcelib.machine.src.checkpoint.owner.memoryvalidateDeltaStorageprivate sourcelib.machine.src.checkpoint.owner.memoryvalidateLiveprivate sourcelib.machine.src.checkpoint.owner.memoryvalidateNormalizedMemorycheckpointcaptureDelta
Static calls · unresolved targets: 1 · external targets: 0.

Source: lib/machine/src/checkpoint/owner/memory.zig:94

zig
/// Computes the memory digest that one ordered set of changed pages produces/// over a parent memory image. Indices must be strictly ascending, so each page/// appears once, and each supplied page must differ from the parent page at its/// index. An index naming a page table, the boot frame, a transport ring, or/// the stack is rejected. The page array measures 4096 bytes for each index/// supplied. A rejected index returns `DeltaIndicesInvalid`, and a wrong/// page-array length returns `DeltaStorageMismatch`.pub fn deltaDigest(    parent: []align(layout.page_bytes) const u8,    indices: []const u16,    pages: []align(layout.page_bytes) const u8,) Error!types.MemoryDigest {    try layout.validateRamBytes(parent.len);    try validateDeltaStorage(indices, pages);    try validateDelta(parent, indices, pages);    return overlayDigest(parent, indices, pages);}
Called byCallstest sourcelib.machine.src.checkpoint.owner.memorytest: dirty page digest equals a full...test sourcelib.machine.src.checkpoint.owner.memorytest: dirty page digest rejects nonca...private sourcelib.machine.src.checkpoint.owner.memoryoverlayDigestprivate sourcelib.machine.src.checkpoint.owner.memoryvalidateDeltaprivate sourcelib.machine.src.checkpoint.owner.memoryvalidateDeltaStorageprivate sourcelib.machine.src.instance.layoutvalidateRamBytescheckpointdeltaDigest
Static calls · unresolved targets: 1 · external targets: 0.

Source: lib/machine/src/checkpoint/owner/memory.zig:110

zig
/// Rejects any changed page overlapping a load range of the immutable image./// The call validates the image descriptor before reading its load ranges, and/// an overlapping page returns `DeltaIndicesInvalid`. A caller uses this/// validation to keep a changed page from rewriting the kernel image a capture/// claims to have run.pub fn validateDeltaImage(    indices: []const u16,    image: provenance.ImmutableImage,) Error!void {    try provenance.validate(image);    for (indices) |page_index| {        const page_start = @as(u64, page_index) * layout.page_bytes;        const page_end = page_start + layout.page_bytes;        for (image.loads[0..image.load_count]) |load| {            const load_start = std.math.add(                u64,                os.boot.kernel.physical_base,                load.physical_offset,            ) catch return error.ImmutableLoadOutOfBounds;            const load_end = std.math.add(                u64,                load_start,                load.memory_bytes,            ) catch return error.ImmutableLoadOutOfBounds;            if (page_start < load_end and load_start < page_end) {                return error.DeltaIndicesInvalid;            }        }    }}
Called byCallstest sourcelib.machine.src.checkpoint.owner.memorytest: dirty pages cannot replace immu...private sourcelib.machine.src.instance.provenancevalidatecheckpointvalidateDeltaImage
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/machine/src/checkpoint/owner/memory.zig:37

zig
/// Checks that a memory image has the right length and normalized shape before/// hashing it into a memory digest. A length other than 67,108,864 bytes/// returns `RamBytesMismatch`, and page tables outside their canonical form, or/// a nonzero byte in the boot frame, either transport ring, or the kernel/// stack, returns `MemoryNotNormalized`.pub fn validatedDigest(    ram: []align(layout.page_bytes) const u8,    image: provenance.ImmutableImage,) Error!types.MemoryDigest {    try validateNormalizedMemory(ram, image);    return digest(ram);}
Called byCallscheckpointpublishMaterializedprivate sourcelib.machine.src.checkpoint.owner.stateverifyMaterialprivate sourcelib.machine.src.checkpoint.owner.memorydigestprivate sourcelib.machine.src.checkpoint.owner.memoryvalidateNormalizedMemorycheckpointvalidatedMemoryDigest
Static calls · unresolved targets: 1 · external targets: 0.

Source: lib/machine/src/checkpoint/owner/state.zig:53

zig
/// The failures of durable publication, ownership, corruption, identity, and/// memory.pub const Error = error{    CheckpointClosed,    CheckpointCorrupt,    CheckpointRootMismatch,    CheckpointStorageInUse,    MemoryAliasesStorage,    SourceAliasesDestination,    StorageAliasesInstance,    StorageAliasesOwner,    StorageAliasesRam,    RamBytesMismatch,} || identity.Error || instance_receipt.Error || memory.Error || provenance.Error;

Source: lib/machine/src/checkpoint/owner/state.zig:200

zig
/// Claims empty storage for memory that another source will fill. The storage/// and the memory lie apart from each other and carry the sizes the call/// requires. An existing claim or publication returns `CheckpointStorageInUse`.pub fn beginMaterialization(    storage: *Storage,    ram: []align(layout.page_bytes) u8,) Error!Materialization {    try validateStoredInputs(storage, ram);    const owner = ownerState(storage);    if (owner.status.cmpxchgStrong(        @backingInt(Status.empty),        @backingInt(Status.capturing),        .acq_rel,        .acquire,    ) != null) return error.CheckpointStorageInUse;    return .{ .storage = storage, .ram = ram };}
Called byCallsNo direct callersprivate sourcelib.machine.src.checkpoint.owner.stateownerStateprivate sourcelib.machine.src.checkpoint.owner.statevalidateStoredInputscheckpointbeginMaterialization
Static calls · unresolved targets: 1 · external targets: 1.

Source: lib/machine/src/checkpoint/owner/state.zig:381

zig
/// Requires initialized storage to be empty. Storage already in use returns/// `CheckpointStorageInUse`, and a malformed status byte returns/// `CheckpointCorrupt`. The caller checks storage before starting work that/// would waste it.pub fn ensureAvailable(storage: *const Storage) Error!void {    if (try checkedStatus(ownerStateConst(storage)) != .empty) {        return error.CheckpointStorageInUse;    }}
Called byCallsNo direct callersprivate sourcelib.machine.src.checkpoint.owner.statecheckedStatusprivate sourcelib.machine.src.checkpoint.owner.stateownerStateConstcheckpointensureAvailable
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/machine/src/checkpoint/owner/state.zig:474

zig
/// Validates the CPU restart frame and the settled receipt, then computes the/// restore identity from the material and a memory digest.pub fn identify(    material: types.Material,    memory_digest: types.MemoryDigest,) Error!types.Identity {    const state_digest = try identity.state(        material.receipt,        material.cpu,        material.immutable_image,        memory_digest,    );    return .{        .root = identity.root(material.profile, state_digest),        .semantic = try instance_receipt.semanticReceiptDigest(material.receipt),    };}
Called byCallsprivate sourcelib.machine.src.checkpoint.owner.stateverifyMaterialprivate sourcelib.machine.src.checkpoint.owner.identitystatecheckpointidentify
Static calls · unresolved targets: 0 · external targets: 2.

Source: lib/machine/src/checkpoint/owner/state.zig:452

zig
/// Rebuilds each identity a checkpoint carries, then returns the metadata it/// has authenticated.pub fn inspect(checkpoint: *const Checkpoint) Error!types.Contents {    const storage = checkpoint.storage;    const source = checkpoint.ram;    try validateStoredInputs(storage, source);    const owner = ownerStateConst(storage);    if (try checkedStatus(owner) != .published) {        return error.CheckpointClosed;    }    if (!owns(checkpoint, owner)) return error.CheckpointClosed;    const material = storedMaterial(owner);    const memory_digest = owner.memory_digest;    const root_value = owner.root;    try verifyMaterial(material, memory_digest, root_value, source);    return .{        .root = root_value,        .memory = memory_digest,        .material = material,    };}
Called byCallsprivate sourcelib.machine.src.checkpoint.owner.stateinspectForRestoreprivate sourcelib.machine.src.checkpoint.owner.statecheckedStatusprivate sourcelib.machine.src.checkpoint.owner.stateownerStateConstprivate sourcelib.machine.src.checkpoint.owner.stateownsprivate sourcelib.machine.src.checkpoint.owner.statestoredMaterialprivate sourcelib.machine.src.checkpoint.owner.statevalidateStoredInputsprivate sourcelib.machine.src.checkpoint.owner.stateverifyMaterialcheckpointinspect
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/machine/src/checkpoint/owner/state.zig:417

zig
/// Checks a durable checkpoint against `expected`, writes its normalized memory/// into an aligned destination that lies outside the checkpoint's own regions,/// and returns the restore material. Bytes already written stay in the/// destination when the closing check fails.pub fn materializeForRestore(    checkpoint: *const Checkpoint,    expected: types.Root,    destination: []align(layout.page_bytes) u8,) Error!types.Material {    const storage = checkpoint.storage;    const source = checkpoint.ram;    try validateStoredInputs(storage, destination);    if (buffersOverlap(source, destination)) {        return error.SourceAliasesDestination;    }    const material = try inspectForRestore(checkpoint, expected);    const owner = ownerStateConst(storage);    const memory_digest = owner.memory_digest;    const root_value = owner.root;    @memcpy(destination, source);    try verifyMaterial(material, memory_digest, root_value, destination);    return material;}
Called byCallstest sourcelib.machine.src.checkpoint.owner.statetest: restore materialization rejects...private sourcelib.machine.src.checkpoint.owner.statebuffersOverlapprivate sourcelib.machine.src.checkpoint.owner.stateinspectForRestoreprivate sourcelib.machine.src.checkpoint.owner.stateownerStateConstprivate sourcelib.machine.src.checkpoint.owner.statevalidateStoredInputsprivate sourcelib.machine.src.checkpoint.owner.stateverifyMaterialcheckpointmaterializeForRestore
Static calls · unresolved targets: 1 · external targets: 0.

Source: lib/machine/src/checkpoint/owner/state.zig:391

zig
/// Opens a published checkpoint whose root is `expected`, checking the stored/// material and the memory image behind it. A stored root other than `expected`/// returns `CheckpointRootMismatch`. Ownership of the two regions stays with/// the caller, and the returned handle points at them.pub fn open(    storage: *const Storage,    ram: []align(layout.page_bytes) const u8,    expected: types.Root,) Error!Checkpoint {    try validateStoredInputs(storage, ram);    const owner = ownerStateConst(storage);    if (try checkedStatus(owner) != .published) {        return error.CheckpointClosed;    }    if (!std.meta.eql(owner.root, expected)) {        return error.CheckpointRootMismatch;    }    const checkpoint: Checkpoint = .{        .storage = storage,        .ram = ram,        .root_digest = expected.digest,    };    try checkpoint.verify();    return checkpoint;}
Called byCallscheckpointrecoverAfterCrashCheckpointverifyprivate sourcelib.machine.src.checkpoint.owner.statecheckedStatusprivate sourcelib.machine.src.checkpoint.owner.stateownerStateConstprivate sourcelib.machine.src.checkpoint.owner.statevalidateStoredInputscheckpointopen
Static calls · unresolved targets: 1 · external targets: 0.

Source: lib/machine/src/checkpoint/owner/state.zig:179

zig
/// Copies live memory into a separate caller-owned memory region, normalizes/// it, authenticates the material, and publishes one handle with a single/// atomic store. Both memory slices must have `ram_alignment` and `ram_bytes`./// The two slices must be disjoint from the storage and from each other. A/// failure after the storage is claimed returns that storage to empty. Copied/// or normalized bytes can sit in the destination after a failure.pub fn publish(    material: types.Material,    storage: *Storage,    source: []align(layout.page_bytes) const u8,    destination: []align(layout.page_bytes) u8,) Error!Checkpoint {    return switch (try publishUntil(        material,        storage,        source,        destination,        null,    )) {        .interrupted => unreachable,        .published => |checkpoint| checkpoint,    };}
Called byCallsNo direct callersprivate sourcelib.machine.src.checkpoint.owner.statepublishUntilcheckpointpublish
Static calls · unresolved targets: 1 · external targets: 0.

Source: lib/machine/src/checkpoint/owner/state.zig:234

zig
/// Authenticates caller-filled memory against the expected memory digest and/// the expected checkpoint root, then publishes it with a single atomic store./// An authentication failure after the claim is confirmed aborts the claim. On/// success, the returned handle points at the candidate's storage and memory.pub fn publishMaterialized(    candidate: *Materialization,    material: types.Material,    expected_root: types.Root,    expected_memory: types.MemoryDigest,) Error!Checkpoint {    if (!candidate.active) return error.CheckpointStorageInUse;    const owner = ownerState(candidate.storage);    if (try checkedStatus(owner) != .capturing) {        return error.CheckpointStorageInUse;    }    errdefer abortMaterialization(candidate);    try provenance.validateRam(material.immutable_image, candidate.ram);    const memory_digest = try memory.validatedDigest(        candidate.ram,        material.immutable_image,    );    if (!std.meta.eql(memory_digest, expected_memory)) {        return error.MemoryDigestMismatch;    }    const state_digest = try identity.state(        material.receipt,        material.cpu,        material.immutable_image,        memory_digest,    );    const root_value = identity.root(material.profile, state_digest);    if (!std.meta.eql(root_value, expected_root)) {        return error.CheckpointRootMismatch;    }    return switch (publishAuthenticated(        material,        owner,        candidate.storage,        candidate.ram,        memory_digest,        root_value,        null,    )) {        .interrupted => unreachable,        .published => |checkpoint| result: {            candidate.active = false;            break :result checkpoint;        },    };}
Called byCallsNo direct callersprivate sourcelib.machine.src.checkpoint.owner.identitystatecheckpointvalidatedMemoryDigestprivate sourcelib.machine.src.checkpoint.owner.stateabortMaterializationprivate sourcelib.machine.src.checkpoint.owner.statecheckedStatusprivate sourcelib.machine.src.checkpoint.owner.stateownerState+2 morecheckpointpublishMaterialized
Static calls · unresolved targets: 0 · external targets: 1.

Source: lib/machine/src/checkpoint/owner/state.zig:494

zig
/// Recovers caller-owned storage after a crash. An interrupted capture is reset/// to empty. Storage found published needs an expected root from the caller,/// and the call returns a handle it has verified. An invalid status, root,/// storage, or memory returns the matching error.pub fn recoverAfterCrash(    storage: *Storage,    ram: []align(layout.page_bytes) const u8,    expected: ?types.Root,) Error!Recovery {    try validateStoredInputs(storage, ram);    const owner = ownerState(storage);    return switch (try checkedStatus(owner)) {        .empty => .empty,        .capturing => result: {            reset(owner);            break :result .empty;        },        .published => .{ .published = try open(            storage,            ram,            expected orelse return error.CheckpointRootMismatch,        ) },    };}
Called byCallstest sourcelib.machine.src.checkpoint.owner.statetest: checkpoint recovery discards un...private sourcelib.machine.src.checkpoint.owner.statecheckedStatuscheckpointopenprivate sourcelib.machine.src.checkpoint.owner.stateownerStateprivate sourcelib.machine.src.checkpoint.owner.stateresetprivate sourcelib.machine.src.checkpoint.owner.statevalidateStoredInputscheckpointrecoverAfterCrash
Static calls · unresolved targets: 1 · external targets: 0.

Source: lib/machine/src/checkpoint/owner/state.zig:28

zig
pub const storage_alignment: usize = @alignOf(OwnerState);

Source: lib/machine/src/checkpoint/owner/state.zig:29

zig
pub const storage_bytes: usize = @sizeOf(OwnerState);

Source: lib/machine/src/checkpoint/owner/state.zig:517

zig
/// Confirms that an allocation made elsewhere for the metadata measures/// `storage_bytes` and nothing else.pub fn validateStorageBytes(bytes: usize) error{StorageBytesMismatch}!void {    if (bytes != storage_bytes) return error.StorageBytesMismatch;}
Called byCallsNo direct callersprivate sourcelib.machine.src.checkpoint.sourcebuffersOverlapcheckpoint.Sourcealiases
Static calls · unresolved targets: 0 · external targets: 1.

Source: lib/machine/src/checkpoint/root.zig

zig
//! A program running under a virtual machine has to be halted and turned into a//! value that carries a name, and a run has to be started again from that value//! later. The deterministic virtual machine this package runs, with a fixed//! memory size and a restricted kernel, is a *machine*.//!//! Callers want three things from such a value: restart a machine where it//! stopped, decide whether two runs reached the same state, and accept a//! capture from a party they have no reason to trust.//!//! The machine's fixed 67,108,864 bytes, addressed from zero, holding 16,384//! pages, is its *memory*. A region of 4096 contiguous bytes of a machine's//! memory, named by its zero-based index, is a *page*. The four memory regions//! carrying per-run transport and activation state are the *boot frame*,//! *request ring*, *event ring*, and *kernel stack*. A machine's memory holds//! per-run state in its page tables, boot frame, request ring, event ring, and//! kernel stack, so two runs that reached the same logical state hold different//! bytes there, and hashing memory as it stands would give one state two names.//! Memory alone leaves out where execution resumes, so a name over memory alone//! would let two different restart states share one name. A memory image is//! 67,108,864 bytes, so copying and hashing one per capture costs a full pass,//! and a machine captured repeatedly changes a small part of it between two//! captures. A capture can be interrupted part way, and a reader arriving//! afterwards has to tell a finished capture from an abandoned one.//!//! A hash tree yields one root digest over a large value and lets a changed//! region be rehashed along a single path (Merkle, 1979). A content-addressed//! object store keys each object by the digest of its bytes and shares the//! subtrees two versions have in common, as Git does for its trees.//!//! The complete binary tree over the 16,384 page digests, 14 levels deep, with//! each node binding its level to its two ordered child digests, is the *page//! tree*. From the first source, the code builds that page tree and runs a//! changed-page rebuild that walks one path per changed page. From the second//! source, the immutable root store keys pages, tree nodes, and manifests by//! digest, writes new objects only along the paths a capture changed, and//! reuses the parent's digests everywhere else.//!//! The in-place operation that rewrites page tables to their canonical form and//! zeroes the boot frame, request ring, event ring, and kernel stack is//! *normalization*. The memory image that normalization produces is *normalized//! memory*. Under the first departure, memory is normalized before it is//! hashed, which gives one logical state one name.//!//! Under the second departure, the name is layered. The SHA-256 identity of a//! normalized memory image, binding the page tree's root to the fixed memory//! geometry, is the *memory digest*, which names normalized memory. The record//! of a stopped machine boundary with activation authority removed, so one//! guest state keeps one identity across runs, is a *settled receipt*. The ten//! register values a restarted machine begins with, each fixed by the kernel//! manifest for one entry offset, form the *CPU restart frame*. The kernel//! image's digest, the initial CPU state it admits, its entry offset, and up to//! four load ranges placing image bytes in memory make up the *immutable image//! descriptor*. The SHA-256 identity of one restart state, committing the//! settled receipt, the CPU restart frame, the immutable image digest, and the//! memory digest, is the *state digest*. The machine configuration an execution//! ran under, identified by a profile fingerprint that is a SHA-256 digest, is//! an *execution profile*. The digest binding that profile fingerprint to the//! state digest is the *checkpoint root*.//!//! The borrowed value naming a published checkpoint's storage, memory, and root//! digest is the *handle*. Claiming empty storage, copying memory into the//! caller's second region, normalizing it, computing and writing the identity,//! and finishing with one atomic store that makes the handle visible is//! *publication*. Under the third departure, publication ensures that a crash//! leaves the storage either empty or holding a complete capture.//!//! Recomputing the memory, state, and root digests from the stored bytes and//! comparing them with the stored ones is *verification*. Under the fourth//! departure, verification occurs on every open, so a digest found in storage//! is checked before it is used.//!//! Captured machine execution state carrying an identity that any holder of the//! bytes can recompute is a *checkpoint*. A capture takes four forms over the//! same name. A checkpoint holding a complete normalized memory image, keeping//! its metadata and its page-aligned memory in two caller-owned regions, is a//! *durable checkpoint*. A checkpoint holding ordered changed pages against a//! durable parent is a *hot snapshot*, recorded by the `hot` namespace. The//! fixed 67,112,960-byte encoding of one durable checkpoint, consisting of a//! 4096-byte header followed by all normalized memory, is a *checkpoint//! stream*, encoded by the `stream` namespace. A caller-supplied//! content-addressed store that owns every stored byte and answers reads and//! writes by digest is a *provider*. The `roots` namespace stores pages and//! manifests as objects through such a provider.const owner = @import("owner/root.zig");const profile = @import("../profile/root.zig");const source = @import("source.zig");pub const stream = @import("stream/root.zig");pub const hot = @import("hot/root.zig");pub const roots = @import("roots/root.zig");pub const Checkpoint = owner.Checkpoint;pub const Contents = owner.Contents;pub const CpuState = owner.CpuState;pub const DurableError = owner.Error;pub const Error = DurableError || hot.Error;pub const Identity = owner.Identity;pub const Material = owner.Material;pub const Materialization = owner.Materialization;pub const MemoryDigest = owner.MemoryDigest;pub const Recovery = owner.Recovery;pub const Root = owner.Root;pub const Source = source.Source;pub const PreparedSource = source.Prepared;pub const StateDigest = owner.StateDigest;pub const Storage = owner.Storage;pub const ram_alignment = owner.ram_alignment;pub const ram_bytes = owner.ram_bytes;pub const page_count = owner.page_count;pub const storage_alignment = owner.storage_alignment;pub const storage_bytes = owner.storage_bytes;pub const validateStorageBytes = owner.validateStorageBytes;pub const validateParent = owner.validateParent;pub const open = owner.open;pub const recoverAfterCrash = owner.recoverAfterCrash;pub const captureDelta = owner.captureDelta;pub const deltaDigest = owner.deltaDigest;pub const identify = owner.identify;pub const inspect = owner.inspect;pub const materializeForRestore = owner.materializeForRestore;pub const beginMaterialization = owner.beginMaterialization;pub const ensureAvailable = owner.ensureAvailable;pub const publish = owner.publish;pub const publishMaterialized = owner.publishMaterialized;pub const validateDeltaImage = owner.validateDeltaImage;pub const validatedMemoryDigest = owner.validatedMemoryDigest;pub const determinism_sources = [_]profile.DeterminismSource{    .checkpoint_memory,    .checkpoint_source,};

Source: lib/machine/src/root.zig:66

zig
pub const checkpoint = @import("checkpoint/root.zig");

Complete call list for checkpoint.publishMaterialized

7 direct calls.

Audit

Definitions33
Public names33
Members18
Version26.7.0
Revisiondaab053ee433