pub struct RegionManager<const MAX: usize> { /* private fields */ }Expand description
Manages a fixed-capacity table of owned memory regions.
MAX is the compile-time upper bound on the number of regions.
Implementations§
Source§impl<const MAX: usize> RegionManager<MAX>
impl<const MAX: usize> RegionManager<MAX>
Sourcepub fn create(&mut self, config: RegionConfig) -> RvmResult<OwnedRegionId>
pub fn create(&mut self, config: RegionConfig) -> RvmResult<OwnedRegionId>
Create a new memory region from the given configuration.
Validates alignment, non-zero page count, and overlap with existing regions in the same partition.
§Errors
Returns RvmError::AlignmentError if addresses are not page-aligned.
Returns RvmError::ResourceLimitExceeded if page count is zero or
the manager is at capacity.
Returns RvmError::MemoryOverlap if the region overlaps an existing
region in the same partition.
Sourcepub fn create_auto_id(
&mut self,
owner: PartitionId,
guest_base: GuestPhysAddr,
host_base: PhysAddr,
page_count: u32,
tier: Tier,
permissions: MemoryPermissions,
) -> RvmResult<OwnedRegionId>
pub fn create_auto_id( &mut self, owner: PartitionId, guest_base: GuestPhysAddr, host_base: PhysAddr, page_count: u32, tier: Tier, permissions: MemoryPermissions, ) -> RvmResult<OwnedRegionId>
Allocate a fresh OwnedRegionId and create the region.
§Errors
See RegionManager::create for error conditions.
Sourcepub fn destroy(&mut self, region_id: OwnedRegionId) -> RvmResult<OwnedRegion>
pub fn destroy(&mut self, region_id: OwnedRegionId) -> RvmResult<OwnedRegion>
Destroy a region, freeing its slot.
§Errors
Returns RvmError::PartitionNotFound if the region does not exist.
Sourcepub fn transfer(
&mut self,
region_id: OwnedRegionId,
new_owner: PartitionId,
) -> RvmResult<()>
pub fn transfer( &mut self, region_id: OwnedRegionId, new_owner: PartitionId, ) -> RvmResult<()>
Transfer ownership of a region to a new partition.
This conceptually moves the region: the old owner loses access and the new owner gains it. The guest-physical mapping remains the same (the new partition sees the region at the same guest address).
§Errors
Returns RvmError::PartitionNotFound if the region does not exist.
Returns RvmError::MemoryOverlap if the new owner already has a
region at the same guest address range.
Sourcepub fn get(&self, region_id: OwnedRegionId) -> Option<&OwnedRegion>
pub fn get(&self, region_id: OwnedRegionId) -> Option<&OwnedRegion>
Look up a region by its identifier.
Sourcepub fn get_mut(&mut self, region_id: OwnedRegionId) -> Option<&mut OwnedRegion>
pub fn get_mut(&mut self, region_id: OwnedRegionId) -> Option<&mut OwnedRegion>
Look up a region by its identifier (mutable).
Sourcepub fn translate(
&self,
owner: PartitionId,
guest: GuestPhysAddr,
) -> Option<AddressMapping>
pub fn translate( &self, owner: PartitionId, guest: GuestPhysAddr, ) -> Option<AddressMapping>
Translate a guest physical address to a host physical address within the given partition.
Sourcepub fn count_for_partition(&self, owner: PartitionId) -> usize
pub fn count_for_partition(&self, owner: PartitionId) -> usize
Count how many regions are owned by a given partition.
Sourcepub fn regions_for_partition(
&self,
owner: PartitionId,
out: &mut [OwnedRegionId],
) -> usize
pub fn regions_for_partition( &self, owner: PartitionId, out: &mut [OwnedRegionId], ) -> usize
Iterate over the region IDs owned by a given partition.
Writes matching IDs into out and returns the count written.