Expand description
s9vm : AMD-V (SVM) hardware layer.
Counterpart of the VT-x activation in super. Provides, for AMD CPUs:
- detection (
detect) through CPUID andVM_CR; - per-CPU activation (
activate_current_cpu):EFER.SVME, host state-save area (VM_HSAVE_PA) and the host extra-state page used byvmsave/vmload; - the world switch
vmrun, written in assembly because it must preserve the host general registers, swap the guest ones and bracket the entry withclgi/stgi.
The pure parts live in super::svm_caps (capability decoding) and
super::svm_vmcb (VMCB layout, exit decoding), both host-testable.
ยงStatus
Hardware layer of the AMD backend. init_probe only detects and logs:
activation is never done implicitly, because setting EFER.SVME changes CPU
behavior and must be an explicit decision of the caller. The vCPU that
drives vmrun (VMCB setup, FPU/XCR0 switching, injection) is
super::svm_vcpu, and the nested page tables are
super::mmu::SecondLevel::new_npt.
Not yet done: wiring into the VM life cycle of super::vm (backend
selection, device model, exit dispatch) and execution on real hardware.
Re-exportsยง
use core::sync::atomic::AtomicBool;๐use core::sync::atomic::AtomicU32;๐use core::sync::atomic::AtomicU64;๐use core::sync::atomic::Ordering;๐use super::caps::HwCaps;๐use super::svm_caps;๐use super::svm_caps::SvmCaps;๐use super::svm_caps::SvmCapsError;๐use super::InitError;๐use crate::memory::frame::FrameAllocOptions;๐use crate::memory::frame::FramePurpose;๐use crate::memory::frame::PhysFrame;๐
Structsยง
- Guest
Gprs - Guest general-purpose registers that
vmrundoes not keep in the VMCB.
Constantsยง
- MAX_
CPUS ๐ - Maximum number of tracked CPUs (aligned with
percpu::MAX_CPUS).
Staticsยง
- ACTIVATED ๐
- CPUs on which SVM is enabled.
- ACTIVE_
CPUS ๐ - Number of CPUs on which SVM is enabled.
- HOST_
VMCB ๐ - Per-CPU host extra-state page (
vmsave/vmloadtarget), physical address. - HSAVE ๐
- Per-CPU host state-save area (
VM_HSAVE_PA), physical address.
Functionsยง
- activate_
current_ cpu - Enables SVM on the current CPU.
- active_
cpu_ count - Number of CPUs on which SVM is enabled.
- alloc_
zeroed_ ๐frame - Allocates one zeroed 4 KiB frame.
- detect
- Reads the raw SVM registers and decodes them. No CPU state is modified.
- free_
frame ๐ - host_
vmcb_ phys - Physical address of
cpuโs host extra-state page (vmsave/vmload), if SVM is activated there. Pass it ashost_vmcb_patovmrun. - hsave_
phys - Physical address of
cpuโs host state-save area (VM_HSAVE_PA), if SVM is activated there. The SVM counterpart of the VT-x activation region. - hw_caps
- Synthetic
HwCapsfor an AMD CPU, orNonewhen SVM is unusable. - init_
probe - Probes AMD-V and logs the result. Never modifies CPU state.
- is_
activated - True if SVM is enabled on
cpu. - s9vm_
svm_ ๐ โvmrun - vmrunโ
- Enters the guest described by
guest_vmcb_paand returns on#VMEXIT.