Struct x86_64::X8664arch

source ·
pub struct X8664arch;

Implementations§

source§

impl X8664arch

source

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
source

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<()>

source

pub(crate) fn load_kernel( mem: &GuestMemory, kernel_image: &mut File ) -> Result<(boot_params, u64, GuestAddress)>

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, and the entry point (initial RIP value).

source

pub fn setup_system_memory( mem: &GuestMemory, cmdline: &CStr, 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 commandline
  • initrd_file - an initial ramdisk image
source

pub(crate) fn get_pcie_vcfg_mmio_range( mem: &GuestMemory, pcie_cfg_mmio: &AddressRange ) -> AddressRange

source

pub(crate) fn get_high_mmio_range<V: Vm>(vm: &V) -> AddressRange

Returns the high mmio range

source

pub fn get_base_linux_cmdline() -> Cmdline

This returns a minimal kernel command for this architecture

source

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 object
    • fw_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
source

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
source

pub fn setup_legacy_cmos_device( 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
source

pub fn setup_acpi_devices( 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 to
    • resources 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 tables
    • irq_chip the IrqChip object for registering irq events
    • battery indicate whether to create the battery
    • mmio_bus the MMIO bus to add the devices to
    • pci_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.
source

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
source

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

§

type Error = Error

source§

fn read_registers(vcpu: &T) -> Result<X86_64CoreRegs>

Reads vCPU’s registers.
source§

fn write_registers(vcpu: &T, regs: &X86_64CoreRegs) -> Result<()>

Writes vCPU’s registers.
source§

fn read_register(_vcpu: &T, _reg: X86_64CoreRegId) -> Result<Vec<u8>>

Reads bytes from the guest register.
source§

fn write_register(_vcpu: &T, _reg: X86_64CoreRegId, _buf: &[u8]) -> Result<()>

Writes bytes to the specified guest register.
source§

fn read_memory( vcpu: &T, guest_mem: &GuestMemory, vaddr: GuestAddress, len: usize ) -> Result<Vec<u8>>

Reads bytes from the guest memory.
source§

fn write_memory( vcpu: &T, guest_mem: &GuestMemory, vaddr: GuestAddress, buf: &[u8] ) -> Result<()>

Writes bytes to the specified guest memory.
source§

fn enable_singlestep(vcpu: &T) -> Result<()>

Make the next vCPU’s run single-step.
source§

fn get_max_hw_breakpoints(_vcpu: &T) -> Result<usize>

Get maximum number of hardware breakpoints.
source§

fn set_hw_breakpoints(vcpu: &T, breakpoints: &[GuestAddress]) -> Result<()>

Set hardware breakpoints at the given addresses.
source§

impl LinuxArch for X8664arch

§

type Error = Error

source§

fn guest_memory_layout( components: &VmComponents, _hypervisor: &impl Hypervisor ) -> Result<Vec<(GuestAddress, u64, MemoryRegionOptions)>, Self::Error>

Returns a Vec of the valid memory addresses as pairs of address and length. These should be used to configure the GuestMemory structure for the platform. Read more
source§

fn get_system_allocator_config<V: Vm>(vm: &V) -> SystemAllocatorConfig

Gets the configuration for a new SystemAllocator that fits the given Vm’s memory layout. Read more
source§

fn build_vm<V, Vcpu>( components: VmComponents, 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> ) -> Result<RunnableLinuxVm<V, Vcpu>, Self::Error>where V: VmX86_64, Vcpu: VcpuX86_64,

Takes VmComponents and generates a RunnableLinuxVm. Read more
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<()>

Configures the vcpu and should be called once per vcpu from the vcpu’s thread. Read more
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>

Configures and add a pci device into vm
source§

fn get_host_cpu_frequencies_khz() -> Result<BTreeMap<usize, Vec<u32>>>

Returns frequency map for each of the host’s logical cores.
source§

fn get_host_cpu_capacity() -> Result<BTreeMap<usize, u32>>

Returns capacity map of the host’s logical cores.
source§

fn get_host_cpu_clusters() -> Result<Vec<CpuSet>>

Returns cluster masks for each of the host’s logical cores.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for Twhere T: Any,

§

fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>

Convert 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, Global>) -> Rc<dyn Any, Global>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for Twhere T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T, Global>) -> Arc<dyn Any + Sync + Send, Global>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V