Make `populate_device` infallible

This commit is contained in:
Ruihan Li 2026-01-30 11:15:20 +08:00 committed by Tate, Hongliang Tian
parent 8297da7247
commit ab4e0d9012
2 changed files with 3 additions and 10 deletions

View File

@ -188,22 +188,15 @@ impl VmMapping {
///
/// In debug builds, this method panics if the mapping is not a device
/// memory mapping.
pub(super) fn populate_device(
&self,
vm_space: &VmSpace,
io_mem: IoMem,
vmo_offset: usize,
) -> Result<()> {
pub(super) fn populate_device(&self, vm_space: &VmSpace, io_mem: IoMem, vmo_offset: usize) {
debug_assert!(matches!(self.mapped_mem, MappedMemory::Device));
let preempt_guard = disable_preempt();
let map_range = self.map_to_addr..self.map_to_addr + self.map_size.get();
let mut cursor = vm_space.cursor_mut(&preempt_guard, &map_range)?;
let mut cursor = vm_space.cursor_mut(&preempt_guard, &map_range).unwrap();
let io_page_prop =
PageProperty::new_user(PageFlags::from(self.perms), io_mem.cache_policy());
cursor.map_iomem(io_mem, io_page_prop, self.map_size.get(), vmo_offset);
Ok(())
}
/// Prints the mapping information in the format of `/proc/[pid]/maps`.

View File

@ -350,7 +350,7 @@ impl<'a> VmarMapOptions<'a> {
// Exchange the operation is ok since we hold the write lock on the
// VMAR.
if let Some(io_mem) = io_mem {
vm_mapping.populate_device(parent.vm_space(), io_mem, vmo_offset)?;
vm_mapping.populate_device(parent.vm_space(), io_mem, vmo_offset);
}
// Add the mapping to the VMAR.