From bad1a7a79a04f167ca8d267df047ac50b6730794 Mon Sep 17 00:00:00 2001 From: Yuke Peng Date: Tue, 18 Feb 2025 15:25:37 +0800 Subject: [PATCH] Panic if overriding existing device page tables --- ostd/src/arch/x86/iommu/dma_remapping/context_table.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ostd/src/arch/x86/iommu/dma_remapping/context_table.rs b/ostd/src/arch/x86/iommu/dma_remapping/context_table.rs index cb02f22d8..9f7a7d26b 100644 --- a/ostd/src/arch/x86/iommu/dma_remapping/context_table.rs +++ b/ostd/src/arch/x86/iommu/dma_remapping/context_table.rs @@ -5,7 +5,6 @@ use alloc::collections::BTreeMap; use core::mem::size_of; -use log::warn; use ostd_pod::Pod; use super::second_stage::{DeviceMode, PageTableEntry, PagingConsts}; @@ -116,9 +115,12 @@ impl RootTable { * size_of::(), ) .unwrap(); + if bus_entry.is_present() { - warn!("IOMMU: Overwriting the existing device page table"); + panic!("existing device page tables should not be overridden"); } + + // Activate page table. let address = unsafe { page_table.root_paddr() }; context_table.page_tables.insert(address, page_table); let entry = ContextEntry(address as u128 | 1 | 0x1_0000_0000_0000_0000);