modus
Menu
On this page

The module guest_builder

Sandboxed freestanding guest builder module .

Boots a Linux kernel of 64 bits in a guest of the kernel's Guest_Run, and answers its exits with the machine of modus:contract/guest_os. Runs inside a call host with zero network, zero real clock, and zero ambient grants:

  • decodes and validates the canonical Guest_Build_Spec;
  • copies the kernel image into the memory of the guest and verifies it against spec.kernel_hash via BLAKE3 there, before any parse;
  • copies the initial archive that the spec names to its place in the memory of the guest and verifies it against spec.initial_archive_hash there, before the boot gives it to Linux;
  • loads it by the 64-bit boot protocol of Linux (zero page, page table, descriptors, command line with the command of the build);
  • maps the memory of the guest in regions that switch between Write and Execute, never both;
  • gives the guest a serial console, a virtio console, a read-only virtio disk of inputs and a writable virtio disk of outputs, and no network device;
  • extracts the output disk into canonical MODTREE1 bytes only on clean exit code 0 with zero sandbox violations, and reports the BLAKE3 hash of the whole output disk.

See: Recipes, builders and the cache in the repository

guest_builder module with no entry

Hash
2f0d19bdcdf542de6e04337d530a273c45e85d049acd479f7bedfe43c920dfea
Size
143360 bytes
Exports
3
Imports
0
Imported by
0
License
MIT

Sandboxed freestanding guest builder module

FactValue
KindModules with no entry
Sourcesrc/modules/system/guest_builder
Boot imageyes: in the boot image, 143360 bytes in this build
Build settingsnone: the defaults of the source
Importsnone
Imported bynone

Neighbours

It imports no module, and no module imports it. The module graph shows it with the other modules that have no edge.

Exports

ExportWhat it does
build(spec_bytes: Bytes(Read), kernel_image: Bytes(Read), initial_archive: Bytes(Read), input_disk: Bytes(Read), output_tree: Handle(Read, Write), report: Guest_Build_Report) -> Integerboots the Linux kernel of the spec in a sandboxed guest and writes the canonical MODTREE1 output tree into output_tree on clean exit code 0, returning the canonical tree byte count written or -1 with an error record
status() -> Table(Guest_Builder_Status)gives the counts of the builds of this process in one row
disks_check(spec_bytes: Bytes(Read), input_disk: Bytes(Read)) -> Integerchecks a build before it runs, with no guest: the spec, the input disk as a read-only disk of inputs, and the bound of the blank output disk against what this process holds

build

build(spec_bytes: (Read), kernel_image: (Read), initial_archive: (Read), input_disk: (Read), output_tree: (Read, Write), report: ) -> 

build boots the Linux kernel of the spec in a sandboxed guest and writes the canonical MODTREE1 output tree into output_tree on clean exit code 0, returning the canonical tree byte count written or -1 with an error record. The report holds the BLAKE3 hash of the whole output disk.

Parameters
  • spec_bytes: (Read)
  • kernel_image: (Read)
  • initial_archive: (Read)
  • input_disk: (Read)
  • output_tree: (Read, Write)
  • report:
Result
When it fails
a negative result, and the error record
Source
src/modules/system/guest_builder/main.odin:254

status

status() -> ()

status gives the counts of the builds of this process in one row.

The result is 1.

Parameters
none
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/guest_builder/status.odin:56

disks_check

disks_check(spec_bytes: (Read), input_disk: (Read)) -> 

disks_check checks a build before it runs, with no guest: the spec, the input disk as a read-only disk of inputs, and the bound of the blank output disk against what this process holds. A build that passes it can still fail in its guest, never at its disks.

  • spec_bytes: the canonical Guest_Build_Spec.
  • input_disk: the MODGBD1 image of the inputs; empty for no input.

The result is the bytes of the blank output disk that the build gives the guest, or ERROR with an error record whose value found is the Guest_Builder_Refusal.

Parameters
  • spec_bytes: (Read)
  • input_disk: (Read)
Result
When it fails
a negative result, and the error record
Source
src/modules/system/guest_builder/status.odin:75

Read from the source of the module, as the build reads it to describe the exports (tools/modustool/build/describe.odin).

Bytes wire form

A wire form of the module contract: one word of a call. Bytes with no description.

Handle wire form

A wire form of the module contract: one word of a call. A handle that the caller lends for the time of the call, in a register.

Guest_Build_Report record of a module

A record of the module guest_builder: 128 bytes, aligned on 8 bytes, 0 bytes of padding.

  • statei6408 bytes
  • refusali6488 bytes
  • guest_exit_codei64168 bytes
  • guest_exitsi64248 bytes
  • sandbox_violationsi64328 bytes
  • tree_bytes_writteni64408 bytes
  • machine_failurei64488 bytes
  • console_bytesi64568 bytes

and 2 more

Integer wire form

A wire form of the module contract: one word of a call. A signed integer of 64 bits, in a register.

Error_Record record of a module

A record of the module guest_builder: 56 bytes, aligned on 8 bytes, 0 bytes of padding.

  • kindi6408 bytes
  • uniti6488 bytes
  • operationi64168 bytes
  • argumenti64248 bytes
  • valuei64328 bytes
  • limiti64408 bytes
  • foundi64488 bytes

Table wire form

A wire form of the module contract: one word of a call. Records of one description that follow each other (a table).

Guest_Builder_Status record of a module

A record of the module guest_builder: 96 bytes, aligned on 8 bytes, 0 bytes of padding.

  • buildsi6408 bytes
  • succeededi6488 bytes
  • refusedi64168 bytes
  • failedi64248 bytes
  • timed_outi64328 bytes
  • last_statei64408 bytes
  • last_refusali64488 bytes
  • last_tree_bytesi64568 bytes

and 1 more