Expand description
s9vm : hardware backend abstraction (Intel VT-x or AMD-V).
The world registry, the run loop and the device model of s9vm drive a vCPU
through the API of Vcpu (VT-x). HwVcpu wraps either that vCPU or an
SvmVcpu behind the same method names, so the callers stay written once.
The Vmx variant forwards every call unchanged: the Intel path behaves as
if the wrapper were not there.
For AMD, exits are converted to the VT-x shape (super::svm_exit) and the
few VT-x-only concepts are emulated or made no-ops:
| VT-x concept | AMD-V counterpart |
|---|---|
load/clear/configure_host (VMCS currency) | no-op: a VMCB is plain memory |
| external-interrupt exiting | always on (INTR intercept) |
| preemption timer | emulated from the TSC on INTR exits (SLICE_DIVISOR) |
| interrupt-window exiting | VINTR intercept + virtual interrupt |
Re-exportsยง
use alloc::string::String;๐use core::sync::atomic::AtomicU32;๐use core::sync::atomic::Ordering;๐use crate::s9vm::caps::HwCaps;๐use crate::s9vm::exit;๐use crate::s9vm::exit::ExitReason;๐use crate::s9vm::guest::GuestState;๐use crate::s9vm::msr::MsrModel;๐use crate::s9vm::svm;๐use crate::s9vm::svm_exit;๐use crate::s9vm::svm_vcpu::SvmVcpu;๐use crate::s9vm::svm_vcpu::SvmVcpuError;๐use crate::s9vm::svm_vmcb::exit_code;๐use crate::s9vm::vcpu::ExitInfo;๐use crate::s9vm::vcpu::Vcpu;๐use crate::s9vm::vcpu::VcpuError;๐use crate::s9vm::Backend;๐
Structsยง
- SvmBackend
Vcpu - An AMD vCPU plus the state of its emulated preemption timer.
Enumsยง
- HwVcpu
- A virtual CPU of either backend.
Constantsยง
- FALLBACK_
TSC_ ๐HZ - TSC frequency assumed when none was published (2 GHz).
- SLICE_
DIVISOR - Fraction of a second of guest time between two emulated preemption-timer
exits on AMD (
1 / SLICE_DIVISORs). VT-xโs default slice is of the same order (roughly 0.1-0.5 s).
Staticsยง
- NEXT_
ASID ๐ - Next ASID to hand out; wraps within the CPUโs range.
Traitsยง
- VcpuOps
- The operations the device model needs from a vCPU, whatever the backend.
Functionsยง
- allocate_
asid ๐ - Allocates a guest ASID in
1..=max_guest_asid. - slice_
expired ๐ - True when the emulated slice (
1 / SLICE_DIVISORs of TSC) has elapsed.