mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-28 03:43:23 +00:00
Avoid potential deadlock in iommu remapping
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
601040f2fa
commit
da5e7a21cb
@ -11,7 +11,7 @@ use crate::{
|
|||||||
bus::pci::PciDeviceLocation,
|
bus::pci::PciDeviceLocation,
|
||||||
mm::{Daddr, PageTable},
|
mm::{Daddr, PageTable},
|
||||||
prelude::Paddr,
|
prelude::Paddr,
|
||||||
sync::SpinLock,
|
sync::{LocalIrqDisabled, SpinLock},
|
||||||
};
|
};
|
||||||
|
|
||||||
mod context_table;
|
mod context_table;
|
||||||
@ -74,4 +74,7 @@ pub fn init() {
|
|||||||
info!("[IOMMU] DMA remapping enabled");
|
info!("[IOMMU] DMA remapping enabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
static PAGE_TABLE: Once<SpinLock<RootTable>> = Once::new();
|
// TODO: Currently `map()` or `unmap()` could be called in both task and interrupt
|
||||||
|
// contexts (e.g., within the virtio-blk module), potentially leading to deadlocks.
|
||||||
|
// Once this issue is resolved, `LocalIrqDisabled` is no longer needed.
|
||||||
|
static PAGE_TABLE: Once<SpinLock<RootTable, LocalIrqDisabled>> = Once::new();
|
||||||
|
@ -26,7 +26,7 @@ use crate::{
|
|||||||
x86::kernel::acpi::dmar::{Dmar, Remapping},
|
x86::kernel::acpi::dmar::{Dmar, Remapping},
|
||||||
},
|
},
|
||||||
mm::paddr_to_vaddr,
|
mm::paddr_to_vaddr,
|
||||||
sync::SpinLock,
|
sync::{LocalIrqDisabled, SpinLock},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
@ -91,7 +91,10 @@ impl IommuRegisters {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Enable DMA remapping with static RootTable
|
/// Enable DMA remapping with static RootTable
|
||||||
pub(super) fn enable_dma_remapping(&mut self, root_table: &'static SpinLock<RootTable>) {
|
pub(super) fn enable_dma_remapping(
|
||||||
|
&mut self,
|
||||||
|
root_table: &'static SpinLock<RootTable, LocalIrqDisabled>,
|
||||||
|
) {
|
||||||
// Set root table address
|
// Set root table address
|
||||||
self.root_table_address
|
self.root_table_address
|
||||||
.write(root_table.lock().root_paddr() as u64);
|
.write(root_table.lock().root_paddr() as u64);
|
||||||
|
Reference in New Issue
Block a user