Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ riscv_vcpu = "0.1"
arm_vcpu = { git = "https://github.com/arceos-hypervisor/arm_vcpu", branch = "next" }
arm_vgic = { version = "0.1", features = ["vgicv3"] }

[patch.crates-io]
axvmconfig = { git = "https://github.com/arceos-hypervisor/axvmconfig.git", branch = "next" }
axvcpu = {git = "https://github.com/arceos-hypervisor/axvcpu.git", branch = "next"}
10 changes: 8 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use alloc::vec::Vec;
use axaddrspace::GuestPhysAddr;

pub use axvmconfig::{
AxVMCrateConfig, EmulatedDeviceConfig, PassThroughDeviceConfig, VMInterruptMode, VMType,
VmMemConfig, VmMemMappingType,
AxVMCrateConfig, EmulatedDeviceConfig, PassThroughAddressConfig, PassThroughDeviceConfig,
VMInterruptMode, VMType, VmMemConfig, VmMemMappingType,
};

// /// A part of `AxVCpuConfig`, which represents an architecture-dependent `VCpu`.
Expand Down Expand Up @@ -56,6 +56,7 @@ pub struct AxVMConfig {
emu_devices: Vec<EmulatedDeviceConfig>,
pass_through_devices: Vec<PassThroughDeviceConfig>,
excluded_devices: Vec<Vec<String>>,
pass_through_addresses: Vec<PassThroughAddressConfig>,
// TODO: improve interrupt passthrough
spi_list: Vec<u32>,
interrupt_mode: VMInterruptMode,
Expand Down Expand Up @@ -86,6 +87,7 @@ impl From<AxVMCrateConfig> for AxVMConfig {
emu_devices: cfg.devices.emu_devices,
pass_through_devices: cfg.devices.passthrough_devices,
excluded_devices: cfg.devices.excluded_devices,
pass_through_addresses: cfg.devices.passthrough_addresses,
spi_list: Vec::new(),
interrupt_mode: cfg.devices.interrupt_mode,
}
Expand Down Expand Up @@ -127,6 +129,10 @@ impl AxVMConfig {
pub fn excluded_devices(&self) -> &Vec<Vec<String>> {
&self.excluded_devices
}

pub fn pass_through_addresses(&self) -> &Vec<PassThroughAddressConfig> {
&self.pass_through_addresses
}
// /// Returns configurations related to VM memory regions.
// pub fn memory_regions(&self) -> Vec<VmMemConfig> {
// &self.memory_regions
Expand Down
10 changes: 10 additions & 0 deletions src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@ impl<H: AxVMHal, U: AxVCpuHal> AxVM<H, U> {
));
}

for pt_addr in inner_mut.config.pass_through_addresses() {
debug!(
"PT addr region: [{:#x}~{:#x}]",
pt_addr.base_gpa,
pt_addr.base_gpa + pt_addr.length,
);
// Align the base address and length to 4K boundaries.
pt_dev_region.push((align_down_4k(pt_addr.base_gpa), align_up_4k(pt_addr.length)));
}

pt_dev_region.sort_by_key(|(gpa, _)| *gpa);

// Merge overlapping regions.
Expand Down
Loading