Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8703,6 +8703,7 @@ dependencies = [
"chipset_device",
"guestmem",
"inspect",
"membacking",
"memory_range",
"mesh",
"pal_async",
Expand Down
4 changes: 4 additions & 0 deletions openvmm/membacking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ mod sys {
/// On Unix, this is an empty (uninhabitable) enum.
pub type RemoteProcess = sys::RemoteProcess;

pub use mapping_manager::Mappable;
pub use memory_manager::DeviceMemoryMapper;
pub use memory_manager::GuestMemoryBuilder;
pub use memory_manager::GuestMemoryClient;
Expand All @@ -97,3 +98,6 @@ pub use memory_manager::PartitionAttachError;
pub use memory_manager::RamVisibility;
pub use memory_manager::RamVisibilityControl;
pub use memory_manager::SharedMemoryBacking;
pub use region_manager::DmaMapperClient;
pub use region_manager::DmaMapperHandle;
pub use region_manager::DmaTarget;
7 changes: 7 additions & 0 deletions openvmm/membacking/src/mapping_manager/va_mapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ use std::sync::Arc;
use std::thread::JoinHandle;
use thiserror::Error;

/// A virtual address space mapper for guest memory.
///
/// Maintains a reserved VA range and maps file-backed or anonymous memory
/// into it as directed by the mapping manager.
pub struct VaMapper {
inner: Arc<MapperInner>,
process: Option<RemoteProcess>,
Expand Down Expand Up @@ -259,14 +263,17 @@ impl VaMapper {
self.inner.request_mapping(range, false).await
}

/// Returns the base pointer of the VA reservation.
pub fn as_ptr(&self) -> *mut u8 {
self.inner.mapping.as_ptr().cast()
}

/// Returns the length of the VA reservation in bytes.
pub fn len(&self) -> usize {
self.inner.mapping.len()
}

/// Returns the remote process, if this mapper maps into a remote process.
pub fn process(&self) -> Option<&RemoteProcess> {
self.process.as_ref()
}
Expand Down
5 changes: 4 additions & 1 deletion openvmm/membacking/src/memory_manager/device_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ impl MappableGuestMemory for DeviceMemoryControl {
MemoryRange::try_from(gpa..gpa.wrapping_add(self.0.len as u64))
.map_err(|err| io::Error::new(io::ErrorKind::InvalidInput, err))?,
DEVICE_PRIORITY,
false, // device memory cannot currently be a DMA target
false, // not a DMA target: excludes device BARs from
// GuestMemorySharing (vhost-user). IOMMU consumers
// get notified of these mappings via the DmaMapper
// path regardless of this flag.
)
.await
.map_err(io::Error::other)?;
Expand Down
5 changes: 5 additions & 0 deletions openvmm/membacking/src/memory_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,11 @@ impl GuestMemoryManager {
DeviceMemoryMapper::new(self.region_manager.client().clone())
}

/// Returns a client for registering DMA mappers (VFIO, iommufd).
pub fn dma_mapper_client(&self) -> crate::region_manager::DmaMapperClient {
crate::region_manager::DmaMapperClient::new(self.region_manager.client())
}

/// Returns an object for manipulating the visibility state of different RAM
/// regions.
pub fn ram_visibility_control(&self) -> RamVisibilityControl {
Expand Down
Loading
Loading