The entry guest_demo
The first guest: a process that runs a few instructions of another system on the processor, in a guest, and receives what the guest does as records. The design: Architecture: A guest.
What it is for. It is the proof of the guest support of the kernel, and the smallest process that uses it. The guest is a process that this process made and never started: its addresses are the memory of the guest. One page holds 16-bit code at the guest address 0x1000:
mov dx, 0x80
mov al, 42
out dx, al
hlt
The process runs the guest processor with Guest_Run. The out arrives as an exit record Port_Write with the port and the value; the process moves the guest to the next instruction and runs it again; the hlt arrives as an exit Halt. Then the process moves the guest to an int1 after the hlt: the instruction arrives as an exit Other with the exit code 0x88 (icebp), because the kernel lets no guest deliver its debug exception to itself. Then the guest writes the page that holds its code: two pages at the guest address 0x2000 are a switching mapping (made with Write, Execute and No_Access), whose pages the kernel switches between Write and Execute at each fault. Memory_Protect refuses to make it read only, and to change one page of it. The code is
mov byte [0x2010], 0x90
in the page that it writes: it never completes, and the run ends with the exit Writes_Own_Page, with the address 0x2010 and b 0 (16-bit code). Then it checks that a guest takes no thread: Process_Start of the guest gives Bad_State.
On a machine whose processors have no virtualization support that the kernel uses, the first run gives Bad_Operation with the error kind Unsupported, and the process says so: no guest runs there.
Start: start("guest_demo") in the console. It needs no grant: its own budget pays the guest process, its memory and its page tables.
What a reader sees: no window. The log has "guest_demo: the guest wrote 42 to the port 0x80, then halted after it: as it must", or the line of a machine with no support, then "guest_demo: ok". A fault gives "guest_demo: failed: " and what came.
The design: A guest in the repository.
guest_demo module with an entry
- Hash
5a1ebe2491b41d00871e15c66911ad59f173abe246900001c75d46201543d376- Size
45056 bytes- Exports
0- Imports
0- Imported by
0- License
- MIT
The first guest: a process that runs a few instructions of another system on the processor, in a guest, and receives what the guest does as records
| Fact | Value |
|---|---|
| Kind | Modules with an entry |
| Source | src/modules/demonstrations/guest_demo |
| Boot image | yes: in the boot image, 45056 bytes in this build |
| Build settings | none: the defaults of the source |
| Imports | none |
| Imported by | none |
Neighbours
It imports no module, and no module imports it. The module graph shows it with the other modules that have no edge.
Exports
| Export | What it does |
|---|---|
entry() |
entry
entry()
- Form
- The entry of the module: one parameter, an address, fixed by the contract.
src/modules/demonstrations/guest_demo/main.odin:136
Read from the source of the module, as the build reads it to describe the exports (tools/modustool/build/describe.odin).
What the root service gives it
| What | Value | As the root service says |
|---|---|---|
| Grants | none | A guest in its own memory. |
| Other terms of its start grant set | none | |
| Budget that it asks for |
| The process itself and its guest. The working memory holds what the counted parts do not: the load of the process (its page tables, its stack guard, the copy of its writable data), one page of guest memory, the page tables of the guest and the two pages that the first run takes. 180 pages, as the other small processes that hold no window. |
The start grant set is read from start_grant_sets in src/modules/system/root/start_grant_sets.odin. The stated budget is read from the constant MODULE_BUDGET of the source of the module (its line); the build adds the counted parts and writes the sum in the module (tools/modustool/build/budget_count.odin); the root service accepts it up to the largest budget of a process, and adds the limits of processor time and of log records (src/modules/system/root/budgets.odin).
