Expand description
Bare-metal virtualization s9vm (kernel mechanism). s9vm : bare-metal virtualization system of strat9-os.
ยงPrinciple
Bedrock provides the mechanism (per-CPU VT-x activation, hardware control block, second-level translation, exit reception, event injection), the policy silo (to come) will decide the life cycle of machines, device model, and interrupt routing.
ยงLayout
| Module | Content | Host-testable |
|---|---|---|
caps | VT-x capability MSR decoding | yes |
control | field encoding, control block primitives | yes (compiles) |
mmu | second-level translation tables | yes |
exit | exit decoding and classification | yes |
svm_caps | AMD-V capability decoding | yes |
svm_vmcb | AMD VMCB layout, exit decoding | yes |
svm_state | GuestState <-> VMCB translation, permission maps | yes |
svm | AMD-V activation and vmrun world switch | no |
svm_vcpu | AMD-V vCPU (VMCB, FPU switch, injection) | no |
ยงInitialization cycle
- very early detection (CPUID + MSR), without side effects;
- per-CPU activation when the frame allocator is ready (component
bootstrap):CR4.VMXE, 4 KiB activation region, activation; - vCPUs will be created later by the policy layer.
The absence of VT-x is never fatal: the kernel boots normally and
logs virtualisation inactive.
Re-exportsยง
use core::sync::atomic::AtomicBool;๐use core::sync::atomic::AtomicU32;๐use core::sync::atomic::AtomicU64;๐use core::sync::atomic::AtomicU8;๐use core::sync::atomic::Ordering;๐use caps::CapsError;๐use caps::HwCaps;๐use caps::MsrSnapshot;๐
Modulesยง
- acpi
- s9vm : static ACPI tables presented to guests.
- apic
- s9vm : pure model of the guest local APIC (xAPIC / x2APIC).
- backend
- s9vm : hardware backend abstraction (Intel VT-x or AMD-V).
- bios
- s9vm : pure PC BIOS service model for a real-mode DOS-class guest.
- biosrom
- s9vm : real-mode BIOS ROM stubs, low-memory layout and demo boot image.
- bootinfo
- s9vm : guest boot information page.
- bootparams
- s9vm : guest boot parameters (firmware hand-off block).
- bzimage
- s9vm : boot-protocol image (โbzImageโ) parser and load plan.
- caps
- s9vm : decoding of hardware virtualization capabilities (Intel VT-x).
- control
- s9vm : processor control block (guest/host state structure).
- cpuid
- s9vm : guest CPU description (CPUID model).
- decode
- s9vm : minimal x86-64 instruction decoder for exit emulation.
- dma
- 8237 DMA controller (master and slave register files).
- dosboot
- s9vm : DOS-class real-mode guest runner.
- emulate
- s9vm : in-kernel emulation of a minimal guest device set.
- exit
- s9vm : decoding of hardware exits (VM-exits).
- exitqueue
- s9vm : bounded exit event queue.
- fdc
- 82077AA-compatible floppy disk controller and 1.44 MiB drive model.
- firmware
- s9vm : generic guest-firmware images (SeaBIOS and other BIOS ROMs).
- fpu
- s9vm : host/guest FPU and SIMD state switching around a guest entry.
- fwcfg
- QEMU
fw_cfgfirmware-configuration interface (legacy I/O port mode). - guest
- s9vm : guest state and validation before entry.
- guestcode
- s9vm : machine-code payloads used by the host-side smoke tests.
- guestprog
- s9vm : guest program builder (tiny assembler for in-kernel test payloads).
- guestpt
- s9vm : guest page tables for a 64-bit guest entry.
- hpet
- s9vm : pure model of the guest High Precision Event Timer (HPET).
- image
- s9vm : guest image format and loading plan.
- ioapic
- s9vm : pure model of the guest I/O APIC.
- iommu
- s9vm : device address translation (IOMMU model).
- keyboard
- 8042 keyboard controller model (ports
0x60/0x64). - keyfeed
- Host keystrokes waiting to be typed into a DOS guest.
- launch
- s9vm : guest entry/exit trampoline.
- linuxboot
- s9vm : guest-physical layout of a 64-bit boot-protocol guest.
- machine
- s9vm : kernel bridge between a vCPU and the pure emulation layer.
- memmap
- s9vm : guest memory map (GPA).
- mmu
- s9vm : second-level translation (hardware page tables).
- msr
- s9vm : modelled guest MSRs (interception policy and shadow state).
- pci
- s9vm : guest-visible PCI host bridge (pure model).
- pic
- s9vm : pure model of the guest 8259A programmable interrupt controller.
- pit
- s9vm : pure model of the Intel 8254/8253 programmable interval timer.
- rtc
- s9vm : MC146818-compatible CMOS real-time clock model for guests.
- selftest
- s9vm : hardware smoke test of the engine.
- smp
- s9vm : guest SMP bring-up model.
- svm
- s9vm : AMD-V (SVM) hardware layer.
- svm_
caps - s9vm : decoding of AMD SVM capabilities.
- svm_
exit - s9vm : translation of AMD
#VMEXITinformation to the VT-x exit format. - svm_
state - s9vm : translation between the VT-x style
GuestStateand an AMD VMCB. - svm_
vcpu - s9vm : AMD-V vCPU.
- svm_
vmcb - s9vm : AMD VMCB layout, intercepts and
#VMEXITdecoding. - system
- Chipset system-control ports (
0x92and0xCF9). - timing
- s9vm : pure timing and exit-latency measurement.
- tsc
- s9vm : time-stamp counter frequency model.
- uart
- s9vm : 16550A-compatible UART device (pure model, COM1).
- vcpu
- s9vm : vCPU: state, control block configuration, entry/exit.
- vga
- Minimal VGA register model (CRTC, sequencer, graphics, attribute, status).
- virtio
- s9vm : virtio split-queue core (pure).
- virtio_
blk - s9vm : virtio block device (pure model, MMIO transport).
- virtio_
console - s9vm : virtio console device (pure model, MMIO transport).
- virtio_
net - s9vm : virtio network device (pure model, MMIO transport).
- vm
- s9vm : registry of virtual worlds and guest memory.
- zeropage
- s9vm : x86 boot-protocol zero page (
struct boot_params) builder.
Enumsยง
Constantsยง
- CR4_
VMXE ๐ CR4.VMXEbit (hardware extension enable).- MAX_
CPUS ๐ - Maximum number of tracked CPUs (aligned with
percpu::MAX_CPUS). - S9VM_
ENABLED - Global compile/behavior switch.
Staticsยง
- ACTIVATED ๐
- CPU whose activation succeeded.
- ACTIVE_
CPUS ๐ - Number of activated CPUs.
- BACKEND ๐
- Selected backend (
Backend as u8). - CAPS_
VALID ๐ - Capabilities detected once and for all (0 = not detected).
- REGIONS ๐
- Per-CPU activation regions (physical address, 0 = not activated).
Functionsยง
- activate_
current_ cpu - Attempts to activate VT-x on the current CPU.
- activate_
current_ ๐cpu_ vmx - Intel VT-x activation of the current CPU (see
activate_current_cpu). - activation_
region - Physical address of a CPUโs activation region, if activated.
- active_
cpu_ count - Number of CPUs on which VT-x is active.
- backend
- The hardware virtualization backend in use.
- detect
- Detects hardware capabilities of the active backend. Does not modify any CPU state.
- detect_
vmx - Detects Intel VT-x capabilities only. Does not modify any CPU state.
- detected
- True if the capabilities were detected at boot.
- enable_
virtualization ๐ โ - Executes the hardware activation (
vmxon) on a pre-initialized region. - init
- Initialization called by the boot component.
- init_
svm ๐ - AMD-V initialization: detect, activate the boot CPU, select the backend.
- publish_
tsc_ ๐frequency - Publishes the host TSC frequency in the
tsccache, once. - read_
cr4 ๐ - Reads
CR4. - read_
msr ๐ - Reads an MSR through the architecture layer.
- unavailable_
reason - Explains why VT-x is unavailable, for logs and diagnostics.
- write_
cr4 ๐ โ - Writes
CR4. - write_
msr ๐ - Writes an MSR through the architecture layer.