Files
RedBear-OS/local/patches/base/redox.patch
T
vasilito 4f1704b6a4 Remove broken ivrs/mcfg stubs from acpid base patch
The base patch referenced ivrs and mcfg modules that don't exist in the source tree, causing build failures. Removed the module declarations, imports, and init calls. MCFG is already handled by pcid (the PCI daemon). IVRS (AMD IOMMU) needs real implementation, not a stub. DMAR iterator fix and Dmar::init() call preserved.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-12 20:42:57 +01:00

55 lines
2.1 KiB
Diff

diff --git a/drivers/acpid/src/acpi.rs b/drivers/acpid/src/acpi.rs
index 94a1eb17..3b376904 100644
--- a/drivers/acpid/src/acpi.rs
+++ b/drivers/acpid/src/acpi.rs
@@ -25,6 +25,8 @@ use amlserde::{AmlSerde, AmlSerdeValue};
#[cfg(target_arch = "x86_64")]
pub mod dmar;
+#[cfg(target_arch = "x86_64")]
+use self::dmar::Dmar;
use crate::aml_physmem::{AmlPageCache, AmlPhysMemHandler};
/// The raw SDT header struct, as defined by the ACPI specification.
@@ -458,7 +460,10 @@ impl AcpiContext {
}
Fadt::init(&mut this);
- //TODO (hangs on real hardware): Dmar::init(&this);
+ // DMAR (Intel VT-d) init — previously disabled due to iterator bug (type_bytes copied
+ // instead of len_bytes in DmarRawIter). Safe to call now: on AMD systems, no DMAR table
+ // exists and this returns early with a warning.
+ Dmar::init(&this);
this
}
diff --git a/drivers/acpid/src/acpi/dmar/mod.rs b/drivers/acpid/src/acpi/dmar/mod.rs
index c42b379a..e4411261 100644
--- a/drivers/acpid/src/acpi/dmar/mod.rs
+++ b/drivers/acpid/src/acpi/dmar/mod.rs
@@ -471,15 +471,19 @@ impl<'sdt> Iterator for DmarRawIter<'sdt> {
let type_bytes = <[u8; 2]>::try_from(type_bytes)
.expect("expected a 2-byte slice to be convertible to [u8; 2]");
- let len_bytes = <[u8; 2]>::try_from(type_bytes)
+ let len_bytes = <[u8; 2]>::try_from(len_bytes)
.expect("expected a 2-byte slice to be convertible to [u8; 2]");
- let ty = u16::from_ne_bytes(type_bytes);
- let len = u16::from_ne_bytes(len_bytes);
-
- let len = usize::try_from(len).expect("expected u16 to fit within usize");
+ let len = u16::from_ne_bytes(len_bytes) as usize;
+
+ // Validate minimum entry header size and prevent infinite loops
+ if len < 4 || len > self.bytes.len() {
+ return None;
+ }
+
+ let ty = u16::from_ne_bytes(type_bytes);
if len > remainder.len() {
log::warn!("DMAR remapping structure length was smaller than the remaining length of the table.");
return None;
}