Skip to main content

Module vcpu

Module vcpu 

Source
Expand description

s9vm : vCPU: state, control block configuration, entry/exit.

A Vcpu is the guest execution unit. It owns:

  • a hardware control block (ControlBlock);
  • a dedicated host stack (used by the trampoline to return from the guest);
  • the guest state (GuestState) and the EnterFrame exchange area.

Configuration is deliberately explicit (configure_host, configure_guest, configure_controls) rather than spread across the constructor: each step is checkable and hardware errors (VMfail) can be attributed to a step.

No policy is decided here: the module does not know what a guest OS, a device or a complete virtual machine is.

Re-exportsยง

use crate::memory::frame::FrameAllocOptions; ๐Ÿ”’
use crate::memory::frame::FramePurpose; ๐Ÿ”’
use crate::memory::frame::PhysFrame; ๐Ÿ”’
use crate::s9vm::caps::HwCaps; ๐Ÿ”’
use crate::s9vm::control::field; ๐Ÿ”’
use crate::s9vm::control::ControlBlock; ๐Ÿ”’
use crate::s9vm::control::ControlError; ๐Ÿ”’
use crate::s9vm::exit::ExitClass; ๐Ÿ”’
use crate::s9vm::exit::ExitReason; ๐Ÿ”’
use crate::s9vm::fpu::FpuSwitch; ๐Ÿ”’
use crate::s9vm::guest::GuestState; ๐Ÿ”’
use crate::s9vm::launch::s9vm_enter_guest; ๐Ÿ”’
use crate::s9vm::launch::s9vm_guest_exit; ๐Ÿ”’
use crate::s9vm::launch::EnterFrame; ๐Ÿ”’
use crate::s9vm::mmu; ๐Ÿ”’
use crate::s9vm::mmu::Perms; ๐Ÿ”’
use crate::s9vm::mmu::SecondLevel; ๐Ÿ”’
use crate::s9vm::mmu::TableMemory; ๐Ÿ”’
use crate::s9vm::msr; ๐Ÿ”’
use crate::s9vm::msr::MsrModel; ๐Ÿ”’

Modulesยง

bits
Control bits useful for configuration (SDM).
msr_bitmap
Layout of the 4 KiB MSR bitmap.

Structsยง

ExitInfo
Information about a guest exit, copied out of the control block.
HhdmTables
Table provider that accesses physical memory through the HHDM and keeps track of the allocated tables so they can be freed.
HostStack ๐Ÿ”’
Host stack dedicated to the trampoline.
SecondLevelMemory
Pre-allocated resources for second-level translation.
Vcpu
A vCPU: resources, guest state and control block.

Enumsยง

VcpuError
vCPU lifecycle errors.

Constantsยง

DEFAULT_PREEMPTION_TIMER_TICKS
Number of preemption-timer counts per guest time slice.
GPR_RSP ๐Ÿ”’
Index of RSP in the x86 register encoding order.

Functionsยง

alloc_msr_bitmap ๐Ÿ”’
Allocates the MSR bitmap of a vCPU.
gpr_from_frame ๐Ÿ”’
Reads a general-purpose register out of the entry frame (encoding order).
gpr_into_frame ๐Ÿ”’
Writes a general-purpose register into the entry frame (encoding order).
primary_controls ๐Ÿ”’
Primary processor-based controls of a vCPU.
read_cr0 ๐Ÿ”’
read_cr3 ๐Ÿ”’
read_cr4 ๐Ÿ”’
read_gdtr ๐Ÿ”’
Reads the global descriptor table base (sgdt).
read_idtr ๐Ÿ”’
Reads the interrupt descriptor table base (sidt).
service_pending_host_interrupts
Opens a one-instruction window so a pending host interrupt can be delivered to the host while the vCPU loop keeps interrupts disabled.
set_msr_intercept ๐Ÿ”’
Marks one MSR as intercepted (read and/or write) in the bitmap.
shadow_gpr ๐Ÿ”’
Mutable view of the shadow copy of a general-purpose register.
tr_base ๐Ÿ”’
Base of a TSS descriptor from its selector (GDT).