pub struct X8664arch;
Implementations§
source§impl X8664arch
impl X8664arch
sourcepub(crate) fn load_bios(mem: &GuestMemory, bios_image: &mut File) -> Result<()>
pub(crate) fn load_bios(mem: &GuestMemory, bios_image: &mut File) -> Result<()>
Loads the bios from an open file.
§Arguments
mem
- The memory to be used by the guest.bios_image
- the File object for the specified bios
pub(crate) fn setup_pflash( pflash_image: File, block_size: u32, bios_size: u64, mmio_bus: &Bus, jail: Option<Minijail>, swap_controller: &mut Option<SwapController> ) -> Result<()>
sourcepub(crate) fn load_cmdline(
guest_mem: &GuestMemory,
guest_addr: GuestAddress,
cmdline: Cmdline,
kernel_max_cmdline_len: usize
) -> Result<()>
pub(crate) fn load_cmdline( guest_mem: &GuestMemory, guest_addr: GuestAddress, cmdline: Cmdline, kernel_max_cmdline_len: usize ) -> Result<()>
Writes the command line string to the given memory slice.
§Arguments
guest_mem
- A u8 slice that will be partially overwritten by the command line.guest_addr
- The address inguest_mem
at which to load the command line.cmdline
- The kernel command line.kernel_max_cmdline_len
- The maximum command line length (without NUL terminator) supported by the kernel.
sourcepub(crate) fn load_kernel(
mem: &GuestMemory,
kernel_image: &mut File
) -> Result<(boot_params, u64, GuestAddress, CpuMode, KernelType)>
pub(crate) fn load_kernel( mem: &GuestMemory, kernel_image: &mut File ) -> Result<(boot_params, u64, GuestAddress, CpuMode, KernelType)>
Loads the kernel from an open file.
§Arguments
mem
- The memory to be used by the guest.kernel_image
- the File object for the specified kernel.
§Returns
On success, returns the Linux x86_64 boot protocol parameters, the first address past the
end of the kernel, the entry point (initial RIP
value), the initial CPU mode, and the type
of kernel.
sourcepub fn setup_system_memory(
arch_memory_layout: &ArchMemoryLayout,
mem: &GuestMemory,
cmdline: Cmdline,
initrd_file: Option<File>,
android_fstab: Option<File>,
kernel_end: u64,
params: boot_params,
dump_device_tree_blob: Option<PathBuf>,
device_tree_overlays: Vec<DtbOverlay>
) -> Result<()>
pub fn setup_system_memory( arch_memory_layout: &ArchMemoryLayout, mem: &GuestMemory, cmdline: Cmdline, initrd_file: Option<File>, android_fstab: Option<File>, kernel_end: u64, params: boot_params, dump_device_tree_blob: Option<PathBuf>, device_tree_overlays: Vec<DtbOverlay> ) -> Result<()>
Configures the system memory space should be called once per vm before starting vcpu threads.
§Arguments
mem
- The memory to be used by the guest.cmdline
- the kernel commandlineinitrd_file
- an initial ramdisk image
pub(crate) fn get_pcie_vcfg_mmio_range( mem: &GuestMemory, pcie_cfg_mmio: &AddressRange ) -> AddressRange
sourcepub(crate) fn get_high_mmio_range<V: Vm>(
vm: &V,
arch_memory_layout: &ArchMemoryLayout
) -> AddressRange
pub(crate) fn get_high_mmio_range<V: Vm>( vm: &V, arch_memory_layout: &ArchMemoryLayout ) -> AddressRange
Returns the high mmio range
sourcepub fn get_base_linux_cmdline() -> Cmdline
pub fn get_base_linux_cmdline() -> Cmdline
This returns a minimal kernel command for this architecture
sourcepub(crate) fn setup_fw_cfg_device(
io_bus: &Bus,
fw_cfg_parameters: Vec<FwCfgParameters>,
bootorder_fw_cfg_blob: Vec<u8>,
fw_cfg_jail: Option<Minijail>,
swap_controller: &mut Option<SwapController>
) -> Result<()>
pub(crate) fn setup_fw_cfg_device( io_bus: &Bus, fw_cfg_parameters: Vec<FwCfgParameters>, bootorder_fw_cfg_blob: Vec<u8>, fw_cfg_jail: Option<Minijail>, swap_controller: &mut Option<SwapController> ) -> Result<()>
Sets up fw_cfg device.
§Arguments
io_bus
- the IO bus objectfw_cfg_parameters
- command-line specified data to add to device. May contain all None fields if user did not specify data to add to the device
sourcepub fn setup_legacy_i8042_device(
io_bus: &Bus,
pit_uses_speaker_port: bool,
vm_evt_wrtube: SendTube
) -> Result<()>
pub fn setup_legacy_i8042_device( io_bus: &Bus, pit_uses_speaker_port: bool, vm_evt_wrtube: SendTube ) -> Result<()>
Sets up the legacy x86 i8042/KBD platform device
§Arguments
-
io_bus
- the IO bus object
-
pit_uses_speaker_port
- does the PIT use port 0x61 for the PC speaker
-
vm_evt_wrtube
- the event object which should receive exit events
sourcepub fn setup_legacy_cmos_device(
arch_memory_layout: &ArchMemoryLayout,
io_bus: &Bus,
irq_chip: &mut dyn IrqChipX86_64,
vm_control: Tube,
mem_size: u64
) -> Result<()>
pub fn setup_legacy_cmos_device( arch_memory_layout: &ArchMemoryLayout, io_bus: &Bus, irq_chip: &mut dyn IrqChipX86_64, vm_control: Tube, mem_size: u64 ) -> Result<()>
Sets up the legacy x86 CMOS/RTC platform device
§Arguments
-
io_bus
- the IO bus object
-
mem_size
- the size in bytes of physical ram for the guest
sourcepub fn setup_acpi_devices(
arch_memory_layout: &ArchMemoryLayout,
pci_root: Arc<Mutex<PciRoot>>,
mem: &GuestMemory,
io_bus: &Bus,
resources: &mut SystemAllocator,
suspend_tube: Arc<Mutex<SendTube>>,
vm_evt_wrtube: SendTube,
sdts: Vec<SDT>,
irq_chip: &mut dyn IrqChip,
sci_irq: u32,
battery: (Option<BatteryType>, Option<Minijail>),
mmio_bus: &Bus,
max_bus: u8,
resume_notify_devices: &mut Vec<Arc<Mutex<dyn BusResumeDevice>>>,
swap_controller: &mut Option<SwapController>,
ac_adapter: bool,
guest_suspended_cvar: Option<Arc<(Mutex<bool>, Condvar)>>,
pci_irqs: &[(PciAddress, u32, PciInterruptPin)]
) -> Result<(AcpiDevResource, Option<BatControl>)>
pub fn setup_acpi_devices( arch_memory_layout: &ArchMemoryLayout, pci_root: Arc<Mutex<PciRoot>>, mem: &GuestMemory, io_bus: &Bus, resources: &mut SystemAllocator, suspend_tube: Arc<Mutex<SendTube>>, vm_evt_wrtube: SendTube, sdts: Vec<SDT>, irq_chip: &mut dyn IrqChip, sci_irq: u32, battery: (Option<BatteryType>, Option<Minijail>), mmio_bus: &Bus, max_bus: u8, resume_notify_devices: &mut Vec<Arc<Mutex<dyn BusResumeDevice>>>, swap_controller: &mut Option<SwapController>, ac_adapter: bool, guest_suspended_cvar: Option<Arc<(Mutex<bool>, Condvar)>>, pci_irqs: &[(PciAddress, u32, PciInterruptPin)] ) -> Result<(AcpiDevResource, Option<BatControl>)>
Sets up the acpi devices for this platform and return the resources which is used to set the ACPI tables.
§Arguments
io_bus
the I/O bus to add the devices toresources
the SystemAllocator to allocate IO and MMIO for acpi devices.suspend_tube
the tube object which used to suspend/resume the VM.sdts
ACPI system description tablesirq_chip
the IrqChip object for registering irq eventsbattery
indicate whether to create the batterymmio_bus
the MMIO bus to add the devices topci_irqs
IRQ assignment of PCI devices. Tuples of (PCI address, gsi, PCI interrupt pin). Note that this matches one of the return values of generate_pci_root.
sourcepub fn setup_serial_devices(
protection_type: ProtectionType,
irq_chip: &mut dyn IrqChip,
io_bus: &Bus,
serial_parameters: &BTreeMap<(SerialHardware, u8), SerialParameters>,
serial_jail: Option<Minijail>,
swap_controller: &mut Option<SwapController>
) -> Result<Vec<SerialDeviceInfo>>
pub fn setup_serial_devices( protection_type: ProtectionType, irq_chip: &mut dyn IrqChip, io_bus: &Bus, serial_parameters: &BTreeMap<(SerialHardware, u8), SerialParameters>, serial_jail: Option<Minijail>, swap_controller: &mut Option<SwapController> ) -> Result<Vec<SerialDeviceInfo>>
Sets up the serial devices for this platform. Returns a list of configured serial devices.
§Arguments
-
irq_chip
the IrqChip object for registering irq events
-
io_bus
the I/O bus to add the devices to
-
serial_parameters
- definitions for how the serial devices should be configured
pub(crate) fn setup_debugcon_devices( protection_type: ProtectionType, io_bus: &Bus, serial_parameters: &BTreeMap<(SerialHardware, u8), SerialParameters>, debugcon_jail: Option<Minijail>, swap_controller: &mut Option<SwapController> ) -> Result<()>
Trait Implementations§
source§impl<T: VcpuX86_64> GdbOps<T> for X8664arch
impl<T: VcpuX86_64> GdbOps<T> for X8664arch
type Error = Error
source§fn read_registers(vcpu: &T) -> Result<X86_64CoreRegs>
fn read_registers(vcpu: &T) -> Result<X86_64CoreRegs>
source§fn read_register(_vcpu: &T, _reg: X86_64CoreRegId) -> Result<Vec<u8>>
fn read_register(_vcpu: &T, _reg: X86_64CoreRegId) -> Result<Vec<u8>>
source§fn write_register(_vcpu: &T, _reg: X86_64CoreRegId, _buf: &[u8]) -> Result<()>
fn write_register(_vcpu: &T, _reg: X86_64CoreRegId, _buf: &[u8]) -> Result<()>
source§fn read_memory(
vcpu: &T,
guest_mem: &GuestMemory,
vaddr: GuestAddress,
len: usize
) -> Result<Vec<u8>>
fn read_memory( vcpu: &T, guest_mem: &GuestMemory, vaddr: GuestAddress, len: usize ) -> Result<Vec<u8>>
source§fn write_memory(
vcpu: &T,
guest_mem: &GuestMemory,
vaddr: GuestAddress,
buf: &[u8]
) -> Result<()>
fn write_memory( vcpu: &T, guest_mem: &GuestMemory, vaddr: GuestAddress, buf: &[u8] ) -> Result<()>
source§fn get_max_hw_breakpoints(_vcpu: &T) -> Result<usize>
fn get_max_hw_breakpoints(_vcpu: &T) -> Result<usize>
source§fn set_hw_breakpoints(vcpu: &T, breakpoints: &[GuestAddress]) -> Result<()>
fn set_hw_breakpoints(vcpu: &T, breakpoints: &[GuestAddress]) -> Result<()>
source§impl LinuxArch for X8664arch
impl LinuxArch for X8664arch
type Error = Error
type ArchMemoryLayout = ArchMemoryLayout
source§fn arch_memory_layout(
components: &VmComponents
) -> Result<Self::ArchMemoryLayout, Self::Error>
fn arch_memory_layout( components: &VmComponents ) -> Result<Self::ArchMemoryLayout, Self::Error>
source§fn guest_memory_layout(
components: &VmComponents,
arch_memory_layout: &Self::ArchMemoryLayout,
_hypervisor: &impl Hypervisor
) -> Result<Vec<(GuestAddress, u64, MemoryRegionOptions)>, Self::Error>
fn guest_memory_layout( components: &VmComponents, arch_memory_layout: &Self::ArchMemoryLayout, _hypervisor: &impl Hypervisor ) -> Result<Vec<(GuestAddress, u64, MemoryRegionOptions)>, Self::Error>
GuestMemory
structure for the platform. Read moresource§fn get_system_allocator_config<V: Vm>(
vm: &V,
arch_memory_layout: &Self::ArchMemoryLayout
) -> SystemAllocatorConfig
fn get_system_allocator_config<V: Vm>( vm: &V, arch_memory_layout: &Self::ArchMemoryLayout ) -> SystemAllocatorConfig
source§fn build_vm<V, Vcpu>(
components: VmComponents,
arch_memory_layout: &Self::ArchMemoryLayout,
vm_evt_wrtube: &SendTube,
system_allocator: &mut SystemAllocator,
serial_parameters: &BTreeMap<(SerialHardware, u8), SerialParameters>,
serial_jail: Option<Minijail>,
battery: (Option<BatteryType>, Option<Minijail>),
vm: V,
ramoops_region: Option<RamoopsRegion>,
devs: Vec<(Box<dyn BusDeviceObj>, Option<Minijail>)>,
irq_chip: &mut dyn IrqChipX86_64,
vcpu_ids: &mut Vec<usize>,
dump_device_tree_blob: Option<PathBuf>,
debugcon_jail: Option<Minijail>,
pflash_jail: Option<Minijail>,
fw_cfg_jail: Option<Minijail>,
swap_controller: &mut Option<SwapController>,
guest_suspended_cvar: Option<Arc<(Mutex<bool>, Condvar)>>,
device_tree_overlays: Vec<DtbOverlay>,
_fdt_position: Option<FdtPosition>,
_no_pmu: bool
) -> Result<RunnableLinuxVm<V, Vcpu>, Self::Error>where
V: VmX86_64,
Vcpu: VcpuX86_64,
fn build_vm<V, Vcpu>(
components: VmComponents,
arch_memory_layout: &Self::ArchMemoryLayout,
vm_evt_wrtube: &SendTube,
system_allocator: &mut SystemAllocator,
serial_parameters: &BTreeMap<(SerialHardware, u8), SerialParameters>,
serial_jail: Option<Minijail>,
battery: (Option<BatteryType>, Option<Minijail>),
vm: V,
ramoops_region: Option<RamoopsRegion>,
devs: Vec<(Box<dyn BusDeviceObj>, Option<Minijail>)>,
irq_chip: &mut dyn IrqChipX86_64,
vcpu_ids: &mut Vec<usize>,
dump_device_tree_blob: Option<PathBuf>,
debugcon_jail: Option<Minijail>,
pflash_jail: Option<Minijail>,
fw_cfg_jail: Option<Minijail>,
swap_controller: &mut Option<SwapController>,
guest_suspended_cvar: Option<Arc<(Mutex<bool>, Condvar)>>,
device_tree_overlays: Vec<DtbOverlay>,
_fdt_position: Option<FdtPosition>,
_no_pmu: bool
) -> Result<RunnableLinuxVm<V, Vcpu>, Self::Error>where
V: VmX86_64,
Vcpu: VcpuX86_64,
source§fn configure_vcpu<V: Vm>(
vm: &V,
hypervisor: &dyn HypervisorX86_64,
irq_chip: &mut dyn IrqChipX86_64,
vcpu: &mut dyn VcpuX86_64,
vcpu_init: VcpuInitX86_64,
vcpu_id: usize,
num_cpus: usize,
cpu_config: Option<CpuConfigX86_64>
) -> Result<()>
fn configure_vcpu<V: Vm>( vm: &V, hypervisor: &dyn HypervisorX86_64, irq_chip: &mut dyn IrqChipX86_64, vcpu: &mut dyn VcpuX86_64, vcpu_init: VcpuInitX86_64, vcpu_id: usize, num_cpus: usize, cpu_config: Option<CpuConfigX86_64> ) -> Result<()>
source§fn register_pci_device<V: VmX86_64, Vcpu: VcpuX86_64>(
linux: &mut RunnableLinuxVm<V, Vcpu>,
device: Box<dyn PciDevice>,
minijail: Option<Minijail>,
resources: &mut SystemAllocator,
hp_control_tube: &Sender<PciRootCommand>,
swap_controller: &mut Option<SwapController>
) -> Result<PciAddress>
fn register_pci_device<V: VmX86_64, Vcpu: VcpuX86_64>( linux: &mut RunnableLinuxVm<V, Vcpu>, device: Box<dyn PciDevice>, minijail: Option<Minijail>, resources: &mut SystemAllocator, hp_control_tube: &Sender<PciRootCommand>, swap_controller: &mut Option<SwapController> ) -> Result<PciAddress>
source§fn get_host_cpu_frequencies_khz() -> Result<BTreeMap<usize, Vec<u32>>>
fn get_host_cpu_frequencies_khz() -> Result<BTreeMap<usize, Vec<u32>>>
source§fn get_host_cpu_max_freq_khz() -> Result<BTreeMap<usize, u32>>
fn get_host_cpu_max_freq_khz() -> Result<BTreeMap<usize, u32>>
Auto Trait Implementations§
impl RefUnwindSafe for X8664arch
impl Send for X8664arch
impl Sync for X8664arch
impl Unpin for X8664arch
impl UnwindSafe for X8664arch
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.